From 393a8ccef9384e84490b1c7f940b5f87408e94b4 Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Mon, 6 Jan 2014 13:29:16 -0800 Subject: [PATCH] Remove avoid_frame_with_high_error from RD loop The feature undergoes prior assumption that the recursive partition size search from 4x4 to 64x64, hence utilizing information from small blocks to determine early termination in large block rate-distortion optimization search. The current codebase is now going from top down. The previous function might go with not properly initialized values, hence removed. Tested on pedestrian_area_1080p at 4000 kbps running under speed 2. No visible difference in runtime observed. Change-Id: I553df415c6191413762db7ae34e8790c71d8118e --- vp9/encoder/vp9_block.h | 3 -- vp9/encoder/vp9_onyx_if.c | 2 -- vp9/encoder/vp9_onyx_int.h | 1 - vp9/encoder/vp9_rdopt.c | 63 -------------------------------------- 4 files changed, 69 deletions(-) diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h index 374f42923..c011948b9 100644 --- a/vp9/encoder/vp9_block.h +++ b/vp9/encoder/vp9_block.h @@ -62,9 +62,6 @@ typedef struct { // Bit flag for each mode whether it has high error in comparison to others. unsigned int modes_with_high_error; - - // Bit flag for each ref frame whether it has high error compared to others. - unsigned int frames_with_high_error; } PICK_MODE_CONTEXT; struct macroblock_plane { diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 2e34b4a78..831f9f592 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -624,7 +624,6 @@ void vp9_set_speed_features(VP9_COMP *cpi) { sf->use_lp32x32fdct = 0; sf->adaptive_motion_search = 0; sf->adaptive_pred_filter_type = 0; - sf->use_avoid_tested_higherror = 0; sf->reference_masking = 0; sf->use_one_partition_size_always = 0; sf->less_rectangular_check = 0; @@ -669,7 +668,6 @@ void vp9_set_speed_features(VP9_COMP *cpi) { #else sf->static_segmentation = 0; #endif - sf->use_avoid_tested_higherror = 1; sf->adaptive_rd_thresh = 1; sf->recode_loop = (speed < 1); diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h index d32711c32..b4e043b33 100644 --- a/vp9/encoder/vp9_onyx_int.h +++ b/vp9/encoder/vp9_onyx_int.h @@ -252,7 +252,6 @@ typedef struct { LAST_FRAME_PARTITION_METHOD use_lastframe_partitioning; TX_SIZE_SEARCH_METHOD tx_size_search_method; int use_lp32x32fdct; - int use_avoid_tested_higherror; int use_one_partition_size_always; int less_rectangular_check; int use_square_partition_only; diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index 46fe16347..e9bb5b575 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -3136,7 +3136,6 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, int64_t best_filter_rd[SWITCHABLE_FILTER_CONTEXTS]; int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS]; MB_MODE_INFO best_mbmode = { 0 }; - int j; int mode_index, best_mode_index = 0; unsigned int ref_costs_single[MAX_REF_FRAMES], ref_costs_comp[MAX_REF_FRAMES]; vp9_prob comp_mode_p; @@ -3149,10 +3148,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, int64_t dist_uv[TX_SIZES]; int skip_uv[TX_SIZES]; MB_PREDICTION_MODE mode_uv[TX_SIZES]; - unsigned int ref_frame_mask = 0; - unsigned int mode_mask = 0; int64_t mode_distortions[MB_MODE_COUNT] = {-1}; - int64_t frame_distortions[MAX_REF_FRAMES] = {-1}; int intra_cost_penalty = 20 * vp9_dc_quant(cm->base_qindex, cm->y_dc_delta_q); const int bws = num_8x8_blocks_wide_lookup[bsize] / 2; const int bhs = num_8x8_blocks_high_lookup[bsize] / 2; @@ -3161,7 +3157,6 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, x->skip_encode = cpi->sf.skip_encode_frame && x->q_index < QIDX_SKIP_THRESH; // Everywhere the flag is set the error is much higher than its neighbors. - ctx->frames_with_high_error = 0; ctx->modes_with_high_error = 0; estimate_ref_frame_costs(cpi, segment_id, ref_costs_single, ref_costs_comp, @@ -3180,39 +3175,6 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, *returnrate = INT_MAX; - // Create a mask set to 1 for each reference frame used by a smaller - // resolution. - if (cpi->sf.use_avoid_tested_higherror) { - switch (block_size) { - case BLOCK_64X64: - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - ref_frame_mask |= x->mb_context[i][j].frames_with_high_error; - mode_mask |= x->mb_context[i][j].modes_with_high_error; - } - } - for (i = 0; i < 4; i++) { - ref_frame_mask |= x->sb32_context[i].frames_with_high_error; - mode_mask |= x->sb32_context[i].modes_with_high_error; - } - break; - case BLOCK_32X32: - for (i = 0; i < 4; i++) { - ref_frame_mask |= - x->mb_context[x->sb_index][i].frames_with_high_error; - mode_mask |= x->mb_context[x->sb_index][i].modes_with_high_error; - } - break; - default: - // Until we handle all block sizes set it to present; - ref_frame_mask = 0; - mode_mask = 0; - break; - } - ref_frame_mask = ~ref_frame_mask; - mode_mask = ~mode_mask; - } - for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) { x->pred_mv_sad[ref_frame] = INT_MAX; if (cpi->ref_frame_flags & flag_list[ref_frame]) { @@ -3295,19 +3257,6 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, if (x->fast_ms > 2 && ref_frame != x->subblock_ref) continue; - if (cpi->sf.use_avoid_tested_higherror && bsize >= BLOCK_8X8) { - if (!(ref_frame_mask & (1 << ref_frame))) { - continue; - } - if (!(mode_mask & (1 << this_mode))) { - continue; - } - if (second_ref_frame != NONE - && !(ref_frame_mask & (1 << second_ref_frame))) { - continue; - } - } - mbmi->ref_frame[0] = ref_frame; mbmi->ref_frame[1] = second_ref_frame; @@ -3556,10 +3505,6 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, || distortion2 < mode_distortions[this_mode]) { mode_distortions[this_mode] = distortion2; } - if (frame_distortions[ref_frame] == -1 - || distortion2 < frame_distortions[ref_frame]) { - frame_distortions[ref_frame] = distortion2; - } // Did this mode help.. i.e. is it the new best mode if (this_rd < best_rd || x->skip) { @@ -3712,14 +3657,6 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x, } } - // Flag all ref frames that have a distortion thats > 2x the best we found at - // this level. - for (ref_frame = INTRA_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) { - if (frame_distortions[ref_frame] > 2 * *returndistortion) { - ctx->frames_with_high_error |= (1 << ref_frame); - } - } - assert((cm->mcomp_filter_type == SWITCHABLE) || (cm->mcomp_filter_type == best_mbmode.interp_filter) || !is_inter_block(&best_mbmode)); -- 2.40.0