Commit a1ac9728 authored by Alex Converse's avatar Alex Converse

Import the aom_read/write_symbol abstractions from aom/master

Change-Id: I0b255c05108c3b97e74df1b59c34111c9e9a5770
parent 91e4e604
......@@ -104,6 +104,20 @@ static INLINE int aom_read_tree(aom_reader *r, const aom_tree_index *tree,
return aom_read_tree_bits(r, tree, probs);
}
static INLINE int aom_read_symbol(aom_reader *r, const aom_cdf_prob *cdf,
int nsymbs) {
#if CONFIG_ANS
(void)nsymbs;
return rans_read(r, cdf);
#else
(void)r;
(void)cdf;
(void)nsymbs;
assert(0 && "Unsupported bitreader operation");
return -1;
#endif
}
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -86,6 +86,24 @@ static INLINE void aom_write_tree(aom_writer *w, const aom_tree_index *tree,
aom_write_tree_bits(w, tree, probs, bits, len, i);
}
static INLINE void aom_write_symbol(aom_writer *w, int symb,
const aom_cdf_prob *cdf, int nsymbs) {
#if CONFIG_ANS
struct rans_sym s;
(void)nsymbs;
assert(cdf);
s.cum_prob = cdf[symb];
s.prob = cdf[symb + 1] - s.cum_prob;
buf_rans_write(w, &s);
#else
(void)w;
(void)symb;
(void)cdf;
(void)nsymbs;
assert(0 && "Unsupported bitwriter operation");
#endif
}
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -23,6 +23,9 @@ extern "C" {
typedef uint8_t aom_prob;
// TODO(negge): Rename this aom_prob once we remove vpxbool.
typedef uint16_t aom_cdf_prob;
#define MAX_PROB 255
#define aom_prob_half ((aom_prob)128)
......
......@@ -166,7 +166,8 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
}
#if CONFIG_ANS
cdf = &coef_cdfs[band][ctx];
token = ONE_TOKEN + rans_read(r, *cdf);
token =
ONE_TOKEN + aom_read_symbol(r, *cdf, CATEGORY6_TOKEN - ONE_TOKEN + 1);
INCREMENT_COUNT(ONE_TOKEN + (token > ONE_TOKEN));
switch (token) {
case ONE_TOKEN:
......
......@@ -657,11 +657,8 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
aom_write(w, t != ZERO_TOKEN, p->context_tree[1]);
if (t != ZERO_TOKEN) {
struct rans_sym s;
const rans_lut *token_cdf = p->token_cdf;
s.cum_prob = (*token_cdf)[t - ONE_TOKEN];
s.prob = (*token_cdf)[t - ONE_TOKEN + 1] - s.cum_prob;
buf_rans_write(w, &s);
aom_write_symbol(w, t - ONE_TOKEN, *p->token_cdf,
CATEGORY6_TOKEN - ONE_TOKEN + 1);
}
}
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment