Go to the documentation of this file.
31 }
else if (
state->last_len !=
N) {
34 memcpy(last,
state->last,
sizeof(last));
37 for (
i = 0;
i <
N/2;
i++) {
38 int k = (int)(
i * ratio);
54 return state->last[0] << 12;
78 while ((i_max - i_min) > 1) {
79 i = i_min + ((i_max - i_min) / 2);
83 else if (
c > (j >> 8))
92 uint16_t
a, uint16_t
b)
95 if (
state->cur[0] > 0xF)
109 ac->
high = UINT16_MAX;
114 const uint16_t *cdf, uint16_t cdf_len)
121 int rng =
high - low + 1;
122 int c = ((((int)(
val - low + 1)) << 14) - ((int)1));
124 const uint16_t *p = cdf - 1;
129 if ((p[1] * rng) >
c)
133 if ((p[2] * rng) >
c)
135 if ((p[1] * rng) >
c)
140 if ((p[1] * rng) <=
c)
143 for (
int i = 8;
i >= 1;
i >>= 1)
144 if ((p[
i] * rng) >
c)
148 if ((p[16] * rng) >
c)
150 if ((p[8] * rng) >
c)
152 if (p != (cdf - 1 + 24))
153 if ((p[4] * rng) >
c)
155 if ((p[2] * rng) >
c)
158 if (p != (cdf - 1 + 24 + 2))
159 if ((p[1] * rng) >
c)
167 sym = (int)((ptrdiff_t)(p - cdf)) + 1;
169 high = low + ((rng * cdf[sym - 1]) >> 14) - 1;
170 low += (rng * cdf[sym]) >> 14;
176 }
else if (low >= 32768) {
180 }
else if (low >= 16384 &&
high < 49152) {
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static double val(void *priv, double ch)
const uint32_t ff_aac_ac_hash_m[742]
#define FF_ARRAY_ELEMS(a)
void ff_aac_ac_finish(AACArithState *state, int offset, int N)
void ff_aac_ac_init(AACArith *ac, GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
uint16_t ff_aac_ac_decode(AACArith *ac, GetBitContext *gb, const uint16_t *cdf, uint16_t cdf_len)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
uint32_t ff_aac_ac_get_context(AACArithState *state, uint32_t c, int i, int N)
uint32_t ff_aac_ac_get_pk(uint32_t c)
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
#define i(width, name, range_min, range_max)
void ff_aac_ac_update_context(AACArithState *state, int idx, uint16_t a, uint16_t b)
uint32_t ff_aac_ac_map_process(AACArithState *state, int reset, int N)
const uint8_t ff_aac_ac_lookup_m[742]