OpenJPEG 2.5.3
mqc_inl.h File Reference

Go to the source code of this file.

Macros

#define opj_mqc_mpsexchange_macro(d, curctx, a)
#define opj_mqc_lpsexchange_macro(d, curctx, a)
#define opj_mqc_bytein_macro(mqc, c, ct)
#define opj_mqc_renormd_macro(mqc, a, c, ct)
#define opj_mqc_decode_macro(d, mqc, curctx, a, c, ct)
#define DOWNLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct)
#define UPLOAD_MQC_VARIABLES(mqc, curctx, a, c, ct)
#define opj_mqc_renormd(mqc)
 Renormalize mqc->a and mqc->c while decoding.
#define opj_mqc_decode(d, mqc)
 Decode a symbol.
#define opj_mqc_renorme_macro(mqc, a_, c_, ct_)
 Renormalize mqc->a and mqc->c while encoding, so that mqc->a stays between 0x8000 and 0x10000.
#define opj_mqc_codemps_macro(mqc, curctx, a, c, ct)
#define opj_mqc_codelps_macro(mqc, curctx, a, c, ct)
#define opj_mqc_encode_macro(mqc, curctx, a, c, ct, d)
#define opj_mqc_bypass_enc_macro(mqc, c, ct, d)

Functions

static INLINE OPJ_UINT32 opj_mqc_raw_decode (opj_mqc_t *mqc)
 Decode a symbol using raw-decoder.
static INLINE void opj_mqc_bytein (opj_mqc_t *const mqc)
 Input a byte.
void opj_mqc_byteout (opj_mqc_t *mqc)
 Output a byte, doing bit-stuffing if necessary.

Macro Definition Documentation

◆ DOWNLOAD_MQC_VARIABLES

#define DOWNLOAD_MQC_VARIABLES ( mqc,
curctx,
a,
c,
ct )
Value:
register const opj_mqc_state_t **curctx = mqc->curctx; \
register OPJ_UINT32 c = mqc->c; \
register OPJ_UINT32 a = mqc->a; \
register OPJ_UINT32 ct = mqc->ct
struct opj_mqc_state opj_mqc_state_t
This struct defines the state of a context.
uint32_t OPJ_UINT32
Definition openjpeg.h:132

Referenced by opj_t1_enc_clnpass(), opj_t1_enc_refpass(), and opj_t1_enc_sigpass().

◆ opj_mqc_bypass_enc_macro

#define opj_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 = (OPJ_BYTE)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
Definition mqc.h:99
unsigned char OPJ_BYTE
Definition openjpeg.h:123

◆ opj_mqc_bytein_macro

#define opj_mqc_bytein_macro ( mqc,
c,
ct )
Value:
{ \
OPJ_UINT32 l_c; \
/* Given opj_mqc_init_dec() we know that at some point we will */ \
/* have a 0xFF 0xFF artificial marker */ \
l_c = *(mqc->bp + 1); \
if (*mqc->bp == 0xff) { \
if (l_c > 0x8f) { \
c += 0xff00; \
ct = 8; \
mqc->end_of_byte_stream_counter ++; \
} else { \
mqc->bp++; \
c += l_c << 9; \
ct = 7; \
} \
} else { \
mqc->bp++; \
c += l_c << 8; \
ct = 8; \
} \
}

Referenced by opj_mqc_bytein().

◆ opj_mqc_codelps_macro

#define opj_mqc_codelps_macro ( mqc,
curctx,
a,
c,
ct )
Value:
{ \
a -= (*curctx)->qeval; \
if (a < (*curctx)->qeval) { \
c += (*curctx)->qeval; \
} else { \
a = (*curctx)->qeval; \
} \
*curctx = (*curctx)->nlps; \
opj_mqc_renorme_macro(mqc, a, c, ct); \
}

Referenced by opj_mqc_codelps().

◆ opj_mqc_codemps_macro

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

Referenced by opj_mqc_codemps().

◆ opj_mqc_decode

#define opj_mqc_decode ( d,
mqc )
Value:
opj_mqc_decode_macro(d, mqc, mqc->curctx, mqc->a, mqc->c, mqc->ct)
#define opj_mqc_decode_macro(d, mqc, curctx, a, c, ct)
Definition mqc_inl.h:138

Decode a symbol.

Parameters
dOPJ_UINT32 value where to store the decoded symbol
mqcMQC handle
Returns
Returns the decoded symbol (0 or 1) in d

Referenced by opj_t1_dec_clnpass_check_segsym().

◆ opj_mqc_decode_macro

#define opj_mqc_decode_macro ( d,
mqc,
curctx,
a,
c,
ct )
Value:
{ \
/* Implements ISO 15444-1 C.3.2 Decoding a decision (DECODE) */ \
/* Note: alternate "J.2 - Decoding an MPS or an LPS in the */ \
/* software-conventions decoder" has been tried, but does not bring any */ \
/* improvement. See https://github.com/uclouvain/openjpeg/issues/921 */ \
a -= (*curctx)->qeval; \
if ((c >> 16) < (*curctx)->qeval) { \
opj_mqc_lpsexchange_macro(d, curctx, a); \
opj_mqc_renormd_macro(mqc, a, c, ct); \
} else { \
c -= (*curctx)->qeval << 16; \
if ((a & 0x8000) == 0) { \
opj_mqc_mpsexchange_macro(d, curctx, a); \
opj_mqc_renormd_macro(mqc, a, c, ct); \
} else { \
d = (*curctx)->mps; \
} \
} \
}

◆ opj_mqc_encode_macro

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

Referenced by opj_t1_enc_clnpass().

◆ opj_mqc_lpsexchange_macro

#define opj_mqc_lpsexchange_macro ( d,
curctx,
a )
Value:
{ \
if (a < (*curctx)->qeval) { \
a = (*curctx)->qeval; \
d = (*curctx)->mps; \
*curctx = (*curctx)->nmps; \
} else { \
a = (*curctx)->qeval; \
d = !((*curctx)->mps); \
*curctx = (*curctx)->nlps; \
} \
}

◆ opj_mqc_mpsexchange_macro

#define opj_mqc_mpsexchange_macro ( d,
curctx,
a )
Value:
{ \
if (a < (*curctx)->qeval) { \
d = !((*curctx)->mps); \
*curctx = (*curctx)->nlps; \
} else { \
d = (*curctx)->mps; \
*curctx = (*curctx)->nmps; \
} \
}

◆ opj_mqc_renormd

#define opj_mqc_renormd ( mqc)
Value:
opj_mqc_renormd_macro(mqc, mqc->a, mqc->c, mqc->ct)
#define opj_mqc_renormd_macro(mqc, a, c, ct)
Definition mqc_inl.h:126

Renormalize mqc->a and mqc->c while decoding.

Parameters
mqcMQC handle

◆ opj_mqc_renormd_macro

#define opj_mqc_renormd_macro ( mqc,
a,
c,
ct )
Value:
{ \
do { \
if (ct == 0) { \
opj_mqc_bytein_macro(mqc, c, ct); \
} \
a <<= 1; \
c <<= 1; \
ct--; \
} while (a < 0x8000); \
}

◆ opj_mqc_renorme_macro

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

Renormalize mqc->a and mqc->c while encoding, so that mqc->a stays between 0x8000 and 0x10000.

Parameters
mqcMQC handle
a_value of mqc->a
c_value of mqc->c_
ct_value of mqc->ct_

Referenced by opj_mqc_renorme().

◆ UPLOAD_MQC_VARIABLES

#define UPLOAD_MQC_VARIABLES ( mqc,
curctx,
a,
c,
ct )
Value:
mqc->curctx = curctx; \
mqc->c = c; \
mqc->a = a; \
mqc->ct = ct;

Referenced by opj_t1_enc_clnpass(), opj_t1_enc_refpass(), and opj_t1_enc_sigpass().

Function Documentation

◆ opj_mqc_bytein()

INLINE void opj_mqc_bytein ( opj_mqc_t *const mqc)
static

Input a byte.

Parameters
mqcMQC handle

References opj_mqc::c, opj_mqc::ct, INLINE, and opj_mqc_bytein_macro.

Referenced by opj_mqc_init_dec().

◆ opj_mqc_byteout()

void opj_mqc_byteout ( opj_mqc_t * mqc)

Output a byte, doing bit-stuffing if necessary.

After a 0xff byte, the next byte must be smaller than 0x90.

Parameters
mqcMQC handle

References opj_mqc::bp, opj_mqc::c, opj_mqc::ct, and opj_mqc::start.

Referenced by opj_mqc_erterm_enc(), and opj_mqc_flush().

◆ opj_mqc_raw_decode()

INLINE OPJ_UINT32 opj_mqc_raw_decode ( opj_mqc_t * mqc)
static

Decode a symbol using raw-decoder.

Cfr p.506 TAUBMAN

Parameters
mqcMQC handle
Returns
Returns the decoded symbol (0 or 1)

References opj_mqc::bp, opj_mqc::c, opj_mqc::ct, and INLINE.

Referenced by opj_t1_dec_refpass_step_raw(), and opj_t1_dec_sigpass_step_raw().