From 61a47da869a3f507e446caa19ac0209fcbb475fe Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Wed, 24 Apr 2013 12:14:58 -0700 Subject: [PATCH] Adding is_inter_mode function. Change-Id: I2d32d46002cb92c63050c2b8328865c406103621 --- vp9/common/vp9_blockd.h | 5 +++++ vp9/common/vp9_pred_common.c | 6 ++---- vp9/decoder/vp9_decodemv.c | 2 +- vp9/encoder/vp9_bitstream.c | 2 +- vp9/encoder/vp9_encodeframe.c | 3 +-- vp9/encoder/vp9_rdopt.c | 4 ++-- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index b03e354f9..693fa4b0e 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -98,6 +98,11 @@ typedef enum { MB_MODE_COUNT } MB_PREDICTION_MODE; +static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) { + return mode >= NEARESTMV && mode <= SPLITMV; +} + + // Segment level features. typedef enum { SEG_LVL_ALT_Q = 0, // Use alternate Quantizer .... diff --git a/vp9/common/vp9_pred_common.c b/vp9/common/vp9_pred_common.c index c12920c4d..882b56f0c 100644 --- a/vp9/common/vp9_pred_common.c +++ b/vp9/common/vp9_pred_common.c @@ -59,16 +59,14 @@ unsigned char vp9_get_pred_context(const VP9_COMMON *const cm, case PRED_SWITCHABLE_INTERP: { // left const int left_in_image = xd->left_available && left_mi->mbmi.mb_in_image; - const int left_mv_pred = left_mi->mbmi.mode >= NEARESTMV && - left_mi->mbmi.mode <= SPLITMV; + const int left_mv_pred = is_inter_mode(left_mi->mbmi.mode); const int left_interp = left_in_image && left_mv_pred ? vp9_switchable_interp_map[left_mi->mbmi.interp_filter] : VP9_SWITCHABLE_FILTERS; // above const int above_in_image = xd->up_available && above_mi->mbmi.mb_in_image; - const int above_mv_pred = above_mi->mbmi.mode >= NEARESTMV && - above_mi->mbmi.mode <= SPLITMV; + const int above_mv_pred = is_inter_mode(above_mi->mbmi.mode); const int above_interp = above_in_image && above_mv_pred ? vp9_switchable_interp_map[above_mi->mbmi.interp_filter] : VP9_SWITCHABLE_FILTERS; diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 65e81b997..e00e95155 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -692,7 +692,7 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, #endif } - if (mbmi->mode >= NEARESTMV && mbmi->mode <= SPLITMV) { + if (is_inter_mode(mbmi->mode)) { mbmi->interp_filter = cm->mcomp_filter_type == SWITCHABLE ? read_switchable_filter_type(pbi, r) : cm->mcomp_filter_type; diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index 62ee0bb12..870d9d41b 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -794,7 +794,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_accum_mv_refs(&cpi->common, mode, mi->mb_mode_context[rf]); } - if (mode >= NEARESTMV && mode <= SPLITMV) { + if (is_inter_mode(mode)) { if (cpi->common.mcomp_filter_type == SWITCHABLE) { write_token(bc, vp9_switchable_interp_tree, vp9_get_pred_probs(&cpi->common, xd, diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 65e6b18ea..0fd785f5a 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -505,8 +505,7 @@ static void update_state(VP9_COMP *cpi, } #endif if (cpi->common.mcomp_filter_type == SWITCHABLE && - mbmi->mode >= NEARESTMV && - mbmi->mode <= SPLITMV) { + is_inter_mode(mbmi->mode)) { ++cpi->switchable_interp_count [vp9_get_pred_context(&cpi->common, xd, PRED_SWITCHABLE_INTERP)] [vp9_switchable_interp_map[mbmi->interp_filter]]; diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index c448ce596..df71ad30f 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -4042,7 +4042,7 @@ static void rd_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, // Accumulate filter usage stats // TODO(agrange): Use RD criteria to select interpolation filter mode. - if ((best_mode >= NEARESTMV) && (best_mode <= SPLITMV)) + if (is_inter_mode(best_mode)) ++cpi->best_switchable_interp_count[vp9_switchable_interp_map[best_filter]]; // Reduce the activation RD thresholds for the best choice mode @@ -4852,7 +4852,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, // Accumulate filter usage stats // TODO(agrange): Use RD criteria to select interpolation filter mode. - if ((best_mode >= NEARESTMV) && (best_mode <= SPLITMV)) + if (is_inter_mode(best_mode)) ++cpi->best_switchable_interp_count[vp9_switchable_interp_map[best_filter]]; // TODO(rbultje) integrate with RD thresholding