Commit c9ec26f1 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Moving common code into vp9_update_mv_count().

Change-Id: I512482853bdf2695fbdf1c705a2ada354ccf76cf
parent 4d903f47
...@@ -985,12 +985,7 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, ...@@ -985,12 +985,7 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
#endif #endif
if (!frame_is_intra_only(cm)) { if (!frame_is_intra_only(cm)) {
if (is_inter_block(mbmi)) { if (is_inter_block(mbmi)) {
if (mbmi->sb_type < BLOCK_8X8 || mbmi->mode == NEWMV) { vp9_update_mv_count(cm, xd);
MV best_mv[2];
for (i = 0; i < 1 + has_second_ref(mbmi); ++i)
best_mv[i] = mbmi->ref_mvs[mbmi->ref_frame[i]][0].as_mv;
vp9_update_mv_count(cm, xd, best_mv);
}
if (cm->interp_filter == SWITCHABLE) { if (cm->interp_filter == SWITCHABLE) {
const int ctx = vp9_get_pred_context_switchable_interp(xd); const int ctx = vp9_get_pred_context_switchable_interp(xd);
...@@ -1462,7 +1457,6 @@ static int sb_has_motion(const VP9_COMMON *cm, MODE_INFO **prev_mi_8x8) { ...@@ -1462,7 +1457,6 @@ static int sb_has_motion(const VP9_COMMON *cm, MODE_INFO **prev_mi_8x8) {
static void update_state_rt(VP9_COMP *cpi, const PICK_MODE_CONTEXT *ctx, static void update_state_rt(VP9_COMP *cpi, const PICK_MODE_CONTEXT *ctx,
int mi_row, int mi_col, int bsize) { int mi_row, int mi_col, int bsize) {
int i;
VP9_COMMON *const cm = &cpi->common; VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb; MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd; MACROBLOCKD *const xd = &x->e_mbd;
...@@ -1480,14 +1474,8 @@ static void update_state_rt(VP9_COMP *cpi, const PICK_MODE_CONTEXT *ctx, ...@@ -1480,14 +1474,8 @@ static void update_state_rt(VP9_COMP *cpi, const PICK_MODE_CONTEXT *ctx,
vp9_init_plane_quantizers(cpi, x); vp9_init_plane_quantizers(cpi, x);
} }
if (is_inter_block(mbmi)) { if (is_inter_block(mbmi)) {
if (mbmi->sb_type < BLOCK_8X8 || mbmi->mode == NEWMV) { vp9_update_mv_count(cm, xd);
MV best_mv[2];
for (i = 0; i < 1 + has_second_ref(mbmi); ++i)
best_mv[i] = mbmi->ref_mvs[mbmi->ref_frame[i]][0].as_mv;
vp9_update_mv_count(cm, xd, best_mv);
}
if (cm->interp_filter == SWITCHABLE) { if (cm->interp_filter == SWITCHABLE) {
const int pred_ctx = vp9_get_pred_context_switchable_interp(xd); const int pred_ctx = vp9_get_pred_context_switchable_interp(xd);
......
...@@ -229,22 +229,21 @@ void vp9_build_nmv_cost_table(int *mvjoint, int *mvcost[2], ...@@ -229,22 +229,21 @@ void vp9_build_nmv_cost_table(int *mvjoint, int *mvcost[2],
build_nmv_component_cost_table(mvcost[1], &ctx->comps[1], usehp); 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) { nmv_context_counts *counts) {
int i; int i;
for (i = 0; i < 1 + is_compound; ++i) {
const MV diff = { mv[i].as_mv.row - ref[i].row, for (i = 0; i < 1 + has_second_ref(mbmi); ++i) {
mv[i].as_mv.col - ref[i].col }; 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); vp9_inc_mv(&diff, counts);
} }
} }
void vp9_update_mv_count(VP9_COMMON *cm, const MACROBLOCKD *xd, 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]; const MODE_INFO *mi = xd->mi_8x8[0];
const MB_MODE_INFO *const mbmi = &mi->mbmi; 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) { if (mbmi->sb_type < BLOCK_8X8) {
const int num_4x4_w = num_4x4_blocks_wide_lookup[mbmi->sb_type]; const int num_4x4_w = num_4x4_blocks_wide_lookup[mbmi->sb_type];
...@@ -255,11 +254,12 @@ void vp9_update_mv_count(VP9_COMMON *cm, const MACROBLOCKD *xd, ...@@ -255,11 +254,12 @@ void vp9_update_mv_count(VP9_COMMON *cm, const MACROBLOCKD *xd,
for (idx = 0; idx < 2; idx += num_4x4_w) { for (idx = 0; idx < 2; idx += num_4x4_w) {
const int i = idy * 2 + idx; const int i = idy * 2 + idx;
if (mi->bmi[i].as_mode == NEWMV) 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) { } else {
inc_mvs(mbmi->mv, best_ref_mv, is_compound, counts); if (mbmi->mode == NEWMV)
inc_mvs(mbmi, mbmi->mv, &cm->counts.mv);
} }
} }
...@@ -28,8 +28,7 @@ void vp9_encode_mv(VP9_COMP *cpi, vp9_writer* w, const MV* mv, const MV* ref, ...@@ -28,8 +28,7 @@ void vp9_encode_mv(VP9_COMP *cpi, vp9_writer* w, const MV* mv, const MV* ref,
void vp9_build_nmv_cost_table(int *mvjoint, int *mvcost[2], void vp9_build_nmv_cost_table(int *mvjoint, int *mvcost[2],
const nmv_context* mvctx, int usehp); const nmv_context* mvctx, int usehp);
void vp9_update_mv_count(VP9_COMMON *cm, const MACROBLOCKD *xd, void vp9_update_mv_count(VP9_COMMON *cm, const MACROBLOCKD *xd);
const MV best_ref_mv[2]);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
......
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