From: Jingning Han Date: Tue, 3 May 2016 23:42:08 +0000 (-0700) Subject: Unify the per directional filter type system for compound modes X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4677e1a718a0ba28a0d485469c70e08db4c45303;p=libvpx Unify the per directional filter type system for compound modes For the current stage, we assume a single prediction filter type per direction in the settings of compound inter prediction modes. Change-Id: I12a1afdd364b93fcee870bd11ad01fc40ab48cff --- diff --git a/vp10/decoder/decodemv.c b/vp10/decoder/decodemv.c index fd14ef590..a92af27e9 100644 --- a/vp10/decoder/decodemv.c +++ b/vp10/decoder/decodemv.c @@ -1617,15 +1617,20 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi, #endif // CONFIG_EXT_INTER #if CONFIG_DUAL_FILTER - for (ref = 0; ref < 4; ++ref) { - const int frame_idx = (ref >> 1); + for (ref = 0; ref < 2; ++ref) { mbmi->interp_filter[ref] = (cm->interp_filter == SWITCHABLE) ? EIGHTTAP_REGULAR : cm->interp_filter; - if (mbmi->ref_frame[frame_idx] > INTRA_FRAME && - has_subpel_mv_component(xd, ref)) + if (has_subpel_mv_component(xd, ref) || + (mbmi->ref_frame[1] > INTRA_FRAME && + has_subpel_mv_component(xd, ref + 2))) mbmi->interp_filter[ref] = read_interp_filter(cm, xd, ref, r); } + // The index system worsk as: + // (0, 1) -> (vertical, horizontal) filter types for the first ref frame. + // (2, 3) -> (vertical, horizontal) filter types for the second ref frame. + mbmi->interp_filter[2] = mbmi->interp_filter[0]; + mbmi->interp_filter[3] = mbmi->interp_filter[1]; #else #if CONFIG_EXT_INTERP mbmi->interp_filter = read_interp_filter(cm, xd, r); diff --git a/vp10/encoder/bitstream.c b/vp10/encoder/bitstream.c index 4f8e89c56..9c07051af 100644 --- a/vp10/encoder/bitstream.c +++ b/vp10/encoder/bitstream.c @@ -938,10 +938,10 @@ static void write_switchable_interp_filter(VP10_COMP *cpi, #endif // CONFIG_DUAL_FILTER #endif // CONFIG_EXT_INTERP #if CONFIG_DUAL_FILTER - for (dir = 0; dir < 4; ++dir) { - const int frame_idx = (dir >> 1); - if (mbmi->ref_frame[frame_idx] > INTRA_FRAME && - has_subpel_mv_component(xd, dir)) { + for (dir = 0; dir < 2; ++dir) { + if (has_subpel_mv_component(xd, dir) || + (mbmi->ref_frame[1] > INTRA_FRAME && + has_subpel_mv_component(xd, dir + 2))) { const int ctx = vp10_get_pred_context_switchable_interp(xd, dir); vp10_write_token(w, vp10_switchable_interp_tree, cm->fc->switchable_interp_prob[ctx], diff --git a/vp10/encoder/encodeframe.c b/vp10/encoder/encodeframe.c index ec8e9b30f..d78d19906 100644 --- a/vp10/encoder/encodeframe.c +++ b/vp10/encoder/encodeframe.c @@ -1023,12 +1023,13 @@ static void choose_partitioning(VP10_COMP *const cpi, static void reset_intmv_filter_type(VP10_COMMON *cm, MACROBLOCKD *xd, MB_MODE_INFO *mbmi) { int dir; - for (dir = 0; dir < 4; ++dir) { - const int frame_idx = (dir >> 1); - if (mbmi->ref_frame[frame_idx] > INTRA_FRAME && - !has_subpel_mv_component(xd, dir)) + for (dir = 0; dir < 2; ++dir) { + if (!has_subpel_mv_component(xd, dir) && + (mbmi->ref_frame[1] == NONE || + !has_subpel_mv_component(xd, dir + 2))) mbmi->interp_filter[dir] = (cm->interp_filter == SWITCHABLE) ? EIGHTTAP_REGULAR : cm->interp_filter; + mbmi->interp_filter[dir + 2] = mbmi->interp_filter[dir]; } } @@ -1036,10 +1037,10 @@ static void update_filter_type_count(FRAME_COUNTS *counts, const MACROBLOCKD *xd, const MB_MODE_INFO *mbmi) { int dir; - for (dir = 0; dir < 4; ++dir) { - const int frame_idx = (dir >> 1); - if (mbmi->ref_frame[frame_idx] > INTRA_FRAME && - has_subpel_mv_component(xd, dir)) { + for (dir = 0; dir < 2; ++dir) { + if (has_subpel_mv_component(xd, dir) || + (mbmi->ref_frame[1] > INTRA_FRAME && + has_subpel_mv_component(xd, dir + 2))) { const int ctx = vp10_get_pred_context_switchable_interp(xd, dir); ++counts->switchable_interp[ctx][mbmi->interp_filter[dir]]; } diff --git a/vp10/encoder/rd.c b/vp10/encoder/rd.c index f935e3537..0d91fbd6c 100644 --- a/vp10/encoder/rd.c +++ b/vp10/encoder/rd.c @@ -729,10 +729,10 @@ int vp10_get_switchable_rate(const VP10_COMP *cpi, int inter_filter_cost = 0; int dir; - for (dir = 0; dir < 4; ++dir) { - const int frame_idx = (dir >> 1); - if (mbmi->ref_frame[frame_idx] > INTRA_FRAME && - has_subpel_mv_component(xd, dir)) { + for (dir = 0; dir < 2; ++dir) { + if (has_subpel_mv_component(xd, dir) || + (mbmi->ref_frame[1] > INTRA_FRAME && + has_subpel_mv_component(xd, dir + 2))) { const int ctx = vp10_get_pred_context_switchable_interp(xd, dir); inter_filter_cost += cpi->switchable_interp_costs[ctx][mbmi->interp_filter[dir]]; diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c index d9bf8fea7..3fdee6d2a 100644 --- a/vp10/encoder/rdopt.c +++ b/vp10/encoder/rdopt.c @@ -10116,6 +10116,9 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi, if (cm->interp_filter != BILINEAR) { #if CONFIG_DUAL_FILTER tmp_best_filter[0] = EIGHTTAP_REGULAR; + tmp_best_filter[1] = EIGHTTAP_REGULAR; + tmp_best_filter[2] = EIGHTTAP_REGULAR; + tmp_best_filter[3] = EIGHTTAP_REGULAR; #else tmp_best_filter = EIGHTTAP_REGULAR; #endif