📄 dst_arith_decoder.h
字号:
} \
else \
{ /* Process LPS_EXCHANGE */ \
if (_A_ < _delta_) \
{ /* MPS is decoded. */ \
*(_csp_) = dst_arith_trans_mps[*(_csp_)]; \
} \
else \
{ /* LPS is decoded. */ \
_sym_ = 1-_sym_; \
*(_csp_) = dst_arith_trans_lps[*(_csp_)]; \
} \
_A_ = _delta_; \
renormd(_A_,_C_,_ct_,_state_); \
(_csp_)[DST_ARITH_MAX_CTXTS] = \
dst_arith_state_to_delta[*(_csp_)]; \
} \
}
/*****************************************************************************/
/* MACRO _dst_get_symbol */
/*****************************************************************************/
#define _dst_get_symbol(__A,__C,__ct,__state,__sym,__csp) \
{ \
std_int __delta; \
\
_addto_symbol_count(1); \
__delta = (__csp)[DST_ARITH_MAX_CTXTS]; \
dst_complete_get_symbol(__A,__C,__ct,__state,__sym,__csp,__delta); \
}
/*****************************************************************************/
/* MACRO _dst_get_symbol_skewed_failed */
/*****************************************************************************/
#define _dst_get_symbol_skewed_failed(__A,__C,__ACthresh,__cum_delta, \
__ct,__state,__sym,__csp) \
{ \
__cum_delta -= (__csp)[DST_ARITH_MAX_CTXTS]; \
__A -= __cum_delta; \
__C -= ((unsigned) __cum_delta) << 16; \
__cum_delta = (__csp)[DST_ARITH_MAX_CTXTS]; \
dst_complete_get_symbol(__A,__C,__ct,__state,__sym,__csp, \
__cum_delta); \
dst_compute_ac_thresh(__A,__C,__ACthresh); \
__cum_delta = 0; \
}
/*****************************************************************************/
/* MACRO _dst_get_symbol_skewed */
/*****************************************************************************/
#define _dst_get_symbol_skewed(__A,__C,__ACthresh,__cum_delta, \
__ct,__state,__sym,__csp) \
{ \
_addto_symbol_count(1); \
__cum_delta += (__csp)[DST_ARITH_MAX_CTXTS]; \
if (__ACthresh >= __cum_delta) \
{ /* Fast path for skewed statistics with MPS = 0. */ \
__sym = 0; \
} \
else \
_dst_get_symbol_skewed_failed(__A,__C,__ACthresh,__cum_delta, \
__ct,__state,__sym,__csp); \
}
/*****************************************************************************/
/* MACRO dst_get_symbol_skewed */
/* dst_get_symbol */
/* dst_get_symbol_skewed_failed */
/*****************************************************************************/
#ifdef DST_LOG_SYMBOLS
# define dst_get_symbol(A_,C_,ct_,state_,sym_,csp_) \
{ \
_dst_get_symbol(A_,C_,ct_,state_,sym_,csp_); \
dst_arith_coder__check_logged_symbol(state_,csp_,sym_); \
}
# define dst_get_symbol_skewed(A_,C_,ACthresh_,cum_delta_, \
ct_,state_,sym_,csp_) \
{ \
_dst_get_symbol_skewed(A_,C_,ACthresh_,cum_delta_, \
ct_,state_,sym_,csp_); \
dst_arith_coder__check_logged_symbol(state_,csp_,sym_); \
}
# define dst_get_symbol_skewed_failed(A_,C_,ACthresh_,cum_delta_, \
ct_,state_,sym_,csp_) \
{ \
_dst_get_symbol_skewed_failed(A_,C_,ACthresh_,cum_delta_, \
ct_,state_,sym_,csp_); \
dst_arith_coder__check_logged_symbol(state_,csp_,sym_); \
}
#else
# define dst_get_symbol_skewed_failed _dst_get_symbol_skewed_failed
# define dst_get_symbol_skewed _dst_get_symbol_skewed
# define dst_get_symbol _dst_get_symbol
#endif /* DST_LOG_SYMBOLS */
/*****************************************************************************/
/* MACRO dst_get_raw_bit */
/*****************************************************************************/
#ifdef DST_LOG_SYMBOLS
#define dst_get_raw_bit(__lsb,__word,__symbol,__state) \
{ \
_dst_get_raw_bit(__lsb,__word,__symbol,__state); \
dst_arith_coder__check_logged_symbol(__state,0,__symbol); \
}
#else
# define dst_get_raw_bit _dst_get_raw_bit
#endif
/*****************************************************************************/
/* MACRO _dst_get_raw_bit */
/*****************************************************************************/
#define _dst_get_raw_bit(_lsb,_word,_symbol,_state) \
{ \
assert(!(_state)->mqd.active); \
if ((_lsb & 7) == 0) \
{ /* Arrived at byte boundary. Might have bit-stuffing */ \
int _have_ff = (((_word >> _lsb) & 0x00FF) == 0x00FF); \
if (_lsb == 0) \
{ \
_word = dst_arith_coder__input_word(_state); \
_lsb = 32; \
} \
_lsb -= _have_ff; \
} \
_lsb--; \
_symbol = (_word >> _lsb) & 1; \
}
/* ========================================================================= */
/* ------------------------- External Functions ---------------------------- */
/* ========================================================================= */
extern void
dst_arith_coder__initialize(dst_arith_state_ptr state, int num_contexts,
dst_context_state_ptr contexts,
dst_heap_unit_ptr heap, int total_bytes,
int check_error_resilient_termination);
/* After this call, raw binary digits may be retrieved, but arithmetic
codeword segment decoding may not begin until after the first call
to `dst_arith_coder__activate'. Note that the context models are
not initialized until a subsequent call to
`dst_arith_coder__model_init'. The `heap' pointer identifies the
base of the code stream, while `total_bytes' identifies the total
number of valid bytes in the code stream.
If `check_error_resilient_termination' is true (non-zero) then
when the `dst_arith_coder__deactivate' function is called at each
termination point, it will check for consistency with a predictable
termination policy, assumed to have been used by the encoder. */
void
dst_arith_coder__model_init(dst_arith_state_ptr state,
dst_context_state_ptr initial_states);
extern std_int
dst_arith_coder__input_word(dst_arith_state_ptr state);
extern unsigned long
dst_arith_coder__bytein(unsigned long creg, int *ct,
dst_arith_state_ptr state);
/* Internal function for MQ coder, usually invoked through macros.
Returns the value of the `creg' variable. */
extern void
dst_arith_coder__activate(dst_arith_state_ptr state);
/* Activates the embedded arithmetic coding engine to decode symbols. Note
that between initialization or a previous call to
`dst_arith_coder__deactivate' and the activation call, any number of
`raw' binary digits may be retrieved from the bit-stream. The activate
call first byte aligns the portion of the bit-stream which has been
retrieved so far in preparation for MQ codeword generation. */
extern void
dst_arith_coder__set_segment_size(dst_arith_state_ptr state,
int terminating_byte_count);
/* This function may be called at any time while the MQ coder is inactive
and the code stream is byte aligned, i.e. it may be called immediately
after initialization or a call to `dst_arith_coder__deactivate'. It
changes the size of the current segment in the code stream. Attempts
to access data beyond that segment will result in automatic extension
with FF's without consuming data from the next segment. On the other
hand, if some of the current segment is not consumed before starting
the next segment then the unconsumed bytes will not be discarded; they
will be treated as the initial portion of the following segment. This
is necessary, since we often do not know the segment size and so we
install a segment size equal to the length of the entire code stream
until the next point at which the segment size is known.
The `terminating_byte_count' argument provides the total number of
code stream bytes up until the end of the relevant segment. */
extern int
dst_arith_coder__deactivate(dst_arith_state_ptr state);
/* Terminates the current codeword segment. The embedded arithmetic coding
engine is then deactivated so that any further arithmetic coding calls
are illegal until the coder is activated by a new call to
`dst_arith_coder__activate'.
The function may be called even if the arithmetic coder has not
yet been activated, in which case there is nothing to terminate and
the function merely byte aligns the code stream retrieval process.
During error resilient decoding (i.e. when the
`check_error_resilient_termination' flag was raised during initialization)
the function returns an estimate of the number of effective bits of
error resilience information available from the predictable termination
policies employed by the encoder, unless an error is detected in which
case it returns a large negative value. If the error resilient decoding
mode is not in force, the function consistently returns 0. */
extern void
dst_arith_coder__terminate(dst_arith_state_ptr state);
#ifdef DST_LOG_SYMBOLS
extern void
dst_arith_coder__check_logged_symbol(dst_arith_state_ptr state,
dst_context_state_ptr ctxt,
std_int symbol); /* David T mod */
#endif /* DST_LOG_SYMBOLS */
#endif /* DST_ARITH_DECODER_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -