Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4760 right-hear 1
/*
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
 * All rights reserved.
10
 *
11
 * Redistribution and use in source and binary forms, with or without
12
 * modification, are permitted provided that the following conditions
13
 * are met:
14
 * 1. Redistributions of source code must retain the above copyright
15
 *    notice, this list of conditions and the following disclaimer.
16
 * 2. Redistributions in binary form must reproduce the above copyright
17
 *    notice, this list of conditions and the following disclaimer in the
18
 *    documentation and/or other materials provided with the distribution.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
21
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
 * POSSIBILITY OF SUCH DAMAGE.
31
 */
32
#ifndef OPENJPEG_H
33
#define OPENJPEG_H
34
 
35
 
36
/*
37
==========================================================
38
   Compiler directives
39
==========================================================
40
*/
41
 
42
#if defined(OPJ_STATIC) || !defined(_WIN32)
43
#define OPJ_API
44
#define OPJ_CALLCONV
45
#else
46
#define OPJ_CALLCONV __stdcall
47
/*
48
The following ifdef block is the standard way of creating macros which make exporting
49
from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
50
symbol defined on the command line. this symbol should not be defined on any project
51
that uses this DLL. This way any other project whose source files include this file see
52
OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
53
defined with this macro as being exported.
54
*/
55
#if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
56
#define OPJ_API __declspec(dllexport)
57
#else
58
#define OPJ_API __declspec(dllimport)
59
#endif /* OPJ_EXPORTS */
60
#endif /* !OPJ_STATIC || !_WIN32 */
61
 
62
#ifndef __cplusplus
63
#if defined(HAVE_STDBOOL_H)
64
/*
65
The C language implementation does correctly provide the standard header
66
file "stdbool.h".
67
 */
68
#include 
69
#else
70
/*
71
The C language implementation does not provide the standard header file
72
"stdbool.h" as required by ISO/IEC 9899:1999.  Try to compensate for this
73
braindamage below.
74
*/
75
#if !defined(bool)
76
#define	bool	int
77
#endif
78
#if !defined(true)
79
#define true	1
80
#endif
81
#if !defined(false)
82
#define	false	0
83
#endif
84
#endif
85
#endif /* __cplusplus */
86
 
87
/*
88
==========================================================
89
   Useful constant definitions
90
==========================================================
91
*/
92
 
93
#define OPJ_PATH_LEN 4096 /**< Maximum allowed size for filenames */
94
 
95
#define J2K_MAXRLVLS 33					/**< Number of maximum resolution level authorized */
96
#define J2K_MAXBANDS (3*J2K_MAXRLVLS-2)	/**< Number of maximum sub-band linked to number of resolution level */
97
 
98
/* UniPG>> */
99
#define JPWL_MAX_NO_TILESPECS	16 /**< Maximum number of tile parts expected by JPWL: increase at your will */
100
#define JPWL_MAX_NO_PACKSPECS	16 /**< Maximum number of packet parts expected by JPWL: increase at your will */
101
#define JPWL_MAX_NO_MARKERS	512 /**< Maximum number of JPWL markers: increase at your will */
102
#define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" /**< index file name used when JPWL is on */
103
#define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */
104
#define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */
105
#define JPWL_MAXIMUM_HAMMING 2 /**< Expect this maximum number of bit errors in marker id's */
106
#define JPWL_MAXIMUM_EPB_ROOM 65450 /**< Expect this maximum number of bytes for composition of EPBs */
107
/* <
108
 
109
/*
110
==========================================================
111
   enum definitions
112
==========================================================
113
*/
114
/**
115
Rsiz Capabilities
116
*/
117
typedef enum RSIZ_CAPABILITIES {
118
	STD_RSIZ = 0,		/** Standard JPEG2000 profile*/
119
	CINEMA2K = 3,		/** Profile name for a 2K image*/
120
	CINEMA4K = 4		/** Profile name for a 4K image*/
121
} OPJ_RSIZ_CAPABILITIES;
122
 
123
/**
124
Digital cinema operation mode
125
*/
126
typedef enum CINEMA_MODE {
127
	OFF = 0,					/** Not Digital Cinema*/
128
	CINEMA2K_24 = 1,	/** 2K Digital Cinema at 24 fps*/
129
	CINEMA2K_48 = 2,	/** 2K Digital Cinema at 48 fps*/
130
	CINEMA4K_24 = 3		/** 4K Digital Cinema at 24 fps*/
131
}OPJ_CINEMA_MODE;
132
 
133
/**
134
Progression order
135
*/
136
typedef enum PROG_ORDER {
137
	PROG_UNKNOWN = -1,	/**< place-holder */
138
	LRCP = 0,		/**< layer-resolution-component-precinct order */
139
	RLCP = 1,		/**< resolution-layer-component-precinct order */
140
	RPCL = 2,		/**< resolution-precinct-component-layer order */
141
	PCRL = 3,		/**< precinct-component-resolution-layer order */
142
	CPRL = 4		/**< component-precinct-resolution-layer order */
143
} OPJ_PROG_ORDER;
144
 
145
/**
146
Supported image color spaces
147
*/
148
typedef enum COLOR_SPACE {
149
	CLRSPC_UNKNOWN = -1,	/**< not supported by the library */
150
	CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */
151
	CLRSPC_SRGB = 1,		/**< sRGB */
152
	CLRSPC_GRAY = 2,		/**< grayscale */
153
	CLRSPC_SYCC = 3			/**< YUV */
154
} OPJ_COLOR_SPACE;
155
 
156
/**
157
Supported codec
158
*/
159
typedef enum CODEC_FORMAT {
160
	CODEC_UNKNOWN = -1,	/**< place-holder */
161
	CODEC_J2K = 0,		/**< JPEG-2000 codestream : read/write */
162
	CODEC_JPT = 1,		/**< JPT-stream (JPEG 2000, JPIP) : read only */
163
	CODEC_JP2 = 2		/**< JPEG-2000 file format : read/write */
164
} OPJ_CODEC_FORMAT;
165
 
166
/**
167
Limit decoding to certain portions of the codestream.
168
*/
169
typedef enum LIMIT_DECODING {
170
	NO_LIMITATION = 0,				  /**< No limitation for the decoding. The entire codestream will de decoded */
171
	LIMIT_TO_MAIN_HEADER = 1,		/**< The decoding is limited to the Main Header */
172
	DECODE_ALL_BUT_PACKETS = 2	/**< Decode everything except the JPEG 2000 packets */
173
} OPJ_LIMIT_DECODING;
174
 
175
/*
176
==========================================================
177
   event manager typedef definitions
178
==========================================================
179
*/
180
 
181
/**
182
Callback function prototype for events
183
@param msg Event message
184
@param client_data
185
*/
186
typedef void (*opj_msg_callback) (const char *msg, void *client_data);
187
 
188
/**
189
Message handler object
190
used for
191
    192
  • Error messages
  • 193
  • Warning messages
  • 194
  • Debugging messages
  • 195
    196
    */
    197
    typedef struct opj_event_mgr {
    198
    	/** Error message callback if available, NULL otherwise */
    199
    	opj_msg_callback error_handler;
    200
    	/** Warning message callback if available, NULL otherwise */
    201
    	opj_msg_callback warning_handler;
    202
    	/** Debug message callback if available, NULL otherwise */
    203
    	opj_msg_callback info_handler;
    204
    } opj_event_mgr_t;
    205
     
    206
     
    207
    /*
    208
    ==========================================================
    209
       codec typedef definitions
    210
    ==========================================================
    211
    */
    212
     
    213
    /**
    214
    Progression order changes
    215
    */
    216
    typedef struct opj_poc {
    217
    	/** Resolution num start, Component num start, given by POC */
    218
    	int resno0, compno0;
    219
    	/** Layer num end,Resolution num end, Component num end, given by POC */
    220
    	int layno1, resno1, compno1;
    221
    	/** Layer num start,Precinct num start, Precinct num end */
    222
    	int layno0, precno0, precno1;
    223
    	/** Progression order enum*/
    224
    	OPJ_PROG_ORDER prg1,prg;
    225
    	/** Progression order string*/
    226
    	char progorder[5];
    227
    	/** Tile number */
    228
    	int tile;
    229
    	/** Start and end values for Tile width and height*/
    230
    	int tx0,tx1,ty0,ty1;
    231
    	/** Start value, initialised in pi_initialise_encode*/
    232
    	int layS, resS, compS, prcS;
    233
    	/** End value, initialised in pi_initialise_encode */
    234
    	int layE, resE, compE, prcE;
    235
    	/** Start and end values of Tile width and height, initialised in pi_initialise_encode*/
    236
    	int txS,txE,tyS,tyE,dx,dy;
    237
    	/** Temporary values for Tile parts, initialised in pi_create_encode */
    238
    	int lay_t, res_t, comp_t, prc_t,tx0_t,ty0_t;
    239
    } opj_poc_t;
    240
     
    241
    /**
    242
    Compression parameters
    243
    */
    244
    typedef struct opj_cparameters {
    245
    	/** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
    246
    	bool tile_size_on;
    247
    	/** XTOsiz */
    248
    	int cp_tx0;
    249
    	/** YTOsiz */
    250
    	int cp_ty0;
    251
    	/** XTsiz */
    252
    	int cp_tdx;
    253
    	/** YTsiz */
    254
    	int cp_tdy;
    255
    	/** allocation by rate/distortion */
    256
    	int cp_disto_alloc;
    257
    	/** allocation by fixed layer */
    258
    	int cp_fixed_alloc;
    259
    	/** add fixed_quality */
    260
    	int cp_fixed_quality;
    261
    	/** fixed layer */
    262
    	int *cp_matrice;
    263
    	/** comment for coding */
    264
    	char *cp_comment;
    265
    	/** csty : coding style */
    266
    	int csty;
    267
    	/** progression order (default LRCP) */
    268
    	OPJ_PROG_ORDER prog_order;
    269
    	/** progression order changes */
    270
    	opj_poc_t POC[32];
    271
    	/** number of progression order changes (POC), default to 0 */
    272
    	int numpocs;
    273
    	/** number of layers */
    274
    	int tcp_numlayers;
    275
    	/** rates of layers */
    276
    	float tcp_rates[100];
    277
    	/** different psnr for successive layers */
    278
    	float tcp_distoratio[100];
    279
    	/** number of resolutions */
    280
    	int numresolution;
    281
    	/** initial code block width, default to 64 */
    282
     	int cblockw_init;
    283
    	/** initial code block height, default to 64 */
    284
    	int cblockh_init;
    285
    	/** mode switch (cblk_style) */
    286
    	int mode;
    287
    	/** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
    288
    	int irreversible;
    289
    	/** region of interest: affected component in [0..3], -1 means no ROI */
    290
    	int roi_compno;
    291
    	/** region of interest: upshift value */
    292
    	int roi_shift;
    293
    	/* number of precinct size specifications */
    294
    	int res_spec;
    295
    	/** initial precinct width */
    296
    	int prcw_init[J2K_MAXRLVLS];
    297
    	/** initial precinct height */
    298
    	int prch_init[J2K_MAXRLVLS];
    299
     
    300
    	/**@name command line encoder parameters (not used inside the library) */
    301
    	/*@{*/
    302
    	/** input file name */
    303
    	char infile[OPJ_PATH_LEN];
    304
    	/** output file name */
    305
    	char outfile[OPJ_PATH_LEN];
    306
    	/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
    307
    	int index_on;
    308
    	/** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
    309
    	char index[OPJ_PATH_LEN];
    310
    	/** subimage encoding: origin image offset in x direction */
    311
    	int image_offset_x0;
    312
    	/** subimage encoding: origin image offset in y direction */
    313
    	int image_offset_y0;
    314
    	/** subsampling value for dx */
    315
    	int subsampling_dx;
    316
    	/** subsampling value for dy */
    317
    	int subsampling_dy;
    318
    	/** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/
    319
    	int decod_format;
    320
    	/** output file format 0: J2K, 1: JP2, 2: JPT */
    321
    	int cod_format;
    322
    	/*@}*/
    323
     
    324
    /* UniPG>> */
    325
    	/**@name JPWL encoding parameters */
    326
    	/*@{*/
    327
    	/** enables writing of EPC in MH, thus activating JPWL */
    328
    	bool jpwl_epc_on;
    329
    	/** error protection method for MH (0,1,16,32,37-128) */
    330
    	int jpwl_hprot_MH;
    331
    	/** tile number of header protection specification (>=0) */
    332
    	int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
    333
    	/** error protection methods for TPHs (0,1,16,32,37-128) */
    334
    	int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
    335
    	/** tile number of packet protection specification (>=0) */
    336
    	int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
    337
    	/** packet number of packet protection specification (>=0) */
    338
    	int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
    339
    	/** error protection methods for packets (0,1,16,32,37-128) */
    340
    	int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
    341
    	/** enables writing of ESD, (0=no/1/2 bytes) */
    342
    	int jpwl_sens_size;
    343
    	/** sensitivity addressing size (0=auto/2/4 bytes) */
    344
    	int jpwl_sens_addr;
    345
    	/** sensitivity range (0-3) */
    346
    	int jpwl_sens_range;
    347
    	/** sensitivity method for MH (-1=no,0-7) */
    348
    	int jpwl_sens_MH;
    349
    	/** tile number of sensitivity specification (>=0) */
    350
    	int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
    351
    	/** sensitivity methods for TPHs (-1=no,0-7) */
    352
    	int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
    353
    	/*@}*/
    354
    /* <
    355
     
    356
    	/** Digital Cinema compliance 0-not compliant, 1-compliant*/
    357
    	OPJ_CINEMA_MODE cp_cinema;
    358
    	/** Maximum rate for each component. If == 0, component size limitation is not considered */
    359
    	int max_comp_size;
    360
    	/** Profile name*/
    361
    	OPJ_RSIZ_CAPABILITIES cp_rsiz;
    362
    	/** Tile part generation*/
    363
    	char tp_on;
    364
    	/** Flag for Tile part generation*/
    365
    	char tp_flag;
    366
    	/** MCT (multiple component transform) */
    367
    	char tcp_mct;
    368
    } opj_cparameters_t;
    369
     
    370
    /**
    371
    Decompression parameters
    372
    */
    373
    typedef struct opj_dparameters {
    374
    	/**
    375
    	Set the number of highest resolution levels to be discarded.
    376
    	The image resolution is effectively divided by 2 to the power of the number of discarded levels.
    377
    	The reduce factor is limited by the smallest total number of decomposition levels among tiles.
    378
    	if != 0, then original dimension divided by 2^(reduce);
    379
    	if == 0 or not used, image is decoded to the full resolution
    380
    	*/
    381
    	int cp_reduce;
    382
    	/**
    383
    	Set the maximum number of quality layers to decode.
    384
    	If there are less quality layers than the specified number, all the quality layers are decoded.
    385
    	if != 0, then only the first "layer" layers are decoded;
    386
    	if == 0 or not used, all the quality layers are decoded
    387
    	*/
    388
    	int cp_layer;
    389
     
    390
    	/**@name command line encoder parameters (not used inside the library) */
    391
    	/*@{*/
    392
    	/** input file name */
    393
    	char infile[OPJ_PATH_LEN];
    394
    	/** output file name */
    395
    	char outfile[OPJ_PATH_LEN];
    396
    	/** input file format 0: J2K, 1: JP2, 2: JPT */
    397
    	int decod_format;
    398
    	/** output file format 0: PGX, 1: PxM, 2: BMP */
    399
    	int cod_format;
    400
    	/*@}*/
    401
     
    402
    /* UniPG>> */
    403
    	/**@name JPWL decoding parameters */
    404
    	/*@{*/
    405
    	/** activates the JPWL correction capabilities */
    406
    	bool jpwl_correct;
    407
    	/** expected number of components */
    408
    	int jpwl_exp_comps;
    409
    	/** maximum number of tiles */
    410
    	int jpwl_max_tiles;
    411
    	/*@}*/
    412
    /* <
    413
     
    414
    	/**
    415
    	Specify whether the decoding should be done on the entire codestream, or be limited to the main header
    416
    	Limiting the decoding to the main header makes it possible to extract the characteristics of the codestream
    417
    	if == NO_LIMITATION, the entire codestream is decoded;
    418
    	if == LIMIT_TO_MAIN_HEADER, only the main header is decoded;
    419
    	*/
    420
    	OPJ_LIMIT_DECODING cp_limit_decoding;
    421
     
    422
    } opj_dparameters_t;
    423
     
    424
    /** Common fields between JPEG-2000 compression and decompression master structs. */
    425
     
    426
    #define opj_common_fields \
    427
    	opj_event_mgr_t *event_mgr;	/**< pointer to the event manager */\
    428
    	void * client_data;			/**< Available for use by application */\
    429
    	bool is_decompressor;		/**< So common code can tell which is which */\
    430
    	OPJ_CODEC_FORMAT codec_format;	/**< selected codec */\
    431
    	void *j2k_handle;			/**< pointer to the J2K codec */\
    432
    	void *jp2_handle;			/**< pointer to the JP2 codec */\
    433
    	void *mj2_handle			/**< pointer to the MJ2 codec */
    434
     
    435
    /* Routines that are to be used by both halves of the library are declared
    436
     * to receive a pointer to this structure.  There are no actual instances of
    437
     * opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t.
    438
     */
    439
    typedef struct opj_common_struct {
    440
      opj_common_fields;		/* Fields common to both master struct types */
    441
      /* Additional fields follow in an actual opj_cinfo_t or
    442
       * opj_dinfo_t.  All three structs must agree on these
    443
       * initial fields!  (This would be a lot cleaner in C++.)
    444
       */
    445
    } opj_common_struct_t;
    446
     
    447
    typedef opj_common_struct_t * opj_common_ptr;
    448
     
    449
    /**
    450
    Compression context info
    451
    */
    452
    typedef struct opj_cinfo {
    453
    	/** Fields shared with opj_dinfo_t */
    454
    	opj_common_fields;
    455
    	/* other specific fields go here */
    456
    } opj_cinfo_t;
    457
     
    458
    /**
    459
    Decompression context info
    460
    */
    461
    typedef struct opj_dinfo {
    462
    	/** Fields shared with opj_cinfo_t */
    463
    	opj_common_fields;
    464
    	/* other specific fields go here */
    465
    } opj_dinfo_t;
    466
     
    467
    /*
    468
    ==========================================================
    469
       I/O stream typedef definitions
    470
    ==========================================================
    471
    */
    472
     
    473
    /*
    474
     * Stream open flags.
    475
     */
    476
    /** The stream was opened for reading. */
    477
    #define OPJ_STREAM_READ	0x0001
    478
    /** The stream was opened for writing. */
    479
    #define OPJ_STREAM_WRITE 0x0002
    480
     
    481
    /**
    482
    Byte input-output stream (CIO)
    483
    */
    484
    typedef struct opj_cio {
    485
    	/** codec context */
    486
    	opj_common_ptr cinfo;
    487
     
    488
    	/** open mode (read/write) either OPJ_STREAM_READ or OPJ_STREAM_WRITE */
    489
    	int openmode;
    490
    	/** pointer to the start of the buffer */
    491
    	unsigned char *buffer;
    492
    	/** buffer size in bytes */
    493
    	int length;
    494
     
    495
    	/** pointer to the start of the stream */
    496
    	unsigned char *start;
    497
    	/** pointer to the end of the stream */
    498
    	unsigned char *end;
    499
    	/** pointer to the current position */
    500
    	unsigned char *bp;
    501
    } opj_cio_t;
    502
     
    503
    /*
    504
    ==========================================================
    505
       image typedef definitions
    506
    ==========================================================
    507
    */
    508
     
    509
    /**
    510
    Defines a single image component
    511
    */
    512
    typedef struct opj_image_comp {
    513
    	/** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
    514
    	int dx;
    515
    	/** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
    516
    	int dy;
    517
    	/** data width */
    518
    	int w;
    519
    	/** data height */
    520
    	int h;
    521
    	/** x component offset compared to the whole image */
    522
    	int x0;
    523
    	/** y component offset compared to the whole image */
    524
    	int y0;
    525
    	/** precision */
    526
    	int prec;
    527
    	/** image depth in bits */
    528
    	int bpp;
    529
    	/** signed (1) / unsigned (0) */
    530
    	int sgnd;
    531
    	/** number of decoded resolution */
    532
    	int resno_decoded;
    533
    	/** number of division by 2 of the out image compared to the original size of image */
    534
    	int factor;
    535
    	/** image component data */
    536
    	int *data;
    537
    } opj_image_comp_t;
    538
     
    539
    /**
    540
    Defines image data and characteristics
    541
    */
    542
    typedef struct opj_image {
    543
    	/** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */
    544
    	int x0;
    545
    	/** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */
    546
    	int y0;
    547
    	/** Xsiz: width of the reference grid */
    548
    	int x1;
    549
    	/** Ysiz: height of the reference grid */
    550
    	int y1;
    551
    	/** number of components in the image */
    552
    	int numcomps;
    553
    	/** color space: sRGB, Greyscale or YUV */
    554
    	OPJ_COLOR_SPACE color_space;
    555
    	/** image components */
    556
    	opj_image_comp_t *comps;
    557
    	/** 'restricted' ICC profile */
    558
    	unsigned char *icc_profile_buf;
    559
    	/** size of ICC profile */
    560
    	int icc_profile_len;
    561
    } opj_image_t;
    562
     
    563
    /**
    564
    Component parameters structure used by the opj_image_create function
    565
    */
    566
    typedef struct opj_image_comptparm {
    567
    	/** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
    568
    	int dx;
    569
    	/** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
    570
    	int dy;
    571
    	/** data width */
    572
    	int w;
    573
    	/** data height */
    574
    	int h;
    575
    	/** x component offset compared to the whole image */
    576
    	int x0;
    577
    	/** y component offset compared to the whole image */
    578
    	int y0;
    579
    	/** precision */
    580
    	int prec;
    581
    	/** image depth in bits */
    582
    	int bpp;
    583
    	/** signed (1) / unsigned (0) */
    584
    	int sgnd;
    585
    } opj_image_cmptparm_t;
    586
     
    587
    /*
    588
    ==========================================================
    589
       Information on the JPEG 2000 codestream
    590
    ==========================================================
    591
    */
    592
     
    593
    /**
    594
    Index structure : Information concerning a packet inside tile
    595
    */
    596
    typedef struct opj_packet_info {
    597
    	/** packet start position (including SOP marker if it exists) */
    598
    	int start_pos;
    599
    	/** end of packet header position (including EPH marker if it exists)*/
    600
    	int end_ph_pos;
    601
    	/** packet end position */
    602
    	int end_pos;
    603
    	/** packet distorsion */
    604
    	double disto;
    605
    } opj_packet_info_t;
    606
     
    607
    /**
    608
    Index structure : Information concerning tile-parts
    609
    */
    610
    typedef struct opj_tp_info {
    611
    	/** start position of tile part */
    612
    	int tp_start_pos;
    613
    	/** end position of tile part header */
    614
    	int tp_end_header;
    615
    	/** end position of tile part */
    616
    	int tp_end_pos;
    617
    	/** start packet of tile part */
    618
    	int tp_start_pack;
    619
    	/** number of packets of tile part */
    620
    	int tp_numpacks;
    621
    } opj_tp_info_t;
    622
     
    623
    /**
    624
    Index structure : information regarding tiles
    625
    */
    626
    typedef struct opj_tile_info {
    627
    	/** value of thresh for each layer by tile cfr. Marcela   */
    628
    	double *thresh;
    629
    	/** number of tile */
    630
    	int tileno;
    631
    	/** start position */
    632
    	int start_pos;
    633
    	/** end position of the header */
    634
    	int end_header;
    635
    	/** end position */
    636
    	int end_pos;
    637
    	/** precinct number for each resolution level (width) */
    638
    	int pw[33];
    639
    	/** precinct number for each resolution level (height) */
    640
    	int ph[33];
    641
    	/** precinct size (in power of 2), in X for each resolution level */
    642
    	int pdx[33];
    643
    	/** precinct size (in power of 2), in Y for each resolution level */
    644
    	int pdy[33];
    645
    	/** information concerning packets inside tile */
    646
    	opj_packet_info_t *packet;
    647
    	/** add fixed_quality */
    648
    	int numpix;
    649
    	/** add fixed_quality */
    650
    	double distotile;
    651
    	/** number of tile parts */
    652
    	int num_tps;
    653
    	/** information concerning tile parts */
    654
    	opj_tp_info_t *tp;
    655
    } opj_tile_info_t;
    656
     
    657
    /* UniPG>> */
    658
    /**
    659
    Marker structure
    660
    */
    661
    typedef struct opj_marker_info_t {
    662
    	/** marker type */
    663
    	unsigned short int type;
    664
    	/** position in codestream */
    665
    	int pos;
    666
    	/** length, marker val included */
    667
    	int len;
    668
    } opj_marker_info_t;
    669
    /* <
    670
     
    671
    /**
    672
    Index structure of the codestream
    673
    */
    674
    typedef struct opj_codestream_info {
    675
    	/** maximum distortion reduction on the whole image (add for Marcela) */
    676
    	double D_max;
    677
    	/** packet number */
    678
    	int packno;
    679
    	/** writing the packet in the index with t2_encode_packets */
    680
    	int index_write;
    681
    	/** image width */
    682
    	int image_w;
    683
    	/** image height */
    684
    	int image_h;
    685
    	/** progression order */
    686
    	OPJ_PROG_ORDER prog;
    687
    	/** tile size in x */
    688
    	int tile_x;
    689
    	/** tile size in y */
    690
    	int tile_y;
    691
    	/** */
    692
    	int tile_Ox;
    693
    	/** */
    694
    	int tile_Oy;
    695
    	/** number of tiles in X */
    696
    	int tw;
    697
    	/** number of tiles in Y */
    698
    	int th;
    699
    	/** component numbers */
    700
    	int numcomps;
    701
    	/** number of layer */
    702
    	int numlayers;
    703
    	/** number of decomposition for each component */
    704
    	int *numdecompos;
    705
    /* UniPG>> */
    706
    	/** number of markers */
    707
    	int marknum;
    708
    	/** list of markers */
    709
    	opj_marker_info_t *marker;
    710
    	/** actual size of markers array */
    711
    	int maxmarknum;
    712
    /* <
    713
    	/** main header position */
    714
    	int main_head_start;
    715
    	/** main header position */
    716
    	int main_head_end;
    717
    	/** codestream's size */
    718
    	int codestream_size;
    719
    	/** information regarding tiles inside image */
    720
    	opj_tile_info_t *tile;
    721
    } opj_codestream_info_t;
    722
     
    723
    #ifdef __cplusplus
    724
    extern "C" {
    725
    #endif
    726
     
    727
     
    728
    /*
    729
    ==========================================================
    730
       openjpeg version
    731
    ==========================================================
    732
    */
    733
     
    734
    OPJ_API const char * OPJ_CALLCONV opj_version(void);
    735
     
    736
    /*
    737
    ==========================================================
    738
       image functions definitions
    739
    ==========================================================
    740
    */
    741
     
    742
    /**
    743
    Create an image
    744
    @param numcmpts number of components
    745
    @param cmptparms components parameters
    746
    @param clrspc image color space
    747
    @return returns a new image structure if successful, returns NULL otherwise
    748
    */
    749
    OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
    750
     
    751
    /**
    752
    Deallocate any resources associated with an image
    753
    @param image image to be destroyed
    754
    */
    755
    OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
    756
     
    757
    /*
    758
    ==========================================================
    759
       stream functions definitions
    760
    ==========================================================
    761
    */
    762
     
    763
    /**
    764
    Open and allocate a memory stream for read / write.
    765
    On reading, the user must provide a buffer containing encoded data. The buffer will be
    766
    wrapped by the returned CIO handle.
    767
    On writing, buffer parameters must be set to 0: a buffer will be allocated by the library
    768
    to contain encoded data.
    769
    @param cinfo Codec context info
    770
    @param buffer Reading: buffer address. Writing: NULL
    771
    @param length Reading: buffer length. Writing: 0
    772
    @return Returns a CIO handle if successful, returns NULL otherwise
    773
    */
    774
    OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
    775
     
    776
    /**
    777
    Close and free a CIO handle
    778
    @param cio CIO handle to free
    779
    */
    780
    OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio);
    781
     
    782
    /**
    783
    Get position in byte stream
    784
    @param cio CIO handle
    785
    @return Returns the position in bytes
    786
    */
    787
    OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio);
    788
    /**
    789
    Set position in byte stream
    790
    @param cio CIO handle
    791
    @param pos Position, in number of bytes, from the beginning of the stream
    792
    */
    793
    OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
    794
     
    795
    /*
    796
    ==========================================================
    797
       event manager functions definitions
    798
    ==========================================================
    799
    */
    800
     
    801
    OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
    802
     
    803
    /*
    804
    ==========================================================
    805
       codec functions definitions
    806
    ==========================================================
    807
    */
    808
    /**
    809
    Creates a J2K/JPT/JP2 decompression structure
    810
    @param format Decoder to select
    811
    @return Returns a handle to a decompressor if successful, returns NULL otherwise
    812
    */
    813
    OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
    814
    /**
    815
    Destroy a decompressor handle
    816
    @param dinfo decompressor handle to destroy
    817
    */
    818
    OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo);
    819
    /**
    820
    Set decoding parameters to default values
    821
    @param parameters Decompression parameters
    822
    */
    823
    OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
    824
    /**
    825
    Setup the decoder decoding parameters using user parameters.
    826
    Decoding parameters are returned in j2k->cp.
    827
    @param dinfo decompressor handle
    828
    @param parameters decompression parameters
    829
    */
    830
    OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
    831
    /**
    832
    Decode an image from a JPEG-2000 codestream
    833
    @param dinfo decompressor handle
    834
    @param cio Input buffer stream
    835
    @return Returns a decoded image if successful, returns NULL otherwise
    836
    */
    837
    OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
    838
     
    839
    /**
    840
    Decode an image from a JPEG-2000 codestream and extract the codestream information
    841
    @param dinfo decompressor handle
    842
    @param cio Input buffer stream
    843
    @param cstr_info Codestream information structure if needed afterwards, NULL otherwise
    844
    @return Returns a decoded image if successful, returns NULL otherwise
    845
    */
    846
    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);
    847
    /**
    848
    Creates a J2K/JP2 compression structure
    849
    @param format Coder to select
    850
    @return Returns a handle to a compressor if successful, returns NULL otherwise
    851
    */
    852
    OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
    853
    /**
    854
    Destroy a compressor handle
    855
    @param cinfo compressor handle to destroy
    856
    */
    857
    OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo);
    858
    /**
    859
    Set encoding parameters to default values, that means :
    860
      861
    • Lossless
    • 862
    • 1 tile
    • 863
    • Size of precinct : 2^15 x 2^15 (means 1 precinct)
    • 864
    • Size of code-block : 64 x 64
    • 865
    • Number of resolutions: 6
    • 866
    • No SOP marker in the codestream
    • 867
    • No EPH marker in the codestream
    • 868
    • No sub-sampling in x or y direction
    • 869
    • No mode switch activated
    • 870
    • Progression order: LRCP
    • 871
    • No index file
    • 872
    • No ROI upshifted
    • 873
    • No offset of the origin of the image
    • 874
    • No offset of the origin of the tiles
    • 875
    • Reversible DWT 5-3
    • 876
      877
      @param parameters Compression parameters
      878
      */
      879
      OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
      880
      /**
      881
      Setup the encoder parameters using the current image and using user parameters.
      882
      @param cinfo Compressor handle
      883
      @param parameters Compression parameters
      884
      @param image Input filled image
      885
      */
      886
      OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
      887
      /**
      888
      Encode an image into a JPEG-2000 codestream
      889
      @param cinfo compressor handle
      890
      @param cio Output buffer stream
      891
      @param image Image to encode
      892
      @param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci()
      893
      @return Returns true if successful, returns false otherwise
      894
      */
      895
      OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
      896
      /**
      897
      Encode an image into a JPEG-2000 codestream and extract the codestream information
      898
      @param cinfo compressor handle
      899
      @param cio Output buffer stream
      900
      @param image Image to encode
      901
      @param cstr_info Codestream information structure if needed afterwards, NULL otherwise
      902
      @return Returns true if successful, returns false otherwise
      903
      */
      904
      OPJ_API 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);
      905
      /**
      906
      Destroy Codestream information after compression or decompression
      907
      @param cstr_info Codestream information structure
      908
      */
      909
      OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
      910
       
      911
      #ifdef __cplusplus
      912
      }
      913
      #endif
      914
       
      915
      #endif /* OPENJPEG_H */