OpenJPEG 1.5.2
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
45
48
52#define JPWL_ASSUME OPJ_TRUE
53
57typedef struct jpwl_epb_ms {
65 int tileno;
67 unsigned char index;
69 int hprot;
71 int k_pre;
73 int n_pre;
77 int k_post;
79 int n_post;
86 unsigned short int Lepb;
88 unsigned char Depb;
90 unsigned long int LDPepb;
92 unsigned long int Pepb;
94 unsigned char *data;
97
101typedef 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;
124
128typedef 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;
157 unsigned long int svalnum;
162
166typedef struct jpwl_red_ms {
168 unsigned short int Lred;
170 unsigned char Pred;
172 unsigned char *data;
174
207
214void jpwl_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
215
223void jpwl_prepare_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
224
231void jpwl_dump_marks(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image);
232
237void j2k_read_epc(opj_j2k_t *j2k);
238
246void j2k_write_epc(opj_j2k_t *j2k);
247
252void j2k_read_epb(opj_j2k_t *j2k);
253
258void j2k_write_epb(opj_j2k_t *j2k);
259
264void j2k_read_esd(opj_j2k_t *j2k);
265
270void j2k_read_red(opj_j2k_t *j2k);
271
283jpwl_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
333opj_bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf);
334
335opj_bool jpwl_epb_fill(opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf, unsigned char *post_buf);
336
337void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
338
344
355opj_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
363opj_bool jpwl_check_tile(opj_j2k_t *j2k, opj_tcd_t *tcd, int tileno);
364
366
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
394
395#endif /* USE_JPWL */
396
397#ifdef USE_JPSEC
398
401
406void j2k_read_sec(opj_j2k_t *j2k);
407
412void j2k_write_sec(opj_j2k_t *j2k);
413
418void j2k_read_insec(opj_j2k_t *j2k);
419
421
422#endif /* USE_JPSEC */
423
424#endif /* __JPWL_H */
425
Functions used to compute the 16- and 32-bit CRC of byte arrays.
struct opj_j2k opj_j2k_t
JPEG-2000 codestream reader/writer.
static jpwl_marker_t jwmarker[JPWL_MAX_NO_MARKERS]
properties of JPWL markers to insert
Definition jpwl.c:45
static int jwmarker_num
number of JPWL prepared markers
Definition jpwl.c:43
struct jpwl_red_ms jpwl_red_ms_t
RED (Residual Error Descriptor) Marker segment.
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
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
struct jpwl_esd_ms jpwl_esd_ms_t
ESD (Error Sensitivity Descriptor) Marker segment.
void j2k_write_epb(opj_j2k_t *j2k)
Write the EPB marker (Error Protection Block)
Definition jpwl.c:1134
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
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
void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len)
Definition jpwl.c:164
struct jpwl_marker jpwl_marker_t
Structure used to store JPWL markers temporary position and readyness.
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
void j2k_read_esd(opj_j2k_t *j2k)
Read the ESD marker (Error Sensitivity Descriptor)
Definition jpwl.c:1170
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
opj_bool jpwl_esd_fill(opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf)
Definition jpwl_lib.c:1336
void j2k_write_sec(opj_j2k_t *j2k)
Write the SEC marker (SEcured Codestream)
Definition jpwl.c:1327
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
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_read_insec(opj_j2k_t *j2k)
Read the INSEC marker (SEcured Codestream)
Definition jpwl.c:1341
void j2k_read_red(opj_j2k_t *j2k)
Read the RED marker (Residual Error Descriptor)
Definition jpwl.c:1200
void j2k_read_epb(opj_j2k_t *j2k)
Read the EPB marker (Error Protection Block)
Definition jpwl.c:1019
struct jpwl_epb_ms jpwl_epb_ms_t
EPB (Error Protection Block) Marker segment.
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
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
void j2k_read_epc(opj_j2k_t *j2k)
Read the EPC marker (Error Protection Capability)
Definition jpwl.c:907
opj_bool jpwl_correct(opj_j2k_t *j2k)
corrects the data in the JPWL codestream
Definition jpwl_lib.c:546
void jpwl_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image)
Encode according to JPWL specs.
Definition jpwl.c:114
struct jpwl_epc_ms jpwl_epc_ms_t
EPC (Error Protection Capability) Marker segment.
void j2k_read_sec(opj_j2k_t *j2k)
Read the SEC marker (SEcured Codestream)
Definition jpwl.c:1310
struct opj_codestream_info opj_codestream_info_t
Index structure of the codestream.
int opj_bool
Definition openjpeg.h:63
struct opj_image opj_image_t
Defines image data and characteristics.
struct opj_cio opj_cio_t
Byte input-output stream (CIO)
Functions used to compute Reed-Solomon parity and check of byte arrays.
EPB (Error Protection Block) Marker segment.
Definition jpwl.h:57
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 index
index in current header (0-63)
Definition jpwl.h:67
int tileno
TH where this marker has been placed (-1 means MH)
Definition jpwl.h:65
int n_pre
code word length of pre-data
Definition jpwl.h:73
opj_bool packed
is it in packed mode?
Definition jpwl.h:63
int pre_len
length of pre-data
Definition jpwl.h:75
opj_bool latest
is the latest in header?
Definition jpwl.h:61
unsigned long int Pepb
four bytes, next error management method
Definition jpwl.h:92
int k_post
message word length of post-data
Definition jpwl.h:77
int hprot
error protection method [-1=absent 0=none 1=predefined 16=CRC-16 32=CRC-32 37-128=RS]
Definition jpwl.h:69
unsigned long int LDPepb
four bytes, from 0 to 2^31-1
Definition jpwl.h:90
int k_pre
message word length of pre-data
Definition jpwl.h:71
int post_len
length of post-data
Definition jpwl.h:81
int n_post
code word length of post-data
Definition jpwl.h:79
unsigned char * data
EPB data, variable size.
Definition jpwl.h:94
unsigned char Depb
single byte for the style
Definition jpwl.h:88
EPC (Error Protection Capability) Marker segment.
Definition jpwl.h:101
unsigned char Pepc
one byte, signals JPWL techniques adoption
Definition jpwl.h:119
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
opj_bool epb_on
is EPB active?
Definition jpwl.h:107
opj_bool red_on
is RED active?
Definition jpwl.h:105
unsigned char * data
EPC data, variable length.
Definition jpwl.h:121
opj_bool esd_on
is ESD active?
Definition jpwl.h:103
unsigned short int Lepc
two bytes for the length of EPC MS, exluding the marker itself (9 to 65535 bytes)
Definition jpwl.h:113
unsigned long int DL
four bytes, the codestream length from SOC to EOC
Definition jpwl.h:117
ESD (Error Sensitivity Descriptor) Marker segment.
Definition jpwl.h:128
int tileno
tile where this marker has been placed (-1 means MH)
Definition jpwl.h:155
size_t sensval_size
size of a single sensitivity pair (address+value)
Definition jpwl.h:159
unsigned char addrm
codestream addressing mode [0=packet, 1=byte range, 2=packet range, 3=reserved]
Definition jpwl.h:130
unsigned long int svalnum
number of sensitivity values
Definition jpwl.h:157
unsigned char * data
ESD data, variable length.
Definition jpwl.h:148
unsigned char senst
type of sensitivity [0=relative error, 1=MSE, 2=MSE reduction, 3=PSNR, 4=PSNR increment,...
Definition jpwl.h:136
unsigned char se_size
size of sensitivity data (1/2 bytes)
Definition jpwl.h:138
unsigned short int Cesd
two bytes, component of error sensitivity
Definition jpwl.h:144
unsigned char ad_size
size of codestream addresses [2/4 bytes]
Definition jpwl.h:132
unsigned char Pesd
one byte, signals JPWL techniques adoption
Definition jpwl.h:146
int numcomps
number of components in the image
Definition jpwl.h:153
unsigned short int Lesd
two bytes for the length of ESD MS, exluding the marker itself (4 to 65535 bytes)
Definition jpwl.h:142
Structure used to store JPWL markers temporary position and readyness.
Definition jpwl.h:178
unsigned long int pos
position where the marker should go, in the pre-JPWL codestream
Definition jpwl.h:193
union jpwl_marker::jpwl_marks m
opj_bool pos_ready
the marker position is ready or not?
Definition jpwl.h:201
opj_bool data_ready
are the written data ready or not
Definition jpwl.h:205
double dpos
same as before, only written as a double, so we can sort it better
Definition jpwl.h:195
opj_bool parms_ready
the marker parameters are ready or not?
Definition jpwl.h:203
int id
marker value (J2K_MS_EPC, etc.)
Definition jpwl.h:180
unsigned short int len
length of the marker segment (marker excluded)
Definition jpwl.h:197
opj_bool len_ready
the marker length is ready or not?
Definition jpwl.h:199
RED (Residual Error Descriptor) Marker segment.
Definition jpwl.h:166
unsigned char * data
RED data, variable length.
Definition jpwl.h:172
unsigned char Pred
one byte, signals JPWL techniques adoption
Definition jpwl.h:170
unsigned short int Lred
two bytes for the length of RED MS, exluding the marker itself (3 to 65535 bytes)
Definition jpwl.h:168
struct opj_tcd opj_tcd_t
Tile coder/decoder.
union keeping the pointer to the real marker struct
Definition jpwl.h:182
jpwl_epb_ms_t * epbmark
pointer to EPB marker
Definition jpwl.h:184
jpwl_red_ms_t * redmark
pointer to RED marker
Definition jpwl.h:190
jpwl_epc_ms_t * epcmark
pointer to EPC marker
Definition jpwl.h:186
jpwl_esd_ms_t * esdmark
pointer to ESD marker
Definition jpwl.h:188