OpenJPEG  1.5.1
Macros | Functions
jpwl_lib.c File Reference
#include "opj_includes.h"
#include <limits.h>

Macros

#define MIN_V1   0.0
 Minimum and maximum values for the double->pfp conversion. More...
 
#define MAX_V1   17293822569102704640.0
 
#define MIN_V2   0.000030517578125
 
#define MAX_V2   131040.0
 

Functions

unsigned short int jpwl_double_to_pfp (double V, int bytes)
 conversion between a double precision floating point number and the corresponding pseudo-floating point used to represent sensitivity values More...
 
double jpwl_pfp_to_double (unsigned short int em, int bytes)
 conversion between a pseudo-floating point used to represent sensitivity values and the corresponding double precision floating point number
More...
 
int jpwl_markcomp (const void *arg1, const void *arg2)
 this function is used to compare two JPWL markers based on their relevant wishlist position More...
 
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 More...
 
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 More...
 
void jpwl_epb_write (opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf)
 write an EPB MS to a buffer More...
 
jpwl_epc_ms_tjpwl_epc_create (opj_j2k_t *j2k, opj_bool esd_on, opj_bool red_on, opj_bool epb_on, opj_bool info_on)
 create an EPC marker segment More...
 
opj_bool jpwl_epb_fill (opj_j2k_t *j2k, jpwl_epb_ms_t *epb, unsigned char *buf, unsigned char *post_buf)
 
opj_bool jpwl_correct (opj_j2k_t *j2k)
 corrects the data in the JPWL codestream More...
 
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 More...
 
void jpwl_epc_write (opj_j2k_t *j2k, jpwl_epc_ms_t *epc, unsigned char *buf)
 write an EPC MS to a buffer More...
 
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 More...
 
jpwl_esd_ms_tjpwl_esd_create (opj_j2k_t *j2k, int comp, unsigned char addrm, unsigned char ad_size, unsigned char senst, int se_size, int tileno, unsigned long int svalnum, void *sensval)
 create an EPC marker segment More...
 
opj_bool jpwl_esd_fill (opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf)
 
void jpwl_esd_write (opj_j2k_t *j2k, jpwl_esd_ms_t *esd, unsigned char *buf)
 write an ESD MS to a buffer More...
 
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 More...
 

Macro Definition Documentation

◆ MAX_V1

#define MAX_V1   17293822569102704640.0

◆ MAX_V2

#define MAX_V2   131040.0

◆ MIN_V1

#define MIN_V1   0.0

Minimum and maximum values for the double->pfp conversion.

◆ MIN_V2

#define MIN_V2   0.000030517578125

Function Documentation

◆ jpwl_correct()

opj_bool jpwl_correct ( opj_j2k_t j2k)

◆ jpwl_double_to_pfp()

unsigned short int jpwl_double_to_pfp ( double  V,
int  bytes 
)

conversion between a double precision floating point number and the corresponding pseudo-floating point used to represent sensitivity values

Parameters
Vthe double precision value
bytesthe number of bytes of the representation
Returns
the pseudo-floating point value (cast accordingly)

References MAX_V1, MAX_V2, MIN_V1, and MIN_V2.

Referenced by jpwl_esd_fill().

◆ 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()

opj_bool jpwl_epb_fill ( opj_j2k_t j2k,
jpwl_epb_ms_t epb,
unsigned char *  buf,
unsigned char *  post_buf 
)

◆ jpwl_epb_write()

void jpwl_epb_write ( opj_j2k_t j2k,
jpwl_epb_ms_t epbmark,
unsigned char *  buf 
)

write an EPB MS to a buffer

Parameters
j2kJ2K compressor handle
epbmarkpointer to the EPB MS
bufpointer to the memory buffer

References opj_j2k::cstr_info, jpwl_epb_ms::Depb, j2k_add_marker(), J2K_MS_EPB, jpwl_epb_ms::LDPepb, jpwl_epb_ms::Lepb, and jpwl_epb_ms::Pepb.

Referenced by jpwl_dump_marks().

◆ 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, jpwl_marker::data_ready, jpwl_marker::dpos, jpwl_marker::jpwl_marks::epbmark, EVT_ERROR, jpwl_marker::id, J2K_MS_EPB, jpwl_epb_create(), JPWL_MAX_NO_MARKERS, JPWL_MAXIMUM_EPB_ROOM, jwmarker, jwmarker_num, jpwl_marker::len, jpwl_marker::len_ready, jpwl_epb_ms::Lepb, jpwl_marker::m, min, opj_event_msg(), OPJ_FALSE, OPJ_TRUE, jpwl_marker::parms_ready, jpwl_marker::pos, and jpwl_marker::pos_ready.

Referenced by jpwl_prepare_marks().

◆ jpwl_epc_create()

jpwl_epc_ms_t* jpwl_epc_create ( opj_j2k_t j2k,
opj_bool  esd_on,
opj_bool  red_on,
opj_bool  epb_on,
opj_bool  info_on 
)

create an EPC marker segment

Parameters
j2kJ2K compressor handle
esd_ontrue if ESD is activated
red_ontrue if RED is activated
epb_ontrue if EPB is activated
info_ontrue if informative techniques are activated
Returns
returns the freshly created EPC

References opj_j2k::cinfo, opj_j2k::cp, jpwl_epc_ms::DL, opj_cp::epb_on, jpwl_epc_ms::epb_on, opj_cp::esd_on, jpwl_epc_ms::esd_on, EVT_ERROR, opj_cp::info_on, jpwl_epc_ms::info_on, jpwl_epc_ms::Lepc, opj_event_msg(), opj_malloc, jpwl_epc_ms::Pcrc, jpwl_epc_ms::Pepc, opj_cp::red_on, and jpwl_epc_ms::red_on.

Referenced by jpwl_prepare_marks().

◆ jpwl_epc_write()

void jpwl_epc_write ( opj_j2k_t j2k,
jpwl_epc_ms_t epcmark,
unsigned char *  buf 
)

write an EPC MS to a buffer

Parameters
j2kJ2K compressor handle
epcmarkpointer to the EPC MS
bufpointer to the memory buffer

References opj_j2k::cstr_info, jpwl_epc_ms::DL, j2k_add_marker(), J2K_MS_EPC, jpwl_epc_ms::Lepc, jpwl_epc_ms::Pcrc, and jpwl_epc_ms::Pepc.

Referenced by jpwl_dump_marks().

◆ jpwl_esd_create()

jpwl_esd_ms_t* jpwl_esd_create ( opj_j2k_t j2k,
int  comps,
unsigned char  addrm,
unsigned char  ad_size,
unsigned char  senst,
int  se_size,
int  tileno,
unsigned long int  svalnum,
void *  sensval 
)

create an EPC marker segment

Parameters
j2kJ2K compressor handle
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)
tilenotile where this ESD lies (-1 means MH)
svalnumnumber of sensitivity values (if 0, they will be automatically filled)
sensvalpointer to an array of sensitivity values (if NULL, they will be automatically filled)
Returns
returns the freshly created ESD

References jpwl_esd_ms::ad_size, jpwl_esd_ms::addrm, jpwl_esd_ms::Cesd, opj_j2k::cinfo, opj_codestream_info::codestream_size, opj_j2k::cstr_info, jpwl_esd_ms::data, EVT_ERROR, opj_j2k::image, jpwl_esd_ms::Lesd, jpwl_esd_ms::numcomps, opj_image::numcomps, opj_event_msg(), opj_malloc, opj_codestream_info::packno, jpwl_esd_ms::Pesd, jpwl_esd_ms::se_size, jpwl_esd_ms::senst, jpwl_esd_ms::sensval_size, jpwl_esd_ms::svalnum, opj_codestream_info::th, jpwl_esd_ms::tileno, and opj_codestream_info::tw.

Referenced by jpwl_prepare_marks().

◆ jpwl_esd_fill()

opj_bool jpwl_esd_fill ( opj_j2k_t j2k,
jpwl_esd_ms_t esd,
unsigned char *  buf 
)

◆ jpwl_esd_write()

void jpwl_esd_write ( opj_j2k_t j2k,
jpwl_esd_ms_t esdmark,
unsigned char *  buf 
)

write an ESD MS to a buffer

Parameters
j2kJ2K compressor handle
esdmarkpointer to the ESD MS
bufpointer to the memory buffer

References jpwl_esd_ms::Cesd, opj_j2k::cstr_info, j2k_add_marker(), J2K_MS_ESD, jpwl_esd_ms::Lesd, jpwl_esd_ms::numcomps, and jpwl_esd_ms::Pesd.

Referenced by jpwl_dump_marks().

◆ 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

◆ jpwl_markcomp()

int jpwl_markcomp ( const void *  arg1,
const void *  arg2 
)

this function is used to compare two JPWL markers based on their relevant wishlist position

Parameters
arg1pointer to first marker
arg2pointer to second marker
Returns
1 if arg1>arg2, 0 if arg1=arg2, -1 if arg1<arg2

Referenced by jpwl_dump_marks().

◆ jpwl_pfp_to_double()

double jpwl_pfp_to_double ( unsigned short int  em,
int  bytes 
)

conversion between a pseudo-floating point used to represent sensitivity values and the corresponding double precision floating point number

Parameters
emthe pseudo-floating point value (cast accordingly)
bytesthe number of bytes of the representation
Returns
the double precision value

Referenced by jpwl_esd_fill().

◆ jpwl_update_info()

opj_bool jpwl_update_info ( opj_j2k_t j2k,
jpwl_marker_t jwmarker,
int  jwmarker_num 
)