Commit eeedc633 authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Yaowu Xu

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.

Manually cherry-picked from aom/master:
33a143fa

Change-Id: I6c686cdd3e0f179d7e95c5bc6984558b62d46d67
parent debaface
......@@ -90,8 +90,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;
......@@ -99,6 +99,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
......
......@@ -70,6 +70,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
......
......@@ -662,7 +662,7 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
if (t != ONE_TOKEN) {
int len = UNCONSTRAINED_NODES - p->skip_eob_node;
av1_write_tree(w, av1_coef_con_tree,
aom_write_tree(w, av1_coef_con_tree,
av1_pareto8_full[p->context_tree[PIVOT_NODE] - 1], v,
n - len, 0);
}
......@@ -836,7 +836,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