ht_block_encoding.cpp File Reference
`#include <algorithm>`
`#include "coding_units.hpp"`
`#include "ht_block_encoding.hpp"`
`#include "coding_local.hpp"`
`#include "enc_CxtVLC_tables.hpp"`
`#include "utils.hpp"`

## Macros

#define | Q0 0
#define | Q1 1
#define | MAKE_STORAGE()

## Functions

void | print_block (const j2k_codeblock *const block)
static void | make_storage (const j2k_codeblock *const block, const uint16_t qy, const uint16_t qx, const uint16_t QH, const uint16_t QW, uint8_t *const sigma_n, uint32_t *const v_n, int32_t *const E_n, uint8_t *const rho_q)
static void | make_storage_one (const j2k_codeblock *const block, const uint16_t qy, const uint16_t qx, const uint16_t QH, const uint16_t QW, uint8_t *const sigma_n, uint32_t *const v_n, int32_t *const E_n, uint8_t *const rho_q)
int32_t | termMELandVLC (state_VLC_enc &VLC, state_MEL_enc &MEL)
int32_t | htj2k_encode (j2k_codeblock *const block, const uint8_t ROIshift) noexcept

## Variables

auto | encode_UVLC0
auto | encode_UVLC1

## Macro Definition Documentation

## MAKE_STORAGE

#define MAKE_STORAGE | ( |  | ) |

Value:
{ \
const int32_t x[8] = {2 * qx, 2 * qx, 2 * qx + 1, 2 * qx + 1, \
2 * (qx + 1), 2 * (qx + 1), 2 * (qx + 1) + 1, 2 * (qx + 1) + 1}; \
const int32_t y[8] = {2 * qy, 2 * qy + 1, 2 * qy, 2 * qy + 1, 2 * qy, 2 * qy + 1, 2 * qy, 2 * qy + 1}; \
for (int i = 0; i < 4; ++i) \
sigma_n[i] = \
(block->block_states[(y[i] + 1) * (block->size.x + 2) + (x[i] + 1)] >> SHIFT_SIGMA) & 1; \
rho_q[0] = sigma_n[0] + (sigma_n[1] << 1) + (sigma_n[2] << 2) + (sigma_n[3] << 3); \
for (int i = 4; i < 8; ++i) \
sigma_n[i] = \
(block->block_states[(y[i] + 1) * (block->size.x + 2) + (x[i] + 1)] >> SHIFT_SIGMA) & 1; \
rho_q[1] = sigma_n[4] + (sigma_n[5] << 1) + (sigma_n[6] << 2) + (sigma_n[7] << 3); \
for (int i = 0; i < 8; ++i) { \
if ((x[i] >= 0 && x[i] < (block->size.x)) && (y[i] >= 0 && y[i] < (block->size.y))) \
v_n[i] = block->sample_buf[x[i] + y[i] * block->size.x]; \
else \
v_n[i] = 0; \
} \
for (int i = 0; i < 8; ++i) \
E_n[i] = (32 - count_leading_zeros(((v_n[i] >> 1) << 1) + 1)) * sigma_n[i]; \
}
SHIFT_SIGMA
#define SHIFT_SIGMA
Definition coding_local.hpp:31
count_leading_zeros
static uint32_t count_leading_zeros(const uint32_t x)
Definition utils.hpp:88

## Q0

#define Q0 0

## Q1

#define Q1 1

## Function Documentation

## htj2k_encode()

int32_t htj2k_encode | ( | j2k_codeblock *const | block,
|  | const uint8_t | ROIshift
| ) |  |

noexcept

References ceil_int, state_MS_enc::emitMagSgnBits(), state_VLC_enc::emitVLCBits(), enc_CxtVLC_table0, enc_CxtVLC_table1, encode_UVLC0, encode_UVLC1, state_MEL_enc::encodeMEL(), MAKE_STORAGE, make_storage_one(), MAX_Lcup, MAX_Scup, popcount32(), Q0, Q1, round_up, state_MEL_enc::termMEL(), termMELandVLC(), and state_MS_enc::termMS().

Referenced by openhtj2k::T1OpenHTJ2K::compress().

## make_storage()

static void make_storage | ( | const j2k_codeblock *const | block,
|  | const uint16_t | qy,
|  | const uint16_t | qx,
|  | const uint16_t | QH,
|  | const uint16_t | QW,
|  | uint8_t *const | sigma_n,
|  | uint32_t *const | v_n,
|  | int32_t *const | E_n,
|  | uint8_t *const | rho_q
| ) |  |

inline static

References count_leading_zeros(), j2k_codeblock::get_state(), j2k_codeblock::sample_buf, Sigma(), j2k_codeblock::size, element_siz::x, and element_siz::y.

## make_storage_one()

static void make_storage_one | ( | const j2k_codeblock *const | block,
|  | const uint16_t | qy,
|  | const uint16_t | qx,
|  | const uint16_t | QH,
|  | const uint16_t | QW,
|  | uint8_t *const | sigma_n,
|  | uint32_t *const | v_n,
|  | int32_t *const | E_n,
|  | uint8_t *const | rho_q
| ) |  |

inline static

References count_leading_zeros(), j2k_codeblock::get_state(), j2k_codeblock::sample_buf, Sigma(), j2k_codeblock::size, element_siz::x, and element_siz::y.

Referenced by htj2k_encode().

## print_block()

void print_block | ( | const j2k_codeblock *const | block | ) |

References ceil_int, j2k_codeblock::sample_buf, j2k_codeblock::size, element_siz::x, and element_siz::y.

## termMELandVLC()

int32_t termMELandVLC | ( | state_VLC_enc & | VLC,
|  | state_MEL_enc & | MEL
| ) |  |

Referenced by htj2k_encode().

## Variable Documentation

## encode_UVLC0

auto encode_UVLC0

Initial value:
= [](uint16_t &cwd, uint8_t &lw, int32_t u1, int32_t u2 = 0) {
int32_t tmp;
tmp = enc_UVLC_table0[u1 + (u2 << 5)];
lw = (tmp & 0xFF);
cwd = tmp >> 8;
}
enc_UVLC_table0
const uint32_t enc_UVLC_table0[1024]
Definition enc_CxtVLC_tables.hpp:352

Referenced by htj2k_encode().

## encode_UVLC1

auto encode_UVLC1

Initial value:
= [](uint16_t &cwd, uint8_t &lw, int32_t u1, int32_t u2 = 0) {
int32_t tmp;
tmp = enc_UVLC_table1[u1 + (u2 << 5)];
lw = (tmp & 0xFF);
cwd = tmp >> 8;
}
enc_UVLC_table1
const uint32_t enc_UVLC_table1[1024]
Definition enc_CxtVLC_tables.hpp:482

Referenced by htj2k_encode().