27#ifndef AVCODEC_CAVS_AEC_H
28#define AVCODEC_CAVS_AEC_H
40#define CAVS_AEC_NUM_CTX 323
47 if ((
unsigned)
inc >= (
unsigned)span)
69#define CAVS_AEC_LGPMPS_INIT 1023
70#define CAVS_AEC_LGPMPS_MAX 1023
71#define CAVS_AEC_LGPMPS_REFLECT 2047
72#define CAVS_AEC_LGPMPS_BYPASS 1023
73#define CAVS_AEC_LGPMPS_STUFF 4
74#define CAVS_AEC_RT1_INIT 0xFF
79 static const uint8_t cwr_tab[4] = { 3, 3, 4, 5 };
81 static const uint16_t lps_inc_tab[6] = { 0, 0, 0, 197, 95, 46 };
82 const int cwr = cwr_tab[m->
cycno];
86 else if (m->
cycno == 0)
102 int pred_mps,
int lg_pmps)
105 const int lps_range = lg_pmps >> 2;
106 int rs2, rt2, s_flag, bin;
110 if (aec->
rt1 >= lps_range) {
112 rt2 = aec->
rt1 - lps_range;
116 rt2 = 256 + aec->
rt1 - lps_range;
120 if (rs2 > aec->
vs || (rs2 == aec->
vs && aec->
vt >= rt2)) {
121 int t_rlps = s_flag ? aec->
rt1 + lps_range : lps_range;
128 while (t_rlps < 0x100) {
129 t_rlps = t_rlps << 1;
132 aec->
rt1 = t_rlps & 0xFF;
139 if (bin != pred_mps) {
164 m = &aec->
ctx[ctx_idx];
173 int ctx_idx,
int ctx_idx_w)
176 int pred_mps, lg_pmps, bin;
181 m1 = &aec->
ctx[ctx_idx];
182 m2 = &aec->
ctx[ctx_idx_w];
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static int ff_cavs_aec_decode_decision_w(CAVSAECContext *aec, int ctx_idx, int ctx_idx_w)
Decode a bin with two weighted context models (8.4.4.3.2).
static int ff_cavs_aec_decode_decision(CAVSAECContext *aec, int ctx_idx)
Decode a bin with one context model (8.4.4.3.2).
static int ff_cavs_aec_ctx_idx(int start, int span, int inc)
Table 51 start index + ctxIdxInc, or AVERROR_INVALIDDATA/AVERROR_BUG.
void ff_cavs_aec_init(CAVSAECContext *aec, GetBitContext *gb)
Reset all contexts and start the decoder on byte aligned gb (8.4.1).
static int ff_cavs_aec_decode_stuffing_bit(CAVSAECContext *aec)
Decode aec_mb_stuffing_bit, fixed lgPmps (8.4.4.3.4).
#define CAVS_AEC_LGPMPS_REFLECT
#define CAVS_AEC_LGPMPS_BYPASS
#define CAVS_AEC_LGPMPS_STUFF
#define CAVS_AEC_LGPMPS_MAX
static av_always_inline int cavs_aec_decode_bin(CAVSAECContext *aec, int pred_mps, int lg_pmps)
Decode one bin (8.4.4.3.2); the caller supplies predMps and lgPmps.
static void cavs_aec_update_ctx(CAVSAECModel *m, int bin)
Adapt one context model after a bin has been decoded, 8.4.4.3.5.
static int ff_cavs_aec_decode_bypass(CAVSAECContext *aec)
Decode a bypass bin, fixed lgPmps (8.4.4.3.3).
bitstream reader API header.
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Macro definitions for various function/variable attributes.
Utility Preprocessor macros.
static int inc(int num, int period)
int vs
offset exponent (valueS)
GetBitContext * gb
bitstream reader, shared with the slice parser
CAVSAECModel ctx[CAVS_AEC_NUM_CTX]
context models, 8.4.2.1
int rt1
range mantissa, init 0xFF (rT1)
int rs1
range exponent, init 0 (rS1)
int vt
offset mantissa, 9 bits inside a call (valueT)
uint8_t mps
mps: more probable symbol, 1 bit, init 0
uint8_t cycno
cycno: adaptation counter, 2 bits, init 0
uint16_t lg_pmps
lgPmps: log domain P(MPS), 11 bits, init 1023