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 
284  opj_cparameters_t *parameters,
285  opj_image_t *image,
286  opj_event_mgr_t * p_manager);
287 
296  opj_stream_private_t *stream,
297  opj_event_mgr_t * p_manager);
298 
299 
311  opj_stream_private_t *stream,
312  opj_image_t * p_image,
313  opj_event_mgr_t * p_manager);
314 
315 
322  opj_event_mgr_t * p_manager);
323 
324 /* ----------------------------------------------------------------------- */
325 
332  opj_event_mgr_t * p_manager);
333 
345  opj_jp2_t *jp2,
346  opj_image_t ** p_image,
347  opj_event_mgr_t * p_manager );
348 
364  OPJ_UINT32 * p_tile_index,
365  OPJ_UINT32 * p_data_size,
366  OPJ_INT32 * p_tile_x0,
367  OPJ_INT32 * p_tile_y0,
368  OPJ_INT32 * p_tile_x1,
369  OPJ_INT32 * p_tile_y1,
370  OPJ_UINT32 * p_nb_comps,
371  OPJ_BOOL * p_go_on,
372  opj_stream_private_t *p_stream,
373  opj_event_mgr_t * p_manager );
374 
386  OPJ_UINT32 p_tile_index,
387  OPJ_BYTE * p_data,
388  OPJ_UINT32 p_data_size,
389  opj_stream_private_t *p_stream,
390  opj_event_mgr_t * p_manager );
391 
404  OPJ_UINT32 p_tile_index,
405  OPJ_BYTE * p_data,
406  OPJ_UINT32 p_data_size,
407  opj_stream_private_t *p_stream,
408  opj_event_mgr_t * p_manager );
409 
415 opj_jp2_t* opj_jp2_create (OPJ_BOOL p_is_decoder);
416 
421 void opj_jp2_destroy(opj_jp2_t *jp2);
422 
423 
438  opj_image_t* p_image,
439  OPJ_INT32 p_start_x, OPJ_INT32 p_start_y,
440  OPJ_INT32 p_end_x, OPJ_INT32 p_end_y,
441  opj_event_mgr_t * p_manager );
442 
447  opj_stream_private_t *p_stream,
448  opj_image_t* p_image,
449  opj_event_mgr_t * p_manager,
450  OPJ_UINT32 tile_index );
451 
452 
457  OPJ_UINT32 res_factor,
458  opj_event_mgr_t * p_manager);
459 
460 
461 /* TODO MSD: clean these 3 functions */
470 void jp2_dump (opj_jp2_t* p_jp2, OPJ_INT32 flag, FILE* out_stream);
471 
480 
489 
490 
494 
495 #endif /* __JP2_H */
496 
OPJ_UINT32 numcomps
Definition: jp2.h:170
JPEG-2000 file format reader/writer.
Definition: jp2.h:156
struct opj_procedure_list * m_validation_list
list of validation procedures
Definition: jp2.h:161
struct opj_jp2_cmap_comp opj_jp2_cmap_comp_t
Component mappings: channel index, mapping type, palette index.
int64_t OPJ_OFF_T
Definition: openjpeg.h:130
OPJ_UINT32 bpcc
Definition: jp2.h:150
Definition: jp2.h:210
OPJ_BOOL jpip_on
Definition: jp2.h:191
OPJ_OFF_T jpip_iptr_offset
Definition: jp2.h:190
opj_jp2_comps_t * comps
Definition: jp2.h:183
struct opj_procedure_list * m_procedure_list
list of execution procedures
Definition: jp2.h:163
Message handler object used for.
Definition: event.h:50
struct opj_jp2_img_header_writer_handler opj_jp2_img_header_writer_handler_t
struct opj_jp2_color opj_jp2_color_t
Collector for ICC profile, palette, component mapping, channel description.
OPJ_UINT32 icc_profile_len
Definition: jp2.h:137
OPJ_UINT16 asoc
Definition: jp2.h:97
int OPJ_BOOL
Definition: openjpeg.h:110
OPJ_BOOL opj_jp2_encode(opj_jp2_t *jp2, opj_stream_private_t *stream, opj_event_mgr_t *p_manager)
Encode an image into a JPEG-2000 file stream.
Definition: jp2.c:1854
JPEG-2000 codestream reader/writer.
Definition: j2k.h:539
OPJ_BOOL opj_jp2_write_tile(opj_jp2_t *p_jp2, OPJ_UINT32 p_tile_index, OPJ_BYTE *p_data, OPJ_UINT32 p_data_size, opj_stream_private_t *p_stream, opj_event_mgr_t *p_manager)
Writes a tile.
Definition: jp2.c:2593
OPJ_UINT32 length
Definition: jp2.h:205
OPJ_UINT32 id
Definition: jp2.h:213
Byte input-output stream.
Definition: cio.h:87
OPJ_BYTE * channel_size
Definition: jp2.h:125
unsigned char OPJ_BYTE
Definition: openjpeg.h:117
OPJ_BOOL opj_jp2_read_tile_header(opj_jp2_t *p_jp2, OPJ_UINT32 *p_tile_index, OPJ_UINT32 *p_data_size, OPJ_INT32 *p_tile_x0, OPJ_INT32 *p_tile_y0, OPJ_INT32 *p_tile_x1, OPJ_INT32 *p_tile_y1, OPJ_UINT32 *p_nb_comps, OPJ_BOOL *p_go_on, opj_stream_private_t *p_stream, opj_event_mgr_t *p_manager)
Reads a tile header.
Definition: jp2.c:2569
OPJ_BYTE * channel_sign
Definition: jp2.h:124
OPJ_UINT32 numcl
Definition: jp2.h:181
opj_jp2_t * opj_jp2_create(OPJ_BOOL p_is_decoder)
Creates a jpeg2000 file decompressor.
Definition: jp2.c:2751
JP2 Box.
Definition: jp2.h:204
opj_jp2_cdef_info_t * info
Definition: jp2.h:105
OPJ_UINT32 w
Definition: jp2.h:166
Definition: jp2.h:88
OPJ_UINT16 cn
Definition: jp2.h:97
OPJ_UINT32 IPR
Definition: jp2.h:174
OPJ_UINT32 depth
Definition: jp2.h:148
uint16_t OPJ_UINT16
Definition: openjpeg.h:124
OPJ_BOOL opj_jp2_decode_tile(opj_jp2_t *p_jp2, OPJ_UINT32 p_tile_index, OPJ_BYTE *p_data, OPJ_UINT32 p_data_size, opj_stream_private_t *p_stream, opj_event_mgr_t *p_manager)
Decode tile data.
Definition: jp2.c:2605
struct opj_jp2_cdef opj_jp2_cdef_t
Channel descriptions and number of descriptions.
OPJ_BOOL(* handler)(opj_jp2_t *jp2, OPJ_BYTE *p_header_data, OPJ_UINT32 p_header_size, opj_event_mgr_t *p_manager)
Definition: jp2.h:215
int32_t OPJ_INT32
Definition: openjpeg.h:125
Information structure about the codestream (FIXME should be expand and enhance)
Definition: openjpeg.h:915
OPJ_BYTE mtyp
Definition: jp2.h:115
OPJ_BOOL opj_jp2_set_decoded_resolution_factor(opj_jp2_t *p_jp2, OPJ_UINT32 res_factor, opj_event_mgr_t *p_manager)
Definition: jp2.c:2814
struct opj_jp2_comps opj_jp2_comps_t
JP2 component.
OPJ_BOOL opj_jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_t *image, opj_event_mgr_t *p_manager)
Setup the encoder parameters using the current image and using user parameters.
Definition: jp2.c:1685
OPJ_UINT32 type
Definition: jp2.h:206
OPJ_BOOL opj_jp2_end_decompress(opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
Ends the decompression procedures and possibiliy add data to be read after the codestream.
Definition: jp2.c:1861
opj_jp2_cdef_t * jp2_cdef
Definition: jp2.h:139
opj_j2k_t * j2k
handle to the J2K codec
Definition: jp2.h:159
OPJ_UINT32 * entries
Definition: jp2.h:123
OPJ_UINT32 minversion
Definition: jp2.h:180
OPJ_OFF_T j2k_codestream_offset
Definition: jp2.h:189
OPJ_BYTE nr_channels
Definition: jp2.h:128
OPJ_BOOL opj_jp2_set_decode_area(opj_jp2_t *p_jp2, opj_image_t *p_image, OPJ_INT32 p_start_x, OPJ_INT32 p_start_y, OPJ_INT32 p_end_x, OPJ_INT32 p_end_y, opj_event_mgr_t *p_manager)
Sets the given area to be decoded.
Definition: jp2.c:2684
Defines image data and characteristics.
Definition: openjpeg.h:661
OPJ_UINT16 typ
Definition: jp2.h:97
OPJ_UINT32 jp2_state
Definition: jp2.h:192
Definition: jp2.h:75
OPJ_BOOL ignore_pclr_cmap_cdef
Definition: jp2.h:197
Decompression parameters.
Definition: openjpeg.h:508
Collector for ICC profile, palette, component mapping, channel description.
Definition: jp2.h:134
OPJ_BOOL opj_jp2_read_header(opj_stream_private_t *p_stream, opj_jp2_t *jp2, opj_image_t **p_image, opj_event_mgr_t *p_manager)
Reads a jpeg2000 file header structure.
Definition: jp2.c:2495
OPJ_UINT32 precedence
Definition: jp2.h:178
A list of procedures.
Definition: function_list.h:57
OPJ_UINT32 jp2_img_state
Definition: jp2.h:193
OPJ_BOOL opj_jp2_start_compress(opj_jp2_t *jp2, opj_stream_private_t *stream, opj_image_t *p_image, opj_event_mgr_t *p_manager)
Starts a compression scheme, i.e.
Definition: jp2.c:2133
OPJ_BYTE * icc_profile_buf
Definition: jp2.h:136
OPJ_UINT32 m_size
Definition: jp2.h:230
OPJ_BYTE pcol
Definition: jp2.h:115
void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters)
Setup the decoder decoding parameters using user parameters.
Definition: jp2.c:1671
OPJ_BOOL opj_jp2_write_jp2h(opj_jp2_t *jp2, opj_stream_private_t *stream, opj_event_mgr_t *p_manager)
Writes the Jpeg2000 file Header box - JP2 Header box (warning, this is a super box).
Definition: jp2.c:1451
OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2, opj_stream_private_t *p_stream, opj_image_t *p_image, opj_event_mgr_t *p_manager)
Decode an image from a JPEG-2000 file stream.
Definition: jp2.c:1397
OPJ_UINT32 approx
Definition: jp2.h:176
OPJ_UINT16 nr_entries
Definition: jp2.h:127
struct opj_jp2 opj_jp2_t
JPEG-2000 file format reader/writer.
OPJ_INT32 init_pos
Definition: jp2.h:207
Definition: jp2.h:80
OPJ_UINT32 C
Definition: jp2.h:172
struct opj_jp2_pclr opj_jp2_pclr_t
Palette data: table entries, palette columns.
struct opj_jp2_box opj_jp2_box_t
JP2 Box.
Component mappings: channel index, mapping type, palette index.
Definition: jp2.h:112
OPJ_BYTE * m_data
Definition: jp2.h:228
opj_codestream_index_t * jp2_get_cstr_index(opj_jp2_t *p_jp2)
Get the codestream index from a JPEG2000 codec.
Definition: jp2.c:2804
opj_jp2_pclr_t * jp2_pclr
Definition: jp2.h:140
OPJ_UINT16 n
Definition: jp2.h:106
Index structure of the codestream (FIXME should be expand and enhance)
Definition: openjpeg.h:990
OPJ_UINT32 enumcs
Definition: jp2.h:177
Definition: jp2.h:81
Definition: jp2.h:79
opj_codestream_info_v2_t * jp2_get_cstr_info(opj_jp2_t *p_jp2)
Get the codestream info from a JPEG2000 codec.
Definition: jp2.c:2809
OPJ_UINT32 UnkC
Definition: jp2.h:173
void opj_jp2_destroy(opj_jp2_t *jp2)
Destroy a JP2 decompressor handle.
Definition: jp2.c:2616
opj_jp2_color_t color
Definition: jp2.h:195
uint32_t OPJ_UINT32
Definition: openjpeg.h:126
OPJ_UINT32 bpc
Definition: jp2.h:171
Palette data: table entries, palette columns.
Definition: jp2.h:121
struct opj_jp2_header_handler opj_jp2_header_handler_t
OPJ_UINT32 h
Definition: jp2.h:168
opj_jp2_cmap_comp_t * cmap
Definition: jp2.h:126
Compression parameters.
Definition: openjpeg.h:353
OPJ_UINT32 brand
Definition: jp2.h:179
OPJ_BOOL opj_jp2_get_tile(opj_jp2_t *p_jp2, opj_stream_private_t *p_stream, opj_image_t *p_image, opj_event_mgr_t *p_manager, OPJ_UINT32 tile_index)
Definition: jp2.c:2694
JP2_IMG_STATE
Definition: jp2.h:85
OPJ_BYTE jp2_has_colr
Definition: jp2.h:141
OPJ_BOOL opj_jp2_end_compress(opj_jp2_t *jp2, opj_stream_private_t *cio, opj_event_mgr_t *p_manager)
Ends the compression procedures and possibiliy add data to be read after the codestream.
Definition: jp2.c:1882
OPJ_UINT32 sgnd
Definition: jp2.h:149
OPJ_UINT16 cmp
Definition: jp2.h:114
struct opj_jp2_cdef_info opj_jp2_cdef_info_t
Channel description: channel index, type, assocation.
OPJ_UINT32 * cl
Definition: jp2.h:182
Definition: jp2.h:76
Definition: jp2.h:87
Definition: jp2.h:77
OPJ_UINT32 meth
Definition: jp2.h:175
JP2 component.
Definition: jp2.h:147
JP2_STATE
< Resolution box (super-box)
Definition: jp2.h:73
Channel description: channel index, type, assocation.
Definition: jp2.h:95
Channel descriptions and number of descriptions.
Definition: jp2.h:103
Definition: jp2.h:78
void jp2_dump(opj_jp2_t *p_jp2, OPJ_INT32 flag, FILE *out_stream)
Dump some elements from the JP2 decompression structure .
Definition: jp2.c:2794