OpenJPEG  1.5.1
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 
unsigned short int Lepb
two bytes for the length of EPB MS, exluding the marker itself (11 to 65535 bytes) ...
Definition: jpwl.h:86
unsigned char * data
ESD data, variable length.
Definition: jpwl.h:148
jpwl_epc_ms_t * epcmark
pointer to EPC marker
Definition: jpwl.h:186
EPB (Error Protection Block) Marker segment.
Definition: jpwl.h:57
opj_bool parms_ready
the marker parameters are ready or not?
Definition: jpwl.h:203
jpwl_esd_ms_t * esdmark
pointer to ESD marker
Definition: jpwl.h:188
unsigned short int len
length of the marker segment (marker excluded)
Definition: jpwl.h:197
opj_bool latest
is the latest in header?
Definition: jpwl.h:61
unsigned char se_size
size of sensitivity data (1/2 bytes)
Definition: jpwl.h:138
static jpwl_marker_t jwmarker[JPWL_MAX_NO_MARKERS]
properties of JPWL markers to insert
Definition: jpwl.c:45
int hprot
error protection method [-1=absent 0=none 1=predefined 16=CRC-16 32=CRC-32 37-128=RS] ...
Definition: jpwl.h:69
Tile coder/decoder.
Definition: tcd.h:173
int n_pre
code word length of pre-data
Definition: jpwl.h:73
JPEG-2000 codestream reader/writer.
Definition: j2k.h:314
void j2k_read_sec(opj_j2k_t *j2k)
Read the SEC marker (SEcured Codestream)
Definition: jpwl.c:1310
void j2k_read_red(opj_j2k_t *j2k)
Read the RED marker (Residual Error Descriptor)
Definition: jpwl.c:1200
opj_bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno)
check that a tile and its children have valid data
Definition: jpwl.c:1223
unsigned short int Lred
two bytes for the length of RED MS, exluding the marker itself (3 to 65535 bytes) ...
Definition: jpwl.h:168
int k_post
message word length of post-data
Definition: jpwl.h:77
struct jpwl_red_ms jpwl_red_ms_t
RED (Residual Error Descriptor) Marker segment.
int pre_len
length of pre-data
Definition: jpwl.h:75
size_t sensval_size
size of a single sensitivity pair (address+value)
Definition: jpwl.h:159
opj_bool info_on
are informative techniques active?
Definition: jpwl.h:109
unsigned short int Pcrc
two bytes, CRC for the EPC, excluding Pcrc itself
Definition: jpwl.h:115
jpwl_epb_ms_t * jpwl_epb_create(opj_j2k_t *j2k, opj_bool latest, opj_bool packed, int tileno, int idx, int hprot, unsigned long int pre_len, unsigned long int post_len)
create an EPB marker segment
Definition: jpwl_lib.c:199
void j2k_write_epc(opj_j2k_t *j2k)
Write the EPC marker (Error Protection Capability), BUT the DL field is always set to 0 (this simplif...
Definition: jpwl.c:958
Functions used to compute the 16- and 32-bit CRC of byte arrays.
unsigned char * data
EPC data, variable length.
Definition: jpwl.h:121
Functions used to compute Reed-Solomon parity and check of byte arrays.
unsigned char * data
EPB data, variable size.
Definition: jpwl.h:94
int jpwl_epbs_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num, opj_bool latest, opj_bool packed, opj_bool insideMH, int *idx, int hprot, double place_pos, int tileno, unsigned long int pre_len, unsigned long int post_len)
add a number of EPB marker segments
Definition: jpwl_lib.c:76
opj_bool pos_ready
the marker position is ready or not?
Definition: jpwl.h:201
Defines image data and characteristics.
Definition: openjpeg.h:533
void jpwl_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image)
Encode according to JPWL specs.
Definition: jpwl.c:114
opj_bool data_ready
are the written data ready or not
Definition: jpwl.h:205
opj_bool jpwl_epb_correct(opj_j2k_t *j2k, unsigned char *buffer, int type, int pre_len, int post_len, int *conn, unsigned char **L4_bufp)
corrects the data protected by an EPB
Definition: jpwl_lib.c:744
unsigned long int LDPepb
four bytes, from 0 to 2^31-1
Definition: jpwl.h:90
struct jpwl_epc_ms jpwl_epc_ms_t
EPC (Error Protection Capability) Marker segment.
unsigned char senst
type of sensitivity [0=relative error, 1=MSE, 2=MSE reduction, 3=PSNR, 4=PSNR increment, 5=MAXERR (absolute peak error), 6=TSE (total squared error), 7=reserved
Definition: jpwl.h:136
jpwl_red_ms_t * redmark
pointer to RED marker
Definition: jpwl.h:190
opj_bool esd_on
is ESD active?
Definition: jpwl.h:103
unsigned char index
index in current header (0-63)
Definition: jpwl.h:67
void j2k_read_epc(opj_j2k_t *j2k)
Read the EPC marker (Error Protection Capability)
Definition: jpwl.c:907
Byte input-output stream (CIO)
Definition: openjpeg.h:475
void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image)
Prepare the list of JPWL markers, after the Part 1 codestream has been finalized (index struct is ful...
Definition: jpwl.c:183
unsigned char ad_size
size of codestream addresses [2/4 bytes]
Definition: jpwl.h:132
opj_bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf, unsigned char *post_buf)
Definition: jpwl_lib.c:359
unsigned short int Lesd
two bytes for the length of ESD MS, exluding the marker itself (4 to 65535 bytes) ...
Definition: jpwl.h:142
EPC (Error Protection Capability) Marker segment.
Definition: jpwl.h:101
union keeping the pointer to the real marker struct
Definition: jpwl.h:182
opj_bool jpwl_update_info(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int jwmarker_num)
updates the information structure by modifying the positions and lengths
Definition: jpwl_lib.c:1685
unsigned char Pepc
one byte, signals JPWL techniques adoption
Definition: jpwl.h:119
struct jpwl_esd_ms jpwl_esd_ms_t
ESD (Error Sensitivity Descriptor) Marker segment.
int post_len
length of post-data
Definition: jpwl.h:81
void j2k_write_sec(opj_j2k_t *j2k)
Write the SEC marker (SEcured Codestream)
Definition: jpwl.c:1327
void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image)
Dump the list of JPWL markers, after it has been prepared.
Definition: jpwl.c:712
int id
marker value (J2K_MS_EPC, etc.)
Definition: jpwl.h:180
void j2k_read_epb(opj_j2k_t *j2k)
Read the EPB marker (Error Protection Block)
Definition: jpwl.c:1019
unsigned short int Cesd
two bytes, component of error sensitivity
Definition: jpwl.h:144
double dpos
same as before, only written as a double, so we can sort it better
Definition: jpwl.h:195
unsigned short int Lepc
two bytes for the length of EPC MS, exluding the marker itself (9 to 65535 bytes) ...
Definition: jpwl.h:113
int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num, int comps, unsigned char addrm, unsigned char ad_size, unsigned char senst, unsigned char se_size, double place_pos, int tileno)
add a number of ESD marker segments
Definition: jpwl_lib.c:1195
unsigned char * data
RED data, variable length.
Definition: jpwl.h:172
unsigned long int Pepb
four bytes, next error management method
Definition: jpwl.h:92
opj_bool jpwl_correct(opj_j2k_t *j2k)
corrects the data in the JPWL codestream
Definition: jpwl_lib.c:546
unsigned char Depb
single byte for the style
Definition: jpwl.h:88
unsigned long int DL
four bytes, the codestream length from SOC to EOC
Definition: jpwl.h:117
int opj_bool
Definition: openjpeg.h:63
ESD (Error Sensitivity Descriptor) Marker segment.
Definition: jpwl.h:128
unsigned long int pos
position where the marker should go, in the pre-JPWL codestream
Definition: jpwl.h:193
opj_bool len_ready
the marker length is ready or not?
Definition: jpwl.h:199
void j2k_write_epb(opj_j2k_t *j2k)
Write the EPB marker (Error Protection Block)
Definition: jpwl.c:1134
int tileno
TH where this marker has been placed (-1 means MH)
Definition: jpwl.h:65
opj_bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf)
Definition: jpwl_lib.c:1336
void j2k_read_insec(opj_j2k_t *j2k)
Read the INSEC marker (SEcured Codestream)
Definition: jpwl.c:1341
opj_bool red_on
is RED active?
Definition: jpwl.h:105
opj_bool packed
is it in packed mode?
Definition: jpwl.h:63
int k_pre
message word length of pre-data
Definition: jpwl.h:71
RED (Residual Error Descriptor) Marker segment.
Definition: jpwl.h:166
int tileno
tile where this marker has been placed (-1 means MH)
Definition: jpwl.h:155
unsigned long int svalnum
number of sensitivity values
Definition: jpwl.h:157
Structure used to store JPWL markers temporary position and readyness.
Definition: jpwl.h:178
opj_bool epb_on
is EPB active?
Definition: jpwl.h:107
struct jpwl_epb_ms jpwl_epb_ms_t
EPB (Error Protection Block) Marker segment.
int numcomps
number of components in the image
Definition: jpwl.h:153
struct jpwl_marker jpwl_marker_t
Structure used to store JPWL markers temporary position and readyness.
union jpwl_marker::jpwl_marks m
void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len)
Definition: jpwl.c:164
unsigned char Pesd
one byte, signals JPWL techniques adoption
Definition: jpwl.h:146
Index structure of the codestream.
Definition: openjpeg.h:672
unsigned char Pred
one byte, signals JPWL techniques adoption
Definition: jpwl.h:170
void j2k_read_esd(opj_j2k_t *j2k)
Read the ESD marker (Error Sensitivity Descriptor)
Definition: jpwl.c:1170
static int jwmarker_num
number of JPWL prepared markers
Definition: jpwl.c:43
int n_post
code word length of post-data
Definition: jpwl.h:79
unsigned char addrm
codestream addressing mode [0=packet, 1=byte range, 2=packet range, 3=reserved]
Definition: jpwl.h:130
jpwl_epb_ms_t * epbmark
pointer to EPB marker
Definition: jpwl.h:184