Commit a5c4469d authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Nathan Egge

Create aom_cdf_prob type for 16-bit probabilities.

Change-Id: I33899eca44300037816c9f20c965aa8311a1ef52
parent 4bdf5205
......@@ -131,7 +131,7 @@ static INLINE int aom_read_tree(aom_reader *r, const aom_tree_index *tree,
#endif
}
static INLINE int aom_read_symbol(aom_reader *r, const uint16_t *cdf,
static INLINE int aom_read_symbol(aom_reader *r, const aom_cdf_prob *cdf,
int nsymbs) {
#if CONFIG_RANS
(void)nsymbs;
......
......@@ -99,7 +99,7 @@ static INLINE void aom_write_tree(aom_writer *w, const aom_tree_index *tree,
}
static INLINE void aom_write_symbol(aom_writer *w, int symb,
const uint16_t *cdf, int nsymbs) {
const aom_cdf_prob *cdf, int nsymbs) {
#if CONFIG_RANS
(void)nsymbs;
struct rans_sym s;
......
......@@ -53,7 +53,7 @@ static INLINE int daala_read_tree_bits(daala_reader *r,
const aom_prob *probs) {
aom_tree_index i = 0;
do {
uint16_t cdf[16];
aom_cdf_prob cdf[16];
aom_tree_index index[16];
int path[16];
int dist[16];
......@@ -67,7 +67,7 @@ static INLINE int daala_read_tree_bits(daala_reader *r,
return -i;
}
static INLINE int daala_read_symbol(daala_reader *r, const uint16_t *cdf,
static INLINE int daala_read_symbol(daala_reader *r, const aom_cdf_prob *cdf,
int nsymbs) {
return od_ec_decode_cdf_q15(&r->ec, cdf, nsymbs, "aom");
}
......
......@@ -46,7 +46,7 @@ static INLINE void daala_write_tree_bits(daala_writer *w,
aom_tree_index root;
root = i;
do {
uint16_t cdf[16];
aom_cdf_prob cdf[16];
aom_tree_index index[16];
int path[16];
int dist[16];
......@@ -79,7 +79,7 @@ static INLINE void daala_write_tree_bits(daala_writer *w,
}
static INLINE void daala_write_symbol(daala_writer *w, int symb,
const uint16_t *cdf, int nsymbs) {
const aom_cdf_prob *cdf, int nsymbs) {
od_ec_encode_cdf_q15(&w->ec, symb, cdf, nsymbs);
}
......
......@@ -68,7 +68,7 @@ struct tree_node {
int len;
int l;
int r;
uint16_t pdf;
aom_cdf_prob pdf;
};
/* Compute the probability of this node in Q23 */
......@@ -96,7 +96,8 @@ static int tree_node_cmp(tree_node a, tree_node b) {
/* Given a Q15 probability for symbol subtree rooted at tree[n], this function
computes the probability of each symbol (defined as a node that has no
children). */
static uint16_t tree_node_compute_probs(tree_node *tree, int n, uint16_t pdf) {
static aom_cdf_prob tree_node_compute_probs(tree_node *tree, int n,
aom_cdf_prob pdf) {
if (tree[n].l == 0) {
/* This prevents probability computations in Q15 that underflow from
producing a symbol that has zero probability. */
......@@ -106,15 +107,15 @@ static uint16_t tree_node_compute_probs(tree_node *tree, int n, uint16_t pdf) {
} else {
/* We process the smaller probability first, */
if (tree[n].prob < 128) {
uint16_t lp;
uint16_t rp;
aom_cdf_prob lp;
aom_cdf_prob rp;
lp = (((uint32_t)pdf) * tree[n].prob + 128) >> 8;
lp = tree_node_compute_probs(tree, tree[n].l, lp);
rp = tree_node_compute_probs(tree, tree[n].r, lp > pdf ? 0 : pdf - lp);
return lp + rp;
} else {
uint16_t rp;
uint16_t lp;
aom_cdf_prob rp;
aom_cdf_prob lp;
rp = (((uint32_t)pdf) * (256 - tree[n].prob) + 128) >> 8;
rp = tree_node_compute_probs(tree, tree[n].r, rp);
lp = tree_node_compute_probs(tree, tree[n].l, rp > pdf ? 0 : pdf - rp);
......@@ -123,8 +124,9 @@ static uint16_t tree_node_compute_probs(tree_node *tree, int n, uint16_t pdf) {
}
}
static int tree_node_extract(tree_node *tree, int n, int symb, uint16_t *pdf,
aom_tree_index *index, int *path, int *len) {
static int tree_node_extract(tree_node *tree, int n, int symb,
aom_cdf_prob *pdf, aom_tree_index *index,
int *path, int *len) {
if (tree[n].l == 0) {
pdf[symb] = tree[n].pdf;
if (index != NULL) index[symb] = tree[n].index;
......@@ -138,7 +140,7 @@ static int tree_node_extract(tree_node *tree, int n, int symb, uint16_t *pdf,
}
int tree_to_cdf(const aom_tree_index *tree, const aom_prob *probs,
aom_tree_index root, uint16_t *cdf, aom_tree_index *index,
aom_tree_index root, aom_cdf_prob *cdf, aom_tree_index *index,
int *path, int *len) {
tree_node symb[2 * 16 - 1];
int nodes;
......
......@@ -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)
......@@ -95,11 +98,11 @@ void aom_tree_merge_probs(const aom_tree_index *tree, const aom_prob *pre_probs,
#if CONFIG_DAALA_EC
int tree_to_cdf(const aom_tree_index *tree, const aom_prob *probs,
aom_tree_index root, uint16_t *cdf, aom_tree_index *ind,
aom_tree_index root, aom_cdf_prob *cdf, aom_tree_index *ind,
int *pth, int *len);
static INLINE void av1_tree_to_cdf(const aom_tree_index *tree,
const aom_prob *probs, uint16_t *cdf) {
const aom_prob *probs, aom_cdf_prob *cdf) {
aom_tree_index index[16];
int path[16];
int dist[16];
......
......@@ -53,9 +53,6 @@ typedef struct frame_contexts {
aom_prob y_mode_prob[BLOCK_SIZE_GROUPS][INTRA_MODES - 1];
aom_prob uv_mode_prob[INTRA_MODES][INTRA_MODES - 1];
aom_prob partition_prob[PARTITION_CONTEXTS][PARTITION_TYPES - 1];
#if CONFIG_DAALA_EC
uint16_t partition_cdf[PARTITION_CONTEXTS][PARTITION_TYPES];
#endif
av1_coeff_probs_model coef_probs[TX_SIZES][PLANE_TYPES];
#if CONFIG_RANS
coeff_cdf_model coef_cdfs[TX_SIZES][PLANE_TYPES];
......@@ -98,10 +95,11 @@ typedef struct frame_contexts {
aom_prob inter_ext_tx_prob[EXT_TX_SIZES][TX_TYPES - 1];
int initialized;
#if CONFIG_DAALA_EC
uint16_t
aom_cdf_prob partition_cdf[PARTITION_CONTEXTS][PARTITION_TYPES];
aom_cdf_prob
switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
uint16_t intra_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES][TX_TYPES];
uint16_t inter_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES];
aom_cdf_prob intra_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES][TX_TYPES];
aom_cdf_prob inter_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES];
#endif
} FRAME_CONTEXT;
......
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