OpenJPEG 1.5.1
jpwl.h File Reference

The JPEG-2000 Part11 (JPWL) marker segments manager. More...

#include "crc.h"
#include "rs.h"

Go to the source code of this file.

Data Structures

struct  jpwl_epb_ms
 EPB (Error Protection Block) Marker segment. More...
 
struct  jpwl_epc_ms
 EPC (Error Protection Capability) Marker segment. More...
 
struct  jpwl_esd_ms
 ESD (Error Sensitivity Descriptor) Marker segment. More...
 
struct  jpwl_red_ms
 RED (Residual Error Descriptor) Marker segment. More...
 
struct  jpwl_marker
 Structure used to store JPWL markers temporary position and readyness. More...
 
union  jpwl_marker::jpwl_marks
 union keeping the pointer to the real marker struct More...
 

Macros

#define JPWL_ASSUME   OPJ_TRUE
 Assume a basic codestream structure, so you can resort better from uncorrected errors.
 
#define jpwl_updateCRC16(CRC, DATA)
 Macro functions for CRC computation.
 
#define jpwl_updateCRC32(CRC, DATA)
 Computes the CRC-32, as stated in JPWL specs.
 

Typedefs

typedef struct jpwl_epb_ms jpwl_epb_ms_t
 EPB (Error Protection Block) Marker segment.
 
typedef struct jpwl_epc_ms jpwl_epc_ms_t
 EPC (Error Protection Capability) Marker segment.
 
typedef struct jpwl_esd_ms jpwl_esd_ms_t
 ESD (Error Sensitivity Descriptor) Marker segment.
 
typedef struct jpwl_red_ms jpwl_red_ms_t
 RED (Residual Error Descriptor) Marker segment.
 
typedef struct jpwl_marker jpwl_marker_t
 Structure used to store JPWL markers temporary position and readyness.
 

Functions

void jpwl_encode (opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image)
 Encode according to JPWL specs.
 
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 full)
 
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.
 
void j2k_read_epc (opj_j2k_t *j2k)
 Read the EPC marker (Error Protection Capability)
 
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 simplifies the management of EPBs and it is openly stated in the standard as a possible value, mening that the information is not available) and the informative techniques are not yet implemented.
 
void j2k_read_epb (opj_j2k_t *j2k)
 Read the EPB marker (Error Protection Block)
 
void j2k_write_epb (opj_j2k_t *j2k)
 Write the EPB marker (Error Protection Block)
 
void j2k_read_esd (opj_j2k_t *j2k)
 Read the ESD marker (Error Sensitivity Descriptor)
 
void j2k_read_red (opj_j2k_t *j2k)
 Read the RED marker (Residual Error Descriptor)
 
jpwl_epb_ms_tjpwl_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
 
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
 
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
 
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
 
opj_bool jpwl_esd_fill (opj_j2k_t *j2k, jpwl_esd_ms_t *esdmark, unsigned char *buf)
 
opj_bool jpwl_epb_fill (opj_j2k_t *j2k, jpwl_epb_ms_t *epbmark, unsigned char *buf, unsigned char *post_buf)
 
void j2k_add_marker (opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len)
 
opj_bool jpwl_correct (opj_j2k_t *j2k)
 corrects the data in the JPWL codestream
 
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
 
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
 
void j2k_read_sec (opj_j2k_t *j2k)
 Read the SEC marker (SEcured Codestream)
 
void j2k_write_sec (opj_j2k_t *j2k)
 Write the SEC marker (SEcured Codestream)
 
void j2k_read_insec (opj_j2k_t *j2k)
 Read the INSEC marker (SEcured Codestream)
 

Detailed Description

The JPEG-2000 Part11 (JPWL) marker segments manager.

The functions in JPWL.C have for goal to read/write the markers added by JPWL.

Macro Definition Documentation

◆ JPWL_ASSUME

#define JPWL_ASSUME   OPJ_TRUE

Assume a basic codestream structure, so you can resort better from uncorrected errors.

Referenced by j2k_decode(), j2k_read_ppm(), j2k_read_qcc(), j2k_read_qcx(), j2k_read_rgn(), j2k_read_siz(), j2k_read_sot(), j2k_read_unk(), jpwl_check_tile(), and t2_decode_packet().

◆ jpwl_updateCRC16

#define jpwl_updateCRC16 ( CRC,
DATA )
Value:
updateCRC16(CRC, DATA)
void updateCRC16(unsigned short *crc, unsigned char data)
file: CRC16.HPP
Definition crc.c:91

Macro functions for CRC computation.

Computes the CRC-16, as stated in JPWL specs

Parameters
CRCtwo bytes containing the CRC value (must be initialized with 0x0000)
DATAbyte for which the CRC is computed; call this on every byte of the sequence and get the CRC at the end

Referenced by j2k_read_epc(), j2k_write_epc(), jpwl_dump_marks(), jpwl_epb_correct(), and jpwl_epb_fill().

◆ jpwl_updateCRC32

#define jpwl_updateCRC32 ( CRC,
DATA )
Value:
updateCRC32(CRC, DATA)
void updateCRC32(unsigned long *crc, unsigned char data)
file: CRC32.HPP
Definition crc.c:156

Computes the CRC-32, as stated in JPWL specs.

Parameters
CRCfour bytes containing the CRC value (must be initialized with 0x00000000)
DATAbyte for which the CRC is computed; call this on every byte of the sequence and get the CRC at the end

Referenced by jpwl_epb_correct(), and jpwl_epb_fill().

Typedef Documentation

◆ jpwl_epb_ms_t

typedef struct jpwl_epb_ms jpwl_epb_ms_t

EPB (Error Protection Block) Marker segment.

◆ jpwl_epc_ms_t

typedef struct jpwl_epc_ms jpwl_epc_ms_t

EPC (Error Protection Capability) Marker segment.

◆ jpwl_esd_ms_t

typedef struct jpwl_esd_ms jpwl_esd_ms_t

ESD (Error Sensitivity Descriptor) Marker segment.

◆ jpwl_marker_t

typedef struct jpwl_marker jpwl_marker_t

Structure used to store JPWL markers temporary position and readyness.

◆ jpwl_red_ms_t

typedef struct jpwl_red_ms jpwl_red_ms_t

RED (Residual Error Descriptor) Marker segment.

Function Documentation

◆ j2k_add_marker()

◆ j2k_read_epb()

◆ j2k_read_epc()

void j2k_read_epc ( opj_j2k_t * j2k)

Read the EPC marker (Error Protection Capability)

Parameters
j2kJ2K handle

References opj_j2k::cinfo, opj_j2k::cio, cio_read(), cio_seek(), cio_skip(), cio_tell(), EVT_INFO, jpwl_updateCRC16, and opj_event_msg().

◆ j2k_read_esd()

void j2k_read_esd ( opj_j2k_t * j2k)

Read the ESD marker (Error Sensitivity Descriptor)

Parameters
j2kJ2K handle

References opj_j2k::cinfo, opj_j2k::cio, cio_read(), cio_skip(), cio_tell(), EVT_INFO, opj_j2k::image, opj_image::numcomps, and opj_event_msg().

◆ j2k_read_insec()

void j2k_read_insec ( opj_j2k_t * j2k)

Read the INSEC marker (SEcured Codestream)

Parameters
j2kJ2K handle

References opj_j2k::cinfo, opj_j2k::cio, cio_read(), cio_skip(), cio_tell(), EVT_INFO, and opj_event_msg().

◆ j2k_read_red()

void j2k_read_red ( opj_j2k_t * j2k)

Read the RED marker (Residual Error Descriptor)

Parameters
j2kJ2K handle

References opj_j2k::cinfo, opj_j2k::cio, cio_read(), cio_skip(), cio_tell(), EVT_INFO, and opj_event_msg().

◆ j2k_read_sec()

void j2k_read_sec ( opj_j2k_t * j2k)

Read the SEC marker (SEcured Codestream)

Parameters
j2kJ2K handle

References opj_j2k::cinfo, opj_j2k::cio, cio_read(), cio_skip(), cio_tell(), EVT_INFO, and opj_event_msg().

◆ j2k_write_epb()

void j2k_write_epb ( opj_j2k_t * j2k)

Write the EPB marker (Error Protection Block)

Parameters
j2kJ2K handle

References opj_j2k::cio, cio_seek(), cio_skip(), cio_tell(), cio_write(), opj_j2k::cstr_info, j2k_add_marker(), and J2K_MS_EPB.

◆ j2k_write_epc()

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 simplifies the management of EPBs and it is openly stated in the standard as a possible value, mening that the information is not available) and the informative techniques are not yet implemented.

Parameters
j2kJ2K handle

References opj_j2k::cio, cio_read(), cio_seek(), cio_skip(), cio_tell(), cio_write(), opj_j2k::cstr_info, j2k_add_marker(), J2K_MS_EPC, and jpwl_updateCRC16.

◆ j2k_write_sec()

void j2k_write_sec ( opj_j2k_t * j2k)

Write the SEC marker (SEcured Codestream)

Parameters
j2kJ2K handle

References opj_j2k::cio, cio_write(), and J2K_MS_SEC.

◆ jpwl_check_tile()

◆ jpwl_correct()

◆ jpwl_dump_marks()

◆ jpwl_encode()

void jpwl_encode ( opj_j2k_t * j2k,
opj_cio_t * cio,
opj_image_t * image )

Encode according to JPWL specs.

Parameters
j2kJ2K handle
ciocodestream handle
imageimage handle

References J2K_MS_EPB, J2K_MS_EPC, J2K_MS_ESD, J2K_MS_RED, jpwl_dump_marks(), JPWL_MAX_NO_MARKERS, jpwl_prepare_marks(), jwmarker, jwmarker_num, opj_free, and opj_j2k::pos_correction.

Referenced by j2k_encode().

◆ jpwl_epb_correct()

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

Parameters
j2kJ2K compressor handle
bufferpointer to the EPB position
typetype of EPB: 0=MH, 1=TPH, 2=other, 3=auto
pre_lenlength of pre-data
post_lenlength of post_data
connis a pointer to the length of all connected (packed) EPBs
L4_bufpis a pointer to the buffer pointer of redundancy data
Returns
returns true if correction could be succesfully performed

References opj_cio::bp, opj_j2k::cinfo, opj_j2k::cio, cio_numbytesleft(), cio_read(), cio_seek(), cio_skip(), cio_tell(), eras_dec_rs(), EVT_ERROR, EVT_INFO, EVT_WARNING, init_rs(), jpwl_epb_correct(), jpwl_updateCRC16, jpwl_updateCRC32, NN, opj_event_msg(), OPJ_FALSE, and OPJ_TRUE.

Referenced by j2k_read_epb(), jpwl_correct(), and jpwl_epb_correct().

◆ jpwl_epb_create()

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

Parameters
j2kJ2K compressor handle
latestit is the latest EPB in the header
packedEPB is in packed style
tilenotile number where the marker has been placed (-1 means MH)
idxcurrent EPB running index
hprotapplied protection type (-1/0,1,16,32,37-128)
pre_lenlength of pre-protected data
post_lenlength of post-protected data
Returns
returns the freshly created EPB

References opj_j2k::cinfo, jpwl_epb_ms::Depb, EVT_ERROR, jpwl_epb_ms::hprot, jpwl_epb_ms::k_post, jpwl_epb_ms::k_pre, jpwl_epb_ms::LDPepb, jpwl_epb_ms::Lepb, jpwl_epb_ms::n_post, jpwl_epb_ms::n_pre, opj_event_msg(), opj_malloc, jpwl_epb_ms::Pepb, jpwl_epb_ms::post_len, jpwl_epb_ms::pre_len, and jpwl_epb_ms::tileno.

Referenced by jpwl_epbs_add(), and jpwl_prepare_marks().

◆ jpwl_epb_fill()

◆ jpwl_epbs_add()

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

Parameters
j2kJ2K compressor handle
jwmarkerpointer to the JPWL markers list
jwmarker_numpointer to the number of JPWL markers (gets updated)
latestit is the latest group of EPBs in the header
packedEPBs are in packed style
insideMHit is in the MH
idxpointer to the starting EPB running index (gets updated)
hprotapplied protection type (-1/0,1,16,32,37-128)
place_posplace in original codestream where EPBs should go
tilenotile number of these EPBs
pre_lenlength of pre-protected data
post_lenlength of post-protected data
Returns
returns the length of all added markers

References opj_j2k::cinfo, EVT_ERROR, J2K_MS_EPB, jpwl_epb_create(), JPWL_MAX_NO_MARKERS, JPWL_MAXIMUM_EPB_ROOM, jwmarker, jwmarker_num, jpwl_epb_ms::Lepb, min, opj_event_msg(), OPJ_FALSE, and OPJ_TRUE.

Referenced by jpwl_prepare_marks().

◆ jpwl_esd_fill()

◆ jpwl_esds_add()

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

Parameters
j2kJ2K compressor handle
jwmarkerpointer to the JPWL markers list
jwmarker_numpointer to the number of JPWL markers (gets updated)
compsconsidered component (-1=average, 0/1/2/...=component no.)
addrmaddressing mode (0=packet, 1=byte range, 2=packet range, 3=reserved)
ad_sizesize of addresses (2/4 bytes)
senstsensitivity type
se_sizesensitivity values size (1/2 bytes)
place_posplace in original codestream where EPBs should go
tilenotile number of these EPBs
Returns
returns the length of all added markers

References jwmarker, and jwmarker_num.

◆ jpwl_prepare_marks()

◆ jpwl_update_info()