2 * Copyright (c) 2001-2002, David Janssens
3 * Copyright (c) 2003-2004, Yannick Verschueren
4 * Copyright (c) 2003-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #define VERSION "0.0.8"
33 #define LIBJ2K_API __declspec(dllexport)
35 #define LIBJ2K_API __declspec(dllimport)
44 #define J2K_MAXRLVLS 33
45 #define J2K_MAXBANDS (3*J2K_MAXRLVLS+1)
47 #define J2K_CP_CSTY_PRT 0x01
48 #define J2K_CP_CSTY_SOP 0x02
49 #define J2K_CP_CSTY_EPH 0x04
50 #define J2K_CCP_CSTY_PRT 0x01
51 #define J2K_CCP_CBLKSTY_LAZY 0x01
52 #define J2K_CCP_CBLKSTY_RESET 0x02
53 #define J2K_CCP_CBLKSTY_TERMALL 0x04
54 #define J2K_CCP_CBLKSTY_VSC 0x08
55 #define J2K_CCP_CBLKSTY_PTERM 0x10
56 #define J2K_CCP_CBLKSTY_SEGSYM 0x20
57 #define J2K_CCP_QNTSTY_NOQNT 0
58 #define J2K_CCP_QNTSTY_SIQNT 1
59 #define J2K_CCP_QNTSTY_SEQNT 2
63 int dx, dy; /* XRsiz, YRsiz */
64 int prec; /* precision */
65 int bpp; /* deapth of image in bits */
66 int sgnd; /* signed */
67 int *data; /* image-component data */
72 int x0, y0; /* XOsiz, YOsiz */
73 int x1, y1; /* Xsiz, Ysiz */
74 int numcomps; /* number of components */
75 int index_on; /* 0 = no index || 1 = index */
76 j2k_comp_t *comps; /* image-components */
80 int expn; /* exponent */
81 int mant; /* mantissa */
85 int csty; /* coding style */
86 int numresolutions; /* number of resolutions */
87 int cblkw; /* width of code-blocks */
88 int cblkh; /* height of code-blocks */
89 int cblksty; /* code-block coding style */
90 int qmfbid; /* discrete wavelet transform identifier */
91 int qntsty; /* quantisation style */
92 j2k_stepsize_t stepsizes[J2K_MAXBANDS]; /* stepsizes used for quantisation */
93 int numgbits; /* number of guard bits */
94 int roishift; /* Region of Interest shift */
95 int prcw[J2K_MAXRLVLS]; /* Precinct width */
96 int prch[J2K_MAXRLVLS]; /* Precinct height */
101 int layno1, resno1, compno1;
108 int csty; /* coding style */
109 int prg; /* progression order */
110 int numlayers; /* number of layers */
111 int mct; /* multi-component transform identifier */
112 int rates[100]; /* rates of layers */
113 int numpocs; /* number of progression order changes */
114 int POC; /* Precise if a POC marker has been used O:NO, 1:YES */
115 j2k_poc_t pocs[32]; /* progression order changes */
116 unsigned char *ppt_data; /* packet header store there for futur use in t2_decode_packet */
117 int ppt; /* If ppt == 1 --> there was a PPT marker for the present tile */
118 int ppt_store; /* Use in case of multiple marker PPT (number of info already store) */
119 j2k_tccp_t *tccps; /* tile-component coding parameters */
123 int tx0, ty0; /* XTOsiz, YTOsiz */
124 int tdx, tdy; /* XTsiz, YTsiz */
126 unsigned char *ppm_data; /* packet header store there for futur use in t2_decode_packet */
127 int ppm; /* If ppm == 1 --> there was a PPM marker for the present tile */
128 int ppm_store; /* Use in case of multiple marker PPM (number of info already store) */
129 int ppm_previous; /* Use in case of multiple marker PPM (case on non-finished previous info) */
130 j2k_tcp_t *tcps; /* tile coding parameters */
137 /* Packet information : Layer level */
139 int len; /* Length of the body of the packet */
140 int len_header; /* Length of the header of the packet */
141 int offset; /* Offset of the body of the packet */
142 int offset_header; /* Offset of the header of the packet */
146 /* Access to packet information : precinct level */
152 /* Access to packet information : resolution level */
158 /* Access to packet information : component level */
164 /* Information about the marker */
166 int type; /* type of marker [SIZ, QCD, POC, PPM, CRG, COD] appearing only once */
167 int start_pos; /* Start position of the marker */
168 int len; /* Length of the marker */
172 /* Multiple marker in tile header */
174 info_marker_t *COC; /* COC markers */
175 int num_COC; /* Number of COC marker */
176 int CzCOC; /* Current size of the vector COC */
178 info_marker_t *RGN; /* RGN markers */
179 int num_RGN; /* Number of RGN marker */
180 int CzRGN; /* Current size of the vector RGN */
182 info_marker_t *QCC; /* QCC markers */
183 int num_QCC; /* Number of QCC marker */
184 int CzQCC; /* Current size of the vector QCC */
186 info_marker_t *PLT; /* PLT markers */
187 int num_PLT; /* Number of PLT marker */
188 int CzPLT; /* Current size of the vector PLT */
190 info_marker_t *PPT; /* PPT markers */
191 int num_PPT; /* Number of PPT marker */
192 int CzPPT; /* Current size of the vector PPT */
194 info_marker_t *COM; /* COM markers */
195 int num_COM; /* Number of COM marker */
196 int CzCOM; /* Current size of the vector COC */
197 } info_marker_mul_tile_t;
200 /* Information about each tile_part for a particulary tile */
202 int start_pos; /* Start position of the tile_part */
203 int length; /* Length of the tile_part header + body */
204 int length_header; /* Length of the header */
205 int end_pos; /* End position of the tile part */
206 int end_header; /* End position of the tile part header */
208 int num_reso_AUX; /* Number of resolution level completed */
212 /* Information about each tile */
214 int num_tile; /* Number of Tile */
215 int pw, ph; /* number of precinct by tile */
216 int num_packet; /* number of packet in the tile */
217 info_compo_t *compo; /* component [packet] */
219 info_marker_t *marker; /* information concerning markers inside image [only one apparition] */
220 info_marker_mul_tile_t marker_mul; /* information concerning markers inside image [multiple apparition] */
221 int num_marker; /* number of marker */
223 int numparts; /* number of tile_part for this tile */
224 info_tile_part_t *tile_parts; /* Information about each tile_part */
225 int Cztile_parts; /* Current size of the tile_parts vector */
226 } info_tile_t; /* index struct */
229 /* Multiple marker in main header */
231 info_marker_t *COC; /* COC markers */
232 int num_COC; /* Number of COC marker */
233 int CzCOC; /* Current size of the vector COC */
235 info_marker_t *RGN; /* RGN markers */
236 int num_RGN; /* Number of RGN marker */
237 int CzRGN; /* Current size of the vector RGN */
239 info_marker_t *QCC; /* QCC markers */
240 int num_QCC; /* Number of QCC marker */
241 int CzQCC; /* Current size of the vector QCC */
243 info_marker_t *TLM; /* TLM markers */
244 int num_TLM; /* Number of TLM marker */
245 int CzTLM; /* Current size of the vector TLM */
247 info_marker_t *PLM; /* PLM markers */
248 int num_PLM; /* Number of PLM marker */
249 int CzPLM; /* Current size of the vector PLM */
251 info_marker_t *PPM; /* PPM markers */
252 int num_PPM; /* Number of PPM marker */
253 int CzPPM; /* Current size of the vector PPM */
255 info_marker_t *COM; /* COM markers */
256 int num_COM; /* Number of COM marker */
257 int CzCOM; /* Current size of the vector COM */
258 } info_marker_mul_t; /* index struct */
261 /* Information about image */
263 int Im_w, Im_h; /* Image width and Height */
264 int Tile_x, Tile_y; /* Number of Tile in X and Y */
266 int pw, ph; /* nombre precinct in X and Y */
267 int pdx, pdy; /* size of precinct in X and Y */
269 int Prog; /* progression order */
270 int Comp; /* Component numbers */
271 int Layer; /* number of layer */
272 int Decomposition; /* number of decomposition */
274 int Main_head_end; /* Main header position */
275 int codestream_size; /* codestream's size */
277 info_marker_t *marker; /* information concerning markers inside image [only one apparition] */
278 info_marker_mul_t marker_mul; /* information concerning markers inside image [multiple apparition] */
279 int num_marker; /* number of marker */
281 int num_packet_max; /* Maximum number of packet */
283 int num_max_tile_parts; /* Maximum number of tile-part */
284 info_tile_t *tile; /* information concerning tiles inside image */
285 } info_image_t; /* index struct */