📄 ebcot_arith_decoder.h
字号:
/*****************************************************************************/
/* File name: "ebcot_arith_decoder.h" */
/* Author: David Taubman */
/* Copyright 1998, Hewlett-Packard Company */
/* All rights reserved */
/*****************************************************************************/
#ifndef EBCOT_ARITH_DECODER_H
#define EBCOT_ARITH_DECODER_H
#include <ebcot_common.h>
#include "ebcot_decoder.h"
/* ========================================================================= */
/* --------------------------- Utility Macros ------------------------------ */
/* ========================================================================= */
/*****************************************************************************/
/* MACRO input_one_bit */
/*****************************************************************************/
#define input_one_bit(_state_,_A_,_C_,_word_,_avail_) \
/* arith_state_ptr _state_, std_int _A_, std_int _C_, */ \
/* std_int _word_, std_short _avail_ */ \
{ \
_A_ <<= 1; \
_C_ <<= 1; \
_C_ += ((_word_ >> 31) & 1); \
_word_ <<= 1; \
if ((--_avail_) == 0) \
{ _word_ = ebcot_arith_coder__input_word(_state_); _avail_ = 32; } \
}
/* ========================================================================= */
/* ----------------------- Symbol Decoding Macros -------------------------- */
/* ========================================================================= */
/*****************************************************************************/
/* MACRO get_symbol */
/*****************************************************************************/
#ifdef LOG_SYMBOLS
# define get_symbol(__state,__A,__C,__word,__avail,__symbol,__ctxt) \
{ \
_get_symbol(__state,__A,__C,__word,__avail,__symbol,__ctxt); \
ebcot_arith_coder__check_logged_symbol(__state,__ctxt,__symbol); \
}
#else
# define get_symbol _get_symbol
#endif /* LOG_SYMBOLS */
/*****************************************************************************/
/* MACRO _get_symbol */
/*****************************************************************************/
#define _get_symbol(_state,_A,_C,_word,_avail,_symbol,_ctxt) \
/* arith_state_ptr _state, std_int _A, std_int _C, */ \
/* std_int _word, std_short _avail, ifc_int _symbol, */ \
/* context_state_ptr _ctxt */ \
{ \
context_state _cs; \
std_int _pA; \
\
_increment_symbol_count \
_cs = *_ctxt; \
_pA = ebcot_p0_lut[_cs]; \
_pA *= _A; \
if (_pA > _C) \
{ \
_symbol = 0; \
_A = _pA; \
_cs++; /* Increment S */ \
if ((_cs & S_MASK) == 0) \
{ /* Overflow detected. */ \
_cs--; \
_cs = (_cs>>1) & ~S_MSB; \
_cs++; \
} \
} \
else \
{ \
_symbol = 1; \
_C -= _pA; \
_A = (_A << P_BITS) - _pA; \
_cs += 1 + (1<<S_BITS); /* Increment S and N together. */ \
if (((_cs & S_MASK) == 0) || (_cs & N_OVFL)) \
{ /* Overflow detected. */ \
_cs -= 1 + (1<<S_BITS); \
_cs = (_cs>>1) & ~S_MSB; \
_cs += 1 + (1<<S_BITS); \
} \
} \
*_ctxt = _cs; \
while ((_A & (1<<30)) == 0) \
input_one_bit(_state,_A,_C,_word,_avail); \
_A >>= P_BITS; \
}
/*****************************************************************************/
/* MACRO get_uniform_symbol */
/*****************************************************************************/
#ifdef LOG_SYMBOLS
# define get_uniform_symbol(__state,__A,__C,__word,__avail,__symbol) \
{ \
_get_uniform_symbol(__state,__A,__C,__word,__avail,__symbol); \
ebcot_arith_coder__check_logged_symbol(__state,NULL,__symbol); \
}
#else
# define get_uniform_symbol _get_uniform_symbol
#endif /* LOG_SYMBOLS */
/*****************************************************************************/
/* MACRO _get_uniform_symbol */
/*****************************************************************************/
#define _get_uniform_symbol(_state,_A,_C,_word,_avail,_symbol) \
/* arith_state_ptr _state, std_int _A, std_int _C, */ \
/* std_int _word, std_short _avail, ifc_int _symbol */ \
{ \
_increment_symbol_count \
_A <<= (P_BITS-1); \
if (_A > _C) \
_symbol = 0; \
else \
{ \
_symbol = 1; \
_C -= _A; \
} \
assert(((_A & (1<<30)) == 0) && (_A & (1<<29))); \
input_one_bit(_state,_A,_C,_word,_avail); \
_A >>= P_BITS; \
}
/* ========================================================================= */
/* ------------------------- External Functions ---------------------------- */
/* ========================================================================= */
extern void
ebcot_arith_coder__initialize(arith_state_ptr state, heap_unit_ptr heap,
int code_bytes);
extern void
ebcot_arith_coder__renormalize(arith_state_ptr state);
extern std_int
ebcot_arith_coder__input_word(arith_state_ptr state);
#ifdef LOG_SYMBOLS
extern void
ebcot_arith_coder__check_logged_symbol(arith_state_ptr state,
context_state_ptr ctxt,
std_short symbol);
#endif /* LOG_SYMBOLS */
#endif /* EBCOT_ARITH_DECODER_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -