Avoided ABI breakage
[openjpeg.git] / indexer_JPIP / j2k.h
1 /*
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
5  * All rights reserved. 
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
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.
15  *
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.
27  */
28
29 #define VERSION "0.0.8"
30
31 #ifdef WIN32
32 #ifdef LIBJ2K_EXPORTS
33 #define LIBJ2K_API __declspec(dllexport)
34 #else
35 #define LIBJ2K_API __declspec(dllimport)
36 #endif
37 #else
38 #define LIBJ2K_API
39 #endif
40
41 #ifndef __J2K_H
42 #define __J2K_H
43
44 #define J2K_MAXRLVLS 33
45 #define J2K_MAXBANDS (3*J2K_MAXRLVLS+1)
46
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
60
61 typedef struct 
62 {
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    */
68 } j2k_comp_t;
69
70 typedef struct {
71   int version;
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          */
77 } j2k_image_t;
78
79 typedef struct {
80   int expn;     /* exponent */
81   int mant;     /* mantissa */
82 } j2k_stepsize_t;
83
84 typedef struct {
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                       */
97 } j2k_tccp_t;
98
99 typedef struct {
100     int resno0, compno0; 
101     int layno1, resno1, compno1;
102     int prg;
103     int tile;
104     char progorder[4];
105 } j2k_poc_t;
106
107 typedef struct {
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                                        */
120 } j2k_tcp_t;
121
122 typedef struct {
123   int tx0, ty0;              /* XTOsiz, YTOsiz                                                          */
124   int tdx, tdy;              /* XTsiz, YTsiz                                                            */
125   int tw, th;
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                                                  */
131 } j2k_cp_t;
132
133
134
135
136
137 /* Packet information : Layer level */
138 typedef struct {  
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 */
143 } info_layer_t;
144
145
146 /* Access to packet information : precinct level */
147 typedef struct {  
148   info_layer_t *layer;
149 } info_prec_t;
150
151
152 /* Access to packet information : resolution level */
153 typedef struct {  
154   info_prec_t *prec;
155 } info_reso_t;
156
157
158 /* Access to packet information : component level */
159 typedef struct {  
160   info_reso_t *reso;
161 } info_compo_t;
162
163
164 /* Information about the marker */
165 typedef struct {
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                                              */
169 } info_marker_t;
170
171
172 /* Multiple marker in tile header */
173 typedef struct{
174   info_marker_t *COC;    /* COC markers                    */
175   int num_COC;           /* Number of COC marker           */
176   int CzCOC;             /* Current size of the vector COC */
177   
178   info_marker_t *RGN;    /* RGN markers                    */
179   int num_RGN;           /* Number of RGN marker           */
180   int CzRGN;             /* Current size of the vector RGN */
181   
182   info_marker_t *QCC;    /* QCC markers                    */
183   int num_QCC;           /* Number of QCC marker           */
184   int CzQCC;             /* Current size of the vector QCC */
185   
186   info_marker_t *PLT;    /* PLT markers                    */
187   int num_PLT;           /* Number of PLT marker           */
188   int CzPLT;             /* Current size of the vector PLT */
189   
190   info_marker_t *PPT;    /* PPT markers                    */
191   int num_PPT;           /* Number of PPT marker           */
192   int CzPPT;             /* Current size of the vector PPT */
193   
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; 
198
199
200 /* Information about each tile_part for a particulary tile */
201 typedef struct{
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  */
207
208   int num_reso_AUX;                   /* Number of resolution level completed  */
209 } info_tile_part_t;
210
211
212 /* Information about each tile */
213 typedef struct {
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]                                                */
218   
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                                                  */
222   
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                                                      */
227
228
229 /* Multiple marker in main header */
230 typedef struct{
231   info_marker_t *COC;    /* COC markers                    */
232   int num_COC;           /* Number of COC marker           */
233   int CzCOC;             /* Current size of the vector COC */
234  
235   info_marker_t *RGN;    /* RGN markers                    */
236   int num_RGN;           /* Number of RGN marker           */
237   int CzRGN;             /* Current size of the vector RGN */
238   
239   info_marker_t *QCC;    /* QCC markers                    */
240   int num_QCC;           /* Number of QCC marker           */
241   int CzQCC;             /* Current size of the vector QCC */
242   
243   info_marker_t *TLM;    /* TLM markers                    */
244   int num_TLM;           /* Number of TLM marker           */
245   int CzTLM;             /* Current size of the vector TLM */
246   
247   info_marker_t *PLM;    /* PLM markers                    */
248   int num_PLM;           /* Number of PLM marker           */
249   int CzPLM;             /* Current size of the vector PLM */
250   
251   info_marker_t *PPM;    /* PPM markers                    */
252   int num_PPM;           /* Number of PPM marker           */
253   int CzPPM;             /* Current size of the vector PPM */
254   
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 */
259
260
261 /* Information about image */
262 typedef struct {
263   int Im_w, Im_h;                /* Image width and Height                                            */
264   int Tile_x, Tile_y;            /* Number of Tile in X and Y                                         */
265   int tw, th;
266   int pw, ph;                    /* nombre precinct in X and Y                                        */
267   int pdx, pdy;                  /* size of precinct in X and Y                                       */
268
269   int Prog;                      /* progression order                                                 */
270   int Comp;                      /* Component numbers                                                 */
271   int Layer;                     /* number of layer                                                   */
272   int Decomposition;             /* number of decomposition                                           */
273
274   int Main_head_end;             /* Main header position                                              */
275   int codestream_size;           /* codestream's size                                                 */
276
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                                                  */
280
281   int num_packet_max;            /* Maximum number of packet                                          */
282
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 */
286
287
288 #endif