corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
3 * Copyright (c) 2002-2007, Professor Benoit Macq
4 * Copyright (c) 2001-2003, David Janssens
5 * Copyright (c) 2002-2003, Yannick Verschueren
6 * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
7 * Copyright (c) 2005, Herve Drolon, FreeImage Team
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31 #ifndef __TCD_H
32 #define __TCD_H
33 /**
34 @file tcd.h
35 @brief Implementation of a tile coder/decoder (TCD)
36  
37 The functions in TCD.C have for goal to encode or decode each tile independently from
38 each other. The functions in TCD.C are used by some function in J2K.C.
39 */
40  
41 /** @defgroup TCD TCD - Implementation of a tile coder/decoder */
42 /*@{*/
43  
44 /**
45 FIXME: documentation
46 */
47 typedef struct opj_tcd_seg {
48 unsigned char** data;
49 int dataindex;
50 int numpasses;
51 int len;
52 int maxpasses;
53 int numnewpasses;
54 int newlen;
55 } opj_tcd_seg_t;
56  
57 /**
58 FIXME: documentation
59 */
60 typedef struct opj_tcd_pass {
61 int rate;
62 double distortiondec;
63 int term, len;
64 } opj_tcd_pass_t;
65  
66 /**
67 FIXME: documentation
68 */
69 typedef struct opj_tcd_layer {
70 int numpasses; /* Number of passes in the layer */
71 int len; /* len of information */
72 double disto; /* add for index (Cfr. Marcela) */
73 unsigned char *data; /* data */
74 } opj_tcd_layer_t;
75  
76 /**
77 FIXME: documentation
78 */
79 typedef struct opj_tcd_cblk_enc {
80 unsigned char* data; /* Data */
81 opj_tcd_layer_t* layers; /* layer information */
82 opj_tcd_pass_t* passes; /* information about the passes */
83 int x0, y0, x1, y1; /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
84 int numbps;
85 int numlenbits;
86 int numpasses; /* number of pass already done for the code-blocks */
87 int numpassesinlayers; /* number of passes in the layer */
88 int totalpasses; /* total number of passes */
89 } opj_tcd_cblk_enc_t;
90  
91 typedef struct opj_tcd_cblk_dec {
92 unsigned char* data; /* Data */
93 opj_tcd_seg_t* segs; /* segments informations */
94 int x0, y0, x1, y1; /* dimension of the code-blocks : left upper corner (x0, y0) right low corner (x1,y1) */
95 int numbps;
96 int numlenbits;
97 int len; /* length */
98 int numnewpasses; /* number of pass added to the code-blocks */
99 int numsegs; /* number of segments */
100 } opj_tcd_cblk_dec_t;
101  
102 /**
103 FIXME: documentation
104 */
105 typedef struct opj_tcd_precinct {
106 int x0, y0, x1, y1; /* dimension of the precinct : left upper corner (x0, y0) right low corner (x1,y1) */
107 int cw, ch; /* number of precinct in width and heigth */
108 union{ /* code-blocks informations */
109 opj_tcd_cblk_enc_t* enc;
110 opj_tcd_cblk_dec_t* dec;
111 } cblks;
112 opj_tgt_tree_t *incltree; /* inclusion tree */
113 opj_tgt_tree_t *imsbtree; /* IMSB tree */
114 } opj_tcd_precinct_t;
115  
116 /**
117 FIXME: documentation
118 */
119 typedef struct opj_tcd_band {
120 int x0, y0, x1, y1; /* dimension of the subband : left upper corner (x0, y0) right low corner (x1,y1) */
121 int bandno;
122 opj_tcd_precinct_t *precincts; /* precinct information */
123 int numbps;
124 float stepsize;
125 } opj_tcd_band_t;
126  
127 /**
128 FIXME: documentation
129 */
130 typedef struct opj_tcd_resolution {
131 int x0, y0, x1, y1; /* dimension of the resolution level : left upper corner (x0, y0) right low corner (x1,y1) */
132 int pw, ph;
133 int numbands; /* number sub-band for the resolution level */
134 opj_tcd_band_t bands[3]; /* subband information */
135 } opj_tcd_resolution_t;
136  
137 /**
138 FIXME: documentation
139 */
140 typedef struct opj_tcd_tilecomp {
141 int x0, y0, x1, y1; /* dimension of component : left upper corner (x0, y0) right low corner (x1,y1) */
142 int numresolutions; /* number of resolutions level */
143 opj_tcd_resolution_t *resolutions; /* resolutions information */
144 int *data; /* data of the component */
145 int numpix; /* add fixed_quality */
146 } opj_tcd_tilecomp_t;
147  
148 /**
149 FIXME: documentation
150 */
151 typedef struct opj_tcd_tile {
152 int x0, y0, x1, y1; /* dimension of the tile : left upper corner (x0, y0) right low corner (x1,y1) */
153 int numcomps; /* number of components in tile */
154 opj_tcd_tilecomp_t *comps; /* Components information */
155 int numpix; /* add fixed_quality */
156 double distotile; /* add fixed_quality */
157 double distolayer[100]; /* add fixed_quality */
158 /** packet number */
159 int packno;
160 } opj_tcd_tile_t;
161  
162 /**
163 FIXME: documentation
164 */
165 typedef struct opj_tcd_image {
166 int tw, th; /* number of tiles in width and heigth */
167 opj_tcd_tile_t *tiles; /* Tiles information */
168 } opj_tcd_image_t;
169  
170 /**
171 Tile coder/decoder
172 */
173 typedef struct opj_tcd {
174 /** Position of the tilepart flag in Progression order*/
175 int tp_pos;
176 /** Tile part number*/
177 int tp_num;
178 /** Current tile part number*/
179 int cur_tp_num;
180 /** Total number of tileparts of the current tile*/
181 int cur_totnum_tp;
182 /** Current Packet iterator number */
183 int cur_pino;
184 /** codec context */
185 opj_common_ptr cinfo;
186  
187 /** info on each image tile */
188 opj_tcd_image_t *tcd_image;
189 /** image */
190 opj_image_t *image;
191 /** coding parameters */
192 opj_cp_t *cp;
193 /** pointer to the current encoded/decoded tile */
194 opj_tcd_tile_t *tcd_tile;
195 /** coding/decoding parameters common to all tiles */
196 opj_tcp_t *tcp;
197 /** current encoded/decoded tile */
198 int tcd_tileno;
199 /** Time taken to encode a tile*/
200 double encoding_time;
201 } opj_tcd_t;
202  
203 /** @name Exported functions */
204 /*@{*/
205 /* ----------------------------------------------------------------------- */
206  
207 /**
208 Dump the content of a tcd structure
209 */
210 void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t *img);
211 /**
212 Create a new TCD handle
213 @param cinfo Codec context info
214 @return Returns a new TCD handle if successful returns NULL otherwise
215 */
216 opj_tcd_t* tcd_create(opj_common_ptr cinfo);
217 /**
218 Destroy a previously created TCD handle
219 @param tcd TCD handle to destroy
220 */
221 void tcd_destroy(opj_tcd_t *tcd);
222 /**
223 Initialize the tile coder (allocate the memory)
224 @param tcd TCD handle
225 @param image Raw image
226 @param cp Coding parameters
227 @param curtileno Number that identifies the tile that will be encoded
228 */
229 void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int curtileno);
230 /**
231 Free the memory allocated for encoding
232 @param tcd TCD handle
233 */
234 void tcd_free_encode(opj_tcd_t *tcd);
235 /**
236 Initialize the tile coder (reuses the memory allocated by tcd_malloc_encode)
237 @param tcd TCD handle
238 @param image Raw image
239 @param cp Coding parameters
240 @param curtileno Number that identifies the tile that will be encoded
241 */
242 void tcd_init_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int curtileno);
243 /**
244 Initialize the tile decoder
245 @param tcd TCD handle
246 @param image Raw image
247 @param cp Coding parameters
248 */
249 void tcd_malloc_decode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp);
250 void tcd_malloc_decode_tile(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int tileno, opj_codestream_info_t *cstr_info);
251 void tcd_makelayer_fixed(opj_tcd_t *tcd, int layno, int final);
252 void tcd_rateallocate_fixed(opj_tcd_t *tcd);
253 void tcd_makelayer(opj_tcd_t *tcd, int layno, double thresh, int final);
254 opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info);
255 /**
256 Encode a tile from the raw image into a buffer
257 @param tcd TCD handle
258 @param tileno Number that identifies one of the tiles to be encoded
259 @param dest Destination buffer
260 @param len Length of destination buffer
261 @param cstr_info Codestream information structure
262 @return
263 */
264 int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_codestream_info_t *cstr_info);
265 /**
266 Decode a tile from a buffer into a raw image
267 @param tcd TCD handle
268 @param src Source buffer
269 @param len Length of source buffer
270 @param tileno Number that identifies one of the tiles to be decoded
271 @param cstr_info Codestream information structure
272 */
273 opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info);
274 /**
275 Free the memory allocated for decoding
276 @param tcd TCD handle
277 */
278 void tcd_free_decode(opj_tcd_t *tcd);
279 void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno);
280  
281 /* ----------------------------------------------------------------------- */
282 /*@}*/
283  
284 /*@}*/
285  
286 #endif /* __TCD_H */