Index: source/libvpx/vp9/encoder/vp9_encodemv.c |
=================================================================== |
--- source/libvpx/vp9/encoder/vp9_encodemv.c (revision 263011) |
+++ source/libvpx/vp9/encoder/vp9_encodemv.c (working copy) |
@@ -13,12 +13,10 @@ |
#include "vp9/common/vp9_common.h" |
#include "vp9/common/vp9_entropymode.h" |
#include "vp9/common/vp9_systemdependent.h" |
+ |
+#include "vp9/encoder/vp9_cost.h" |
#include "vp9/encoder/vp9_encodemv.h" |
-#ifdef ENTROPY_STATS |
-extern unsigned int active_section; |
-#endif |
- |
static struct vp9_token mv_joint_encodings[MV_JOINTS]; |
static struct vp9_token mv_class_encodings[MV_CLASSES]; |
static struct vp9_token mv_fp_encodings[MV_FP_SIZE]; |
@@ -160,7 +158,7 @@ |
vp9_tree_probs_from_distribution(tree, branch_ct, counts); |
for (i = 0; i < n - 1; ++i) |
- update_mv(w, branch_ct[i], &probs[i], NMV_UPDATE_PROB); |
+ update_mv(w, branch_ct[i], &probs[i], MV_UPDATE_PROB); |
} |
void vp9_write_nmv_probs(VP9_COMMON *cm, int usehp, vp9_writer *w) { |
@@ -174,13 +172,13 @@ |
nmv_component *comp = &mvc->comps[i]; |
nmv_component_counts *comp_counts = &counts->comps[i]; |
- update_mv(w, comp_counts->sign, &comp->sign, NMV_UPDATE_PROB); |
+ update_mv(w, comp_counts->sign, &comp->sign, MV_UPDATE_PROB); |
write_mv_update(vp9_mv_class_tree, comp->classes, comp_counts->classes, |
MV_CLASSES, w); |
write_mv_update(vp9_mv_class0_tree, comp->class0, comp_counts->class0, |
CLASS0_SIZE, w); |
for (j = 0; j < MV_OFFSET_BITS; ++j) |
- update_mv(w, comp_counts->bits[j], &comp->bits[j], NMV_UPDATE_PROB); |
+ update_mv(w, comp_counts->bits[j], &comp->bits[j], MV_UPDATE_PROB); |
} |
for (i = 0; i < 2; ++i) { |
@@ -195,8 +193,8 @@ |
if (usehp) { |
for (i = 0; i < 2; ++i) { |
update_mv(w, counts->comps[i].class0_hp, &mvc->comps[i].class0_hp, |
- NMV_UPDATE_PROB); |
- update_mv(w, counts->comps[i].hp, &mvc->comps[i].hp, NMV_UPDATE_PROB); |
+ MV_UPDATE_PROB); |
+ update_mv(w, counts->comps[i].hp, &mvc->comps[i].hp, MV_UPDATE_PROB); |
} |
} |
} |
@@ -231,22 +229,21 @@ |
build_nmv_component_cost_table(mvcost[1], &ctx->comps[1], usehp); |
} |
-static void inc_mvs(const int_mv mv[2], const MV ref[2], int is_compound, |
+static void inc_mvs(const MB_MODE_INFO *mbmi, const int_mv mvs[2], |
nmv_context_counts *counts) { |
int i; |
- for (i = 0; i < 1 + is_compound; ++i) { |
- const MV diff = { mv[i].as_mv.row - ref[i].row, |
- mv[i].as_mv.col - ref[i].col }; |
+ |
+ for (i = 0; i < 1 + has_second_ref(mbmi); ++i) { |
+ const MV *ref = &mbmi->ref_mvs[mbmi->ref_frame[i]][0].as_mv; |
+ const MV diff = {mvs[i].as_mv.row - ref->row, |
+ mvs[i].as_mv.col - ref->col}; |
vp9_inc_mv(&diff, counts); |
} |
} |
-void vp9_update_mv_count(VP9_COMMON *cm, const MACROBLOCKD *xd, |
- const MV best_ref_mv[2]) { |
- const MODE_INFO *mi = xd->mi_8x8[0]; |
+void vp9_update_mv_count(VP9_COMMON *cm, const MACROBLOCKD *xd) { |
+ const MODE_INFO *mi = xd->mi[0]; |
const MB_MODE_INFO *const mbmi = &mi->mbmi; |
- const int is_compound = has_second_ref(mbmi); |
- nmv_context_counts *counts = &cm->counts.mv; |
if (mbmi->sb_type < BLOCK_8X8) { |
const int num_4x4_w = num_4x4_blocks_wide_lookup[mbmi->sb_type]; |
@@ -257,11 +254,12 @@ |
for (idx = 0; idx < 2; idx += num_4x4_w) { |
const int i = idy * 2 + idx; |
if (mi->bmi[i].as_mode == NEWMV) |
- inc_mvs(mi->bmi[i].as_mv, best_ref_mv, is_compound, counts); |
+ inc_mvs(mbmi, mi->bmi[i].as_mv, &cm->counts.mv); |
} |
} |
- } else if (mbmi->mode == NEWMV) { |
- inc_mvs(mbmi->mv, best_ref_mv, is_compound, counts); |
+ } else { |
+ if (mbmi->mode == NEWMV) |
+ inc_mvs(mbmi, mbmi->mv, &cm->counts.mv); |
} |
} |