1 | /* |
2 | * The copyright in this software is being made available under the 2-clauses |
3 | * BSD License, included below. This software may be subject to other third |
4 | * party and contributor rights, including patent rights, and no such rights |
5 | * are granted under this license. |
6 | * |
7 | * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium |
8 | * Copyright (c) 2002-2014, Professor Benoit Macq |
9 | * Copyright (c) 2001-2003, David Janssens |
10 | * Copyright (c) 2002-2003, Yannick Verschueren |
11 | * Copyright (c) 2003-2007, Francois-Olivier Devaux |
12 | * Copyright (c) 2003-2014, Antonin Descampe |
13 | * Copyright (c) 2005, Herve Drolon, FreeImage Team |
14 | * Copyright (c) 2006-2007, Parvatha Elangovan |
15 | * Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr> |
16 | * Copyright (c) 2010-2011, Kaori Hagihara |
17 | * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France |
18 | * Copyright (c) 2012, CS Systemes d'Information, France |
19 | * All rights reserved. |
20 | * |
21 | * Redistribution and use in source and binary forms, with or without |
22 | * modification, are permitted provided that the following conditions |
23 | * are met: |
24 | * 1. Redistributions of source code must retain the above copyright |
25 | * notice, this list of conditions and the following disclaimer. |
26 | * 2. Redistributions in binary form must reproduce the above copyright |
27 | * notice, this list of conditions and the following disclaimer in the |
28 | * documentation and/or other materials provided with the distribution. |
29 | * |
30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' |
31 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
32 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
34 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
35 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
36 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
37 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
38 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
39 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
40 | * POSSIBILITY OF SUCH DAMAGE. |
41 | */ |
42 | #ifndef OPENJPEG_H |
43 | #define OPENJPEG_H |
44 | |
45 | |
46 | /* |
47 | ========================================================== |
48 | Compiler directives |
49 | ========================================================== |
50 | */ |
51 | |
52 | /* |
53 | The inline keyword is supported by C99 but not by C90. |
54 | Most compilers implement their own version of this keyword ... |
55 | */ |
56 | #ifndef INLINE |
57 | #if defined(_MSC_VER) |
58 | #define INLINE __forceinline |
59 | #elif defined(__GNUC__) |
60 | #define INLINE __inline__ |
61 | #elif defined(__MWERKS__) |
62 | #define INLINE inline |
63 | #else |
64 | /* add other compilers here ... */ |
65 | #define INLINE |
66 | #endif /* defined(<Compiler>) */ |
67 | #endif /* INLINE */ |
68 | |
69 | /* deprecated attribute */ |
70 | #ifdef __GNUC__ |
71 | #define OPJ_DEPRECATED(func) func __attribute__ ((deprecated)) |
72 | #elif defined(_MSC_VER) |
73 | #define OPJ_DEPRECATED(func) __declspec(deprecated) func |
74 | #else |
75 | #pragma message("WARNING: You need to implement DEPRECATED for this compiler") |
76 | #define OPJ_DEPRECATED(func) func |
77 | #endif |
78 | |
79 | #if defined(OPJ_STATIC) || !defined(_WIN32) |
80 | /* http://gcc.gnu.org/wiki/Visibility */ |
81 | # if __GNUC__ >= 4 |
82 | # if defined(OPJ_STATIC) /* static library uses "hidden" */ |
83 | # define OPJ_API __attribute__ ((visibility ("hidden"))) |
84 | # else |
85 | # define OPJ_API __attribute__ ((visibility ("default"))) |
86 | # endif |
87 | # define OPJ_LOCAL __attribute__ ((visibility ("hidden"))) |
88 | # else |
89 | # define OPJ_API |
90 | # define OPJ_LOCAL |
91 | # endif |
92 | # define OPJ_CALLCONV |
93 | #else |
94 | # define OPJ_CALLCONV __stdcall |
95 | /* |
96 | The following ifdef block is the standard way of creating macros which make exporting |
97 | from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS |
98 | symbol defined on the command line. this symbol should not be defined on any project |
99 | that uses this DLL. This way any other project whose source files include this file see |
100 | OPJ_API functions as being imported from a DLL, whereas this DLL sees symbols |
101 | defined with this macro as being exported. |
102 | */ |
103 | # if defined(OPJ_EXPORTS) || defined(DLL_EXPORT) |
104 | # define OPJ_API __declspec(dllexport) |
105 | # else |
106 | # define OPJ_API __declspec(dllimport) |
107 | # endif /* OPJ_EXPORTS */ |
108 | #endif /* !OPJ_STATIC || !_WIN32 */ |
109 | |
110 | typedef int OPJ_BOOL; |
111 | #define OPJ_TRUE 1 |
112 | #define OPJ_FALSE 0 |
113 | |
114 | typedef char OPJ_CHAR; |
115 | typedef float OPJ_FLOAT32; |
116 | typedef double OPJ_FLOAT64; |
117 | typedef unsigned char OPJ_BYTE; |
118 | |
119 | #include "opj_stdint.h" |
120 | |
121 | typedef int8_t OPJ_INT8; |
122 | typedef uint8_t OPJ_UINT8; |
123 | typedef int16_t OPJ_INT16; |
124 | typedef uint16_t OPJ_UINT16; |
125 | typedef int32_t OPJ_INT32; |
126 | typedef uint32_t OPJ_UINT32; |
127 | typedef int64_t OPJ_INT64; |
128 | typedef uint64_t OPJ_UINT64; |
129 | |
130 | typedef int64_t OPJ_OFF_T; /* 64-bit file offset type */ |
131 | |
132 | #include <stdio.h> |
133 | typedef size_t OPJ_SIZE_T; |
134 | |
135 | /* Avoid compile-time warning because parameter is not used */ |
136 | #define OPJ_ARG_NOT_USED(x) (void)(x) |
137 | |
138 | /* |
139 | ========================================================== |
140 | Useful constant definitions |
141 | ========================================================== |
142 | */ |
143 | |
144 | #define OPJ_PATH_LEN 4096 /**< Maximum allowed size for filenames */ |
145 | |
146 | #define OPJ_J2K_MAXRLVLS 33 /**< Number of maximum resolution level authorized */ |
147 | #define OPJ_J2K_MAXBANDS (3*OPJ_J2K_MAXRLVLS-2) /**< Number of maximum sub-band linked to number of resolution level */ |
148 | |
149 | #define OPJ_J2K_DEFAULT_NB_SEGS 10 |
150 | #define OPJ_J2K_STREAM_CHUNK_SIZE 0x100000 /** 1 mega by default */ |
151 | #define 1000 |
152 | #define OPJ_J2K_MCC_DEFAULT_NB_RECORDS 10 |
153 | #define OPJ_J2K_MCT_DEFAULT_NB_RECORDS 10 |
154 | |
155 | /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */ |
156 | #define JPWL_MAX_NO_TILESPECS 16 /**< Maximum number of tile parts expected by JPWL: increase at your will */ |
157 | #define JPWL_MAX_NO_PACKSPECS 16 /**< Maximum number of packet parts expected by JPWL: increase at your will */ |
158 | #define JPWL_MAX_NO_MARKERS 512 /**< Maximum number of JPWL markers: increase at your will */ |
159 | #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename" /**< index file name used when JPWL is on */ |
160 | #define JPWL_EXPECTED_COMPONENTS 3 /**< Expect this number of components, so you'll find better the first EPB */ |
161 | #define JPWL_MAXIMUM_TILES 8192 /**< Expect this maximum number of tiles, to avoid some crashes */ |
162 | #define JPWL_MAXIMUM_HAMMING 2 /**< Expect this maximum number of bit errors in marker id's */ |
163 | #define JPWL_MAXIMUM_EPB_ROOM 65450 /**< Expect this maximum number of bytes for composition of EPBs */ |
164 | /* <<UniPG */ |
165 | |
166 | /** |
167 | * EXPERIMENTAL FOR THE MOMENT |
168 | * Supported options about file information used only in j2k_dump |
169 | */ |
170 | #define OPJ_IMG_INFO 1 /**< Basic image information provided to the user */ |
171 | #define OPJ_J2K_MH_INFO 2 /**< Codestream information based only on the main header */ |
172 | #define OPJ_J2K_TH_INFO 4 /**< Tile information based on the current tile header */ |
173 | #define OPJ_J2K_TCH_INFO 8 /**< Tile/Component information of all tiles */ |
174 | #define OPJ_J2K_MH_IND 16 /**< Codestream index based only on the main header */ |
175 | #define OPJ_J2K_TH_IND 32 /**< Tile index based on the current tile */ |
176 | /*FIXME #define OPJ_J2K_CSTR_IND 48*/ /**< */ |
177 | #define OPJ_JP2_INFO 128 /**< JP2 file information */ |
178 | #define OPJ_JP2_IND 256 /**< JP2 file index */ |
179 | |
180 | /** |
181 | * JPEG 2000 Profiles, see Table A.10 from 15444-1 (updated in various AMD) |
182 | * These values help choosing the RSIZ value for the J2K codestream. |
183 | * The RSIZ value triggers various encoding options, as detailed in Table A.10. |
184 | * If OPJ_PROFILE_PART2 is chosen, it has to be combined with one or more extensions |
185 | * described hereunder. |
186 | * Example: rsiz = OPJ_PROFILE_PART2 | OPJ_EXTENSION_MCT; |
187 | * For broadcast profiles, the OPJ_PROFILE value has to be combined with the targeted |
188 | * mainlevel (3-0 LSB, value between 0 and 11): |
189 | * Example: rsiz = OPJ_PROFILE_BC_MULTI | 0x0005; (here mainlevel 5) |
190 | * For IMF profiles, the OPJ_PROFILE value has to be combined with the targeted mainlevel |
191 | * (3-0 LSB, value between 0 and 11) and sublevel (7-4 LSB, value between 0 and 9): |
192 | * Example: rsiz = OPJ_PROFILE_IMF_2K | 0x0040 | 0x0005; (here main 5 and sublevel 4) |
193 | * */ |
194 | #define OPJ_PROFILE_NONE 0x0000 /** no profile, conform to 15444-1 */ |
195 | #define OPJ_PROFILE_0 0x0001 /** Profile 0 as described in 15444-1,Table A.45 */ |
196 | #define OPJ_PROFILE_1 0x0002 /** Profile 1 as described in 15444-1,Table A.45 */ |
197 | #define OPJ_PROFILE_PART2 0x8000 /** At least 1 extension defined in 15444-2 (Part-2) */ |
198 | #define OPJ_PROFILE_CINEMA_2K 0x0003 /** 2K cinema profile defined in 15444-1 AMD1 */ |
199 | #define OPJ_PROFILE_CINEMA_4K 0x0004 /** 4K cinema profile defined in 15444-1 AMD1 */ |
200 | #define OPJ_PROFILE_CINEMA_S2K 0x0005 /** Scalable 2K cinema profile defined in 15444-1 AMD2 */ |
201 | #define OPJ_PROFILE_CINEMA_S4K 0x0006 /** Scalable 4K cinema profile defined in 15444-1 AMD2 */ |
202 | #define OPJ_PROFILE_CINEMA_LTS 0x0007 /** Long term storage cinema profile defined in 15444-1 AMD2 */ |
203 | #define OPJ_PROFILE_BC_SINGLE 0x0100 /** Single Tile Broadcast profile defined in 15444-1 AMD3 */ |
204 | #define OPJ_PROFILE_BC_MULTI 0x0200 /** Multi Tile Broadcast profile defined in 15444-1 AMD3 */ |
205 | #define OPJ_PROFILE_BC_MULTI_R 0x0300 /** Multi Tile Reversible Broadcast profile defined in 15444-1 AMD3 */ |
206 | #define OPJ_PROFILE_IMF_2K 0x0400 /** 2K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */ |
207 | #define OPJ_PROFILE_IMF_4K 0x0401 /** 4K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */ |
208 | #define OPJ_PROFILE_IMF_8K 0x0402 /** 8K Single Tile Lossy IMF profile defined in 15444-1 AMD 8 */ |
209 | #define OPJ_PROFILE_IMF_2K_R 0x0403 /** 2K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */ |
210 | #define OPJ_PROFILE_IMF_4K_R 0x0800 /** 4K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */ |
211 | #define OPJ_PROFILE_IMF_8K_R 0x0801 /** 8K Single/Multi Tile Reversible IMF profile defined in 15444-1 AMD 8 */ |
212 | |
213 | /** |
214 | * JPEG 2000 Part-2 extensions |
215 | * */ |
216 | #define OPJ_EXTENSION_NONE 0x0000 /** No Part-2 extension */ |
217 | #define OPJ_EXTENSION_MCT 0x0100 /** Custom MCT support */ |
218 | |
219 | /** |
220 | * JPEG 2000 profile macros |
221 | * */ |
222 | #define OPJ_IS_CINEMA(v) (((v) >= OPJ_PROFILE_CINEMA_2K)&&((v) <= OPJ_PROFILE_CINEMA_S4K)) |
223 | #define OPJ_IS_STORAGE(v) ((v) == OPJ_PROFILE_CINEMA_LTS) |
224 | #define OPJ_IS_BROADCAST(v) (((v) >= OPJ_PROFILE_BC_SINGLE)&&((v) <= ((OPJ_PROFILE_BC_MULTI_R) | (0x000b)))) |
225 | #define OPJ_IS_IMF(v) (((v) >= OPJ_PROFILE_IMF_2K)&&((v) <= ((OPJ_PROFILE_IMF_8K_R) | (0x009b)))) |
226 | #define OPJ_IS_PART2(v) ((v) & OPJ_PROFILE_PART2) |
227 | |
228 | /** |
229 | * JPEG 2000 codestream and component size limits in cinema profiles |
230 | * */ |
231 | #define OPJ_CINEMA_24_CS 1302083 /** Maximum codestream length for 24fps */ |
232 | #define OPJ_CINEMA_48_CS 651041 /** Maximum codestream length for 48fps */ |
233 | #define OPJ_CINEMA_24_COMP 1041666 /** Maximum size per color component for 2K & 4K @ 24fps */ |
234 | #define OPJ_CINEMA_48_COMP 520833 /** Maximum size per color component for 2K @ 48fps */ |
235 | |
236 | /* |
237 | ========================================================== |
238 | enum definitions |
239 | ========================================================== |
240 | */ |
241 | |
242 | /** |
243 | * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead |
244 | * Rsiz Capabilities |
245 | * */ |
246 | typedef enum RSIZ_CAPABILITIES { |
247 | OPJ_STD_RSIZ = 0, /** Standard JPEG2000 profile*/ |
248 | OPJ_CINEMA2K = 3, /** Profile name for a 2K image*/ |
249 | OPJ_CINEMA4K = 4, /** Profile name for a 4K image*/ |
250 | OPJ_MCT = 0x8100 |
251 | } OPJ_RSIZ_CAPABILITIES; |
252 | |
253 | /** |
254 | * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead |
255 | * Digital cinema operation mode |
256 | * */ |
257 | typedef enum CINEMA_MODE { |
258 | OPJ_OFF = 0, /** Not Digital Cinema*/ |
259 | OPJ_CINEMA2K_24 = 1, /** 2K Digital Cinema at 24 fps*/ |
260 | OPJ_CINEMA2K_48 = 2, /** 2K Digital Cinema at 48 fps*/ |
261 | OPJ_CINEMA4K_24 = 3 /** 4K Digital Cinema at 24 fps*/ |
262 | } OPJ_CINEMA_MODE; |
263 | |
264 | /** |
265 | * Progression order |
266 | * */ |
267 | typedef enum PROG_ORDER { |
268 | OPJ_PROG_UNKNOWN = -1, /**< place-holder */ |
269 | OPJ_LRCP = 0, /**< layer-resolution-component-precinct order */ |
270 | OPJ_RLCP = 1, /**< resolution-layer-component-precinct order */ |
271 | OPJ_RPCL = 2, /**< resolution-precinct-component-layer order */ |
272 | OPJ_PCRL = 3, /**< precinct-component-resolution-layer order */ |
273 | OPJ_CPRL = 4 /**< component-precinct-resolution-layer order */ |
274 | } OPJ_PROG_ORDER; |
275 | |
276 | /** |
277 | * Supported image color spaces |
278 | */ |
279 | typedef enum COLOR_SPACE { |
280 | OPJ_CLRSPC_UNKNOWN = -1, /**< not supported by the library */ |
281 | OPJ_CLRSPC_UNSPECIFIED = 0, /**< not specified in the codestream */ |
282 | OPJ_CLRSPC_SRGB = 1, /**< sRGB */ |
283 | OPJ_CLRSPC_GRAY = 2, /**< grayscale */ |
284 | OPJ_CLRSPC_SYCC = 3, /**< YUV */ |
285 | OPJ_CLRSPC_EYCC = 4, /**< e-YCC */ |
286 | OPJ_CLRSPC_CMYK = 5 /**< CMYK */ |
287 | } OPJ_COLOR_SPACE; |
288 | |
289 | /** |
290 | * Supported codec |
291 | */ |
292 | typedef enum CODEC_FORMAT { |
293 | OPJ_CODEC_UNKNOWN = -1, /**< place-holder */ |
294 | OPJ_CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */ |
295 | OPJ_CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */ |
296 | OPJ_CODEC_JP2 = 2, /**< JP2 file format : read/write */ |
297 | OPJ_CODEC_JPP = 3, /**< JPP-stream (JPEG 2000, JPIP) : to be coded */ |
298 | OPJ_CODEC_JPX = 4 /**< JPX file format (JPEG 2000 Part-2) : to be coded */ |
299 | } OPJ_CODEC_FORMAT; |
300 | |
301 | |
302 | /* |
303 | ========================================================== |
304 | event manager typedef definitions |
305 | ========================================================== |
306 | */ |
307 | |
308 | /** |
309 | * Callback function prototype for events |
310 | * @param msg Event message |
311 | * @param client_data Client object where will be return the event message |
312 | * */ |
313 | typedef void (*opj_msg_callback)(const char *msg, void *client_data); |
314 | |
315 | /* |
316 | ========================================================== |
317 | codec typedef definitions |
318 | ========================================================== |
319 | */ |
320 | |
321 | /** |
322 | * Progression order changes |
323 | * |
324 | */ |
325 | typedef struct opj_poc { |
326 | /** Resolution num start, Component num start, given by POC */ |
327 | OPJ_UINT32 resno0, compno0; |
328 | /** Layer num end,Resolution num end, Component num end, given by POC */ |
329 | OPJ_UINT32 layno1, resno1, compno1; |
330 | /** Layer num start,Precinct num start, Precinct num end */ |
331 | OPJ_UINT32 layno0, precno0, precno1; |
332 | /** Progression order enum*/ |
333 | OPJ_PROG_ORDER prg1, prg; |
334 | /** Progression order string*/ |
335 | OPJ_CHAR progorder[5]; |
336 | /** Tile number */ |
337 | OPJ_UINT32 tile; |
338 | /** Start and end values for Tile width and height*/ |
339 | OPJ_INT32 tx0, tx1, ty0, ty1; |
340 | /** Start value, initialised in pi_initialise_encode*/ |
341 | OPJ_UINT32 layS, resS, compS, prcS; |
342 | /** End value, initialised in pi_initialise_encode */ |
343 | OPJ_UINT32 layE, resE, compE, prcE; |
344 | /** Start and end values of Tile width and height, initialised in pi_initialise_encode*/ |
345 | OPJ_UINT32 txS, txE, tyS, tyE, dx, dy; |
346 | /** Temporary values for Tile parts, initialised in pi_create_encode */ |
347 | OPJ_UINT32 lay_t, res_t, comp_t, prc_t, tx0_t, ty0_t; |
348 | } opj_poc_t; |
349 | |
350 | /** |
351 | * Compression parameters |
352 | * */ |
353 | typedef struct opj_cparameters { |
354 | /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */ |
355 | OPJ_BOOL tile_size_on; |
356 | /** XTOsiz */ |
357 | int cp_tx0; |
358 | /** YTOsiz */ |
359 | int cp_ty0; |
360 | /** XTsiz */ |
361 | int cp_tdx; |
362 | /** YTsiz */ |
363 | int cp_tdy; |
364 | /** allocation by rate/distortion */ |
365 | int cp_disto_alloc; |
366 | /** allocation by fixed layer */ |
367 | int cp_fixed_alloc; |
368 | /** add fixed_quality */ |
369 | int cp_fixed_quality; |
370 | /** fixed layer */ |
371 | int *cp_matrice; |
372 | /** comment for coding */ |
373 | char *; |
374 | /** csty : coding style */ |
375 | int csty; |
376 | /** progression order (default OPJ_LRCP) */ |
377 | OPJ_PROG_ORDER prog_order; |
378 | /** progression order changes */ |
379 | opj_poc_t POC[32]; |
380 | /** number of progression order changes (POC), default to 0 */ |
381 | OPJ_UINT32 numpocs; |
382 | /** number of layers */ |
383 | int tcp_numlayers; |
384 | /** rates of layers - might be subsequently limited by the max_cs_size field. |
385 | * Should be decreasing. 1 can be |
386 | * used as last value to indicate the last layer is lossless. */ |
387 | float tcp_rates[100]; |
388 | /** different psnr for successive layers. Should be increasing. 0 can be |
389 | * used as last value to indicate the last layer is lossless. */ |
390 | float tcp_distoratio[100]; |
391 | /** number of resolutions */ |
392 | int numresolution; |
393 | /** initial code block width, default to 64 */ |
394 | int cblockw_init; |
395 | /** initial code block height, default to 64 */ |
396 | int cblockh_init; |
397 | /** mode switch (cblk_style) */ |
398 | int mode; |
399 | /** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */ |
400 | int irreversible; |
401 | /** region of interest: affected component in [0..3], -1 means no ROI */ |
402 | int roi_compno; |
403 | /** region of interest: upshift value */ |
404 | int roi_shift; |
405 | /* number of precinct size specifications */ |
406 | int res_spec; |
407 | /** initial precinct width */ |
408 | int prcw_init[OPJ_J2K_MAXRLVLS]; |
409 | /** initial precinct height */ |
410 | int prch_init[OPJ_J2K_MAXRLVLS]; |
411 | |
412 | /**@name command line encoder parameters (not used inside the library) */ |
413 | /*@{*/ |
414 | /** input file name */ |
415 | char infile[OPJ_PATH_LEN]; |
416 | /** output file name */ |
417 | char outfile[OPJ_PATH_LEN]; |
418 | /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */ |
419 | int index_on; |
420 | /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */ |
421 | char index[OPJ_PATH_LEN]; |
422 | /** subimage encoding: origin image offset in x direction */ |
423 | int image_offset_x0; |
424 | /** subimage encoding: origin image offset in y direction */ |
425 | int image_offset_y0; |
426 | /** subsampling value for dx */ |
427 | int subsampling_dx; |
428 | /** subsampling value for dy */ |
429 | int subsampling_dy; |
430 | /** input file format 0: PGX, 1: PxM, 2: BMP 3:TIF*/ |
431 | int decod_format; |
432 | /** output file format 0: J2K, 1: JP2, 2: JPT */ |
433 | int cod_format; |
434 | /*@}*/ |
435 | |
436 | /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */ |
437 | /**@name JPWL encoding parameters */ |
438 | /*@{*/ |
439 | /** enables writing of EPC in MH, thus activating JPWL */ |
440 | OPJ_BOOL jpwl_epc_on; |
441 | /** error protection method for MH (0,1,16,32,37-128) */ |
442 | int jpwl_hprot_MH; |
443 | /** tile number of header protection specification (>=0) */ |
444 | int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS]; |
445 | /** error protection methods for TPHs (0,1,16,32,37-128) */ |
446 | int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS]; |
447 | /** tile number of packet protection specification (>=0) */ |
448 | int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS]; |
449 | /** packet number of packet protection specification (>=0) */ |
450 | int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS]; |
451 | /** error protection methods for packets (0,1,16,32,37-128) */ |
452 | int jpwl_pprot[JPWL_MAX_NO_PACKSPECS]; |
453 | /** enables writing of ESD, (0=no/1/2 bytes) */ |
454 | int jpwl_sens_size; |
455 | /** sensitivity addressing size (0=auto/2/4 bytes) */ |
456 | int jpwl_sens_addr; |
457 | /** sensitivity range (0-3) */ |
458 | int jpwl_sens_range; |
459 | /** sensitivity method for MH (-1=no,0-7) */ |
460 | int jpwl_sens_MH; |
461 | /** tile number of sensitivity specification (>=0) */ |
462 | int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS]; |
463 | /** sensitivity methods for TPHs (-1=no,0-7) */ |
464 | int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS]; |
465 | /*@}*/ |
466 | /* <<UniPG */ |
467 | |
468 | /** |
469 | * DEPRECATED: use RSIZ, OPJ_PROFILE_* and MAX_COMP_SIZE instead |
470 | * Digital Cinema compliance 0-not compliant, 1-compliant |
471 | * */ |
472 | OPJ_CINEMA_MODE cp_cinema; |
473 | /** |
474 | * Maximum size (in bytes) for each component. |
475 | * If == 0, component size limitation is not considered |
476 | * */ |
477 | int max_comp_size; |
478 | /** |
479 | * DEPRECATED: use RSIZ, OPJ_PROFILE_* and OPJ_EXTENSION_* instead |
480 | * Profile name |
481 | * */ |
482 | OPJ_RSIZ_CAPABILITIES cp_rsiz; |
483 | /** Tile part generation*/ |
484 | char tp_on; |
485 | /** Flag for Tile part generation*/ |
486 | char tp_flag; |
487 | /** MCT (multiple component transform) */ |
488 | char tcp_mct; |
489 | /** Enable JPIP indexing*/ |
490 | OPJ_BOOL jpip_on; |
491 | /** Naive implementation of MCT restricted to a single reversible array based |
492 | encoding without offset concerning all the components. */ |
493 | void * mct_data; |
494 | /** |
495 | * Maximum size (in bytes) for the whole codestream. |
496 | * If == 0, codestream size limitation is not considered |
497 | * If it does not comply with tcp_rates, max_cs_size prevails |
498 | * and a warning is issued. |
499 | * */ |
500 | int max_cs_size; |
501 | /** RSIZ value |
502 | To be used to combine OPJ_PROFILE_*, OPJ_EXTENSION_* and (sub)levels values. */ |
503 | OPJ_UINT16 rsiz; |
504 | } opj_cparameters_t; |
505 | |
506 | #define OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG 0x0001 |
507 | #define OPJ_DPARAMETERS_DUMP_FLAG 0x0002 |
508 | |
509 | /** |
510 | * Decompression parameters |
511 | * */ |
512 | typedef struct opj_dparameters { |
513 | /** |
514 | Set the number of highest resolution levels to be discarded. |
515 | The image resolution is effectively divided by 2 to the power of the number of discarded levels. |
516 | The reduce factor is limited by the smallest total number of decomposition levels among tiles. |
517 | if != 0, then original dimension divided by 2^(reduce); |
518 | if == 0 or not used, image is decoded to the full resolution |
519 | */ |
520 | OPJ_UINT32 cp_reduce; |
521 | /** |
522 | Set the maximum number of quality layers to decode. |
523 | If there are less quality layers than the specified number, all the quality layers are decoded. |
524 | if != 0, then only the first "layer" layers are decoded; |
525 | if == 0 or not used, all the quality layers are decoded |
526 | */ |
527 | OPJ_UINT32 cp_layer; |
528 | |
529 | /**@name command line decoder parameters (not used inside the library) */ |
530 | /*@{*/ |
531 | /** input file name */ |
532 | char infile[OPJ_PATH_LEN]; |
533 | /** output file name */ |
534 | char outfile[OPJ_PATH_LEN]; |
535 | /** input file format 0: J2K, 1: JP2, 2: JPT */ |
536 | int decod_format; |
537 | /** output file format 0: PGX, 1: PxM, 2: BMP */ |
538 | int cod_format; |
539 | |
540 | /** Decoding area left boundary */ |
541 | OPJ_UINT32 DA_x0; |
542 | /** Decoding area right boundary */ |
543 | OPJ_UINT32 DA_x1; |
544 | /** Decoding area up boundary */ |
545 | OPJ_UINT32 DA_y0; |
546 | /** Decoding area bottom boundary */ |
547 | OPJ_UINT32 DA_y1; |
548 | /** Verbose mode */ |
549 | OPJ_BOOL m_verbose; |
550 | |
551 | /** tile number ot the decoded tile*/ |
552 | OPJ_UINT32 tile_index; |
553 | /** Nb of tile to decode */ |
554 | OPJ_UINT32 nb_tile_to_decode; |
555 | |
556 | /*@}*/ |
557 | |
558 | /* UniPG>> */ /* NOT YET USED IN THE V2 VERSION OF OPENJPEG */ |
559 | /**@name JPWL decoding parameters */ |
560 | /*@{*/ |
561 | /** activates the JPWL correction capabilities */ |
562 | OPJ_BOOL jpwl_correct; |
563 | /** expected number of components */ |
564 | int jpwl_exp_comps; |
565 | /** maximum number of tiles */ |
566 | int jpwl_max_tiles; |
567 | /*@}*/ |
568 | /* <<UniPG */ |
569 | |
570 | unsigned int flags; |
571 | |
572 | } opj_dparameters_t; |
573 | |
574 | |
575 | /** |
576 | * JPEG2000 codec V2. |
577 | * */ |
578 | typedef void * opj_codec_t; |
579 | |
580 | /* |
581 | ========================================================== |
582 | I/O stream typedef definitions |
583 | ========================================================== |
584 | */ |
585 | |
586 | /** |
587 | * Stream open flags. |
588 | * */ |
589 | /** The stream was opened for reading. */ |
590 | #define OPJ_STREAM_READ OPJ_TRUE |
591 | /** The stream was opened for writing. */ |
592 | #define OPJ_STREAM_WRITE OPJ_FALSE |
593 | |
594 | /* |
595 | * Callback function prototype for read function |
596 | */ |
597 | typedef OPJ_SIZE_T(* opj_stream_read_fn)(void * p_buffer, OPJ_SIZE_T p_nb_bytes, |
598 | void * p_user_data) ; |
599 | |
600 | /* |
601 | * Callback function prototype for write function |
602 | */ |
603 | typedef OPJ_SIZE_T(* opj_stream_write_fn)(void * p_buffer, |
604 | OPJ_SIZE_T p_nb_bytes, void * p_user_data) ; |
605 | |
606 | /* |
607 | * Callback function prototype for skip function |
608 | */ |
609 | typedef OPJ_OFF_T(* opj_stream_skip_fn)(OPJ_OFF_T p_nb_bytes, |
610 | void * p_user_data) ; |
611 | |
612 | /* |
613 | * Callback function prototype for seek function |
614 | */ |
615 | typedef OPJ_BOOL(* opj_stream_seek_fn)(OPJ_OFF_T p_nb_bytes, |
616 | void * p_user_data) ; |
617 | |
618 | /* |
619 | * Callback function prototype for free user data function |
620 | */ |
621 | typedef void (* opj_stream_free_user_data_fn)(void * p_user_data) ; |
622 | |
623 | /* |
624 | * JPEG2000 Stream. |
625 | */ |
626 | typedef void * opj_stream_t; |
627 | |
628 | /* |
629 | ========================================================== |
630 | image typedef definitions |
631 | ========================================================== |
632 | */ |
633 | |
634 | /** |
635 | * Defines a single image component |
636 | * */ |
637 | typedef struct opj_image_comp { |
638 | /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */ |
639 | OPJ_UINT32 dx; |
640 | /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */ |
641 | OPJ_UINT32 dy; |
642 | /** data width */ |
643 | OPJ_UINT32 w; |
644 | /** data height */ |
645 | OPJ_UINT32 h; |
646 | /** x component offset compared to the whole image */ |
647 | OPJ_UINT32 x0; |
648 | /** y component offset compared to the whole image */ |
649 | OPJ_UINT32 y0; |
650 | /** precision */ |
651 | OPJ_UINT32 prec; |
652 | /** image depth in bits */ |
653 | OPJ_UINT32 bpp; |
654 | /** signed (1) / unsigned (0) */ |
655 | OPJ_UINT32 sgnd; |
656 | /** number of decoded resolution */ |
657 | OPJ_UINT32 resno_decoded; |
658 | /** number of division by 2 of the out image compared to the original size of image */ |
659 | OPJ_UINT32 factor; |
660 | /** image component data */ |
661 | OPJ_INT32 *data; |
662 | /** alpha channel */ |
663 | OPJ_UINT16 alpha; |
664 | } opj_image_comp_t; |
665 | |
666 | /** |
667 | * Defines image data and characteristics |
668 | * */ |
669 | typedef struct opj_image { |
670 | /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the image area */ |
671 | OPJ_UINT32 x0; |
672 | /** YOsiz: vertical offset from the origin of the reference grid to the top side of the image area */ |
673 | OPJ_UINT32 y0; |
674 | /** Xsiz: width of the reference grid */ |
675 | OPJ_UINT32 x1; |
676 | /** Ysiz: height of the reference grid */ |
677 | OPJ_UINT32 y1; |
678 | /** number of components in the image */ |
679 | OPJ_UINT32 numcomps; |
680 | /** color space: sRGB, Greyscale or YUV */ |
681 | OPJ_COLOR_SPACE color_space; |
682 | /** image components */ |
683 | opj_image_comp_t *comps; |
684 | /** 'restricted' ICC profile */ |
685 | OPJ_BYTE *icc_profile_buf; |
686 | /** size of ICC profile */ |
687 | OPJ_UINT32 icc_profile_len; |
688 | } opj_image_t; |
689 | |
690 | |
691 | /** |
692 | * Component parameters structure used by the opj_image_create function |
693 | * */ |
694 | typedef struct opj_image_comptparm { |
695 | /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */ |
696 | OPJ_UINT32 dx; |
697 | /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */ |
698 | OPJ_UINT32 dy; |
699 | /** data width */ |
700 | OPJ_UINT32 w; |
701 | /** data height */ |
702 | OPJ_UINT32 h; |
703 | /** x component offset compared to the whole image */ |
704 | OPJ_UINT32 x0; |
705 | /** y component offset compared to the whole image */ |
706 | OPJ_UINT32 y0; |
707 | /** precision */ |
708 | OPJ_UINT32 prec; |
709 | /** image depth in bits */ |
710 | OPJ_UINT32 bpp; |
711 | /** signed (1) / unsigned (0) */ |
712 | OPJ_UINT32 sgnd; |
713 | } opj_image_cmptparm_t; |
714 | |
715 | |
716 | /* |
717 | ========================================================== |
718 | Information on the JPEG 2000 codestream |
719 | ========================================================== |
720 | */ |
721 | /* QUITE EXPERIMENTAL FOR THE MOMENT */ |
722 | |
723 | /** |
724 | * Index structure : Information concerning a packet inside tile |
725 | * */ |
726 | typedef struct opj_packet_info { |
727 | /** packet start position (including SOP marker if it exists) */ |
728 | OPJ_OFF_T start_pos; |
729 | /** end of packet header position (including EPH marker if it exists)*/ |
730 | OPJ_OFF_T end_ph_pos; |
731 | /** packet end position */ |
732 | OPJ_OFF_T end_pos; |
733 | /** packet distorsion */ |
734 | double disto; |
735 | } opj_packet_info_t; |
736 | |
737 | |
738 | /* UniPG>> */ |
739 | /** |
740 | * Marker structure |
741 | * */ |
742 | typedef struct opj_marker_info { |
743 | /** marker type */ |
744 | unsigned short int type; |
745 | /** position in codestream */ |
746 | OPJ_OFF_T pos; |
747 | /** length, marker val included */ |
748 | int len; |
749 | } opj_marker_info_t; |
750 | /* <<UniPG */ |
751 | |
752 | /** |
753 | * Index structure : Information concerning tile-parts |
754 | */ |
755 | typedef struct opj_tp_info { |
756 | /** start position of tile part */ |
757 | int tp_start_pos; |
758 | /** end position of tile part header */ |
759 | int ; |
760 | /** end position of tile part */ |
761 | int tp_end_pos; |
762 | /** start packet of tile part */ |
763 | int tp_start_pack; |
764 | /** number of packets of tile part */ |
765 | int tp_numpacks; |
766 | } opj_tp_info_t; |
767 | |
768 | /** |
769 | * Index structure : information regarding tiles |
770 | */ |
771 | typedef struct opj_tile_info { |
772 | /** value of thresh for each layer by tile cfr. Marcela */ |
773 | double *thresh; |
774 | /** number of tile */ |
775 | int tileno; |
776 | /** start position */ |
777 | int start_pos; |
778 | /** end position of the header */ |
779 | int ; |
780 | /** end position */ |
781 | int end_pos; |
782 | /** precinct number for each resolution level (width) */ |
783 | int pw[33]; |
784 | /** precinct number for each resolution level (height) */ |
785 | int ph[33]; |
786 | /** precinct size (in power of 2), in X for each resolution level */ |
787 | int pdx[33]; |
788 | /** precinct size (in power of 2), in Y for each resolution level */ |
789 | int pdy[33]; |
790 | /** information concerning packets inside tile */ |
791 | opj_packet_info_t *packet; |
792 | /** add fixed_quality */ |
793 | int numpix; |
794 | /** add fixed_quality */ |
795 | double distotile; |
796 | /** number of markers */ |
797 | int marknum; |
798 | /** list of markers */ |
799 | opj_marker_info_t *marker; |
800 | /** actual size of markers array */ |
801 | int maxmarknum; |
802 | /** number of tile parts */ |
803 | int num_tps; |
804 | /** information concerning tile parts */ |
805 | opj_tp_info_t *tp; |
806 | } opj_tile_info_t; |
807 | |
808 | /** |
809 | * Index structure of the codestream |
810 | */ |
811 | typedef struct opj_codestream_info { |
812 | /** maximum distortion reduction on the whole image (add for Marcela) */ |
813 | double D_max; |
814 | /** packet number */ |
815 | int packno; |
816 | /** writing the packet in the index with t2_encode_packets */ |
817 | int index_write; |
818 | /** image width */ |
819 | int image_w; |
820 | /** image height */ |
821 | int image_h; |
822 | /** progression order */ |
823 | OPJ_PROG_ORDER prog; |
824 | /** tile size in x */ |
825 | int tile_x; |
826 | /** tile size in y */ |
827 | int tile_y; |
828 | /** */ |
829 | int tile_Ox; |
830 | /** */ |
831 | int tile_Oy; |
832 | /** number of tiles in X */ |
833 | int tw; |
834 | /** number of tiles in Y */ |
835 | int th; |
836 | /** component numbers */ |
837 | int numcomps; |
838 | /** number of layer */ |
839 | int numlayers; |
840 | /** number of decomposition for each component */ |
841 | int *numdecompos; |
842 | /* UniPG>> */ |
843 | /** number of markers */ |
844 | int marknum; |
845 | /** list of markers */ |
846 | opj_marker_info_t *marker; |
847 | /** actual size of markers array */ |
848 | int maxmarknum; |
849 | /* <<UniPG */ |
850 | /** main header position */ |
851 | int main_head_start; |
852 | /** main header position */ |
853 | int main_head_end; |
854 | /** codestream's size */ |
855 | int codestream_size; |
856 | /** information regarding tiles inside image */ |
857 | opj_tile_info_t *tile; |
858 | } opj_codestream_info_t; |
859 | |
860 | /* <----------------------------------------------------------- */ |
861 | /* new output management of the codestream information and index */ |
862 | |
863 | /** |
864 | * Tile-component coding parameters information |
865 | */ |
866 | typedef struct opj_tccp_info { |
867 | /** component index */ |
868 | OPJ_UINT32 compno; |
869 | /** coding style */ |
870 | OPJ_UINT32 csty; |
871 | /** number of resolutions */ |
872 | OPJ_UINT32 numresolutions; |
873 | /** log2 of code-blocks width */ |
874 | OPJ_UINT32 cblkw; |
875 | /** log2 of code-blocks height */ |
876 | OPJ_UINT32 cblkh; |
877 | /** code-block coding style */ |
878 | OPJ_UINT32 cblksty; |
879 | /** discrete wavelet transform identifier: 0 = 9-7 irreversible, 1 = 5-3 reversible */ |
880 | OPJ_UINT32 qmfbid; |
881 | /** quantisation style */ |
882 | OPJ_UINT32 qntsty; |
883 | /** stepsizes used for quantization */ |
884 | OPJ_UINT32 stepsizes_mant[OPJ_J2K_MAXBANDS]; |
885 | /** stepsizes used for quantization */ |
886 | OPJ_UINT32 stepsizes_expn[OPJ_J2K_MAXBANDS]; |
887 | /** number of guard bits */ |
888 | OPJ_UINT32 numgbits; |
889 | /** Region Of Interest shift */ |
890 | OPJ_INT32 roishift; |
891 | /** precinct width */ |
892 | OPJ_UINT32 prcw[OPJ_J2K_MAXRLVLS]; |
893 | /** precinct height */ |
894 | OPJ_UINT32 prch[OPJ_J2K_MAXRLVLS]; |
895 | } |
896 | opj_tccp_info_t; |
897 | |
898 | /** |
899 | * Tile coding parameters information |
900 | */ |
901 | typedef struct opj_tile_v2_info { |
902 | |
903 | /** number (index) of tile */ |
904 | int tileno; |
905 | /** coding style */ |
906 | OPJ_UINT32 csty; |
907 | /** progression order */ |
908 | OPJ_PROG_ORDER prg; |
909 | /** number of layers */ |
910 | OPJ_UINT32 numlayers; |
911 | /** multi-component transform identifier */ |
912 | OPJ_UINT32 mct; |
913 | |
914 | /** information concerning tile component parameters*/ |
915 | opj_tccp_info_t *tccp_info; |
916 | |
917 | } opj_tile_info_v2_t; |
918 | |
919 | /** |
920 | * Information structure about the codestream (FIXME should be expand and enhance) |
921 | */ |
922 | typedef struct opj_codestream_info_v2 { |
923 | /* Tile info */ |
924 | /** tile origin in x = XTOsiz */ |
925 | OPJ_UINT32 tx0; |
926 | /** tile origin in y = YTOsiz */ |
927 | OPJ_UINT32 ty0; |
928 | /** tile size in x = XTsiz */ |
929 | OPJ_UINT32 tdx; |
930 | /** tile size in y = YTsiz */ |
931 | OPJ_UINT32 tdy; |
932 | /** number of tiles in X */ |
933 | OPJ_UINT32 tw; |
934 | /** number of tiles in Y */ |
935 | OPJ_UINT32 th; |
936 | |
937 | /** number of components*/ |
938 | OPJ_UINT32 nbcomps; |
939 | |
940 | /** Default information regarding tiles inside image */ |
941 | opj_tile_info_v2_t m_default_tile_info; |
942 | |
943 | /** information regarding tiles inside image */ |
944 | opj_tile_info_v2_t *tile_info; /* FIXME not used for the moment */ |
945 | |
946 | } opj_codestream_info_v2_t; |
947 | |
948 | |
949 | /** |
950 | * Index structure about a tile part |
951 | */ |
952 | typedef struct opj_tp_index { |
953 | /** start position */ |
954 | OPJ_OFF_T start_pos; |
955 | /** end position of the header */ |
956 | OPJ_OFF_T ; |
957 | /** end position */ |
958 | OPJ_OFF_T end_pos; |
959 | |
960 | } opj_tp_index_t; |
961 | |
962 | /** |
963 | * Index structure about a tile |
964 | */ |
965 | typedef struct opj_tile_index { |
966 | /** tile index */ |
967 | OPJ_UINT32 tileno; |
968 | |
969 | /** number of tile parts */ |
970 | OPJ_UINT32 nb_tps; |
971 | /** current nb of tile part (allocated)*/ |
972 | OPJ_UINT32 current_nb_tps; |
973 | /** current tile-part index */ |
974 | OPJ_UINT32 current_tpsno; |
975 | /** information concerning tile parts */ |
976 | opj_tp_index_t *tp_index; |
977 | |
978 | /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */ |
979 | /** number of markers */ |
980 | OPJ_UINT32 marknum; |
981 | /** list of markers */ |
982 | opj_marker_info_t *marker; |
983 | /** actual size of markers array */ |
984 | OPJ_UINT32 maxmarknum; |
985 | /* <<UniPG */ |
986 | |
987 | /** packet number */ |
988 | OPJ_UINT32 nb_packet; |
989 | /** information concerning packets inside tile */ |
990 | opj_packet_info_t *packet_index; |
991 | |
992 | } opj_tile_index_t; |
993 | |
994 | /** |
995 | * Index structure of the codestream (FIXME should be expand and enhance) |
996 | */ |
997 | typedef struct opj_codestream_index { |
998 | /** main header start position (SOC position) */ |
999 | OPJ_OFF_T main_head_start; |
1000 | /** main header end position (first SOT position) */ |
1001 | OPJ_OFF_T main_head_end; |
1002 | |
1003 | /** codestream's size */ |
1004 | OPJ_UINT64 codestream_size; |
1005 | |
1006 | /* UniPG>> */ /* NOT USED FOR THE MOMENT IN THE V2 VERSION */ |
1007 | /** number of markers */ |
1008 | OPJ_UINT32 marknum; |
1009 | /** list of markers */ |
1010 | opj_marker_info_t *marker; |
1011 | /** actual size of markers array */ |
1012 | OPJ_UINT32 maxmarknum; |
1013 | /* <<UniPG */ |
1014 | |
1015 | /** */ |
1016 | OPJ_UINT32 nb_of_tiles; |
1017 | /** */ |
1018 | opj_tile_index_t *tile_index; /* FIXME not used for the moment */ |
1019 | |
1020 | } opj_codestream_index_t; |
1021 | /* -----------------------------------------------------------> */ |
1022 | |
1023 | /* |
1024 | ========================================================== |
1025 | Metadata from the JP2file |
1026 | ========================================================== |
1027 | */ |
1028 | |
1029 | /** |
1030 | * Info structure of the JP2 file |
1031 | * EXPERIMENTAL FOR THE MOMENT |
1032 | */ |
1033 | typedef struct opj_jp2_metadata { |
1034 | /** */ |
1035 | OPJ_INT32 not_used; |
1036 | |
1037 | } opj_jp2_metadata_t; |
1038 | |
1039 | /** |
1040 | * Index structure of the JP2 file |
1041 | * EXPERIMENTAL FOR THE MOMENT |
1042 | */ |
1043 | typedef struct opj_jp2_index { |
1044 | /** */ |
1045 | OPJ_INT32 not_used; |
1046 | |
1047 | } opj_jp2_index_t; |
1048 | |
1049 | |
1050 | #ifdef __cplusplus |
1051 | extern "C" { |
1052 | #endif |
1053 | |
1054 | |
1055 | /* |
1056 | ========================================================== |
1057 | openjpeg version |
1058 | ========================================================== |
1059 | */ |
1060 | |
1061 | /* Get the version of the openjpeg library*/ |
1062 | OPJ_API const char * OPJ_CALLCONV opj_version(void); |
1063 | |
1064 | /* |
1065 | ========================================================== |
1066 | image functions definitions |
1067 | ========================================================== |
1068 | */ |
1069 | |
1070 | /** |
1071 | * Create an image |
1072 | * |
1073 | * @param numcmpts number of components |
1074 | * @param cmptparms components parameters |
1075 | * @param clrspc image color space |
1076 | * @return returns a new image structure if successful, returns NULL otherwise |
1077 | * */ |
1078 | OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(OPJ_UINT32 numcmpts, |
1079 | opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc); |
1080 | |
1081 | /** |
1082 | * Deallocate any resources associated with an image |
1083 | * |
1084 | * @param image image to be destroyed |
1085 | */ |
1086 | OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image); |
1087 | |
1088 | /** |
1089 | * Creates an image without allocating memory for the image (used in the new version of the library). |
1090 | * |
1091 | * @param numcmpts the number of components |
1092 | * @param cmptparms the components parameters |
1093 | * @param clrspc the image color space |
1094 | * |
1095 | * @return a new image structure if successful, NULL otherwise. |
1096 | */ |
1097 | OPJ_API opj_image_t* OPJ_CALLCONV opj_image_tile_create(OPJ_UINT32 numcmpts, |
1098 | opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc); |
1099 | |
1100 | /** |
1101 | * Allocator for opj_image_t->comps[].data |
1102 | * To be paired with opj_image_data_free. |
1103 | * |
1104 | * @param size number of bytes to allocate |
1105 | * |
1106 | * @return a new pointer if successful, NULL otherwise. |
1107 | * @since 2.2.0 |
1108 | */ |
1109 | OPJ_API void* OPJ_CALLCONV opj_image_data_alloc(OPJ_SIZE_T size); |
1110 | |
1111 | /** |
1112 | * Destructor for opj_image_t->comps[].data |
1113 | * To be paired with opj_image_data_alloc. |
1114 | * |
1115 | * @param ptr Pointer to free |
1116 | * |
1117 | * @since 2.2.0 |
1118 | */ |
1119 | OPJ_API void OPJ_CALLCONV opj_image_data_free(void* ptr); |
1120 | |
1121 | /* |
1122 | ========================================================== |
1123 | stream functions definitions |
1124 | ========================================================== |
1125 | */ |
1126 | |
1127 | /** |
1128 | * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream. |
1129 | * |
1130 | * @param p_is_input if set to true then the stream will be an input stream, an output stream else. |
1131 | * |
1132 | * @return a stream object. |
1133 | */ |
1134 | OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_default_create( |
1135 | OPJ_BOOL p_is_input); |
1136 | |
1137 | /** |
1138 | * Creates an abstract stream. This function does nothing except allocating memory and initializing the abstract stream. |
1139 | * |
1140 | * @param p_buffer_size FIXME DOC |
1141 | * @param p_is_input if set to true then the stream will be an input stream, an output stream else. |
1142 | * |
1143 | * @return a stream object. |
1144 | */ |
1145 | OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size, |
1146 | OPJ_BOOL p_is_input); |
1147 | |
1148 | /** |
1149 | * Destroys a stream created by opj_create_stream. This function does NOT close the abstract stream. If needed the user must |
1150 | * close its own implementation of the stream. |
1151 | * |
1152 | * @param p_stream the stream to destroy. |
1153 | */ |
1154 | OPJ_API void OPJ_CALLCONV opj_stream_destroy(opj_stream_t* p_stream); |
1155 | |
1156 | /** |
1157 | * Sets the given function to be used as a read function. |
1158 | * @param p_stream the stream to modify |
1159 | * @param p_function the function to use a read function. |
1160 | */ |
1161 | OPJ_API void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, |
1162 | opj_stream_read_fn p_function); |
1163 | |
1164 | /** |
1165 | * Sets the given function to be used as a write function. |
1166 | * @param p_stream the stream to modify |
1167 | * @param p_function the function to use a write function. |
1168 | */ |
1169 | OPJ_API void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, |
1170 | opj_stream_write_fn p_function); |
1171 | |
1172 | /** |
1173 | * Sets the given function to be used as a skip function. |
1174 | * @param p_stream the stream to modify |
1175 | * @param p_function the function to use a skip function. |
1176 | */ |
1177 | OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, |
1178 | opj_stream_skip_fn p_function); |
1179 | |
1180 | /** |
1181 | * Sets the given function to be used as a seek function, the stream is then seekable. |
1182 | * @param p_stream the stream to modify |
1183 | * @param p_function the function to use a skip function. |
1184 | */ |
1185 | OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, |
1186 | opj_stream_seek_fn p_function); |
1187 | |
1188 | /** |
1189 | * Sets the given data to be used as a user data for the stream. |
1190 | * @param p_stream the stream to modify |
1191 | * @param p_data the data to set. |
1192 | * @param p_function the function to free p_data when opj_stream_destroy() is called. |
1193 | */ |
1194 | OPJ_API void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream, |
1195 | void * p_data, opj_stream_free_user_data_fn p_function); |
1196 | |
1197 | /** |
1198 | * Sets the length of the user data for the stream. |
1199 | * |
1200 | * @param p_stream the stream to modify |
1201 | * @param data_length length of the user_data. |
1202 | */ |
1203 | OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_length( |
1204 | opj_stream_t* p_stream, OPJ_UINT64 data_length); |
1205 | |
1206 | /** |
1207 | * Create a stream from a file identified with its filename with default parameters (helper function) |
1208 | * @param fname the filename of the file to stream |
1209 | * @param p_is_read_stream whether the stream is a read stream (true) or not (false) |
1210 | */ |
1211 | OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream( |
1212 | const char *fname, OPJ_BOOL p_is_read_stream); |
1213 | |
1214 | /** Create a stream from a file identified with its filename with a specific buffer size |
1215 | * @param fname the filename of the file to stream |
1216 | * @param p_buffer_size size of the chunk used to stream |
1217 | * @param p_is_read_stream whether the stream is a read stream (true) or not (false) |
1218 | */ |
1219 | OPJ_API opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream( |
1220 | const char *fname, |
1221 | OPJ_SIZE_T p_buffer_size, |
1222 | OPJ_BOOL p_is_read_stream); |
1223 | |
1224 | /* |
1225 | ========================================================== |
1226 | event manager functions definitions |
1227 | ========================================================== |
1228 | */ |
1229 | /** |
1230 | * Set the info handler use by openjpeg. |
1231 | * @param p_codec the codec previously initialise |
1232 | * @param p_callback the callback function which will be used |
1233 | * @param p_user_data client object where will be returned the message |
1234 | */ |
1235 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec, |
1236 | opj_msg_callback p_callback, |
1237 | void * p_user_data); |
1238 | /** |
1239 | * Set the warning handler use by openjpeg. |
1240 | * @param p_codec the codec previously initialise |
1241 | * @param p_callback the callback function which will be used |
1242 | * @param p_user_data client object where will be returned the message |
1243 | */ |
1244 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec, |
1245 | opj_msg_callback p_callback, |
1246 | void * p_user_data); |
1247 | /** |
1248 | * Set the error handler use by openjpeg. |
1249 | * @param p_codec the codec previously initialise |
1250 | * @param p_callback the callback function which will be used |
1251 | * @param p_user_data client object where will be returned the message |
1252 | */ |
1253 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, |
1254 | opj_msg_callback p_callback, |
1255 | void * p_user_data); |
1256 | |
1257 | /* |
1258 | ========================================================== |
1259 | codec functions definitions |
1260 | ========================================================== |
1261 | */ |
1262 | |
1263 | /** |
1264 | * Creates a J2K/JP2 decompression structure |
1265 | * @param format Decoder to select |
1266 | * |
1267 | * @return Returns a handle to a decompressor if successful, returns NULL otherwise |
1268 | * */ |
1269 | OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_decompress( |
1270 | OPJ_CODEC_FORMAT format); |
1271 | |
1272 | /** |
1273 | * Destroy a decompressor handle |
1274 | * |
1275 | * @param p_codec decompressor handle to destroy |
1276 | */ |
1277 | OPJ_API void OPJ_CALLCONV opj_destroy_codec(opj_codec_t * p_codec); |
1278 | |
1279 | /** |
1280 | * Read after the codestream if necessary |
1281 | * @param p_codec the JPEG2000 codec to read. |
1282 | * @param p_stream the JPEG2000 stream. |
1283 | */ |
1284 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_decompress(opj_codec_t *p_codec, |
1285 | opj_stream_t *p_stream); |
1286 | |
1287 | |
1288 | /** |
1289 | * Set decoding parameters to default values |
1290 | * @param parameters Decompression parameters |
1291 | */ |
1292 | OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters( |
1293 | opj_dparameters_t *parameters); |
1294 | |
1295 | /** |
1296 | * Setup the decoder with decompression parameters provided by the user and with the message handler |
1297 | * provided by the user. |
1298 | * |
1299 | * @param p_codec decompressor handler |
1300 | * @param parameters decompression parameters |
1301 | * |
1302 | * @return true if the decoder is correctly set |
1303 | */ |
1304 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec, |
1305 | opj_dparameters_t *parameters); |
1306 | |
1307 | /** |
1308 | * Allocates worker threads for the compressor/decompressor. |
1309 | * |
1310 | * By default, only the main thread is used. If this function is not used, |
1311 | * but the OPJ_NUM_THREADS environment variable is set, its value will be |
1312 | * used to initialize the number of threads. The value can be either an integer |
1313 | * number, or "ALL_CPUS". If OPJ_NUM_THREADS is set and this function is called, |
1314 | * this function will override the behaviour of the environment variable. |
1315 | * |
1316 | * Note: currently only has effect on the decompressor. |
1317 | * |
1318 | * @param p_codec decompressor handler |
1319 | * @param num_threads number of threads. |
1320 | * |
1321 | * @return OPJ_TRUE if the decoder is correctly set |
1322 | */ |
1323 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_codec_set_threads(opj_codec_t *p_codec, |
1324 | int num_threads); |
1325 | |
1326 | /** |
1327 | * Decodes an image header. |
1328 | * |
1329 | * @param p_stream the jpeg2000 stream. |
1330 | * @param p_codec the jpeg2000 codec to read. |
1331 | * @param p_image the image structure initialized with the characteristics of encoded image. |
1332 | * |
1333 | * @return true if the main header of the codestream and the JP2 header is correctly read. |
1334 | */ |
1335 | OPJ_API OPJ_BOOL OPJ_CALLCONV (opj_stream_t *p_stream, |
1336 | opj_codec_t *p_codec, |
1337 | opj_image_t **p_image); |
1338 | |
1339 | |
1340 | /** Restrict the number of components to decode. |
1341 | * |
1342 | * This function should be called after opj_read_header(). |
1343 | * |
1344 | * This function enables to restrict the set of decoded components to the |
1345 | * specified indices. |
1346 | * Note that the current implementation (apply_color_transforms == OPJ_FALSE) |
1347 | * is such that neither the multi-component transform at codestream level, |
1348 | * nor JP2 channel transformations will be applied. |
1349 | * Consequently the indices are relative to the codestream. |
1350 | * |
1351 | * Note: opj_decode_tile_data() should not be used together with opj_set_decoded_components(). |
1352 | * |
1353 | * @param p_codec the jpeg2000 codec to read. |
1354 | * @param numcomps Size of the comps_indices array. |
1355 | * @param comps_indices Array of numcomps values representing the indices |
1356 | * of the components to decode (relative to the |
1357 | * codestream, starting at 0) |
1358 | * @param apply_color_transforms Whether multi-component transform at codestream level |
1359 | * or JP2 channel transformations should be applied. |
1360 | * Currently this parameter should be set to OPJ_FALSE. |
1361 | * Setting it to OPJ_TRUE will result in an error. |
1362 | * |
1363 | * @return OPJ_TRUE in case of success. |
1364 | */ |
1365 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_components(opj_codec_t *p_codec, |
1366 | OPJ_UINT32 numcomps, |
1367 | const OPJ_UINT32* comps_indices, |
1368 | OPJ_BOOL apply_color_transforms); |
1369 | |
1370 | /** |
1371 | * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading. |
1372 | * |
1373 | * The coordinates passed to this function should be expressed in the reference grid, |
1374 | * that is to say at the highest resolution level, even if requesting the image at lower |
1375 | * resolution levels. |
1376 | * |
1377 | * Generally opj_set_decode_area() should be followed by opj_decode(), and the |
1378 | * codec cannot be re-used. |
1379 | * In the particular case of an image made of a single tile, several sequences of |
1380 | * calls to opoj_set_decode_area() and opj_decode() are allowed, and will bring |
1381 | * performance improvements when reading an image by chunks. |
1382 | * |
1383 | * @param p_codec the jpeg2000 codec. |
1384 | * @param p_image the decoded image previously setted by opj_read_header |
1385 | * @param p_start_x the left position of the rectangle to decode (in image coordinates). |
1386 | * @param p_end_x the right position of the rectangle to decode (in image coordinates). |
1387 | * @param p_start_y the up position of the rectangle to decode (in image coordinates). |
1388 | * @param p_end_y the bottom position of the rectangle to decode (in image coordinates). |
1389 | * |
1390 | * @return true if the area could be set. |
1391 | */ |
1392 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decode_area(opj_codec_t *p_codec, |
1393 | opj_image_t* p_image, |
1394 | OPJ_INT32 p_start_x, OPJ_INT32 p_start_y, |
1395 | OPJ_INT32 p_end_x, OPJ_INT32 p_end_y); |
1396 | |
1397 | /** |
1398 | * Decode an image from a JPEG-2000 codestream |
1399 | * |
1400 | * @param p_decompressor decompressor handle |
1401 | * @param p_stream Input buffer stream |
1402 | * @param p_image the decoded image |
1403 | * @return true if success, otherwise false |
1404 | * */ |
1405 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode(opj_codec_t *p_decompressor, |
1406 | opj_stream_t *p_stream, |
1407 | opj_image_t *p_image); |
1408 | |
1409 | /** |
1410 | * Get the decoded tile from the codec |
1411 | * |
1412 | * @param p_codec the jpeg2000 codec. |
1413 | * @param p_stream input streamm |
1414 | * @param p_image output image |
1415 | * @param tile_index index of the tile which will be decode |
1416 | * |
1417 | * @return true if success, otherwise false |
1418 | */ |
1419 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_get_decoded_tile(opj_codec_t *p_codec, |
1420 | opj_stream_t *p_stream, |
1421 | opj_image_t *p_image, |
1422 | OPJ_UINT32 tile_index); |
1423 | |
1424 | /** |
1425 | * Set the resolution factor of the decoded image |
1426 | * @param p_codec the jpeg2000 codec. |
1427 | * @param res_factor resolution factor to set |
1428 | * |
1429 | * @return true if success, otherwise false |
1430 | */ |
1431 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_resolution_factor( |
1432 | opj_codec_t *p_codec, OPJ_UINT32 res_factor); |
1433 | |
1434 | /** |
1435 | * Writes a tile with the given data. |
1436 | * |
1437 | * @param p_codec the jpeg2000 codec. |
1438 | * @param p_tile_index the index of the tile to write. At the moment, the tiles must be written from 0 to n-1 in sequence. |
1439 | * @param p_data pointer to the data to write. Data is arranged in sequence, data_comp0, then data_comp1, then ... NO INTERLEAVING should be set. |
1440 | * @param p_data_size this value os used to make sure the data being written is correct. The size must be equal to the sum for each component of |
1441 | * tile_width * tile_height * component_size. component_size can be 1,2 or 4 bytes, depending on the precision of the given component. |
1442 | * @param p_stream the stream to write data to. |
1443 | * |
1444 | * @return true if the data could be written. |
1445 | */ |
1446 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_write_tile(opj_codec_t *p_codec, |
1447 | OPJ_UINT32 p_tile_index, |
1448 | OPJ_BYTE * p_data, |
1449 | OPJ_UINT32 p_data_size, |
1450 | opj_stream_t *p_stream); |
1451 | |
1452 | /** |
1453 | * Reads a tile header. This function is compulsory and allows one to know the size of the tile that will be decoded. |
1454 | * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile. |
1455 | * |
1456 | * @param p_codec the jpeg2000 codec. |
1457 | * @param p_tile_index pointer to a value that will hold the index of the tile being decoded, in case of success. |
1458 | * @param p_data_size pointer to a value that will hold the maximum size of the decoded data, in case of success. In case |
1459 | * of truncated codestreams, the actual number of bytes decoded may be lower. The computation of the size is the same |
1460 | * as depicted in opj_write_tile. |
1461 | * @param p_tile_x0 pointer to a value that will hold the x0 pos of the tile (in the image). |
1462 | * @param p_tile_y0 pointer to a value that will hold the y0 pos of the tile (in the image). |
1463 | * @param p_tile_x1 pointer to a value that will hold the x1 pos of the tile (in the image). |
1464 | * @param p_tile_y1 pointer to a value that will hold the y1 pos of the tile (in the image). |
1465 | * @param p_nb_comps pointer to a value that will hold the number of components in the tile. |
1466 | * @param p_should_go_on pointer to a boolean that will hold the fact that the decoding should go on. In case the |
1467 | * codestream is over at the time of the call, the value will be set to false. The user should then stop |
1468 | * the decoding. |
1469 | * @param p_stream the stream to decode. |
1470 | * @return true if the tile header could be decoded. In case the decoding should end, the returned value is still true. |
1471 | * returning false may be the result of a shortage of memory or an internal error. |
1472 | */ |
1473 | OPJ_API OPJ_BOOL OPJ_CALLCONV (opj_codec_t *p_codec, |
1474 | opj_stream_t * p_stream, |
1475 | OPJ_UINT32 * p_tile_index, |
1476 | OPJ_UINT32 * p_data_size, |
1477 | OPJ_INT32 * p_tile_x0, OPJ_INT32 * p_tile_y0, |
1478 | OPJ_INT32 * p_tile_x1, OPJ_INT32 * p_tile_y1, |
1479 | OPJ_UINT32 * p_nb_comps, |
1480 | OPJ_BOOL * p_should_go_on); |
1481 | |
1482 | /** |
1483 | * Reads a tile data. This function is compulsory and allows one to decode tile data. opj_read_tile_header should be called before. |
1484 | * The user may need to refer to the image got by opj_read_header to understand the size being taken by the tile. |
1485 | * |
1486 | * Note: opj_decode_tile_data() should not be used together with opj_set_decoded_components(). |
1487 | * |
1488 | * @param p_codec the jpeg2000 codec. |
1489 | * @param p_tile_index the index of the tile being decoded, this should be the value set by opj_read_tile_header. |
1490 | * @param p_data pointer to a memory block that will hold the decoded data. |
1491 | * @param p_data_size size of p_data. p_data_size should be bigger or equal to the value set by opj_read_tile_header. |
1492 | * @param p_stream the stream to decode. |
1493 | * |
1494 | * @return true if the data could be decoded. |
1495 | */ |
1496 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode_tile_data(opj_codec_t *p_codec, |
1497 | OPJ_UINT32 p_tile_index, |
1498 | OPJ_BYTE * p_data, |
1499 | OPJ_UINT32 p_data_size, |
1500 | opj_stream_t *p_stream); |
1501 | |
1502 | /* COMPRESSION FUNCTIONS*/ |
1503 | |
1504 | /** |
1505 | * Creates a J2K/JP2 compression structure |
1506 | * @param format Coder to select |
1507 | * @return Returns a handle to a compressor if successful, returns NULL otherwise |
1508 | */ |
1509 | OPJ_API opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format); |
1510 | |
1511 | /** |
1512 | Set encoding parameters to default values, that means : |
1513 | <ul> |
1514 | <li>Lossless |
1515 | <li>1 tile |
1516 | <li>Size of precinct : 2^15 x 2^15 (means 1 precinct) |
1517 | <li>Size of code-block : 64 x 64 |
1518 | <li>Number of resolutions: 6 |
1519 | <li>No SOP marker in the codestream |
1520 | <li>No EPH marker in the codestream |
1521 | <li>No sub-sampling in x or y direction |
1522 | <li>No mode switch activated |
1523 | <li>Progression order: LRCP |
1524 | <li>No index file |
1525 | <li>No ROI upshifted |
1526 | <li>No offset of the origin of the image |
1527 | <li>No offset of the origin of the tiles |
1528 | <li>Reversible DWT 5-3 |
1529 | </ul> |
1530 | @param parameters Compression parameters |
1531 | */ |
1532 | OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters( |
1533 | opj_cparameters_t *parameters); |
1534 | |
1535 | /** |
1536 | * Setup the encoder parameters using the current image and using user parameters. |
1537 | * @param p_codec Compressor handle |
1538 | * @param parameters Compression parameters |
1539 | * @param image Input filled image |
1540 | */ |
1541 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec, |
1542 | opj_cparameters_t *parameters, |
1543 | opj_image_t *image); |
1544 | |
1545 | /** |
1546 | * Start to compress the current image. |
1547 | * @param p_codec Compressor handle |
1548 | * @param p_image Input filled image |
1549 | * @param p_stream Input stgream |
1550 | */ |
1551 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_start_compress(opj_codec_t *p_codec, |
1552 | opj_image_t * p_image, |
1553 | opj_stream_t *p_stream); |
1554 | |
1555 | /** |
1556 | * End to compress the current image. |
1557 | * @param p_codec Compressor handle |
1558 | * @param p_stream Input stgream |
1559 | */ |
1560 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_end_compress(opj_codec_t *p_codec, |
1561 | opj_stream_t *p_stream); |
1562 | |
1563 | /** |
1564 | * Encode an image into a JPEG-2000 codestream |
1565 | * @param p_codec compressor handle |
1566 | * @param p_stream Output buffer stream |
1567 | * |
1568 | * @return Returns true if successful, returns false otherwise |
1569 | */ |
1570 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_encode(opj_codec_t *p_codec, |
1571 | opj_stream_t *p_stream); |
1572 | /* |
1573 | ========================================================== |
1574 | codec output functions definitions |
1575 | ========================================================== |
1576 | */ |
1577 | /* EXPERIMENTAL FUNCTIONS FOR NOW, USED ONLY IN J2K_DUMP*/ |
1578 | |
1579 | /** |
1580 | Destroy Codestream information after compression or decompression |
1581 | @param cstr_info Codestream information structure |
1582 | */ |
1583 | OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_v2_t |
1584 | **cstr_info); |
1585 | |
1586 | |
1587 | /** |
1588 | * Dump the codec information into the output stream |
1589 | * |
1590 | * @param p_codec the jpeg2000 codec. |
1591 | * @param info_flag type of information dump. |
1592 | * @param output_stream output stream where dump the information gotten from the codec. |
1593 | * |
1594 | */ |
1595 | OPJ_API void OPJ_CALLCONV opj_dump_codec(opj_codec_t *p_codec, |
1596 | OPJ_INT32 info_flag, |
1597 | FILE* output_stream); |
1598 | |
1599 | /** |
1600 | * Get the codestream information from the codec |
1601 | * |
1602 | * @param p_codec the jpeg2000 codec. |
1603 | * |
1604 | * @return a pointer to a codestream information structure. |
1605 | * |
1606 | */ |
1607 | OPJ_API opj_codestream_info_v2_t* OPJ_CALLCONV opj_get_cstr_info( |
1608 | opj_codec_t *p_codec); |
1609 | |
1610 | /** |
1611 | * Get the codestream index from the codec |
1612 | * |
1613 | * @param p_codec the jpeg2000 codec. |
1614 | * |
1615 | * @return a pointer to a codestream index structure. |
1616 | * |
1617 | */ |
1618 | OPJ_API opj_codestream_index_t * OPJ_CALLCONV opj_get_cstr_index( |
1619 | opj_codec_t *p_codec); |
1620 | |
1621 | OPJ_API void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t |
1622 | **p_cstr_index); |
1623 | |
1624 | |
1625 | /** |
1626 | * Get the JP2 file information from the codec FIXME |
1627 | * |
1628 | * @param p_codec the jpeg2000 codec. |
1629 | * |
1630 | * @return a pointer to a JP2 metadata structure. |
1631 | * |
1632 | */ |
1633 | OPJ_API opj_jp2_metadata_t* OPJ_CALLCONV opj_get_jp2_metadata( |
1634 | opj_codec_t *p_codec); |
1635 | |
1636 | /** |
1637 | * Get the JP2 file index from the codec FIXME |
1638 | * |
1639 | * @param p_codec the jpeg2000 codec. |
1640 | * |
1641 | * @return a pointer to a JP2 index structure. |
1642 | * |
1643 | */ |
1644 | OPJ_API opj_jp2_index_t* OPJ_CALLCONV opj_get_jp2_index(opj_codec_t *p_codec); |
1645 | |
1646 | |
1647 | /* |
1648 | ========================================================== |
1649 | MCT functions |
1650 | ========================================================== |
1651 | */ |
1652 | |
1653 | /** |
1654 | * Sets the MCT matrix to use. |
1655 | * |
1656 | * @param parameters the parameters to change. |
1657 | * @param pEncodingMatrix the encoding matrix. |
1658 | * @param p_dc_shift the dc shift coefficients to use. |
1659 | * @param pNbComp the number of components of the image. |
1660 | * |
1661 | * @return true if the parameters could be set. |
1662 | */ |
1663 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters, |
1664 | OPJ_FLOAT32 * pEncodingMatrix, |
1665 | OPJ_INT32 * p_dc_shift, |
1666 | OPJ_UINT32 pNbComp); |
1667 | |
1668 | /* |
1669 | ========================================================== |
1670 | Thread functions |
1671 | ========================================================== |
1672 | */ |
1673 | |
1674 | /** Returns if the library is built with thread support. |
1675 | * OPJ_TRUE if mutex, condition, thread, thread pool are available. |
1676 | */ |
1677 | OPJ_API OPJ_BOOL OPJ_CALLCONV opj_has_thread_support(void); |
1678 | |
1679 | /** Return the number of virtual CPUs */ |
1680 | OPJ_API int OPJ_CALLCONV opj_get_num_cpus(void); |
1681 | |
1682 | |
1683 | #ifdef __cplusplus |
1684 | } |
1685 | #endif |
1686 | |
1687 | #endif /* OPENJPEG_H */ |
1688 | |