Renaming treed_write() to vp9_write_tree().

Making name consistent with vp9_read_tree().

Change-Id: Ie213ffe0d5345bf3035f28e17f610894fec79205
This commit is contained in:
Dmitry Kovalev 2013-12-10 18:13:29 -08:00
parent 014b9c70f7
commit 021a15fe9f
4 changed files with 46 additions and 55 deletions

View File

@ -63,14 +63,14 @@ void vp9_entropy_mode_init() {
static void write_intra_mode(vp9_writer *w, MB_PREDICTION_MODE mode,
const vp9_prob *probs) {
write_token(w, vp9_intra_mode_tree, probs, &intra_mode_encodings[mode]);
vp9_write_token(w, vp9_intra_mode_tree, probs, &intra_mode_encodings[mode]);
}
static void write_inter_mode(vp9_writer *w, MB_PREDICTION_MODE mode,
const vp9_prob *probs) {
assert(is_inter_mode(mode));
write_token(w, vp9_inter_mode_tree, probs,
&inter_mode_encodings[INTER_OFFSET(mode)]);
vp9_write_token(w, vp9_inter_mode_tree, probs,
&inter_mode_encodings[INTER_OFFSET(mode)]);
}
static INLINE void write_be32(uint8_t *p, int value) {
@ -179,12 +179,12 @@ static void pack_mb_tokens(vp9_writer* const w,
if (t >= TWO_TOKEN && t < EOB_TOKEN) {
int len = UNCONSTRAINED_NODES - p->skip_eob_node;
int bits = v >> (n - len);
treed_write(w, vp9_coef_tree, p->context_tree, bits, len, i);
treed_write(w, vp9_coef_con_tree,
vp9_pareto8_full[p->context_tree[PIVOT_NODE] - 1], v, n - len,
0);
vp9_write_tree(w, vp9_coef_tree, p->context_tree, bits, len, i);
vp9_write_tree(w, vp9_coef_con_tree,
vp9_pareto8_full[p->context_tree[PIVOT_NODE] - 1],
v, n - len, 0);
} else {
treed_write(w, vp9_coef_tree, p->context_tree, v, n, i);
vp9_write_tree(w, vp9_coef_tree, p->context_tree, v, n, i);
}
if (b->base_val) {
@ -214,7 +214,7 @@ static void pack_mb_tokens(vp9_writer* const w,
static void write_segment_id(vp9_writer *w, const struct segmentation *seg,
int segment_id) {
if (seg->enabled && seg->update_map)
treed_write(w, vp9_segment_tree, seg->tree_probs, segment_id, 3, 0);
vp9_write_tree(w, vp9_segment_tree, seg->tree_probs, segment_id, 3, 0);
}
// This function encodes the reference frame
@ -332,16 +332,15 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
if (!vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)) {
if (bsize >= BLOCK_8X8) {
write_inter_mode(bc, mode, mv_ref_p);
++cm->counts.inter_mode[mi->mode_context[rf]]
[INTER_OFFSET(mode)];
++cm->counts.inter_mode[mi->mode_context[rf]][INTER_OFFSET(mode)];
}
}
if (cm->mcomp_filter_type == SWITCHABLE) {
const int ctx = vp9_get_pred_context_switchable_interp(xd);
write_token(bc, vp9_switchable_interp_tree,
cm->fc.switchable_interp_prob[ctx],
&switchable_interp_encodings[mi->interp_filter]);
vp9_write_token(bc, vp9_switchable_interp_tree,
cm->fc.switchable_interp_prob[ctx],
&switchable_interp_encodings[mi->interp_filter]);
} else {
assert(mi->interp_filter == cm->mcomp_filter_type);
}
@ -470,7 +469,7 @@ static void write_partition(VP9_COMP *cpi, int hbs, int mi_row, int mi_col,
const int has_cols = (mi_col + hbs) < cm->mi_cols;
if (has_rows && has_cols) {
write_token(w, vp9_partition_tree, probs, &partition_encodings[p]);
vp9_write_token(w, vp9_partition_tree, probs, &partition_encodings[p]);
} else if (!has_rows && has_cols) {
assert(p == PARTITION_SPLIT || p == PARTITION_HORZ);
vp9_write(w, p == PARTITION_SPLIT, probs[1]);

View File

@ -111,5 +111,6 @@ static void vp9_write_literal(vp9_writer *w, int data, int bits) {
vp9_write_bit(w, 1 & (data >> bit));
}
#define vp9_write_prob(w, v) vp9_write_literal((w), (v), 8)
#endif // VP9_ENCODER_VP9_BOOLHUFF_H_

View File

@ -47,13 +47,13 @@ static void encode_mv_component(vp9_writer* w, int comp,
vp9_write(w, sign, mvcomp->sign);
// Class
write_token(w, vp9_mv_class_tree, mvcomp->classes,
&mv_class_encodings[mv_class]);
vp9_write_token(w, vp9_mv_class_tree, mvcomp->classes,
&mv_class_encodings[mv_class]);
// Integer bits
if (mv_class == MV_CLASS_0) {
write_token(w, vp9_mv_class0_tree, mvcomp->class0,
&mv_class0_encodings[d]);
vp9_write_token(w, vp9_mv_class0_tree, mvcomp->class0,
&mv_class0_encodings[d]);
} else {
int i;
const int n = mv_class + CLASS0_BITS - 1; // number of bits
@ -62,9 +62,9 @@ static void encode_mv_component(vp9_writer* w, int comp,
}
// Fractional bits
write_token(w, vp9_mv_fp_tree,
mv_class == MV_CLASS_0 ? mvcomp->class0_fp[d] : mvcomp->fp,
&mv_fp_encodings[fr]);
vp9_write_token(w, vp9_mv_fp_tree,
mv_class == MV_CLASS_0 ? mvcomp->class0_fp[d] : mvcomp->fp,
&mv_fp_encodings[fr]);
// High precision bit
if (usehp)
@ -209,7 +209,7 @@ void vp9_encode_mv(VP9_COMP* cpi, vp9_writer* w,
const MV_JOINT_TYPE j = vp9_get_mv_joint(&diff);
usehp = usehp && vp9_use_mv_hp(ref);
write_token(w, vp9_mv_joint_tree, mvctx->joints, &mv_joint_encodings[j]);
vp9_write_token(w, vp9_mv_joint_tree, mvctx->joints, &mv_joint_encodings[j]);
if (mv_joint_vertical(j))
encode_mv_component(w, diff.row, &mvctx->comps[0], usehp);

View File

@ -8,19 +8,12 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VP9_ENCODER_VP9_TREEWRITER_H_
#define VP9_ENCODER_VP9_TREEWRITER_H_
/* Trees map alphabets into huffman-like codes suitable for an arithmetic
bit coder. Timothy S Murphy 11 October 2004 */
#include "vp9/common/vp9_treecoder.h"
#include "vp9/encoder/vp9_boolhuff.h" /* for now */
#define vp9_write_prob(w, v) vp9_write_literal((w), (v), 8)
#define vp9_cost_zero(prob) (vp9_prob_cost[prob])
#define vp9_cost_one(prob) vp9_cost_zero(vp9_complement(prob))
@ -33,31 +26,6 @@ static INLINE unsigned int cost_branch256(const unsigned int ct[2],
return ct[0] * vp9_cost_zero(p) + ct[1] * vp9_cost_one(p);
}
static INLINE void treed_write(vp9_writer *w,
vp9_tree tree, const vp9_prob *probs,
int bits, int len,
vp9_tree_index i) {
do {
const int bit = (bits >> --len) & 1;
vp9_write(w, bit, probs[i >> 1]);
i = tree[i + bit];
} while (len);
}
struct vp9_token {
int value;
int len;
};
void vp9_tokens_from_tree(struct vp9_token*, const vp9_tree_index *);
static INLINE void write_token(vp9_writer *w, vp9_tree tree,
const vp9_prob *probs,
const struct vp9_token *token) {
treed_write(w, tree, probs, token->value, token->len, 0);
}
static INLINE int treed_cost(vp9_tree tree, const vp9_prob *probs,
int bits, int len) {
int cost = 0;
@ -79,4 +47,27 @@ void vp9_tree_probs_from_distribution(vp9_tree tree,
unsigned int branch_ct[ /* n - 1 */ ][2],
const unsigned int num_events[ /* n */ ]);
struct vp9_token {
int value;
int len;
};
void vp9_tokens_from_tree(struct vp9_token*, const vp9_tree_index *);
static INLINE void vp9_write_tree(vp9_writer *w, const vp9_tree_index *tree,
const vp9_prob *probs, int bits, int len,
vp9_tree_index i) {
do {
const int bit = (bits >> --len) & 1;
vp9_write(w, bit, probs[i >> 1]);
i = tree[i + bit];
} while (len);
}
static INLINE void vp9_write_token(vp9_writer *w, const vp9_tree_index *tree,
const vp9_prob *probs,
const struct vp9_token *token) {
vp9_write_tree(w, tree, probs, token->value, token->len, 0);
}
#endif // VP9_ENCODER_VP9_TREEWRITER_H_