Merge "Cleaning up vp9_update_nmv_count function."
This commit is contained in:
@@ -431,19 +431,19 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
|
|||||||
cpi->mode_chosen_counts[mb_mode_index]++;
|
cpi->mode_chosen_counts[mb_mode_index]++;
|
||||||
if (is_inter_block(mbmi)
|
if (is_inter_block(mbmi)
|
||||||
&& (mbmi->sb_type < BLOCK_8X8 || mbmi->mode == NEWMV)) {
|
&& (mbmi->sb_type < BLOCK_8X8 || mbmi->mode == NEWMV)) {
|
||||||
int_mv best_mv, best_second_mv;
|
int_mv best_mv[2];
|
||||||
const MV_REFERENCE_FRAME rf1 = mbmi->ref_frame[0];
|
const MV_REFERENCE_FRAME rf1 = mbmi->ref_frame[0];
|
||||||
const MV_REFERENCE_FRAME rf2 = mbmi->ref_frame[1];
|
const MV_REFERENCE_FRAME rf2 = mbmi->ref_frame[1];
|
||||||
best_mv.as_int = ctx->best_ref_mv.as_int;
|
best_mv[0].as_int = ctx->best_ref_mv.as_int;
|
||||||
best_second_mv.as_int = ctx->second_best_ref_mv.as_int;
|
best_mv[1].as_int = ctx->second_best_ref_mv.as_int;
|
||||||
if (mbmi->mode == NEWMV) {
|
if (mbmi->mode == NEWMV) {
|
||||||
best_mv.as_int = mbmi->ref_mvs[rf1][0].as_int;
|
best_mv[0].as_int = mbmi->ref_mvs[rf1][0].as_int;
|
||||||
if (rf2 > 0)
|
if (rf2 > 0)
|
||||||
best_second_mv.as_int = mbmi->ref_mvs[rf2][0].as_int;
|
best_mv[1].as_int = mbmi->ref_mvs[rf2][0].as_int;
|
||||||
}
|
}
|
||||||
mbmi->best_mv[0].as_int = best_mv.as_int;
|
mbmi->best_mv[0].as_int = best_mv[0].as_int;
|
||||||
mbmi->best_mv[1].as_int = best_second_mv.as_int;
|
mbmi->best_mv[1].as_int = best_mv[1].as_int;
|
||||||
vp9_update_nmv_count(cpi, x, &best_mv, &best_second_mv);
|
vp9_update_mv_count(cpi, x, best_mv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cm->mcomp_filter_type == SWITCHABLE && is_inter_mode(mbmi->mode)) {
|
if (cm->mcomp_filter_type == SWITCHABLE && is_inter_mode(mbmi->mode)) {
|
||||||
|
@@ -314,44 +314,34 @@ void vp9_build_nmv_cost_table(int *mvjoint,
|
|||||||
build_nmv_component_cost_table(mvcost[1], &mvctx->comps[1], usehp);
|
build_nmv_component_cost_table(mvcost[1], &mvctx->comps[1], usehp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vp9_update_nmv_count(VP9_COMP *cpi, MACROBLOCK *x,
|
static void inc_mvs(int_mv mv[2], int_mv ref[2], int is_compound,
|
||||||
int_mv *best_ref_mv, int_mv *second_best_ref_mv) {
|
nmv_context_counts *counts) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 1 + is_compound; ++i) {
|
||||||
|
const MV diff = { mv[i].as_mv.row - ref[i].as_mv.row,
|
||||||
|
mv[i].as_mv.col - ref[i].as_mv.col };
|
||||||
|
vp9_inc_mv(&diff, counts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vp9_update_mv_count(VP9_COMP *cpi, MACROBLOCK *x, int_mv best_ref_mv[2]) {
|
||||||
MODE_INFO *mi = x->e_mbd.mi_8x8[0];
|
MODE_INFO *mi = x->e_mbd.mi_8x8[0];
|
||||||
MB_MODE_INFO *const mbmi = &mi->mbmi;
|
MB_MODE_INFO *const mbmi = &mi->mbmi;
|
||||||
MV diff;
|
const int is_compound = has_second_ref(mbmi);
|
||||||
const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[mbmi->sb_type];
|
|
||||||
const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[mbmi->sb_type];
|
|
||||||
int idx, idy;
|
|
||||||
|
|
||||||
if (mbmi->sb_type < BLOCK_8X8) {
|
if (mbmi->sb_type < BLOCK_8X8) {
|
||||||
PARTITION_INFO *pi = x->partition_info;
|
const int num_4x4_w = num_4x4_blocks_wide_lookup[mbmi->sb_type];
|
||||||
for (idy = 0; idy < 2; idy += num_4x4_blocks_high) {
|
const int num_4x4_h = num_4x4_blocks_high_lookup[mbmi->sb_type];
|
||||||
for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) {
|
int idx, idy;
|
||||||
const int i = idy * 2 + idx;
|
|
||||||
if (pi->bmi[i].mode == NEWMV) {
|
|
||||||
diff.row = mi->bmi[i].as_mv[0].as_mv.row - best_ref_mv->as_mv.row;
|
|
||||||
diff.col = mi->bmi[i].as_mv[0].as_mv.col - best_ref_mv->as_mv.col;
|
|
||||||
vp9_inc_mv(&diff, &cpi->NMVcount);
|
|
||||||
|
|
||||||
if (mi->mbmi.ref_frame[1] > INTRA_FRAME) {
|
for (idy = 0; idy < 2; idy += num_4x4_h) {
|
||||||
diff.row = mi->bmi[i].as_mv[1].as_mv.row -
|
for (idx = 0; idx < 2; idx += num_4x4_w) {
|
||||||
second_best_ref_mv->as_mv.row;
|
const int i = idy * 2 + idx;
|
||||||
diff.col = mi->bmi[i].as_mv[1].as_mv.col -
|
if (x->partition_info->bmi[i].mode == NEWMV)
|
||||||
second_best_ref_mv->as_mv.col;
|
inc_mvs(mi->bmi[i].as_mv, best_ref_mv, is_compound, &cpi->NMVcount);
|
||||||
vp9_inc_mv(&diff, &cpi->NMVcount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mbmi->mode == NEWMV) {
|
} else if (mbmi->mode == NEWMV) {
|
||||||
diff.row = mbmi->mv[0].as_mv.row - best_ref_mv->as_mv.row;
|
inc_mvs(mbmi->mv, best_ref_mv, is_compound, &cpi->NMVcount);
|
||||||
diff.col = mbmi->mv[0].as_mv.col - best_ref_mv->as_mv.col;
|
|
||||||
vp9_inc_mv(&diff, &cpi->NMVcount);
|
|
||||||
|
|
||||||
if (mbmi->ref_frame[1] > INTRA_FRAME) {
|
|
||||||
diff.row = mbmi->mv[1].as_mv.row - second_best_ref_mv->as_mv.row;
|
|
||||||
diff.col = mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col;
|
|
||||||
vp9_inc_mv(&diff, &cpi->NMVcount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ void vp9_build_nmv_cost_table(int *mvjoint,
|
|||||||
int usehp,
|
int usehp,
|
||||||
int mvc_flag_v,
|
int mvc_flag_v,
|
||||||
int mvc_flag_h);
|
int mvc_flag_h);
|
||||||
void vp9_update_nmv_count(VP9_COMP *cpi, MACROBLOCK *x,
|
|
||||||
int_mv *best_ref_mv, int_mv *second_best_ref_mv);
|
void vp9_update_mv_count(VP9_COMP *cpi, MACROBLOCK *x, int_mv best_ref_mv[2]);
|
||||||
|
|
||||||
#endif // VP9_ENCODER_VP9_ENCODEMV_H_
|
#endif // VP9_ENCODER_VP9_ENCODEMV_H_
|
||||||
|
Reference in New Issue
Block a user