Commit 33a143fa authored by Nathan E. Egge's avatar Nathan E. Egge
Browse files

Move tree writing code into bitwriter.h.

Rename av1_write_tree() to aom_write_tree() and move it into bitwriter.h
 to match aom_read_tree() in bitreader.h.

Change-Id: I49a2e418a4bb8d724cb033b787b650da0bc28833
parent 2c38748d
......@@ -57,8 +57,8 @@ static INLINE int aom_read_literal(aom_reader *r, int bits) {
return literal;
}
static INLINE int aom_read_tree(aom_reader *r, const aom_tree_index *tree,
const aom_prob *probs) {
static INLINE int aom_read_tree_bits(aom_reader *r, const aom_tree_index *tree,
const aom_prob *probs) {
aom_tree_index i = 0;
while ((i = tree[i + aom_read(r, probs[i >> 1])]) > 0) continue;
......@@ -66,6 +66,11 @@ static INLINE int aom_read_tree(aom_reader *r, const aom_tree_index *tree,
return -i;
}
static INLINE int aom_read_tree(aom_reader *r, const aom_tree_index *tree,
const aom_prob *probs) {
return aom_read_tree_bits(r, tree, probs);
}
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -41,6 +41,22 @@ static INLINE void aom_write_literal(aom_writer *w, int data, int bits) {
for (bit = bits - 1; bit >= 0; bit--) aom_write_bit(w, 1 & (data >> bit));
}
static INLINE void aom_write_tree_bits(aom_writer *w, const aom_tree_index *tr,
const aom_prob *probs, int bits, int len,
aom_tree_index i) {
do {
const int bit = (bits >> --len) & 1;
aom_write(w, bit, probs[i >> 1]);
i = tr[i + bit];
} while (len);
}
static INLINE void aom_write_tree(aom_writer *w, const aom_tree_index *tree,
const aom_prob *probs, int bits, int len,
aom_tree_index i) {
aom_write_tree_bits(w, tree, probs, bits, len, i);
}
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -336,12 +336,12 @@ static void pack_mb_tokens(aom_writer *w, TOKENEXTRA **tp,
if (t >= TWO_TOKEN && t < EOB_TOKEN) {
int len = UNCONSTRAINED_NODES - p->skip_eob_node;
int bits = v >> (n - len);
av1_write_tree(w, av1_coef_tree, p->context_tree, bits, len, i);
av1_write_tree(w, av1_coef_con_tree,
aom_write_tree(w, av1_coef_tree, p->context_tree, bits, len, i);
aom_write_tree(w, av1_coef_con_tree,
av1_pareto8_full[p->context_tree[PIVOT_NODE] - 1], v,
n - len, 0);
} else {
av1_write_tree(w, av1_coef_tree, p->context_tree, v, n, i);
aom_write_tree(w, av1_coef_tree, p->context_tree, v, n, i);
}
if (b->base_val) {
......@@ -382,7 +382,7 @@ static void write_segment_id(aom_writer *w, const struct segmentation *seg,
const struct segmentation_probs *segp,
int segment_id) {
if (seg->enabled && seg->update_map)
av1_write_tree(w, av1_segment_tree, segp->tree_probs, segment_id, 3, 0);
aom_write_tree(w, av1_segment_tree, segp->tree_probs, segment_id, 3, 0);
}
// This function encodes the reference frame
......
......@@ -29,20 +29,10 @@ struct av1_token {
void av1_tokens_from_tree(struct av1_token *, const aom_tree_index *);
static INLINE void av1_write_tree(aom_writer *w, const aom_tree_index *tree,
const aom_prob *probs, int bits, int len,
aom_tree_index i) {
do {
const int bit = (bits >> --len) & 1;
aom_write(w, bit, probs[i >> 1]);
i = tree[i + bit];
} while (len);
}
static INLINE void av1_write_token(aom_writer *w, const aom_tree_index *tree,
const aom_prob *probs,
const struct av1_token *token) {
av1_write_tree(w, tree, probs, token->value, token->len, 0);
aom_write_tree(w, tree, probs, token->value, token->len, 0);
}
#ifdef __cplusplus
......
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