Commit 0d6980d7 authored by Jingning Han's avatar Jingning Han
Browse files

Remove swap buffer speed feature

The inter prediction residual can undergo different transform types
during the rate-distortion optimization search. The assumption used
in this speed feature no longer holds true. This commit removes the
related code to clean up the codebase and clear out unit test
failure in higher speed setting.

Change-Id: I7f7cd4df2345ed3e607c9fae75b38cd2dbde0cac
parent 33dafdb5
......@@ -4970,13 +4970,7 @@ static void encode_superblock(VP10_COMP *cpi, ThreadData *td,
const int mi_width = num_8x8_blocks_wide_lookup[bsize];
const int mi_height = num_8x8_blocks_high_lookup[bsize];
x->skip_recode = !x->select_tx_size && mbmi->sb_type >= BLOCK_8X8 &&
#if CONFIG_OBMC
!(is_inter_block(mbmi) && is_obmc_allowed(mbmi)) &&
#endif // CONFIG_OBMC
cpi->oxcf.aq_mode != COMPLEXITY_AQ &&
cpi->oxcf.aq_mode != CYCLIC_REFRESH_AQ &&
cpi->sf.allow_skip_recode;
x->skip_recode = 0;
if (!x->skip_recode)
memset(x->skip_txfm, 0, sizeof(x->skip_txfm));
......
......@@ -374,9 +374,6 @@ void vp10_initialize_rd_consts(VP10_COMP *cpi) {
set_error_per_bit(x, rd->RDMULT);
x->select_tx_size = (cpi->sf.tx_size_search_method == USE_LARGESTALL &&
cm->frame_type != KEY_FRAME) ? 0 : 1;
set_block_thresholds(cm, rd);
if (!frame_is_intra_only(cm)) {
......
......@@ -441,31 +441,6 @@ static INLINE int write_uniform_cost(int n, int v) {
return l * vp10_cost_bit(128, 0);
}
static void swap_block_ptr(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx,
int m, int n, int min_plane, int max_plane) {
int i;
for (i = min_plane; i < max_plane; ++i) {
struct macroblock_plane *const p = &x->plane[i];
struct macroblockd_plane *const pd = &x->e_mbd.plane[i];
p->coeff = ctx->coeff_pbuf[i][m];
p->qcoeff = ctx->qcoeff_pbuf[i][m];
pd->dqcoeff = ctx->dqcoeff_pbuf[i][m];
p->eobs = ctx->eobs_pbuf[i][m];
ctx->coeff_pbuf[i][m] = ctx->coeff_pbuf[i][n];
ctx->qcoeff_pbuf[i][m] = ctx->qcoeff_pbuf[i][n];
ctx->dqcoeff_pbuf[i][m] = ctx->dqcoeff_pbuf[i][n];
ctx->eobs_pbuf[i][m] = ctx->eobs_pbuf[i][n];
ctx->coeff_pbuf[i][n] = p->coeff;
ctx->qcoeff_pbuf[i][n] = p->qcoeff;
ctx->dqcoeff_pbuf[i][n] = pd->dqcoeff;
ctx->eobs_pbuf[i][n] = p->eobs;
}
}
// constants for prune 1 and prune 2 decision boundaries
#define FAST_EXT_TX_CORR_MID 0.0
#define FAST_EXT_TX_EDST_MID 0.1
......@@ -870,11 +845,9 @@ static void model_rd_for_sb(const VP10_COMP *const cpi, BLOCK_SIZE bsize,
int64_t dist_sum = 0;
const int ref = xd->mi[0]->mbmi.ref_frame[0];
unsigned int sse;
unsigned int var = 0;
unsigned int sum_sse = 0;
int64_t total_sse = 0;
int skip_flag = 1;
const int shift = 6;
int rate;
int64_t dist;
......@@ -886,12 +859,6 @@ static void model_rd_for_sb(const VP10_COMP *const cpi, BLOCK_SIZE bsize,
const BLOCK_SIZE bs = get_plane_block_size(bsize, pd);
const TX_SIZE max_tx_size = max_txsize_lookup[bs];
const BLOCK_SIZE unit_size = txsize_to_bsize[max_tx_size];
const int64_t dc_thr = p->quant_thred[0] >> shift;
const int64_t ac_thr = p->quant_thred[1] >> shift;
// The low thresholds are used to measure if the prediction errors are
// low enough so that we can skip the mode search.
const int64_t low_dc_thr = VPXMIN(50, dc_thr >> 2);
const int64_t low_ac_thr = VPXMIN(80, ac_thr >> 2);
int bw_shift = (b_width_log2_lookup[bs] - b_width_log2_lookup[unit_size]);
int bh_shift = (b_height_log2_lookup[bs] - b_width_log2_lookup[unit_size]);
int bw = 1 << bw_shift;
......@@ -909,26 +876,12 @@ static void model_rd_for_sb(const VP10_COMP *const cpi, BLOCK_SIZE bsize,
int block_idx = (idy << bw_shift) + idx;
int low_err_skip = 0;
var = cpi->fn_ptr[unit_size].vf(src, p->src.stride,
dst, pd->dst.stride, &sse);
cpi->fn_ptr[unit_size].vf(src, p->src.stride,
dst, pd->dst.stride, &sse);
x->bsse[i][block_idx] = sse;
sum_sse += sse;
x->skip_txfm[i][block_idx] = SKIP_TXFM_NONE;
if (!x->select_tx_size) {
// Check if all ac coefficients can be quantized to zero.
if (var < ac_thr || var == 0) {
x->skip_txfm[i][block_idx] = SKIP_TXFM_AC_ONLY;
// Check if dc coefficient can be quantized to zero.
if (sse - var < dc_thr || sse == var) {
x->skip_txfm[i][block_idx] = SKIP_TXFM_AC_DC;
if (!sse || (var < low_ac_thr && sse - var < low_dc_thr))
low_err_skip = 1;
}
}
}
if (skip_flag && !low_err_skip)
skip_flag = 0;
......@@ -3783,7 +3736,7 @@ static int super_block_uvrd(const VP10_COMP *cpi, MACROBLOCK *x,
}
static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x,
PICK_MODE_CONTEXT *ctx, int dc_mode_cost,
int dc_mode_cost,
PALETTE_MODE_INFO *palette_mode_info,
uint8_t *best_palette_color_map,
PREDICTION_MODE *mode_selected,
......@@ -3955,8 +3908,6 @@ static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x,
*distortion = this_distortion;
*rate_tokenonly = this_rate_tokenonly;
*skippable = s;
if (!x->select_tx_size)
swap_block_ptr(x, ctx, 2, 0, 1, MAX_MB_PLANE);
}
}
}
......@@ -3965,7 +3916,6 @@ static void rd_pick_palette_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x,
#if CONFIG_EXT_INTRA
// Return 1 if an ext intra mode is selected; return 0 otherwise.
static int rd_pick_ext_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x,
PICK_MODE_CONTEXT *ctx,
int *rate, int *rate_tokenonly,
int64_t *distortion, int *skippable,
BLOCK_SIZE bsize, int64_t *best_rd) {
......@@ -4001,8 +3951,6 @@ static int rd_pick_ext_intra_sbuv(VP10_COMP *cpi, MACROBLOCK *x,
*skippable = s;
ext_intra_mode_info = mbmi->ext_intra_mode_info;
ext_intra_selected_flag = 1;
if (!x->select_tx_size)
swap_block_ptr(x, ctx, 2, 0, 1, MAX_MB_PLANE);
}
}
......@@ -4046,7 +3994,6 @@ static void pick_intra_angle_routine_sbuv(VP10_COMP *cpi, MACROBLOCK *x,
}
static int rd_pick_intra_angle_sbuv(VP10_COMP *cpi, MACROBLOCK *x,
PICK_MODE_CONTEXT *ctx,
int *rate, int *rate_tokenonly,
int64_t *distortion, int *skippable,
BLOCK_SIZE bsize, int rate_overhead,
......@@ -4058,7 +4005,6 @@ static int rd_pick_intra_angle_sbuv(VP10_COMP *cpi, MACROBLOCK *x,
int angle_delta, best_angle_delta = 0;
const double rd_adjust = 1.2;
(void)ctx;
*rate_tokenonly = INT_MAX;
if (ANGLE_FAST_SEARCH) {
int deltas_level1[3] = {0, -2, 2};
......@@ -4121,7 +4067,6 @@ static int rd_pick_intra_angle_sbuv(VP10_COMP *cpi, MACROBLOCK *x,
#endif // CONFIG_EXT_INTRA
static int64_t rd_pick_intra_sbuv_mode(VP10_COMP *cpi, MACROBLOCK *x,
PICK_MODE_CONTEXT *ctx,
int *rate, int *rate_tokenonly,
int64_t *distortion, int *skippable,
BLOCK_SIZE bsize, TX_SIZE max_tx_size) {
......@@ -4160,7 +4105,7 @@ static int64_t rd_pick_intra_sbuv_mode(VP10_COMP *cpi, MACROBLOCK *x,
write_uniform_cost(2 * MAX_ANGLE_DELTAS + 1, 0);
mbmi->angle_delta[1] = 0;
if (mbmi->sb_type >= BLOCK_8X8 && is_directional_mode) {
if (!rd_pick_intra_angle_sbuv(cpi, x, ctx, &this_rate,
if (!rd_pick_intra_angle_sbuv(cpi, x, &this_rate,
&this_rate_tokenonly, &this_distortion, &s,
bsize, rate_overhead, best_rd))
continue;
......@@ -4201,14 +4146,12 @@ static int64_t rd_pick_intra_sbuv_mode(VP10_COMP *cpi, MACROBLOCK *x,
*rate_tokenonly = this_rate_tokenonly;
*distortion = this_distortion;
*skippable = s;
if (!x->select_tx_size)
swap_block_ptr(x, ctx, 2, 0, 1, MAX_MB_PLANE);
}
}
if (cpi->common.allow_screen_content_tools && mbmi->sb_type >= BLOCK_8X8) {
best_palette_color_map = x->palette_buffer->best_palette_color_map;
rd_pick_palette_intra_sbuv(cpi, x, ctx,
rd_pick_palette_intra_sbuv(cpi, x,
cpi->intra_uv_mode_cost[mbmi->mode][DC_PRED],
&palette_mode_info, best_palette_color_map,
&mode_selected, &best_rd, rate, rate_tokenonly,
......@@ -4217,7 +4160,7 @@ static int64_t rd_pick_intra_sbuv_mode(VP10_COMP *cpi, MACROBLOCK *x,
#if CONFIG_EXT_INTRA
if (mbmi->sb_type >= BLOCK_8X8 && ALLOW_FILTER_INTRA_MODES) {
if (rd_pick_ext_intra_sbuv(cpi, x, ctx, rate, rate_tokenonly, distortion,
if (rd_pick_ext_intra_sbuv(cpi, x, rate, rate_tokenonly, distortion,
skippable, bsize, &best_rd)) {
mode_selected = mbmi->uv_mode;
ext_intra_mode_info = mbmi->ext_intra_mode_info;
......@@ -4275,7 +4218,8 @@ static void choose_intra_uv_mode(VP10_COMP *cpi, MACROBLOCK *const x,
// Else do a proper rd search for each possible transform size that may
// be considered in the main rd loop.
} else {
rd_pick_intra_sbuv_mode(cpi, x, ctx,
(void)ctx;
rd_pick_intra_sbuv_mode(cpi, x,
rate_uv, rate_uv_tokenonly, dist_uv, skip_uv,
bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize, max_tx_size);
}
......@@ -8116,7 +8060,7 @@ void vp10_rd_pick_intra_mode_sb(VP10_COMP *cpi, MACROBLOCK *x,
max_uv_tx_size = get_uv_tx_size_impl(xd->mi[0]->mbmi.tx_size, bsize,
pd[1].subsampling_x,
pd[1].subsampling_y);
rd_pick_intra_sbuv_mode(cpi, x, ctx, &rate_uv, &rate_uv_tokenonly,
rd_pick_intra_sbuv_mode(cpi, x, &rate_uv, &rate_uv_tokenonly,
&dist_uv, &uv_skip, VPXMAX(BLOCK_8X8, bsize),
max_uv_tx_size);
......@@ -9420,7 +9364,6 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
// Did this mode help.. i.e. is it the new best mode
if (this_rd < best_rd || x->skip) {
int max_plane = MAX_MB_PLANE;
if (!mode_excluded) {
// Note index of best mode so far
best_mode_index = mode_index;
......@@ -9428,7 +9371,6 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
if (ref_frame == INTRA_FRAME) {
/* required for left and above block mv */
mbmi->mv[0].as_int = 0;
max_plane = 1;
} else {
best_pred_sse = x->pred_sse[ref_frame];
}
......@@ -9458,9 +9400,6 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
vp10_cost_bit(vp10_get_skip_prob(cm, xd), this_skip2 || skippable);
best_rate_uv = rate_uv;
if (!x->select_tx_size)
swap_block_ptr(x, ctx, 1, 0, 0, max_plane);
#if CONFIG_VAR_TX
for (i = 0; i < MAX_MB_PLANE; ++i)
memcpy(ctx->blk_skip[i], x->blk_skip[i],
......@@ -9710,10 +9649,8 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
}
this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
if (this_rd < best_rd) {
int max_plane = MAX_MB_PLANE;
best_mode_index = 3;
mbmi->mv[0].as_int = 0;
max_plane = 1;
rd_cost->rate = rate2;
#if CONFIG_SUPERTX
*returnrate_nocoef = best_rate_nocoef;
......@@ -9724,8 +9661,6 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
best_mbmode = *mbmi;
best_skip2 = 0;
best_mode_skippable = skippable;
if (!x->select_tx_size)
swap_block_ptr(x, ctx, 1, 0, 0, max_plane);
memcpy(ctx->zcoeff_blk, x->zcoeff_blk[mbmi->tx_size],
sizeof(ctx->zcoeff_blk[0]) * ctx->num_4x4_blk);
}
......@@ -9901,7 +9836,7 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
TX_SIZE uv_tx_size;
*mbmi = best_mbmode;
uv_tx_size = get_uv_tx_size(mbmi, &xd->plane[1]);
rd_pick_intra_sbuv_mode(cpi, x, ctx, &rate_uv_intra[uv_tx_size],
rd_pick_intra_sbuv_mode(cpi, x, &rate_uv_intra[uv_tx_size],
&rate_uv_tokenonly[uv_tx_size],
&dist_uv[uv_tx_size],
&skip_uv[uv_tx_size],
......@@ -9957,24 +9892,6 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
x->skip |= best_mode_skippable;
if (!x->skip && !x->select_tx_size) {
int has_high_freq_coeff = 0;
int plane;
int max_plane = is_inter_block(&xd->mi[0]->mbmi)
? MAX_MB_PLANE : 1;
for (plane = 0; plane < max_plane; ++plane) {
x->plane[plane].eobs = ctx->eobs_pbuf[plane][1];
has_high_freq_coeff |= vp10_has_high_freq_in_plane(x, bsize, plane);
}
for (plane = max_plane; plane < MAX_MB_PLANE; ++plane) {
x->plane[plane].eobs = ctx->eobs_pbuf[plane][2];
has_high_freq_coeff |= vp10_has_high_freq_in_plane(x, bsize, plane);
}
best_mode_skippable |= !has_high_freq_coeff;
}
assert(best_mode_index >= 0);
store_coding_context(x, ctx, best_mode_index, best_pred_diff,
......@@ -10113,8 +10030,6 @@ void vp10_rd_pick_inter_mode_sb_seg_skip(VP10_COMP *cpi,
vp10_zero(best_pred_diff);
if (!x->select_tx_size)
swap_block_ptr(x, ctx, 1, 0, 0, MAX_MB_PLANE);
store_coding_context(x, ctx, THR_ZEROMV,
best_pred_diff, 0);
}
......@@ -10801,14 +10716,12 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi,
// Did this mode help.. i.e. is it the new best mode
if (this_rd < best_rd || x->skip) {
if (!mode_excluded) {
int max_plane = MAX_MB_PLANE;
// Note index of best mode so far
best_ref_index = ref_index;
if (ref_frame == INTRA_FRAME) {
/* required for left and above block mv */
mbmi->mv[0].as_int = 0;
max_plane = 1;
}
rd_cost->rate = rate2;
......@@ -10828,8 +10741,6 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi,
RDCOST(x->rdmult, x->rddiv, rate_uv, distortion_uv);
best_mbmode = *mbmi;
best_skip2 = this_skip2;
if (!x->select_tx_size)
swap_block_ptr(x, ctx, 1, 0, 0, max_plane);
#if CONFIG_VAR_TX
for (i = 0; i < MAX_MB_PLANE; ++i)
......@@ -10911,7 +10822,7 @@ void vp10_rd_pick_inter_mode_sub8x8(struct VP10_COMP *cpi,
// Do Intra UV best rd mode selection if best mode choice above was intra.
if (best_mbmode.ref_frame[0] == INTRA_FRAME) {
*mbmi = best_mbmode;
rd_pick_intra_sbuv_mode(cpi, x, ctx, &rate_uv_intra,
rd_pick_intra_sbuv_mode(cpi, x, &rate_uv_intra,
&rate_uv_tokenonly,
&dist_uv,
&skip_uv,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment