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