Grok 20.3.2
grk::t1::ojph::local Namespace Reference

Classes

struct  dec_mel_st
 MEL state structure for reading and decoding the MEL bitstream. More...
struct  frwd_struct
 State structure for reading and unstuffing of forward-growing bitstreams; these are: MagSgn and SPP bitstreams. More...
struct  frwd_struct32
 State structure for reading and unstuffing of forward-growing bitstreams; these are: MagSgn and SPP bitstreams. More...
struct  frwd_struct64
 State structure for reading and unstuffing of forward-growing bitstreams; these are: MagSgn and SPP bitstreams. More...
struct  mel_struct
struct  ms_struct
struct  rev_struct
 A structure for reading and unstuffing a segment that grows backward, such as VLC and MRP. More...
struct  uvlc_tbl_struct
struct  vlc_struct

Functions

static bool vlc_init_tables ()
 Initializes vlc_tbl0 and vlc_tbl1 tables, from table0.h and table1.h.
static bool uvlc_init_tables ()
 Initializes uvlc_tbl0 and uvlc_tbl1 tables.
bool ojph_decode_codeblock32 (ui8 *coded_data, ui32 *decoded_data, ui32 missing_msbs, ui32 num_passes, ui32 lengths1, ui32 lengths2, ui32 width, ui32 height, ui32 stride, bool stripe_causal)
 Decodes one codeblock, processing the cleanup, siginificance propagation, and magnitude refinement pass.
bool ojph_decode_codeblock64 (ui8 *coded_data, ui64 *decoded_data, ui32 missing_msbs, ui32 num_passes, ui32 lengths1, ui32 lengths2, ui32 width, ui32 height, ui32 stride, bool stripe_causal)
 Decodes one codeblock, processing the cleanup, siginificance propagation, and magnitude refinement pass.
bool ojph_decode_codeblock_ssse3 (ui8 *coded_data, ui32 *decoded_data, ui32 missing_msbs, ui32 num_passes, ui32 lengths1, ui32 lengths2, ui32 width, ui32 height, ui32 stride, bool stripe_causal)
bool ojph_decode_codeblock_avx2 (ui8 *coded_data, ui32 *decoded_data, ui32 missing_msbs, ui32 num_passes, ui32 lengths1, ui32 lengths2, ui32 width, ui32 height, ui32 stride, bool stripe_causal)
bool ojph_decode_codeblock_wasm (ui8 *coded_data, ui32 *decoded_data, ui32 missing_msbs, ui32 num_passes, ui32 lengths1, ui32 lengths2, ui32 width, ui32 height, ui32 stride, bool stripe_causal)
 Decodes one codeblock, processing the cleanup, siginificance propagation, and magnitude refinement pass.
static void mel_read (dec_mel_st *melp)
 Reads and unstuffs the MEL bitstream.
static void mel_decode (dec_mel_st *melp)
 Decodes unstuffed MEL segment bits stored in tmp to runs.
static void mel_init (dec_mel_st *melp, ui8 *bbuf, int lcup, int scup)
 Initiates a dec_mel_st structure for MEL decoding and reads some bytes in order to get the read address to a multiple of 4.
static int mel_get_run (dec_mel_st *melp)
 Retrieves one run from dec_mel_st; if there are no runs stored MEL segment is decoded.
static void rev_read (rev_struct *vlcp)
 Read and unstuff data from a backwardly-growing segment.
static void rev_init (rev_struct *vlcp, ui8 *data, int lcup, int scup)
 Initiates the rev_struct structure and reads a few bytes to move the read address to multiple of 4.
static ui32 rev_fetch (rev_struct *vlcp)
 Retrieves 32 bits from the head of a rev_struct structure.
static ui32 rev_advance (rev_struct *vlcp, ui32 num_bits)
 Consumes num_bits from a rev_struct structure.
static void rev_read_mrp (rev_struct *mrp)
 Reads and unstuffs from rev_struct.
static void rev_init_mrp (rev_struct *mrp, ui8 *data, int lcup, int len2)
 Initialized rev_struct structure for MRP segment, and reads a number of bytes such that the next 32 bits read are from an address that is a multiple of 4.
static ui32 rev_fetch_mrp (rev_struct *mrp)
 Retrieves 32 bits from the head of a rev_struct structure.
static ui32 rev_advance_mrp (rev_struct *mrp, ui32 num_bits)
 Consumes num_bits from a rev_struct structure.
template<int X>
static void frwd_read (frwd_struct32 *msp)
 Read and unstuffs 32 bits from forward-growing bitstream.
template<int X>
static void frwd_init (frwd_struct32 *msp, const ui8 *data, int size)
 Initialize frwd_struct32 struct and reads some bytes.
static void frwd_advance (frwd_struct32 *msp, ui32 num_bits)
 Consume num_bits bits from the bitstream of frwd_struct32.
template<int X>
static ui32 frwd_fetch (frwd_struct32 *msp)
 Fetches 32 bits from the frwd_struct32 bitstream.
static void mel_read (dec_mel_st *melp)
 Reads and unstuffs the MEL bitstream.
static void mel_decode (dec_mel_st *melp)
 Decodes unstuffed MEL segment bits stored in tmp to runs.
static void mel_init (dec_mel_st *melp, ui8 *bbuf, int lcup, int scup)
 Initiates a dec_mel_st structure for MEL decoding and reads some bytes in order to get the read address to a multiple of 4.
static int mel_get_run (dec_mel_st *melp)
 Retrieves one run from dec_mel_st; if there are no runs stored MEL segment is decoded.
static void rev_read8 (rev_struct *vlcp)
 Read and unstuff data from a backwardly-growing segment.
static void rev_init8 (rev_struct *vlcp, ui8 *data, int lcup, int scup)
 Initiates the rev_struct structure and reads the first byte.
static ui64 rev_fetch64 (rev_struct *vlcp)
 Fills the temporary variable (vlcp->tmp) by up to 64 bits.
static ui64 rev_advance64 (rev_struct *vlcp, ui32 num_bits)
 Consumes num_bits from a rev_struct structure.
static void rev_read_mrp (rev_struct *mrp)
 Reads and unstuffs from rev_struct.
static void rev_init_mrp (rev_struct *mrp, ui8 *data, int lcup, int len2)
 Initialized rev_struct structure for MRP segment, and reads a number of bytes such that the next 32 bits read are from an address that is a multiple of 4.
static ui32 rev_fetch_mrp (rev_struct *mrp)
 Retrieves 32 bits from the head of a rev_struct structure.
static ui32 rev_advance_mrp (rev_struct *mrp, ui32 num_bits)
 Consumes num_bits from a rev_struct structure.
template<int X>
static void frwd_read (frwd_struct64 *msp)
 Read and unstuffs 32 bits from forward-growing bitstream.
template<ui8 X>
static void frwd_read8 (frwd_struct64 *msp)
 Read and unstuffs 8 bits from forward-growing bitstream.
template<int X>
static void frwd_init (frwd_struct64 *msp, const ui8 *data, int size)
 Initialize frwd_struct64 struct and reads some bytes.
template<ui8 X>
static void frwd_init8 (frwd_struct64 *msp, const ui8 *data, int size)
 Initialize frwd_struct64 struct and reads some bytes.
static void frwd_advance (frwd_struct64 *msp, ui32 num_bits)
 Consume num_bits bits from the bitstream of frwd_struct64.
template<int X>
static ui32 frwd_fetch (frwd_struct64 *msp)
 Fetches 32 bits from the frwd_struct64 bitstream.
template<ui8 X>
static ui64 frwd_fetch64 (frwd_struct64 *msp)
 Fetches up to 64 bits from the frwd_struct64 bitstream.
static void mel_read (dec_mel_st *melp)
 Reads and unstuffs the MEL bitstream.
static void mel_decode (dec_mel_st *melp)
 Decodes unstuffed MEL segment bits stored in tmp to runs.
static void mel_init (dec_mel_st *melp, ui8 *bbuf, int lcup, int scup)
 Initiates a dec_mel_st structure for MEL decoding and reads some bytes in order to get the read address to a multiple of 4.
static int mel_get_run (dec_mel_st *melp)
 Retrieves one run from dec_mel_st; if there are no runs stored MEL segment is decoded.
static void rev_read (rev_struct *vlcp)
 Read and unstuff data from a backwardly-growing segment.
static void rev_init (rev_struct *vlcp, ui8 *data, int lcup, int scup)
 Initiates the rev_struct structure and reads a few bytes to move the read address to multiple of 4.
static ui32 rev_fetch (rev_struct *vlcp)
 Retrieves 32 bits from the head of a rev_struct structure.
static ui32 rev_advance (rev_struct *vlcp, ui32 num_bits)
 Consumes num_bits from a rev_struct structure.
static void rev_read_mrp (rev_struct *mrp)
 Reads and unstuffs from rev_struct.
static void rev_init_mrp (rev_struct *mrp, ui8 *data, int lcup, int len2)
 Initialized rev_struct structure for MRP segment, and reads a number of bytes such that the next 32 bits read are from an address that is a multiple of 4.
static ui32 rev_fetch_mrp (rev_struct *mrp)
 Retrieves 32 bits from the head of a rev_struct structure.
template<int X>
static void frwd_read (frwd_struct *msp)
 Read and unstuffs 16 bytes from forward-growing bitstream.
template<int X>
static void frwd_init (frwd_struct *msp, const ui8 *data, int size)
 Initialize frwd_struct struct and reads some bytes.
static void frwd_advance (frwd_struct *msp, ui32 num_bits)
 Consume num_bits bits from the bitstream of frwd_struct.
template<int X>
static v128_t frwd_fetch (frwd_struct *msp)
 Fetches 32 bits from the frwd_struct bitstream.
template<int N>
static v128_t decode_one_quad32 (const v128_t inf_u_q, v128_t U_q, frwd_struct *magsgn, ui32 p, v128_t &vn)
 decodes one quad, using 32 bit data
static v128_t decode_two_quad16 (const v128_t inf_u_q, v128_t U_q, frwd_struct *magsgn, ui32 p, v128_t &vn)
 decodes twos consecutive quads (one octet), using 16 bit data
static bool vlc_init_tables ()
static bool uvlc_init_tables ()
bool initialize_block_encoder_tables ()
static void mel_init (mel_struct *melp, ui32 buffer_size, ui8 *data)
static void mel_emit_bit (mel_struct *melp, int v)
static void mel_encode (mel_struct *melp, bool bit)
static void vlc_init (vlc_struct *vlcp, ui32 buffer_size, ui8 *data)
static void vlc_encode (vlc_struct *vlcp, int cwd, int cwd_len)
static void terminate_mel_vlc (mel_struct *melp, vlc_struct *vlcp)
static void ms_init (ms_struct *msp, ui32 buffer_size, ui8 *data)
static void ms_encode (ms_struct *msp, ui32 cwd, int cwd_len)
static void ms_encode64 (ms_struct *msp, ui64 cwd, int cwd_len)
static void ms_terminate (ms_struct *msp)
void ojph_encode_codeblock32 (ui32 *buf, ui32 missing_msbs, ui32 num_passes, ui32 width, ui32 height, ui32 stride, ui32 *lengths, t1::ojph::mem_elastic_allocator *elastic, t1::ojph::coded_lists *&coded)
void ojph_encode_codeblock64 (ui64 *buf, ui32 missing_msbs, ui32 num_passes, ui32 width, ui32 height, ui32 stride, ui32 *lengths, t1::ojph::mem_elastic_allocator *elastic, t1::ojph::coded_lists *&coded)
void ojph_encode_codeblock_avx2 (ui32 *buf, ui32 missing_msbs, ui32 num_passes, ui32 width, ui32 height, ui32 stride, ui32 *lengths, t1::ojph::mem_elastic_allocator *elastic, t1::ojph::coded_lists *&coded)
void ojph_encode_codeblock_avx512 (ui32 *buf, ui32 missing_msbs, ui32 num_passes, ui32 width, ui32 height, ui32 stride, ui32 *lengths, t1::ojph::mem_elastic_allocator *elastic, t1::ojph::coded_lists *&coded)
bool initialize_block_encoder_tables_avx2 ()
bool initialize_block_encoder_tables_avx512 ()

Variables

ui16 vlc_tbl0 [1024] = { 0 }
 vlc_tbl0 contains decoding information for initial row of quads
ui16 vlc_tbl1 [1024] = { 0 }
 vlc_tbl1 contains decoding information for non-initial row of quads
ui16 uvlc_tbl0 [256+64] = { 0 }
 uvlc_tbl0 contains decoding information for initial row of quads
ui16 uvlc_tbl1 [256] = { 0 }
 uvlc_tbl1 contains decoding information for non-initial row of quads
ui8 uvlc_bias [256+64] = { 0 }
 uvlc_bias contains decoding info. for initial row of quads
static bool vlc_tables_initialized = vlc_init_tables()
 Initializes VLC tables vlc_tbl0 and vlc_tbl1.
static bool uvlc_tables_initialized = uvlc_init_tables()
 Initializes UVLC tables uvlc_tbl0 and uvlc_tbl1.
const int num_uvlc_entries = 75
static uvlc_tbl_struct uvlc_tbl [num_uvlc_entries]

Function Documentation

◆ decode_one_quad32()

template<int N>
v128_t grk::t1::ojph::local::decode_one_quad32 ( const v128_t inf_u_q,
v128_t U_q,
frwd_struct * magsgn,
ui32 p,
v128_t & vn )
inlinestatic

decodes one quad, using 32 bit data

Template Parameters
N0 for the first quad and 1 for the second quad in an octet
Parameters
inf_u_qdecoded VLC code, with interleaved u values
U_qU values
magsgnstructure for forward data buffer
pbitplane at which we are decoding
vnused for handling E values (stores v_n values)
Returns
v128_t decoded quad

References frwd_advance(), frwd_fetch(), OJPH_REPEAT4, OJPH_REPEAT8, and grk::shift.

Referenced by ojph_decode_codeblock_wasm().

◆ decode_two_quad16()

v128_t grk::t1::ojph::local::decode_two_quad16 ( const v128_t inf_u_q,
v128_t U_q,
frwd_struct * magsgn,
ui32 p,
v128_t & vn )
inlinestatic

decodes twos consecutive quads (one octet), using 16 bit data

Parameters
inf_u_qdecoded VLC code, with interleaved u values
U_qU values
magsgnstructure for forward data buffer
pbitplane at which we are decoding
vnused for handling E values (stores v_n values)
Returns
v128_t decoded quad

References frwd_advance(), frwd_fetch(), OJPH_REPEAT8, and grk::shift.

Referenced by ojph_decode_codeblock_wasm().

◆ frwd_advance() [1/3]

void grk::t1::ojph::local::frwd_advance ( frwd_struct * msp,
ui32 num_bits )
inlinestatic

Consume num_bits bits from the bitstream of frwd_struct.

Parameters
[in]mspis a pointer to frwd_struct
[in]num_bitsis the number of bit to consume

References grk::t1::ojph::local::frwd_struct::bits, and grk::t1::ojph::local::frwd_struct::tmp.

◆ frwd_advance() [2/3]

void grk::t1::ojph::local::frwd_advance ( frwd_struct32 * msp,
ui32 num_bits )
inlinestatic

Consume num_bits bits from the bitstream of frwd_struct32.

Parameters
[in]mspis a pointer to frwd_struct32
[in]num_bitsis the number of bit to consume

References grk::t1::ojph::local::frwd_struct32::bits, and grk::t1::ojph::local::frwd_struct32::tmp.

Referenced by decode_one_quad32(), decode_two_quad16(), ojph_decode_codeblock32(), ojph_decode_codeblock64(), and ojph_decode_codeblock_wasm().

◆ frwd_advance() [3/3]

void grk::t1::ojph::local::frwd_advance ( frwd_struct64 * msp,
ui32 num_bits )
inlinestatic

Consume num_bits bits from the bitstream of frwd_struct64.

Parameters
[in]mspis a pointer to frwd_struct64
[in]num_bitsis the number of bit to consume

References grk::t1::ojph::local::frwd_struct64::bits, and grk::t1::ojph::local::frwd_struct64::tmp.

◆ frwd_fetch() [1/3]

template<int X>
v128_t grk::t1::ojph::local::frwd_fetch ( frwd_struct * msp)
inlinestatic

Fetches 32 bits from the frwd_struct bitstream.

Template Parameters
Xis the value fed in when the bitstream is exhausted. See frwd_read regarding the template
Parameters
[in]mspis a pointer to frwd_struct

References grk::t1::ojph::local::frwd_struct::bits, frwd_read(), and grk::t1::ojph::local::frwd_struct::tmp.

◆ frwd_fetch() [2/3]

template<int X>
ui32 grk::t1::ojph::local::frwd_fetch ( frwd_struct32 * msp)
inlinestatic

Fetches 32 bits from the frwd_struct32 bitstream.

Template Parameters
Xis the value fed in when the bitstream is exhausted. See frwd_read regarding the template
Parameters
[in]mspis a pointer to frwd_struct32

References grk::t1::ojph::local::frwd_struct32::bits, frwd_read(), and grk::t1::ojph::local::frwd_struct32::tmp.

Referenced by decode_one_quad32(), decode_two_quad16(), ojph_decode_codeblock32(), ojph_decode_codeblock64(), and ojph_decode_codeblock_wasm().

◆ frwd_fetch() [3/3]

template<int X>
ui32 grk::t1::ojph::local::frwd_fetch ( frwd_struct64 * msp)
inlinestatic

Fetches 32 bits from the frwd_struct64 bitstream.

Template Parameters
Xis the value fed in when the bitstream is exhausted. See frwd_read regarding the template
Parameters
[in]mspis a pointer to frwd_struct64

References grk::t1::ojph::local::frwd_struct64::bits, frwd_read(), and grk::t1::ojph::local::frwd_struct64::tmp.

◆ frwd_fetch64()

template<ui8 X>
ui64 grk::t1::ojph::local::frwd_fetch64 ( frwd_struct64 * msp)
inlinestatic

Fetches up to 64 bits from the frwd_struct64 bitstream.

Template Parameters
Xis the value fed in when the bitstream is exhausted. See frwd_read regarding the template
Parameters
[in]mspis a pointer to frwd_struct64

References grk::t1::ojph::local::frwd_struct64::bits, frwd_read8(), and grk::t1::ojph::local::frwd_struct64::tmp.

Referenced by ojph_decode_codeblock64().

◆ frwd_init() [1/3]

template<int X>
void grk::t1::ojph::local::frwd_init ( frwd_struct * msp,
const ui8 * data,
int size )
inlinestatic

Initialize frwd_struct struct and reads some bytes.

Template Parameters
Xis the value fed in when the bitstream is exhausted. See frwd_read regarding the template
Parameters
[in]mspis a pointer to frwd_struct
[in]datais a pointer to the start of data
[in]sizeis the number of byte in the bitstream

References grk::t1::ojph::local::frwd_struct::bits, grk::t1::ojph::local::frwd_struct::data, frwd_read(), grk::t1::ojph::local::frwd_struct::size, grk::t1::ojph::local::frwd_struct::tmp, and grk::t1::ojph::local::frwd_struct::unstuff.

◆ frwd_init() [2/3]

template<int X>
void grk::t1::ojph::local::frwd_init ( frwd_struct32 * msp,
const ui8 * data,
int size )
inlinestatic

Initialize frwd_struct32 struct and reads some bytes.

Template Parameters
Xis the value fed in when the bitstream is exhausted. See frwd_read regarding the template
Parameters
[in]mspis a pointer to frwd_struct32
[in]datais a pointer to the start of data
[in]sizeis the number of byte in the bitstream

References grk::t1::ojph::local::frwd_struct32::bits, grk::t1::ojph::local::frwd_struct32::data, frwd_read(), grk::t1::ojph::local::frwd_struct32::size, grk::t1::ojph::local::frwd_struct32::tmp, and grk::t1::ojph::local::frwd_struct32::unstuff.

Referenced by ojph_decode_codeblock32(), ojph_decode_codeblock64(), and ojph_decode_codeblock_wasm().

◆ frwd_init() [3/3]

template<int X>
void grk::t1::ojph::local::frwd_init ( frwd_struct64 * msp,
const ui8 * data,
int size )
inlinestatic

Initialize frwd_struct64 struct and reads some bytes.

Template Parameters
Xis the value fed in when the bitstream is exhausted. See frwd_read regarding the template
Parameters
[in]mspis a pointer to frwd_struct64
[in]datais a pointer to the start of data
[in]sizeis the number of byte in the bitstream

References grk::t1::ojph::local::frwd_struct64::bits, grk::t1::ojph::local::frwd_struct64::data, frwd_read(), grk::t1::ojph::local::frwd_struct64::size, grk::t1::ojph::local::frwd_struct64::tmp, and grk::t1::ojph::local::frwd_struct64::unstuff.

◆ frwd_init8()

template<ui8 X>
void grk::t1::ojph::local::frwd_init8 ( frwd_struct64 * msp,
const ui8 * data,
int size )
inlinestatic

Initialize frwd_struct64 struct and reads some bytes.

Template Parameters
Xis the value fed in when the bitstream is exhausted. See frwd_read regarding the template
Parameters
[in]mspis a pointer to frwd_struct64
[in]datais a pointer to the start of data
[in]sizeis the number of byte in the bitstream

References grk::t1::ojph::local::frwd_struct64::bits, grk::t1::ojph::local::frwd_struct64::data, frwd_read8(), grk::t1::ojph::local::frwd_struct64::size, grk::t1::ojph::local::frwd_struct64::tmp, and grk::t1::ojph::local::frwd_struct64::unstuff.

Referenced by ojph_decode_codeblock64().

◆ frwd_read() [1/3]

template<int X>
void grk::t1::ojph::local::frwd_read ( frwd_struct * msp)
inlinestatic

Read and unstuffs 16 bytes from forward-growing bitstream.

A template is used to accommodate a different requirement for MagSgn and SPP bitstreams; in particular, when MagSgn bitstream is consumed, 0xFF's are fed, while when SPP is exhausted 0's are fed in. X controls this value.

Unstuffing prevent sequences that are more than 0xFF7F from appearing in the conpressed sequence. So whenever a value of 0xFF is coded, the MSB of the next byte is set 0 and must be ignored during decoding.

Reading can go beyond the end of buffer by up to 16 bytes.

Template Parameters
Xis the value fed in when the bitstream is exhausted
Parameters
[in]mspis a pointer to frwd_struct structure

References grk::t1::ojph::local::frwd_struct::bits, grk::t1::ojph::count_leading_zeros(), grk::t1::ojph::local::frwd_struct::data, OJPH_REPEAT16, grk::t1::ojph::local::frwd_struct::size, grk::t1::ojph::local::frwd_struct::tmp, and grk::t1::ojph::local::frwd_struct::unstuff.

◆ frwd_read() [2/3]

template<int X>
void grk::t1::ojph::local::frwd_read ( frwd_struct32 * msp)
inlinestatic

Read and unstuffs 32 bits from forward-growing bitstream.

A template is used to accommodate a different requirement for MagSgn and SPP bitstreams; in particular, when MagSgn bitstream is consumed, 0xFF's are fed, while when SPP is exhausted 0's are fed in. X controls this value.

Unstuffing prevent sequences that are more than 0xFF7F from appearing in the conpressed sequence. So whenever a value of 0xFF is coded, the MSB of the next byte is set 0 and must be ignored during decoding.

Reading can go beyond the end of buffer by up to 3 bytes.

Template Parameters
Xis the value fed in when the bitstream is exhausted
Parameters
[in]mspis a pointer to frwd_struct32 structure

References grk::t1::ojph::local::frwd_struct32::bits, grk::t1::ojph::local::frwd_struct32::data, grk::t1::ojph::local::frwd_struct32::size, grk::t1::ojph::local::frwd_struct32::tmp, and grk::t1::ojph::local::frwd_struct32::unstuff.

Referenced by frwd_fetch(), frwd_fetch(), frwd_fetch(), frwd_init(), frwd_init(), and frwd_init().

◆ frwd_read() [3/3]

template<int X>
void grk::t1::ojph::local::frwd_read ( frwd_struct64 * msp)
inlinestatic

Read and unstuffs 32 bits from forward-growing bitstream.

A template is used to accommodate a different requirement for MagSgn and SPP bitstreams; in particular, when MagSgn bitstream is consumed, 0xFF's are fed, while when SPP is exhausted 0's are fed in. X controls this value.

Unstuffing prevent sequences that are more than 0xFF7F from appearing in the conpressed sequence. So whenever a value of 0xFF is coded, the MSB of the next byte is set 0 and must be ignored during decoding.

Reading can go beyond the end of buffer by up to 3 bytes.

Template Parameters
Xis the value fed in when the bitstream is exhausted
Parameters
[in]mspis a pointer to frwd_struct64 structure

References grk::t1::ojph::local::frwd_struct64::bits, grk::t1::ojph::local::frwd_struct64::data, grk::t1::ojph::local::frwd_struct64::size, grk::t1::ojph::local::frwd_struct64::tmp, and grk::t1::ojph::local::frwd_struct64::unstuff.

◆ frwd_read8()

template<ui8 X>
void grk::t1::ojph::local::frwd_read8 ( frwd_struct64 * msp)
inlinestatic

Read and unstuffs 8 bits from forward-growing bitstream.

A template is used to accommodate a different requirement for MagSgn and SPP bitstreams; in particular, when MagSgn bitstream is consumed, 0xFF's are fed, while when SPP is exhausted 0's are fed in. X controls this value.

Unstuffing prevent sequences that are more than 0xFF7F from appearing in the conpressed sequence. So whenever a value of 0xFF is coded, the MSB of the next byte is set 0 and must be ignored during decoding.

Template Parameters
Xis the value fed in when the bitstream is exhausted
Parameters
[in]mspis a pointer to frwd_struct64 structure

References grk::t1::ojph::local::frwd_struct64::bits, grk::t1::ojph::local::frwd_struct64::data, grk::t1::ojph::local::frwd_struct64::size, grk::t1::ojph::local::frwd_struct64::tmp, and grk::t1::ojph::local::frwd_struct64::unstuff.

Referenced by frwd_fetch64(), and frwd_init8().

◆ initialize_block_encoder_tables()

bool grk::t1::ojph::local::initialize_block_encoder_tables ( )

◆ initialize_block_encoder_tables_avx2()

bool grk::t1::ojph::local::initialize_block_encoder_tables_avx2 ( )

Referenced by dispatch_encoder().

◆ initialize_block_encoder_tables_avx512()

bool grk::t1::ojph::local::initialize_block_encoder_tables_avx512 ( )

Referenced by dispatch_encoder().

◆ mel_decode() [1/3]

void grk::t1::ojph::local::mel_decode ( dec_mel_st * melp)
inlinestatic

Decodes unstuffed MEL segment bits stored in tmp to runs.

Runs are stored in "runs" and the number of runs in "num_runs". Each run represents a number of zero events that may or may not terminate in a 1 event. Each run is stored in 7 bits. The LSB is 1 if the run terminates in a 1 event, 0 otherwise. The next 6 bits, for the case terminating with 1, contain the number of consecutive 0 zero events * 2; for the case terminating with 0, they store (number of consecutive 0 zero events - 1) * 2. A total of 6 bits (made up of 1 + 5) should have been enough.

Parameters
[in]melpis a pointer to dec_mel_st structure

References grk::t1::ojph::local::dec_mel_st::bits, grk::t1::ojph::local::dec_mel_st::k, mel_read(), grk::t1::ojph::local::dec_mel_st::num_runs, grk::t1::ojph::local::dec_mel_st::runs, and grk::t1::ojph::local::dec_mel_st::tmp.

Referenced by mel_get_run().

◆ mel_decode() [2/3]

void grk::t1::ojph::local::mel_decode ( dec_mel_st * melp)
inlinestatic

Decodes unstuffed MEL segment bits stored in tmp to runs.

Runs are stored in "runs" and the number of runs in "num_runs". Each run represents a number of zero events that may or may not terminate in a 1 event. Each run is stored in 7 bits. The LSB is 1 if the run terminates in a 1 event, 0 otherwise. The next 6 bits, for the case terminating with 1, contain the number of consecutive 0 zero events * 2; for the case terminating with 0, they store (number of consecutive 0 zero events - 1) * 2. A total of 6 bits (made up of 1 + 5) should have been enough.

Parameters
[in]melpis a pointer to dec_mel_st structure

References mel_read().

◆ mel_decode() [3/3]

void grk::t1::ojph::local::mel_decode ( dec_mel_st * melp)
inlinestatic

Decodes unstuffed MEL segment bits stored in tmp to runs.

Runs are stored in "runs" and the number of runs in "num_runs". Each run represents a number of zero events that may or may not terminate in a 1 event. Each run is stored in 7 bits. The LSB is 1 if the run terminates in a 1 event, 0 otherwise. The next 6 bits, for the case terminating with 1, contain the number of consecutive 0 zero events * 2; for the case terminating with 0, they store (number of consecutive 0 zero events - 1) * 2. A total of 6 bits (made up of 1 + 5) should have been enough.

Parameters
[in]melpis a pointer to dec_mel_st structure

References mel_read().

◆ mel_emit_bit()

◆ mel_encode()

◆ mel_get_run() [1/3]

int grk::t1::ojph::local::mel_get_run ( dec_mel_st * melp)
inlinestatic

Retrieves one run from dec_mel_st; if there are no runs stored MEL segment is decoded.

Parameters
[in]melpis a pointer to dec_mel_st structure

References mel_decode(), grk::t1::ojph::local::dec_mel_st::num_runs, and grk::t1::ojph::local::dec_mel_st::runs.

Referenced by ojph_decode_codeblock32(), ojph_decode_codeblock64(), and ojph_decode_codeblock_wasm().

◆ mel_get_run() [2/3]

int grk::t1::ojph::local::mel_get_run ( dec_mel_st * melp)
inlinestatic

Retrieves one run from dec_mel_st; if there are no runs stored MEL segment is decoded.

Parameters
[in]melpis a pointer to dec_mel_st structure

References mel_decode().

◆ mel_get_run() [3/3]

int grk::t1::ojph::local::mel_get_run ( dec_mel_st * melp)
inlinestatic

Retrieves one run from dec_mel_st; if there are no runs stored MEL segment is decoded.

Parameters
[in]melpis a pointer to dec_mel_st structure

References mel_decode().

◆ mel_init() [1/4]

void grk::t1::ojph::local::mel_init ( dec_mel_st * melp,
ui8 * bbuf,
int lcup,
int scup )
inlinestatic

Initiates a dec_mel_st structure for MEL decoding and reads some bytes in order to get the read address to a multiple of 4.

Parameters
[in]melpis a pointer to dec_mel_st structure
[in]bbufis a pointer to byte buffer
[in]lcupis the length of MagSgn+MEL+VLC segments
[in]scupis the length of MEL+VLC segments

References grk::t1::ojph::local::dec_mel_st::bits, grk::t1::ojph::local::dec_mel_st::data, grk::t1::ojph::local::dec_mel_st::k, grk::t1::ojph::local::dec_mel_st::num_runs, grk::t1::ojph::local::dec_mel_st::runs, grk::t1::ojph::local::dec_mel_st::size, grk::t1::ojph::local::dec_mel_st::tmp, and grk::t1::ojph::local::dec_mel_st::unstuff.

Referenced by ojph_decode_codeblock32(), ojph_decode_codeblock64(), ojph_decode_codeblock_wasm(), ojph_encode_codeblock32(), and ojph_encode_codeblock64().

◆ mel_init() [2/4]

void grk::t1::ojph::local::mel_init ( dec_mel_st * melp,
ui8 * bbuf,
int lcup,
int scup )
inlinestatic

Initiates a dec_mel_st structure for MEL decoding and reads some bytes in order to get the read address to a multiple of 4.

Parameters
[in]melpis a pointer to dec_mel_st structure
[in]bbufis a pointer to byte buffer
[in]lcupis the length of MagSgn+MEL+VLC segments
[in]scupis the length of MEL+VLC segments

◆ mel_init() [3/4]

void grk::t1::ojph::local::mel_init ( dec_mel_st * melp,
ui8 * bbuf,
int lcup,
int scup )
inlinestatic

Initiates a dec_mel_st structure for MEL decoding and reads some bytes in order to get the read address to a multiple of 4.

Parameters
[in]melpis a pointer to dec_mel_st structure
[in]bbufis a pointer to byte buffer
[in]lcupis the length of MagSgn+MEL+VLC segments
[in]scupis the length of MEL+VLC segments

◆ mel_init() [4/4]

◆ mel_read() [1/3]

void grk::t1::ojph::local::mel_read ( dec_mel_st * melp)
inlinestatic

Reads and unstuffs the MEL bitstream.

This design needs more bytes in the codeblock buffer than the length of the cleanup pass by up to 2 bytes.

Unstuffing removes the MSB of the byte following a byte whose value is 0xFF; this prevents sequences larger than 0xFF7F in value from appearing the bitstream.

Parameters
[in]melpis a pointer to dec_mel_st structure

References grk::t1::ojph::local::dec_mel_st::bits, grk::t1::ojph::local::dec_mel_st::data, grk::t1::ojph::local::dec_mel_st::size, grk::t1::ojph::local::dec_mel_st::tmp, and grk::t1::ojph::local::dec_mel_st::unstuff.

Referenced by mel_decode().

◆ mel_read() [2/3]

void grk::t1::ojph::local::mel_read ( dec_mel_st * melp)
inlinestatic

Reads and unstuffs the MEL bitstream.

This design needs more bytes in the codeblock buffer than the length of the cleanup pass by up to 2 bytes.

Unstuffing removes the MSB of the byte following a byte whose value is 0xFF; this prevents sequences larger than 0xFF7F in value from appearing the bitstream.

Parameters
[in]melpis a pointer to dec_mel_st structure

◆ mel_read() [3/3]

void grk::t1::ojph::local::mel_read ( dec_mel_st * melp)
inlinestatic

Reads and unstuffs the MEL bitstream.

This design needs more bytes in the codeblock buffer than the length of the cleanup pass by up to 2 bytes.

Unstuffing removes the MSB of the byte following a byte whose value is 0xFF; this prevents sequences larger than 0xFF7F in value from appearing the bitstream.

Parameters
[in]melpis a pointer to dec_mel_st structure

◆ ms_encode()

◆ ms_encode64()

◆ ms_init()

◆ ms_terminate()

◆ ojph_decode_codeblock32()

bool grk::t1::ojph::local::ojph_decode_codeblock32 ( ui8 * coded_data,
ui32 * decoded_data,
ui32 missing_msbs,
ui32 num_passes,
ui32 lengths1,
ui32 lengths2,
ui32 width,
ui32 height,
ui32 stride,
bool stripe_causal )

Decodes one codeblock, processing the cleanup, siginificance propagation, and magnitude refinement pass.

Parameters
[in]coded_datais a pointer to bitstream
[in]decoded_datais a pointer to decoded codeblock data buf.
[in]missing_msbsis the number of missing MSBs
[in]num_passesis the number of passes: 1 if CUP only, 2 for CUP+SPP, and 3 for CUP+SPP+MRP
[in]lengths1is the length of cleanup pass
[in]lengths2is the length of refinement passes (either SPP only or SPP+MRP)
[in]widthis the decoded codeblock width
[in]heightis the decoded codeblock height
[in]strideis the decoded codeblock buffer stride
[in]stripe_causalis true for stripe causal mode

References grk::t1::ojph::count_leading_zeros(), frwd_advance(), frwd_fetch(), frwd_init(), mel_get_run(), mel_init(), ojph_max, OJPH_WARN, grk::t1::ojph::population_count(), rev_advance(), rev_advance_mrp(), rev_fetch(), rev_fetch_mrp(), rev_init(), rev_init_mrp(), uvlc_tbl0, uvlc_tbl1, vlc_tbl0, and vlc_tbl1.

Referenced by dispatch_decoder().

◆ ojph_decode_codeblock64()

bool grk::t1::ojph::local::ojph_decode_codeblock64 ( ui8 * coded_data,
ui64 * decoded_data,
ui32 missing_msbs,
ui32 num_passes,
ui32 lengths1,
ui32 lengths2,
ui32 width,
ui32 height,
ui32 stride,
bool stripe_causal )

Decodes one codeblock, processing the cleanup, siginificance propagation, and magnitude refinement pass.

Parameters
[in]coded_datais a pointer to bitstream
[in]decoded_datais a pointer to decoded codeblock data buf.
[in]missing_msbsis the number of missing MSBs
[in]num_passesis the number of passes: 1 if CUP only, 2 for CUP+SPP, and 3 for CUP+SPP+MRP
[in]lengths1is the length of cleanup pass
[in]lengths2is the length of refinement passes (either SPP only or SPP+MRP)
[in]widthis the decoded codeblock width
[in]heightis the decoded codeblock height
[in]strideis the decoded codeblock buffer stride
[in]stripe_causalis true for stripe causal mode

References grk::t1::ojph::count_leading_zeros(), frwd_advance(), frwd_fetch(), frwd_fetch64(), frwd_init(), frwd_init8(), mel_get_run(), mel_init(), ojph_max, OJPH_WARN, grk::t1::ojph::population_count(), rev_advance64(), rev_advance_mrp(), rev_fetch64(), rev_fetch_mrp(), rev_init8(), rev_init_mrp(), uvlc_bias, uvlc_tbl0, uvlc_tbl1, vlc_tbl0, and vlc_tbl1.

◆ ojph_decode_codeblock_avx2()

bool grk::t1::ojph::local::ojph_decode_codeblock_avx2 ( ui8 * coded_data,
ui32 * decoded_data,
ui32 missing_msbs,
ui32 num_passes,
ui32 lengths1,
ui32 lengths2,
ui32 width,
ui32 height,
ui32 stride,
bool stripe_causal )

Referenced by dispatch_decoder().

◆ ojph_decode_codeblock_ssse3()

bool grk::t1::ojph::local::ojph_decode_codeblock_ssse3 ( ui8 * coded_data,
ui32 * decoded_data,
ui32 missing_msbs,
ui32 num_passes,
ui32 lengths1,
ui32 lengths2,
ui32 width,
ui32 height,
ui32 stride,
bool stripe_causal )

Referenced by dispatch_decoder().

◆ ojph_decode_codeblock_wasm()

bool grk::t1::ojph::local::ojph_decode_codeblock_wasm ( ui8 * coded_data,
ui32 * decoded_data,
ui32 missing_msbs,
ui32 num_passes,
ui32 lengths1,
ui32 lengths2,
ui32 width,
ui32 height,
ui32 stride,
bool stripe_causal )

Decodes one codeblock, processing the cleanup, siginificance propagation, and magnitude refinement pass.

Parameters
[in]coded_datais a pointer to bitstream
[in]decoded_datais a pointer to decoded codeblock data buf.
[in]missing_msbsis the number of missing MSBs
[in]num_passesis the number of passes: 1 if CUP only, 2 for CUP+SPP, and 3 for CUP+SPP+MRP
[in]lengths1is the length of cleanup pass
[in]lengths2is the length of refinement passes (either SPP only or SPP+MRP)
[in]widthis the decoded codeblock width
[in]heightis the decoded codeblock height
[in]strideis the decoded codeblock buffer stride
[in]stripe_causalis true for stripe causal mode

References decode_one_quad32(), decode_two_quad16(), frwd_advance(), frwd_fetch(), frwd_init(), mel_get_run(), mel_init(), ojph_max, OJPH_REPEAT16, OJPH_REPEAT2, OJPH_REPEAT4, OJPH_REPEAT8, OJPH_WARN, rev_advance(), rev_advance_mrp(), rev_fetch(), rev_fetch_mrp(), rev_init(), rev_init_mrp(), uvlc_tbl0, uvlc_tbl1, vlc_tbl0, and vlc_tbl1.

◆ ojph_encode_codeblock32()

◆ ojph_encode_codeblock64()

◆ ojph_encode_codeblock_avx2()

void grk::t1::ojph::local::ojph_encode_codeblock_avx2 ( ui32 * buf,
ui32 missing_msbs,
ui32 num_passes,
ui32 width,
ui32 height,
ui32 stride,
ui32 * lengths,
t1::ojph::mem_elastic_allocator * elastic,
t1::ojph::coded_lists *& coded )

Referenced by dispatch_encoder().

◆ ojph_encode_codeblock_avx512()

void grk::t1::ojph::local::ojph_encode_codeblock_avx512 ( ui32 * buf,
ui32 missing_msbs,
ui32 num_passes,
ui32 width,
ui32 height,
ui32 stride,
ui32 * lengths,
t1::ojph::mem_elastic_allocator * elastic,
t1::ojph::coded_lists *& coded )

Referenced by dispatch_encoder().

◆ rev_advance() [1/2]

ui32 grk::t1::ojph::local::rev_advance ( rev_struct * vlcp,
ui32 num_bits )
inlinestatic

Consumes num_bits from a rev_struct structure.

Parameters
[in]vlcpis a pointer to rev_struct structure
[in]num_bitsis the number of bits to be removed

References grk::t1::ojph::local::rev_struct::bits, and grk::t1::ojph::local::rev_struct::tmp.

Referenced by ojph_decode_codeblock32(), and ojph_decode_codeblock_wasm().

◆ rev_advance() [2/2]

ui32 grk::t1::ojph::local::rev_advance ( rev_struct * vlcp,
ui32 num_bits )
inlinestatic

Consumes num_bits from a rev_struct structure.

Parameters
[in]vlcpis a pointer to rev_struct structure
[in]num_bitsis the number of bits to be removed

◆ rev_advance64()

ui64 grk::t1::ojph::local::rev_advance64 ( rev_struct * vlcp,
ui32 num_bits )
inlinestatic

Consumes num_bits from a rev_struct structure.

Parameters
[in]vlcpis a pointer to rev_struct structure
[in]num_bitsis the number of bits to be removed

Referenced by ojph_decode_codeblock64().

◆ rev_advance_mrp() [1/2]

ui32 grk::t1::ojph::local::rev_advance_mrp ( rev_struct * mrp,
ui32 num_bits )
inlinestatic

Consumes num_bits from a rev_struct structure.

Parameters
[in]mrpis a pointer to rev_struct structure
[in]num_bitsis the number of bits to be removed

References grk::t1::ojph::local::rev_struct::bits, and grk::t1::ojph::local::rev_struct::tmp.

Referenced by ojph_decode_codeblock32(), ojph_decode_codeblock64(), and ojph_decode_codeblock_wasm().

◆ rev_advance_mrp() [2/2]

ui32 grk::t1::ojph::local::rev_advance_mrp ( rev_struct * mrp,
ui32 num_bits )
inlinestatic

Consumes num_bits from a rev_struct structure.

Parameters
[in]mrpis a pointer to rev_struct structure
[in]num_bitsis the number of bits to be removed

◆ rev_fetch() [1/2]

ui32 grk::t1::ojph::local::rev_fetch ( rev_struct * vlcp)
inlinestatic

Retrieves 32 bits from the head of a rev_struct structure.

By the end of this call, vlcp->tmp must have no less than 33 bits

Parameters
[in]vlcpis a pointer to rev_struct structure

References grk::t1::ojph::local::rev_struct::bits, rev_read(), and grk::t1::ojph::local::rev_struct::tmp.

Referenced by ojph_decode_codeblock32(), and ojph_decode_codeblock_wasm().

◆ rev_fetch() [2/2]

ui32 grk::t1::ojph::local::rev_fetch ( rev_struct * vlcp)
inlinestatic

Retrieves 32 bits from the head of a rev_struct structure.

By the end of this call, vlcp->tmp must have no less than 33 bits

Parameters
[in]vlcpis a pointer to rev_struct structure

References rev_read().

◆ rev_fetch64()

ui64 grk::t1::ojph::local::rev_fetch64 ( rev_struct * vlcp)
inlinestatic

Fills the temporary variable (vlcp->tmp) by up to 64 bits.

By the end of this call, vlcp->tmp must have no less than 56 bits

Parameters
[in]vlcpis a pointer to rev_struct structure

References rev_read8().

Referenced by ojph_decode_codeblock64().

◆ rev_fetch_mrp() [1/3]

ui32 grk::t1::ojph::local::rev_fetch_mrp ( rev_struct * mrp)
inlinestatic

Retrieves 32 bits from the head of a rev_struct structure.

By the end of this call, mrp->tmp must have no less than 33 bits

Parameters
[in]mrpis a pointer to rev_struct structure

References grk::t1::ojph::local::rev_struct::bits, rev_read_mrp(), and grk::t1::ojph::local::rev_struct::tmp.

Referenced by ojph_decode_codeblock32(), ojph_decode_codeblock64(), and ojph_decode_codeblock_wasm().

◆ rev_fetch_mrp() [2/3]

ui32 grk::t1::ojph::local::rev_fetch_mrp ( rev_struct * mrp)
inlinestatic

Retrieves 32 bits from the head of a rev_struct structure.

By the end of this call, mrp->tmp must have no less than 33 bits

Parameters
[in]mrpis a pointer to rev_struct structure

References rev_read_mrp().

◆ rev_fetch_mrp() [3/3]

ui32 grk::t1::ojph::local::rev_fetch_mrp ( rev_struct * mrp)
inlinestatic

Retrieves 32 bits from the head of a rev_struct structure.

By the end of this call, mrp->tmp must have no less than 33 bits

Parameters
[in]mrpis a pointer to rev_struct structure

References rev_read_mrp().

◆ rev_init() [1/2]

void grk::t1::ojph::local::rev_init ( rev_struct * vlcp,
ui8 * data,
int lcup,
int scup )
inlinestatic

Initiates the rev_struct structure and reads a few bytes to move the read address to multiple of 4.

There is another similar rev_init_mrp subroutine. The difference is that this one, rev_init, discards the first 12 bits (they have the sum of the lengths of VLC and MEL segments), and first unstuff depends on first 4 bits.

Parameters
[in]vlcpis a pointer to rev_struct structure
[in]datais a pointer to byte at the start of the cleanup pass
[in]lcupis the length of MagSgn+MEL+VLC segments
[in]scupis the length of MEL+VLC segments

References grk::t1::ojph::local::rev_struct::bits, grk::t1::ojph::local::rev_struct::data, rev_read(), grk::t1::ojph::local::rev_struct::size, grk::t1::ojph::local::rev_struct::tmp, and grk::t1::ojph::local::rev_struct::unstuff.

Referenced by ojph_decode_codeblock32(), and ojph_decode_codeblock_wasm().

◆ rev_init() [2/2]

void grk::t1::ojph::local::rev_init ( rev_struct * vlcp,
ui8 * data,
int lcup,
int scup )
inlinestatic

Initiates the rev_struct structure and reads a few bytes to move the read address to multiple of 4.

There is another similar rev_init_mrp subroutine. The difference is that this one, rev_init, discards the first 12 bits (they have the sum of the lengths of VLC and MEL segments), and first unstuff depends on first 4 bits.

Parameters
[in]vlcpis a pointer to rev_struct structure
[in]datais a pointer to byte at the start of the cleanup pass
[in]lcupis the length of MagSgn+MEL+VLC segments
[in]scupis the length of MEL+VLC segments

References rev_read().

◆ rev_init8()

void grk::t1::ojph::local::rev_init8 ( rev_struct * vlcp,
ui8 * data,
int lcup,
int scup )
inlinestatic

Initiates the rev_struct structure and reads the first byte.

This subroutine initializes the VLC decoder. It discards the first 12 bits (they have the sum of the lengths of VLC and MEL segments), and depending on unstuffing, stores 3 or 4 bits in the unstuffed decoded buffer.

Parameters
[in]vlcpis a pointer to rev_struct structure
[in]datais a pointer to byte at the start of the cleanup pass
[in]lcupis the length of MagSgn+MEL+VLC segments
[in]scupis the length of MEL+VLC segments

Referenced by ojph_decode_codeblock64().

◆ rev_init_mrp() [1/3]

void grk::t1::ojph::local::rev_init_mrp ( rev_struct * mrp,
ui8 * data,
int lcup,
int len2 )
inlinestatic

Initialized rev_struct structure for MRP segment, and reads a number of bytes such that the next 32 bits read are from an address that is a multiple of 4.

Note this is designed for an architecture that read size must be compatible with the alignment of the read address

There is another similar subroutine rev_init. This subroutine does NOT skip the first 12 bits, and starts with unstuff set to true.

Parameters
[in]mrpis a pointer to rev_struct structure
[in]datais a pointer to byte at the start of the cleanup pass
[in]lcupis the length of MagSgn+MEL+VLC segments
[in]len2is the length of SPP+MRP segments

References grk::t1::ojph::local::rev_struct::bits, grk::t1::ojph::local::rev_struct::data, rev_read_mrp(), grk::t1::ojph::local::rev_struct::size, grk::t1::ojph::local::rev_struct::tmp, and grk::t1::ojph::local::rev_struct::unstuff.

Referenced by ojph_decode_codeblock32(), ojph_decode_codeblock64(), and ojph_decode_codeblock_wasm().

◆ rev_init_mrp() [2/3]

void grk::t1::ojph::local::rev_init_mrp ( rev_struct * mrp,
ui8 * data,
int lcup,
int len2 )
inlinestatic

Initialized rev_struct structure for MRP segment, and reads a number of bytes such that the next 32 bits read are from an address that is a multiple of 4.

Note this is designed for an architecture that read size must be compatible with the alignment of the read address

There is another similar subroutine rev_init. This subroutine does NOT skip the first 12 bits, and starts with unstuff set to true.

Parameters
[in]mrpis a pointer to rev_struct structure
[in]datais a pointer to byte at the start of the cleanup pass
[in]lcupis the length of MagSgn+MEL+VLC segments
[in]len2is the length of SPP+MRP segments

References rev_read_mrp().

◆ rev_init_mrp() [3/3]

void grk::t1::ojph::local::rev_init_mrp ( rev_struct * mrp,
ui8 * data,
int lcup,
int len2 )
inlinestatic

Initialized rev_struct structure for MRP segment, and reads a number of bytes such that the next 32 bits read are from an address that is a multiple of 4.

Note this is designed for an architecture that read size must be compatible with the alignment of the read address

There is another similar subroutine rev_init. This subroutine does NOT skip the first 12 bits, and starts with unstuff set to true.

Parameters
[in]mrpis a pointer to rev_struct structure
[in]datais a pointer to byte at the start of the cleanup pass
[in]lcupis the length of MagSgn+MEL+VLC segments
[in]len2is the length of SPP+MRP segments

References rev_read_mrp().

◆ rev_read() [1/2]

void grk::t1::ojph::local::rev_read ( rev_struct * vlcp)
inlinestatic

Read and unstuff data from a backwardly-growing segment.

This reader can read up to 8 bytes from before the VLC segment. Care must be taken not read from unreadable memory, causing a segmentation fault.

Note that there is another subroutine rev_read_mrp that is slightly different. The other one fills zeros when the buffer is exhausted. This one basically does not care if the bytes are consumed, because any extra data should not be used in the actual decoding.

Unstuffing is needed to prevent sequences more than 0xFF8F from appearing in the bits stream; since we are reading backward, we keep watch when a value larger than 0x8F appears in the bitstream. If the byte following this is 0x7F, we unstuff this byte (ignore the MSB of that byte, which should be 0).

Parameters
[in]vlcpis a pointer to rev_struct structure

References grk::t1::ojph::local::rev_struct::bits, grk::t1::ojph::local::rev_struct::data, grk::t1::ojph::local::rev_struct::size, grk::t1::ojph::local::rev_struct::tmp, and grk::t1::ojph::local::rev_struct::unstuff.

Referenced by rev_fetch(), and rev_init().

◆ rev_read() [2/2]

void grk::t1::ojph::local::rev_read ( rev_struct * vlcp)
inlinestatic

Read and unstuff data from a backwardly-growing segment.

This reader can read up to 8 bytes from before the VLC segment. Care must be taken not read from unreadable memory, causing a segmentation fault.

Note that there is another subroutine rev_read_mrp that is slightly different. The other one fills zeros when the buffer is exhausted. This one basically does not care if the bytes are consumed, because any extra data should not be used in the actual decoding.

Unstuffing is needed to prevent sequences more than 0xFF8F from appearing in the bits stream; since we are reading backward, we keep watch when a value larger than 0x8F appears in the bitstream. If the byte following this is 0x7F, we unstuff this byte (ignore the MSB of that byte, which should be 0).

Parameters
[in]vlcpis a pointer to rev_struct structure

◆ rev_read8()

void grk::t1::ojph::local::rev_read8 ( rev_struct * vlcp)
inlinestatic

Read and unstuff data from a backwardly-growing segment.

This reader reads 8 bits from the VLC segment. It fills zeros when the buffer is exhausted; we basically do not care about these zeros because we should not need them – any extra data should not be used in the actual decoding. If these bytes are needed, then there is a problem in the bitstream, but we do not flag this error.

Unstuffing is needed to prevent sequences larger than 0xFF8F from appearing in the bits stream; since we are reading backward, we keep watch when a value larger than 0x8F appears in the bitstream. If the byte following this is 0x7F, we unstuff this byte (ignore the MSB of that byte, which should be 0).

Parameters
[in]vlcpis a pointer to rev_struct structure

Referenced by rev_fetch64().

◆ rev_read_mrp() [1/3]

void grk::t1::ojph::local::rev_read_mrp ( rev_struct * mrp)
inlinestatic

Reads and unstuffs from rev_struct.

This is different than rev_read in that this fills in zeros when the the available data is consumed. The other does not care about the values when all data is consumed.

See rev_read for more information about unstuffing

Parameters
[in]mrpis a pointer to rev_struct structure

References grk::t1::ojph::local::rev_struct::bits, grk::t1::ojph::local::rev_struct::data, grk::t1::ojph::local::rev_struct::size, grk::t1::ojph::local::rev_struct::tmp, and grk::t1::ojph::local::rev_struct::unstuff.

Referenced by rev_fetch_mrp(), and rev_init_mrp().

◆ rev_read_mrp() [2/3]

void grk::t1::ojph::local::rev_read_mrp ( rev_struct * mrp)
inlinestatic

Reads and unstuffs from rev_struct.

This is different than rev_read in that this fills in zeros when the the available data is consumed. The other does not care about the values when all data is consumed.

See rev_read for more information about unstuffing

Parameters
[in]mrpis a pointer to rev_struct structure

◆ rev_read_mrp() [3/3]

void grk::t1::ojph::local::rev_read_mrp ( rev_struct * mrp)
inlinestatic

Reads and unstuffs from rev_struct.

This is different than rev_read in that this fills in zeros when the the available data is consumed. The other does not care about the values when all data is consumed.

See rev_read for more information about unstuffing

Parameters
[in]mrpis a pointer to rev_struct structure

◆ terminate_mel_vlc()

◆ uvlc_init_tables()

bool grk::t1::ojph::local::uvlc_init_tables ( )
static

References num_uvlc_entries, and uvlc_tbl.

◆ vlc_encode()

◆ vlc_init()

◆ vlc_init_tables()

bool grk::t1::ojph::local::vlc_init_tables ( )
static

Variable Documentation

◆ num_uvlc_entries

const int grk::t1::ojph::local::num_uvlc_entries = 75

Referenced by uvlc_init_tables().

◆ uvlc_tbl

uvlc_tbl_struct grk::t1::ojph::local::uvlc_tbl[num_uvlc_entries]
static