OpenJPEG  1.5.0
jpwl.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2003, David Janssens
3  * Copyright (c) 2002-2003, Yannick Verschueren
4  * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
5  * Copyright (c) 2005, Herve Drolon, FreeImage Team
6  * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
7  * Copyright (c) 2005-2006, Dept. of Electronic and Information Engineering, Universita' degli Studi di Perugia, Italy
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 __JPWL_H
32 #define __JPWL_H
33 
34 #ifdef USE_JPWL
35 
36 #include "crc.h"
37 #include "rs.h"
38 
48 
52 #define JPWL_ASSUME OPJ_TRUE
53 
57 typedef struct jpwl_epb_ms {
65  int tileno;
67  unsigned char index;
69  int hprot;
71  int k_pre;
73  int n_pre;
75  int pre_len;
77  int k_post;
79  int n_post;
81  int post_len;
86  unsigned short int Lepb;
88  unsigned char Depb;
90  unsigned long int LDPepb;
92  unsigned long int Pepb;
94  unsigned char *data;
97 
101 typedef struct jpwl_epc_ms {
113  unsigned short int Lepc;
115  unsigned short int Pcrc;
117  unsigned long int DL;
119  unsigned char Pepc;
121  unsigned char *data;
123 } jpwl_epc_ms_t;
124 
128 typedef struct jpwl_esd_ms {
130  unsigned char addrm;
132  unsigned char ad_size;
136  unsigned char senst;
138  unsigned char se_size;
142  unsigned short int Lesd;
144  unsigned short int Cesd;
146  unsigned char Pesd;
148  unsigned char *data;
153  int numcomps;
155  int tileno;
157  unsigned long int svalnum;
159  size_t sensval_size;
161 } jpwl_esd_ms_t;
162 
166 typedef struct jpwl_red_ms {
168  unsigned short int Lred;
170  unsigned char Pred;
172  unsigned char *data;
173 } jpwl_red_ms_t;
174 
178 typedef struct jpwl_marker {
180  int id;
182  union jpwl_marks {
191  } m;
193  unsigned long int pos;
195  double dpos;
197  unsigned short int len;
206 } jpwl_marker_t;
207 
214 void jpwl_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
215 
223 void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
224 
231 void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
232 
237 void j2k_read_epc(opj_j2k_t *j2k);
238 
246 void j2k_write_epc(opj_j2k_t *j2k);
247 
252 void j2k_read_epb(opj_j2k_t *j2k);
253 
258 void j2k_write_epb(opj_j2k_t *j2k);
259 
264 void j2k_read_esd(opj_j2k_t *j2k);
265 
270 void j2k_read_red(opj_j2k_t *j2k);
271 
283 jpwl_epb_ms_t *jpwl_epb_create(opj_j2k_t *j2k, opj_bool latest, opj_bool packed, int tileno, int idx, int hprot,
284  unsigned long int pre_len, unsigned long int post_len);
285 
302  opj_bool latest, opj_bool packed, opj_bool insideMH, int *idx, int hprot,
303  double place_pos, int tileno,
304  unsigned long int pre_len, unsigned long int post_len);
305 
320  int comps, unsigned char addrm, unsigned char ad_size,
321  unsigned char senst, unsigned char se_size,
322  double place_pos, int tileno);
323 
331 
332 
333 opj_bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf);
334 
335 opj_bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf, unsigned char *post_buf);
336 
337 void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
338 
344 
355 opj_bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_len, int post_len, int *conn,
356  unsigned char **L4_bufp);
357 
363 opj_bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno);
364 
373 #define jpwl_updateCRC16(CRC, DATA) updateCRC16(CRC, DATA)
374 
381 #define jpwl_updateCRC32(CRC, DATA) updateCRC32(CRC, DATA)
382 
389 #ifndef min
390 #define min(a,b) (((a) < (b)) ? (a) : (b))
391 #endif /* min */
392 
395 #endif /* USE_JPWL */
396 
397 #ifdef USE_JPSEC
398 
401 
406 void j2k_read_sec(opj_j2k_t *j2k);
407 
412 void j2k_write_sec(opj_j2k_t *j2k);
413 
418 void j2k_read_insec(opj_j2k_t *j2k);
419 
422 #endif /* USE_JPSEC */
423 
424 #endif /* __JPWL_H */
425