OpenJPEG  2.1.0
jp2.h
Go to the documentation of this file.
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) 2002-2003, Yannick Verschueren
10  * Copyright (c) 2005, Herve Drolon, FreeImage Team
11  * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR
12  * Copyright (c) 2012, CS Systemes d'Information, France
13  * All rights reserved.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  * 1. Redistributions of source code must retain the above copyright
19  * notice, this list of conditions and the following disclaimer.
20  * 2. Redistributions in binary form must reproduce the above copyright
21  * notice, this list of conditions and the following disclaimer in the
22  * documentation and/or other materials provided with the distribution.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
25  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 #ifndef __JP2_H
37 #define __JP2_H
38 
46 
47 /*#define JPIP_JPIP 0x6a706970*/
48 
49 #define JP2_JP 0x6a502020
50 #define JP2_FTYP 0x66747970
51 #define JP2_JP2H 0x6a703268
52 #define JP2_IHDR 0x69686472
53 #define JP2_COLR 0x636f6c72
54 #define JP2_JP2C 0x6a703263
55 #define JP2_URL 0x75726c20
56 #define JP2_PCLR 0x70636c72
57 #define JP2_CMAP 0x636d6170
58 #define JP2_CDEF 0x63646566
59 #define JP2_DTBL 0x6474626c
60 #define JP2_BPCC 0x62706363
61 #define JP2_JP2 0x6a703220
63 /* For the future */
64 /* #define JP2_RES 0x72657320 */
65 /* #define JP2_JP2I 0x6a703269 */
66 /* #define JP2_XML 0x786d6c20 */
67 /* #define JP2_UUID 0x75756994 */
68 /* #define JP2_UINF 0x75696e66 */
69 /* #define JP2_ULST 0x756c7374 */
71 /* ----------------------------------------------------------------------- */
72 
73 typedef enum
74 {
81  JP2_STATE_UNKNOWN = 0x7fffffff /* ISO C restricts enumerator values to range of 'int' */
82 }
83 JP2_STATE;
84 
85 typedef enum
86 {
88  JP2_IMG_STATE_UNKNOWN = 0x7fffffff
89 }
91 
95 typedef struct opj_jp2_cdef_info
96 {
99 
103 typedef struct opj_jp2_cdef
104 {
108 
112 typedef struct opj_jp2_cmap_comp
113 {
117 
121 typedef struct opj_jp2_pclr
122 {
130 
134 typedef struct opj_jp2_color
135 {
138 
143 
147 typedef struct opj_jp2_comps {
152 
156 typedef struct opj_jp2
157 {
164 
165  /* width of image */
167  /* height of image */
169  /* number of components in the image */
184  /* FIXME: The following two variables are used to save offset
185  as we write out a JP2 file to disk. This mecanism is not flexible
186  as codec writers will need to extand those fields as new part
187  of the standard are implemented.
188  */
194 
196 
198 }
199 opj_jp2_t;
200 
204 typedef struct opj_jp2_box {
208 } opj_jp2_box_t;
209 
211 {
212  /* marker value */
214  /* action linked to the marker */
216  OPJ_BYTE *p_header_data,
217  OPJ_UINT32 p_header_size,
218  opj_event_mgr_t * p_manager);
219 }
221 
222 
224 {
225  /* action to perform */
226  OPJ_BYTE* (*handler) (opj_jp2_t *jp2, OPJ_UINT32 * p_data_size);
227  /* result of the action : data */
229  /* size of data */
231 }
233 
236 /* ----------------------------------------------------------------------- */
237 
248  opj_stream_private_t *stream,
249  opj_event_mgr_t * p_manager );
250 
257 void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters);
258 
269  opj_stream_private_t *p_stream,
270  opj_image_t* p_image,
271  opj_event_mgr_t * p_manager);
272 
282 void opj_jp2_setup_encoder( opj_jp2_t *jp2,
283  opj_cparameters_t *parameters,
284  opj_image_t *image,
285  opj_event_mgr_t * p_manager);
286 
295  opj_stream_private_t *stream,
296  opj_event_mgr_t * p_manager);
297 
298 
310  opj_stream_private_t *stream,
311  opj_image_t * p_image,
312  opj_event_mgr_t * p_manager);
313 
314 
321  opj_event_mgr_t * p_manager);
322 
323 /* ----------------------------------------------------------------------- */
324 
331  opj_event_mgr_t * p_manager);
332 
344  opj_jp2_t *jp2,
345  opj_image_t ** p_image,
346  opj_event_mgr_t * p_manager );
347 
363  OPJ_UINT32 * p_tile_index,
364  OPJ_UINT32 * p_data_size,
365  OPJ_INT32 * p_tile_x0,
366  OPJ_INT32 * p_tile_y0,
367  OPJ_INT32 * p_tile_x1,
368  OPJ_INT32 * p_tile_y1,
369  OPJ_UINT32 * p_nb_comps,
370  OPJ_BOOL * p_go_on,
371  opj_stream_private_t *p_stream,
372  opj_event_mgr_t * p_manager );
373 
385  OPJ_UINT32 p_tile_index,
386  OPJ_BYTE * p_data,
387  OPJ_UINT32 p_data_size,
388  opj_stream_private_t *p_stream,
389  opj_event_mgr_t * p_manager );
390 
403  OPJ_UINT32 p_tile_index,
404  OPJ_BYTE * p_data,
405  OPJ_UINT32 p_data_size,
406  opj_stream_private_t *p_stream,
407  opj_event_mgr_t * p_manager );
408 
414 opj_jp2_t* opj_jp2_create (OPJ_BOOL p_is_decoder);
415 
420 void opj_jp2_destroy(opj_jp2_t *jp2);
421 
422 
437  opj_image_t* p_image,
438  OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
439  OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
440  opj_event_mgr_t * p_manager );
441 
446  opj_stream_private_t *p_stream,
447  opj_image_t* p_image,
448  opj_event_mgr_t * p_manager,
449  OPJ_UINT32 tile_index );
450 
451 
456  OPJ_UINT32 res_factor,
457  opj_event_mgr_t * p_manager);
458 
459 
460 /* TODO MSD: clean these 3 functions */
469 void jp2_dump (opj_jp2_t* p_jp2, OPJ_INT32 flag, FILE* out_stream);
470 
479 
488 
489 
493 
494 #endif /* __JP2_H */
495