Grok 20.3.2
mqc.h File Reference
#include "mqc_base.h"
#include "mqc_backup.h"
#include "mqc_dec_inl.h"
#include "mqc_enc_inl.h"

Go to the source code of this file.

Classes

struct  grk::t1::mqcoder
 MQ coder. More...

Namespaces

namespace  grk
 ResWindow.
namespace  grk::t1

Macros

#define CODER_SETCURCTX(mqc, ctxno)
#define DEC_PASS_LOCAL_VARIABLES(flagsStride)
#define DEC_PASS_LOCAL_VARIABLES_DIFF(flagsStride)
#define DEC_PASS_HAS_BACKUP_FOR_CURRENT_PASS(coder)
#define DEC_PASS_MQC_BACKUP_LOCAL(coder)
#define DEC_PASS_MQC_RESTORE_LOCAL(coder)
#define DEC_PASS_DO_BACKUP(coder, p)
#define DEC_PASS_BACKUP(coder, p)
#define DEC_PASS_CLN_BACKUP(p)
#define DEC_PASS_RESTORE(coder)
#define DEC_PASS_CLN_RESTORE(coder)
#define DEC_BYTEIN(mqc, c, ct)
#define DEC_RENORM(mqc, a, c, ct)
#define DEC_SYMBOL(d, mqc, curctx, a, c, ct)
#define DEC_SYMBOL_RAW()
#define BYPASS_CT_INIT   0xFF
#define mqc_byteout(mqc)
#define mqc_renorme_macro(mqc, a_, c_, ct_)
#define mqc_codemps_macro(mqc, curctx, a, c, ct)
#define mqc_codelps_macro(mqc, curctx, a, c, ct)
#define mqc_encode_macro(mqc, curctx, a, c, ct, d)
#define mqc_bypass_enc_macro(mqc, c, ct, d)

Variables

const uint32_t grk::t1::A_MIN = 0x8000
const uint8_t grk::t1::B1_POS = 1
const uint8_t grk::t1::B2_POS = 2
const uint8_t grk::t1::B3_POS = 3
const uint8_t grk::t1::B4_POS = 4
const uint8_t grk::t1::B5_POS = 5
const uint8_t grk::t1::B6_POS = 6
const uint8_t grk::t1::B7_POS = 7
const uint8_t grk::t1::B8_POS = 8
const uint8_t grk::t1::B9_POS = 9
const uint8_t grk::t1::B10_POS = 10
const uint8_t grk::t1::B11_POS = 11
const uint8_t grk::t1::B12_POS = 12
const uint8_t grk::t1::red_zone = 6

Macro Definition Documentation

◆ BYPASS_CT_INIT

#define BYPASS_CT_INIT   0xFF

◆ CODER_SETCURCTX

#define CODER_SETCURCTX ( mqc,
ctxno )
Value:
(mqc)->curctx = (mqc)->ctxs + (uint32_t)(ctxno)

Referenced by grk::t1::BlockCoder::checkSegSym(), grk::t1::mqcoder::init_dec(), grk::t1::mqcoder::init_enc(), and grk::t1::mqcoder::segmark_enc().

◆ DEC_BYTEIN

#define DEC_BYTEIN ( mqc,
c,
ct )

◆ DEC_PASS_BACKUP

#define DEC_PASS_BACKUP ( coder,
p )
Value:
if(approaching_red) \
{ \
DEC_PASS_DO_BACKUP(coder, p) \
}

◆ DEC_PASS_CLN_BACKUP

#define DEC_PASS_CLN_BACKUP ( p)
Value:
if(approaching_red) \
{ \
DEC_PASS_DO_BACKUP(coder, p); \
coder.backup_->runlen = runlen; \
coder.backup_->partial = partial; \
}

◆ DEC_PASS_CLN_RESTORE

#define DEC_PASS_CLN_RESTORE ( coder)

◆ DEC_PASS_DO_BACKUP

#define DEC_PASS_DO_BACKUP ( coder,
p )
Value:
decompressBackup(); \
DEC_PASS_MQC_BACKUP_LOCAL(coder); \
auto b = coder.backup_; \
b->position = p; \
b->i = i; \
b->j = j; \
b->k = k; \
b->flagsPtr_ = flagsPtr; \
b->_flags = _flags; \
b->dataPtr_ = dataPtr; \
b->passno_ = passno; \
b->passtype_ = passtype; \
b->numBpsToDecompress_ = (uint8_t)bpno; \
approaching_red = false; \
b->layer_ = (uint16_t)coder.cur_buffer_index;

◆ DEC_PASS_HAS_BACKUP_FOR_CURRENT_PASS

#define DEC_PASS_HAS_BACKUP_FOR_CURRENT_PASS ( coder)
Value:
(coder.backup_->i != BACKUP_DISABLED) && (passno == coder.backup_->passno_)

◆ DEC_PASS_LOCAL_VARIABLES

#define DEC_PASS_LOCAL_VARIABLES ( flagsStride)
Value:
const int32_t one = 1 << bpno; \
const auto mqc = &coder; \
auto dataPtr = uncompressedData_; \
auto flagsPtr = flags_ + flagsStride + 1; \
grk_flag _flags = 0; \
uint16_t i = 0, j = 0, k = 0; \
bool approaching_red; \
(void)approaching_red; \
PUSH_MQC();

◆ DEC_PASS_LOCAL_VARIABLES_DIFF

#define DEC_PASS_LOCAL_VARIABLES_DIFF ( flagsStride)
Value:
const int32_t one = 1 << bpno; \
const auto mqc = &coder; \
auto dataPtr = uncompressedData_; \
auto flagsPtr = flags_ + flagsStride + 1; \
grk_flag _flags = 0; \
uint16_t i = 0, j = 0, k = 0; \
const mqc_state** curctx; \
uint32_t c, a; \
uint8_t ct; \
bool approaching_red = (coder.backup_->i == BACKUP_DISABLED) && \
mqc->bp + red_zone >= mqc->end && \
((coder.cur_buffer_index + 1 >= coder.num_buffers) || \
coder.buffer_lengths[coder.cur_buffer_index + 1] <= red_zone); \
(void)approaching_red;
const uint8_t red_zone
Definition mqc_dec_inl.h:64

◆ DEC_PASS_MQC_BACKUP_LOCAL

#define DEC_PASS_MQC_BACKUP_LOCAL ( coder)
Value:
coder.backup_->a = a; \
coder.backup_->c = c; \
coder.backup_->ct = ct; \
coder.backup_->curctx_index_ = curctx - &coder.ctxs[0]; \
coder.backup_->curctx = &coder.backup_->ctxs[coder.backup_->curctx_index_];

◆ DEC_PASS_MQC_RESTORE_LOCAL

#define DEC_PASS_MQC_RESTORE_LOCAL ( coder)
Value:
a = coder.backup_->a; \
c = coder.backup_->c; \
ct = coder.backup_->ct; \
coder.curctx_index_ = coder.backup_->curctx_index_; \
curctx = &coder.ctxs[coder.curctx_index_]; \
coder.curctx = curctx; \
coder.a = a; \
coder.c = c; \
coder.ct = ct;

◆ DEC_PASS_RESTORE

#define DEC_PASS_RESTORE ( coder)

◆ DEC_RENORM

#define DEC_RENORM ( mqc,
a,
c,
ct )
Value:
{ \
do \
{ \
if(ct == 0) \
{ \
if(mqc->start == mqc->end) \
{ \
c += 0xff00; \
ct = 8; \
mqc->end_of_byte_stream_counter++; \
} \
else \
DEC_BYTEIN(mqc, c, ct); \
} \
a <<= 1; \
c <<= 1; \
ct--; \
} while(a < A_MIN); \
}
const uint32_t A_MIN
Definition mqc_dec_inl.h:20

◆ DEC_SYMBOL

#define DEC_SYMBOL ( d,
mqc,
curctx,
a,
c,
ct )
Value:
do \
{ \
auto ctx = *(curctx); \
a -= ctx->qeval; \
uint32_t qeval_shift = ctx->qeval << 16; \
if(c < qeval_shift) \
{ \
uint32_t mask = (uint32_t)-(a < ctx->qeval); \
a = ctx->qeval; \
d = ctx->mps ^ (~mask & 1); \
*curctx = mask ? ctx->nmps : ctx->nlps; \
DEC_RENORM(mqc, a, c, ct); \
} \
else \
{ \
c -= qeval_shift; \
if(a < A_MIN) \
{ \
uint32_t mask = (uint32_t)-(a < ctx->qeval); \
d = ctx->mps ^ (mask & 1); \
*curctx = mask ? ctx->nlps : ctx->nmps; \
DEC_RENORM(mqc, a, c, ct); \
} \
else \
{ \
d = ctx->mps; \
} \
} \
} while(0)

Referenced by grk::t1::BlockCoder::checkSegSym().

◆ DEC_SYMBOL_RAW

◆ mqc_bypass_enc_macro

#define mqc_bypass_enc_macro ( mqc,
c,
ct,
d )
Value:
{ \
if(ct == BYPASS_CT_INIT) \
ct = 8; \
ct--; \
c = c + ((d) << ct); \
if(ct == 0) \
{ \
*mqc->bp = (uint8_t)c; \
ct = 8; \
/* If the previous byte was 0xff, make sure that the next msb is 0 */ \
if(*mqc->bp == 0xff) \
ct = 7; \
mqc->bp++; \
c = 0; \
} \
}
#define BYPASS_CT_INIT

◆ mqc_byteout

#define mqc_byteout ( mqc)

◆ mqc_codelps_macro

#define mqc_codelps_macro ( mqc,
curctx,
a,
c,
ct )
Value:
do \
{ \
a -= (*curctx)->qeval; \
if(a < (*curctx)->qeval) \
c += (*curctx)->qeval; \
else \
a = (*curctx)->qeval; \
*curctx = (*curctx)->nlps; \
mqc_renorme_macro(mqc, a, c, ct); \
} while(0)

Referenced by grk::t1::mqcoder::segmark_enc().

◆ mqc_codemps_macro

#define mqc_codemps_macro ( mqc,
curctx,
a,
c,
ct )
Value:
do \
{ \
a -= (*curctx)->qeval; \
if((a & 0x8000) == 0) \
{ \
if(a < (*curctx)->qeval) \
a = (*curctx)->qeval; \
else \
c += (*curctx)->qeval; \
*curctx = (*curctx)->nmps; \
mqc_renorme_macro(mqc, a, c, ct); \
} \
else \
{ \
c += (*curctx)->qeval; \
} \
} while(0)

Referenced by grk::t1::mqcoder::segmark_enc().

◆ mqc_encode_macro

#define mqc_encode_macro ( mqc,
curctx,
a,
c,
ct,
d )
Value:
{ \
if((*curctx)->mps == (d)) \
mqc_codemps_macro(mqc, curctx, a, c, ct); \
else \
mqc_codelps_macro(mqc, curctx, a, c, ct); \
}

Referenced by grk::t1::BlockCoder::enc_clnpass().

◆ mqc_renorme_macro

#define mqc_renorme_macro ( mqc,
a_,
c_,
ct_ )
Value:
{ \
do \
{ \
a_ <<= 1; \
c_ <<= 1; \
ct_--; \
if(ct_ == 0) \
{ \
mqc->c = c_; \
mqc_byteout(mqc); \
c_ = mqc->c; \
ct_ = mqc->ct; \
} \
} while((a_ & 0x8000) == 0); \
}