diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h index aef20f272740f9ccce99d31d0ed65050454e5dec..b7263832279dbc9d0fb07502a7b6d639964527c1 100644 --- a/vp9/encoder/vp9_block.h +++ b/vp9/encoder/vp9_block.h @@ -112,7 +112,7 @@ struct macroblock { int quant_fp; // skip forward transform and quantization - int skip_txfm[MAX_MB_PLANE << 2]; + uint8_t skip_txfm[MAX_MB_PLANE << 2]; int64_t bsse[MAX_MB_PLANE << 2]; diff --git a/vp9/encoder/vp9_context_tree.h b/vp9/encoder/vp9_context_tree.h index fccdaf5de805a62542fb2baa87a4adb1162e2205..236389b6f9d84a9a1c452f237ad404e3318e15fd 100644 --- a/vp9/encoder/vp9_context_tree.h +++ b/vp9/encoder/vp9_context_tree.h @@ -36,7 +36,7 @@ typedef struct { // For current partition, only if all Y, U, and V transform blocks' // coefficients are quantized to 0, skippable is set to 0. int skippable; - int skip_txfm[MAX_MB_PLANE << 2]; + uint8_t skip_txfm[MAX_MB_PLANE << 2]; int best_mode_index; int hybrid_pred_diff; int comp_pred_diff; diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index 9651ceef50fa544af98e0a4f0a7a4d56203ec34d..eee6ffe1305fc93951f3ef9471474d5ac1c97b74 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -423,7 +423,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, VP9_ALT_FLAG }; int64_t best_rd = INT64_MAX; int64_t this_rd = INT64_MAX; - int skip_txfm = 0; + uint8_t skip_txfm = 0; int rate = INT_MAX; int64_t dist = INT64_MAX; // var_y and sse_y are saved to be used in skipping checking diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 9af6a0c943add493337c1e1f1b961d60fe43050d..a70669f84e6dacd1cd4cd2eb7ffc069383babfa9 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -2130,6 +2130,8 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, int_mv (*mode_mv)[MAX_REF_FRAMES], int mi_row, int mi_col, int_mv single_newmv[MAX_REF_FRAMES], + INTERP_FILTER (*single_filter)[MAX_REF_FRAMES], + int (*single_skippable)[MAX_REF_FRAMES], int64_t *psse, const int64_t ref_best_rd) { VP9_COMMON *cm = &cpi->common; @@ -2153,7 +2155,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, int orig_dst_stride[MAX_MB_PLANE]; int rs = 0; INTERP_FILTER best_filter = SWITCHABLE; - int skip_txfm[MAX_MB_PLANE << 2] = {0}; + uint8_t skip_txfm[MAX_MB_PLANE << 2] = {0}; int64_t bsse[MAX_MB_PLANE << 2] = {0}; int bsl = mi_width_log2_lookup[bsize]; @@ -2176,6 +2178,12 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, if (frame_mv[refs[0]].as_int == INVALID_MV || frame_mv[refs[1]].as_int == INVALID_MV) return INT64_MAX; + + if (cpi->sf.adaptive_mode_search) { + if (single_filter[this_mode][refs[0]] == + single_filter[this_mode][refs[1]]) + best_filter = single_filter[this_mode][refs[0]]; + } } if (this_mode == NEWMV) { @@ -2365,8 +2373,19 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, vp9_build_inter_predictors_sb(xd, mi_row, mi_col, bsize); model_rd_for_sb(cpi, bsize, x, xd, &tmp_rate, &tmp_dist); rd = RDCOST(x->rdmult, x->rddiv, rs + tmp_rate, tmp_dist); + vpx_memcpy(skip_txfm, x->skip_txfm, sizeof(skip_txfm)); + vpx_memcpy(bsse, x->bsse, sizeof(bsse)); } + if (!is_comp_pred) + single_filter[this_mode][refs[0]] = mbmi->interp_filter; + + if (cpi->sf.adaptive_mode_search) + if (is_comp_pred) + if (single_skippable[this_mode][refs[0]] && + single_skippable[this_mode][refs[1]]) + vpx_memset(skip_txfm, 1, sizeof(skip_txfm)); + if (cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) { // if current pred_error modeled rd is substantially more than the best // so far, do not bother doing full rd @@ -2426,6 +2445,9 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, *skippable = skippable_y && skippable_uv; } + if (!is_comp_pred) + single_skippable[this_mode][refs[0]] = *skippable; + restore_dst_buf(xd, orig_dst, orig_dst_stride); return this_rd; // if 0, this will be re-calculated by caller } @@ -2532,10 +2554,12 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, PREDICTION_MODE this_mode; MV_REFERENCE_FRAME ref_frame, second_ref_frame; unsigned char segment_id = mbmi->segment_id; - int comp_pred, i; + int comp_pred, i, k; int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES]; struct buf_2d yv12_mb[4][MAX_MB_PLANE]; int_mv single_newmv[MAX_REF_FRAMES] = { { 0 } }; + INTERP_FILTER single_inter_filter[MB_MODE_COUNT][MAX_REF_FRAMES]; + int single_skippable[MB_MODE_COUNT][MAX_REF_FRAMES]; static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG, VP9_ALT_FLAG }; int64_t best_rd = best_rd_so_far; @@ -2584,6 +2608,12 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, rate_uv_intra[i] = INT_MAX; for (i = 0; i < MAX_REF_FRAMES; ++i) x->pred_sse[i] = INT_MAX; + for (i = 0; i < MB_MODE_COUNT; ++i) { + for (k = 0; k < MAX_REF_FRAMES; ++k) { + single_inter_filter[i][k] = SWITCHABLE; + single_skippable[i][k] = 0; + } + } *returnrate = INT_MAX; @@ -2866,7 +2896,8 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, &rate_uv, &distortion_uv, &disable_skip, frame_mv, mi_row, mi_col, - single_newmv, &total_sse, best_rd); + single_newmv, single_inter_filter, + single_skippable, &total_sse, best_rd); if (this_rd == INT64_MAX) continue;