mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-09 08:47:31 +09:00
Update aom to commit id e87fb2378f01103d5d6e477a4ef6892dc714e614
This commit is contained in:
parent
debbee1e2a
commit
992c6637e3
429 changed files with 76047 additions and 40937 deletions
55
third_party/aom/aom_dsp/entdec.c
vendored
55
third_party/aom/aom_dsp/entdec.c
vendored
|
|
@ -114,12 +114,8 @@ static int od_ec_dec_normalize(od_ec_dec *dec, od_ec_window dif, unsigned rng,
|
|||
OD_ASSERT(rng <= 65535U);
|
||||
d = 16 - OD_ILOG_NZ(rng);
|
||||
dec->cnt -= d;
|
||||
#if CONFIG_EC_SMALLMUL
|
||||
/*This is equivalent to shifting in 1's instead of 0's.*/
|
||||
dec->dif = ((dif + 1) << d) - 1;
|
||||
#else
|
||||
dec->dif = dif << d;
|
||||
#endif
|
||||
dec->rng = rng << d;
|
||||
if (dec->cnt < 0) od_ec_dec_refill(dec);
|
||||
return ret;
|
||||
|
|
@ -137,11 +133,7 @@ void od_ec_dec_init(od_ec_dec *dec, const unsigned char *buf,
|
|||
dec->tell_offs = 10 - (OD_EC_WINDOW_SIZE - 8);
|
||||
dec->end = buf + storage;
|
||||
dec->bptr = buf;
|
||||
#if CONFIG_EC_SMALLMUL
|
||||
dec->dif = ((od_ec_window)1 << (OD_EC_WINDOW_SIZE - 1)) - 1;
|
||||
#else
|
||||
dec->dif = 0;
|
||||
#endif
|
||||
dec->rng = 0x8000;
|
||||
dec->cnt = -15;
|
||||
dec->error = 0;
|
||||
|
|
@ -149,8 +141,7 @@ void od_ec_dec_init(od_ec_dec *dec, const unsigned char *buf,
|
|||
}
|
||||
|
||||
/*Decode a single binary value.
|
||||
{EC_SMALLMUL} f: The probability that the bit is one, scaled by 32768.
|
||||
{else} f: The probability that the bit is zero, scaled by 32768.
|
||||
f: The probability that the bit is one, scaled by 32768.
|
||||
Return: The value decoded (0 or 1).*/
|
||||
int od_ec_decode_bool_q15(od_ec_dec *dec, unsigned f) {
|
||||
od_ec_window dif;
|
||||
|
|
@ -165,7 +156,6 @@ int od_ec_decode_bool_q15(od_ec_dec *dec, unsigned f) {
|
|||
r = dec->rng;
|
||||
OD_ASSERT(dif >> (OD_EC_WINDOW_SIZE - 16) < r);
|
||||
OD_ASSERT(32768U <= r);
|
||||
#if CONFIG_EC_SMALLMUL
|
||||
v = (r >> 8) * (uint32_t)f >> 7;
|
||||
vw = (od_ec_window)v << (OD_EC_WINDOW_SIZE - 16);
|
||||
ret = 1;
|
||||
|
|
@ -175,30 +165,19 @@ int od_ec_decode_bool_q15(od_ec_dec *dec, unsigned f) {
|
|||
dif -= vw;
|
||||
ret = 0;
|
||||
}
|
||||
#else
|
||||
v = f * (uint32_t)r >> 15;
|
||||
vw = (od_ec_window)v << (OD_EC_WINDOW_SIZE - 16);
|
||||
ret = 0;
|
||||
r_new = v;
|
||||
if (dif >= vw) {
|
||||
r_new = r - v;
|
||||
dif -= vw;
|
||||
ret = 1;
|
||||
}
|
||||
#endif
|
||||
return od_ec_dec_normalize(dec, dif, r_new, ret);
|
||||
}
|
||||
|
||||
/*Decodes a symbol given a cumulative distribution function (CDF) table in Q15.
|
||||
cdf: The CDF, such that symbol s falls in the range
|
||||
[s > 0 ? cdf[s - 1] : 0, cdf[s]).
|
||||
The values must be monotonically non-increasing, and cdf[nsyms - 1]
|
||||
must be 32768.
|
||||
{EC_SMALLMUL}: The CDF contains 32768 minus those values.
|
||||
/*Decodes a symbol given an inverse cumulative distribution function (CDF)
|
||||
table in Q15.
|
||||
icdf: 32768 minus the CDF, such that symbol s falls in the range
|
||||
[s > 0 ? (32768 - icdf[s - 1]) : 0, 32768 - icdf[s]).
|
||||
The values must be monotonically non-increasing, and icdf[nsyms - 1]
|
||||
must be 0.
|
||||
nsyms: The number of symbols in the alphabet.
|
||||
This should be at most 16.
|
||||
Return: The decoded symbol s.*/
|
||||
int od_ec_decode_cdf_q15(od_ec_dec *dec, const uint16_t *cdf, int nsyms) {
|
||||
int od_ec_decode_cdf_q15(od_ec_dec *dec, const uint16_t *icdf, int nsyms) {
|
||||
od_ec_window dif;
|
||||
unsigned r;
|
||||
unsigned c;
|
||||
|
|
@ -209,33 +188,19 @@ int od_ec_decode_cdf_q15(od_ec_dec *dec, const uint16_t *cdf, int nsyms) {
|
|||
dif = dec->dif;
|
||||
r = dec->rng;
|
||||
OD_ASSERT(dif >> (OD_EC_WINDOW_SIZE - 16) < r);
|
||||
OD_ASSERT(cdf[nsyms - 1] == OD_ICDF(32768U));
|
||||
OD_ASSERT(icdf[nsyms - 1] == OD_ICDF(32768U));
|
||||
OD_ASSERT(32768U <= r);
|
||||
#if CONFIG_EC_SMALLMUL
|
||||
c = (unsigned)(dif >> (OD_EC_WINDOW_SIZE - 16));
|
||||
v = r;
|
||||
ret = -1;
|
||||
do {
|
||||
u = v;
|
||||
v = (r >> 8) * (uint32_t)cdf[++ret] >> 7;
|
||||
v = (r >> 8) * (uint32_t)icdf[++ret] >> 7;
|
||||
} while (c < v);
|
||||
OD_ASSERT(v < u);
|
||||
OD_ASSERT(u <= r);
|
||||
r = u - v;
|
||||
dif -= (od_ec_window)v << (OD_EC_WINDOW_SIZE - 16);
|
||||
#else
|
||||
c = (unsigned)(dif >> (OD_EC_WINDOW_SIZE - 16));
|
||||
v = 0;
|
||||
ret = -1;
|
||||
do {
|
||||
u = v;
|
||||
v = cdf[++ret] * (uint32_t)r >> 15;
|
||||
} while (v <= c);
|
||||
OD_ASSERT(u < v);
|
||||
OD_ASSERT(v <= r);
|
||||
r = v - u;
|
||||
dif -= (od_ec_window)u << (OD_EC_WINDOW_SIZE - 16);
|
||||
#endif
|
||||
return od_ec_dec_normalize(dec, dif, r, ret);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue