OpenJPEG  2.0.0
jp2.h
Go to the documentation of this file.
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) 2002-2003, Yannick Verschueren
5  * Copyright (c) 2005, Herve Drolon, FreeImage Team
6  * Copyright (c) 2008;2011-2012, Centre National d'Etudes Spatiales (CNES), France
7  * Copyright (c) 2012, CS Systemes d'Information, France
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 #ifndef __JP2_H
32 #define __JP2_H
33 
41 
42 /*#define JPIP_JPIP 0x6a706970*/
43 
44 #define JP2_JP 0x6a502020
45 #define JP2_FTYP 0x66747970
46 #define JP2_JP2H 0x6a703268
47 #define JP2_IHDR 0x69686472
48 #define JP2_COLR 0x636f6c72
49 #define JP2_JP2C 0x6a703263
50 #define JP2_URL 0x75726c20
51 #define JP2_PCLR 0x70636c72
52 #define JP2_CMAP 0x636d6170
53 #define JP2_CDEF 0x63646566
54 #define JP2_DTBL 0x6474626c
55 #define JP2_BPCC 0x62706363
56 #define JP2_JP2 0x6a703220
58 /* For the future */
59 /* #define JP2_RES 0x72657320 */
60 /* #define JP2_JP2I 0x6a703269 */
61 /* #define JP2_XML 0x786d6c20 */
62 /* #define JP2_UUID 0x75756994 */
63 /* #define JP2_UINF 0x75696e66 */
64 /* #define JP2_ULST 0x756c7374 */
66 /* ----------------------------------------------------------------------- */
67 
68 typedef enum
69 {
76  JP2_STATE_UNKNOWN = 0x7fffffff /* ISO C restricts enumerator values to range of 'int' */
77 }
78 JP2_STATE;
79 
80 typedef enum
81 {
83  JP2_IMG_STATE_UNKNOWN = 0x7fffffff
84 }
86 
90 typedef struct opj_jp2_cdef_info
91 {
94 
98 typedef struct opj_jp2_cdef
99 {
103 
107 typedef struct opj_jp2_cmap_comp
108 {
112 
116 typedef struct opj_jp2_pclr
117 {
125 
129 typedef struct opj_jp2_color
130 {
133 
138 
142 typedef struct opj_jp2_comps {
147 
151 typedef struct opj_jp2
152 {
159 
160  /* width of image */
162  /* height of image */
164  /* number of components in the image */
179  /* FIXME: The following two variables are used to save offset
180  as we write out a JP2 file to disk. This mecanism is not flexible
181  as codec writers will need to extand those fields as new part
182  of the standard are implemented.
183  */
189 
191 
193 }
194 opj_jp2_t;
195 
199 typedef struct opj_jp2_box {
203 } opj_jp2_box_t;
204 
206 {
207  /* marker value */
209  /* action linked to the marker */
211  OPJ_BYTE *p_header_data,
212  OPJ_UINT32 p_header_size,
213  opj_event_mgr_t * p_manager);
214 }
216 
217 
219 {
220  /* action to perform */
221  OPJ_BYTE* (*handler) (opj_jp2_t *jp2, OPJ_UINT32 * p_data_size);
222  /* result of the action : data */
224  /* size of data */
226 }
228 
231 /* ----------------------------------------------------------------------- */
232 
243  opj_stream_private_t *stream,
244  opj_event_mgr_t * p_manager );
245 
252 void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters);
253 
264  opj_stream_private_t *p_stream,
265  opj_image_t* p_image,
266  opj_event_mgr_t * p_manager);
267 
277 void opj_jp2_setup_encoder( opj_jp2_t *jp2,
278  opj_cparameters_t *parameters,
279  opj_image_t *image,
280  opj_event_mgr_t * p_manager);
281 
290  opj_stream_private_t *stream,
291  opj_event_mgr_t * p_manager);
292 
293 
305  opj_stream_private_t *stream,
306  opj_image_t * p_image,
307  opj_event_mgr_t * p_manager);
308 
309 
316  opj_event_mgr_t * p_manager);
317 
318 /* ----------------------------------------------------------------------- */
319 
326  opj_event_mgr_t * p_manager);
327 
339  opj_jp2_t *jp2,
340  opj_image_t ** p_image,
341  opj_event_mgr_t * p_manager );
342 
358  OPJ_UINT32 * p_tile_index,
359  OPJ_UINT32 * p_data_size,
360  OPJ_INT32 * p_tile_x0,
361  OPJ_INT32 * p_tile_y0,
362  OPJ_INT32 * p_tile_x1,
363  OPJ_INT32 * p_tile_y1,
364  OPJ_UINT32 * p_nb_comps,
365  OPJ_BOOL * p_go_on,
366  opj_stream_private_t *p_stream,
367  opj_event_mgr_t * p_manager );
368 
380  OPJ_UINT32 p_tile_index,
381  OPJ_BYTE * p_data,
382  OPJ_UINT32 p_data_size,
383  opj_stream_private_t *p_stream,
384  opj_event_mgr_t * p_manager );
385 
398  OPJ_UINT32 p_tile_index,
399  OPJ_BYTE * p_data,
400  OPJ_UINT32 p_data_size,
401  opj_stream_private_t *p_stream,
402  opj_event_mgr_t * p_manager );
403 
409 opj_jp2_t* opj_jp2_create (OPJ_BOOL p_is_decoder);
410 
415 void opj_jp2_destroy(opj_jp2_t *jp2);
416 
417 
432  opj_image_t* p_image,
433  OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
434  OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
435  opj_event_mgr_t * p_manager );
436 
441  opj_stream_private_t *p_stream,
442  opj_image_t* p_image,
443  opj_event_mgr_t * p_manager,
444  OPJ_UINT32 tile_index );
445 
446 
451  OPJ_UINT32 res_factor,
452  opj_event_mgr_t * p_manager);
453 
454 
455 /* TODO MSD: clean these 3 functions */
464 void jp2_dump (opj_jp2_t* p_jp2, OPJ_INT32 flag, FILE* out_stream);
465 
474 
483 
484 
488 
489 #endif /* __JP2_H */
490