summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_bitstream.c44
-rw-r--r--vp9/encoder/vp9_onyx_if.c3
-rw-r--r--vp9/encoder/vp9_rdopt.c12
-rw-r--r--vp9/encoder/vp9_treewriter.h5
4 files changed, 34 insertions, 30 deletions
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index 146636469..ef7c6d136 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -151,6 +151,30 @@ void write_switchable_interp_stats() {
}
#endif
+static struct vp9_token intra_mode_encodings[INTRA_MODES];
+static struct vp9_token switchable_interp_encodings[SWITCHABLE_FILTERS];
+static struct vp9_token partition_encodings[PARTITION_TYPES];
+static struct vp9_token inter_mode_encodings[INTER_MODES];
+
+void vp9_entropy_mode_init() {
+ vp9_tokens_from_tree(intra_mode_encodings, vp9_intra_mode_tree);
+ vp9_tokens_from_tree(switchable_interp_encodings, vp9_switchable_interp_tree);
+ vp9_tokens_from_tree(partition_encodings, vp9_partition_tree);
+ vp9_tokens_from_tree(inter_mode_encodings, vp9_inter_mode_tree);
+}
+
+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]);
+}
+
+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)]);
+}
+
static INLINE void write_be32(uint8_t *p, int value) {
p[0] = value >> 24;
p[1] = value >> 16;
@@ -213,10 +237,6 @@ void vp9_update_skip_probs(VP9_COMP *cpi, vp9_writer *w) {
vp9_cond_prob_diff_update(w, &cm->fc.mbskip_probs[k], cm->counts.mbskip[k]);
}
-static void write_intra_mode(vp9_writer *bc, int m, const vp9_prob *p) {
- write_token(bc, vp9_intra_mode_tree, p, vp9_intra_mode_encodings + m);
-}
-
static void update_switchable_interp_probs(VP9_COMP *cpi, vp9_writer *w) {
VP9_COMMON *const cm = &cpi->common;
int j;
@@ -293,14 +313,6 @@ static void pack_mb_tokens(vp9_writer* const w,
*tp = p + (p->token == EOSB_TOKEN);
}
-static void write_sb_mv_ref(vp9_writer *w, MB_PREDICTION_MODE mode,
- const vp9_prob *p) {
- assert(is_inter_mode(mode));
- write_token(w, vp9_inter_mode_tree, p,
- &vp9_inter_mode_encodings[INTER_OFFSET(mode)]);
-}
-
-
static void write_segment_id(vp9_writer *w, const struct segmentation *seg,
int segment_id) {
if (seg->enabled && seg->update_map)
@@ -422,7 +434,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
// If segment skip is not enabled code the mode.
if (!vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP)) {
if (bsize >= BLOCK_8X8) {
- write_sb_mv_ref(bc, mode, mv_ref_p);
+ write_inter_mode(bc, mode, mv_ref_p);
++cm->counts.inter_mode[mi->mode_context[rf]]
[INTER_OFFSET(mode)];
}
@@ -432,7 +444,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
const int ctx = vp9_get_pred_context_switchable_interp(xd);
write_token(bc, vp9_switchable_interp_tree,
cm->fc.switchable_interp_prob[ctx],
- &vp9_switchable_interp_encodings[mi->interp_filter]);
+ &switchable_interp_encodings[mi->interp_filter]);
} else {
assert(mi->interp_filter == cm->mcomp_filter_type);
}
@@ -445,7 +457,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) {
for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) {
const int j = idy * 2 + idx;
const MB_PREDICTION_MODE blockmode = m->bmi[j].as_mode;
- write_sb_mv_ref(bc, blockmode, mv_ref_p);
+ write_inter_mode(bc, blockmode, mv_ref_p);
++cm->counts.inter_mode[mi->mode_context[rf]]
[INTER_OFFSET(blockmode)];
@@ -561,7 +573,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, &vp9_partition_encodings[p]);
+ 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]);
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index b28939120..7ba5bc47d 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -39,6 +39,8 @@
#include "vpx_ports/vpx_timer.h"
+void vp9_entropy_mode_init();
+
static void set_default_lf_deltas(struct loopfilter *lf);
#define DEFAULT_INTERP_FILTER SWITCHABLE
@@ -162,6 +164,7 @@ void vp9_initialize_enc() {
vp9_init_minq_luts();
// init_base_skip_probs();
vp9_entropy_mv_init();
+ vp9_entropy_mode_init();
init_done = 1;
}
}
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 43b7d6b7c..b9227b64a 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -290,15 +290,9 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi) {
&cm->fc.nmvc,
cm->allow_high_precision_mv, 1, 1);
- for (i = 0; i < INTER_MODE_CONTEXTS; i++) {
- MB_PREDICTION_MODE m;
-
- for (m = NEARESTMV; m < MB_MODE_COUNT; m++)
- cpi->mb.inter_mode_cost[i][INTER_OFFSET(m)] =
- cost_token(vp9_inter_mode_tree,
- cm->fc.inter_mode_probs[i],
- &vp9_inter_mode_encodings[INTER_OFFSET(m)]);
- }
+ for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
+ vp9_cost_tokens((int *)cpi->mb.inter_mode_cost[i],
+ cm->fc.inter_mode_probs[i], vp9_inter_mode_tree);
}
}
diff --git a/vp9/encoder/vp9_treewriter.h b/vp9/encoder/vp9_treewriter.h
index c9bf4dabe..3245960ac 100644
--- a/vp9/encoder/vp9_treewriter.h
+++ b/vp9/encoder/vp9_treewriter.h
@@ -64,11 +64,6 @@ static INLINE int treed_cost(vp9_tree tree, const vp9_prob *probs,
return cost;
}
-static INLINE int cost_token(vp9_tree tree, const vp9_prob *probs,
- const struct vp9_token *token) {
- return treed_cost(tree, probs, token->value, token->len);
-}
-
void vp9_cost_tokens(int *costs, const vp9_prob *probs, vp9_tree tree);
void vp9_cost_tokens_skip(int *costs, const vp9_prob *probs, vp9_tree tree);