From 9edd4d4db7e4c21e739cf2b78048cace8dc715aa Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Mon, 9 Dec 2013 17:02:38 -0800 Subject: [PATCH] Cleaning up vp9_get_pred_context_switchable_interp() functuion. Change-Id: I67a45a41312ca0efd8fe00ccd8bdc0f97675d09f --- vp9/common/vp9_pred_common.c | 41 +++++++++++++++-------------------------- vp9/common/vp9_pred_common.h | 2 +- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/vp9/common/vp9_pred_common.c b/vp9/common/vp9_pred_common.c index 24cdd5f..b16417d 100644 --- a/vp9/common/vp9_pred_common.c +++ b/vp9/common/vp9_pred_common.c @@ -25,37 +25,26 @@ static INLINE const MB_MODE_INFO *get_left_mbmi(const MODE_INFO *const left) { } // Returns a context number for the given MB prediction signal -unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd) { - const MODE_INFO *const above_mi = get_above_mi(xd); - const MODE_INFO *const left_mi = get_left_mi(xd); - const int above_in_image = above_mi != NULL; - const int left_in_image = left_mi != NULL; +int vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd) { // Note: // The mode info data structure has a one element border above and to the // left of the entries correpsonding to real macroblocks. // The prediction flags in these dummy entries are initialised to 0. - // left - const int left_mv_pred = left_in_image ? is_inter_block(&left_mi->mbmi) - : 0; - const int left_interp = left_in_image && left_mv_pred - ? left_mi->mbmi.interp_filter - : SWITCHABLE_FILTERS; - - // above - const int above_mv_pred = above_in_image ? is_inter_block(&above_mi->mbmi) - : 0; - const int above_interp = above_in_image && above_mv_pred - ? above_mi->mbmi.interp_filter - : SWITCHABLE_FILTERS; + const MODE_INFO *const left_mi = get_left_mi(xd); + const int has_left = left_mi != NULL ? is_inter_block(&left_mi->mbmi) : 0; + const int left_type = has_left ? left_mi->mbmi.interp_filter + : SWITCHABLE_FILTERS; - if (left_interp == above_interp) - return left_interp; - else if (left_interp == SWITCHABLE_FILTERS && - above_interp != SWITCHABLE_FILTERS) - return above_interp; - else if (left_interp != SWITCHABLE_FILTERS && - above_interp == SWITCHABLE_FILTERS) - return left_interp; + const MODE_INFO *const above_mi = get_above_mi(xd); + const int has_above = above_mi != NULL ? is_inter_block(&above_mi->mbmi) : 0; + const int above_type = has_above ? above_mi->mbmi.interp_filter + : SWITCHABLE_FILTERS; + if (left_type == above_type) + return left_type; + else if (left_type == SWITCHABLE_FILTERS && above_type != SWITCHABLE_FILTERS) + return above_type; + else if (left_type != SWITCHABLE_FILTERS && above_type == SWITCHABLE_FILTERS) + return left_type; else return SWITCHABLE_FILTERS; } diff --git a/vp9/common/vp9_pred_common.h b/vp9/common/vp9_pred_common.h index a238489..49d2ffd 100644 --- a/vp9/common/vp9_pred_common.h +++ b/vp9/common/vp9_pred_common.h @@ -59,7 +59,7 @@ static INLINE unsigned char vp9_get_pred_flag_mbskip(const MACROBLOCKD *xd) { return xd->mi_8x8[0]->mbmi.skip_coeff; } -unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd); +int vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd); int vp9_get_intra_inter_context(const MACROBLOCKD *xd); -- 2.7.4