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 j2k_comp_t *comps; /* image-components */
79 int expn; /* exponent */
80 int mant; /* mantissa */
84 int csty; /* coding style */
85 int numresolutions; /* number of resolutions */
86 int cblkw; /* width of code-blocks */
87 int cblkh; /* height of code-blocks */
88 int cblksty; /* code-block coding style */
89 int qmfbid; /* discrete wavelet transform identifier */
90 int qntsty; /* quantisation style */
91 j2k_stepsize_t stepsizes[J2K_MAXBANDS]; /* stepsizes used for quantisation */
92 int numgbits; /* number of guard bits */
93 int roishift; /* Region of Interest shift */
94 int prcw[J2K_MAXRLVLS]; /* Precinct width */
95 int prch[J2K_MAXRLVLS]; /* Precinct height */
100 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 int index_on; /* 0 = no index || 1 = index */
131 j2k_tcp_t *tcps; /* tile coding parameters */
138 /* Packet information : Layer level */
140 int len; /* Length of the body of the packet */
141 int len_header; /* Length of the header of the packet */
142 int offset; /* Offset of the body of the packet */
143 int offset_header; /* Offset of the header of the packet */
147 /* Access to packet information : precinct level */
153 /* Access to packet information : resolution level */
159 /* Access to packet information : component level */
165 /* Information about the marker */
167 int type; /* type of marker [SIZ, QCD, POC, PPM, CRG, COD] appearing only once */
168 int start_pos; /* Start position of the marker */
169 int len; /* Length of the marker */
173 /* Multiple marker in tile header */
175 info_marker_t *COC; /* COC markers */
176 int num_COC; /* Number of COC marker */
177 int CzCOC; /* Current size of the vector COC */
179 info_marker_t *RGN; /* RGN markers */
180 int num_RGN; /* Number of RGN marker */
181 int CzRGN; /* Current size of the vector RGN */
183 info_marker_t *QCC; /* QCC markers */
184 int num_QCC; /* Number of QCC marker */
185 int CzQCC; /* Current size of the vector QCC */
187 info_marker_t *PLT; /* PLT markers */
188 int num_PLT; /* Number of PLT marker */
189 int CzPLT; /* Current size of the vector PLT */
191 info_marker_t *PPT; /* PPT markers */
192 int num_PPT; /* Number of PPT marker */
193 int CzPPT; /* Current size of the vector PPT */
195 info_marker_t *COM; /* COM markers */
196 int num_COM; /* Number of COM marker */
197 int CzCOM; /* Current size of the vector COC */
198 } info_marker_mul_tile_t;
201 /* Information about each tile_part for a particulary tile */
203 int start_pos; /* Start position of the tile_part */
204 int length; /* Length of the tile_part header + body */
205 int length_header; /* Length of the header */
206 int end_pos; /* End position of the tile part */
207 int end_header; /* End position of the tile part header */
209 int num_reso_AUX; /* Number of resolution level completed */
213 /* Information about each tile */
215 int num_tile; /* Number of Tile */
216 int pw, ph; /* number of precinct by tile */
217 int num_packet; /* number of packet in the tile */
218 info_compo_t *compo; /* component [packet] */
220 info_marker_t *marker; /* information concerning markers inside image [only one apparition] */
221 info_marker_mul_tile_t marker_mul; /* information concerning markers inside image [multiple apparition] */
222 int num_marker; /* number of marker */
224 int numparts; /* number of tile_part for this tile */
225 info_tile_part_t *tile_parts; /* Information about each tile_part */
226 int Cztile_parts; /* Current size of the tile_parts vector */
227 } info_tile_t; /* index struct */
230 /* Multiple marker in main header */
232 info_marker_t *COC; /* COC markers */
233 int num_COC; /* Number of COC marker */
234 int CzCOC; /* Current size of the vector COC */
236 info_marker_t *RGN; /* RGN markers */
237 int num_RGN; /* Number of RGN marker */
238 int CzRGN; /* Current size of the vector RGN */
240 info_marker_t *QCC; /* QCC markers */
241 int num_QCC; /* Number of QCC marker */
242 int CzQCC; /* Current size of the vector QCC */
244 info_marker_t *TLM; /* TLM markers */
245 int num_TLM; /* Number of TLM marker */
246 int CzTLM; /* Current size of the vector TLM */
248 info_marker_t *PLM; /* PLM markers */
249 int num_PLM; /* Number of PLM marker */
250 int CzPLM; /* Current size of the vector PLM */
252 info_marker_t *PPM; /* PPM markers */
253 int num_PPM; /* Number of PPM marker */
254 int CzPPM; /* Current size of the vector PPM */
256 info_marker_t *COM; /* COM markers */
257 int num_COM; /* Number of COM marker */
258 int CzCOM; /* Current size of the vector COM */
259 } info_marker_mul_t; /* index struct */
262 /* Information about image */
264 int Im_w, Im_h; /* Image width and Height */
265 int Tile_x, Tile_y; /* Number of Tile in X and Y */
267 int pw, ph; /* nombre precinct in X and Y */
268 int pdx, pdy; /* size of precinct in X and Y */
270 int Prog; /* progression order */
271 int Comp; /* Component numbers */
272 int Layer; /* number of layer */
273 int Decomposition; /* number of decomposition */
275 int Main_head_end; /* Main header position */
276 int codestream_size; /* codestream's size */
278 info_marker_t *marker; /* information concerning markers inside image [only one apparition] */
279 info_marker_mul_t marker_mul; /* information concerning markers inside image [multiple apparition] */
280 int num_marker; /* number of marker */
282 int num_packet_max; /* Maximum number of packet */
284 int num_max_tile_parts; /* Maximum number of tile-part */
285 info_tile_t *tile; /* information concerning tiles inside image */
286 } info_image_t; /* index struct */