Commit 792c2ec4 authored by Sarah Parker's avatar Sarah Parker
Browse files

Merge FINAL_PASS_TRELLIS_OPT with DISABLE_TRELLISQ_SEARCH

The speed feature FINAL_PASS_TRELLIS_OPT is meant to disable
optimize_b during the transform search but allow it for the
final encode of blocks. There was a previously existing macro
called DISABLE_TRELLISQ_SEARCH, which does the same thing. This
patch merges the functionality so the macro serves only to enable
the speed feature.

Change-Id: Ieee70f97f817998b7ca275f6e4647cc89a330ad6
parent 22fba1ff
......@@ -4437,10 +4437,6 @@ static void encode_superblock(const AV1_COMP *const cpi, TileDataEnc *tile_data,
const BLOCK_SIZE block_size = bsize;
const int num_planes = av1_num_planes(cm);
// Only optimize coefficients in the final encode
if (cpi->sf.optimize_coefficients == FINAL_PASS_TRELLIS_OPT)
x->optimize = (dry_run == OUTPUT_ENABLED);
if (!is_inter) {
#if CONFIG_CFL
xd->cfl.store_y = 1;
......@@ -4602,6 +4598,4 @@ static void encode_superblock(const AV1_COMP *const cpi, TileDataEnc *tile_data,
cfl_store_block(xd, mbmi->sb_type, mbmi->tx_size);
}
#endif // CONFIG_CFL
// Turn optimize back off for next block
if (cpi->sf.optimize_coefficients == FINAL_PASS_TRELLIS_OPT) x->optimize = 0;
}
......@@ -595,8 +595,13 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
assert(x->blk_skip[plane][blk_row * bw + blk_col] != 234);
if (x->blk_skip[plane][blk_row * bw + blk_col] == 0) {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_FP);
if (args->enable_optimize_b) {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, AV1_XFORM_QUANT_FP);
} else {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, AV1_XFORM_QUANT_B);
}
} else {
p->eobs[block] = 0;
}
......@@ -620,13 +625,14 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
#if CONFIG_TXK_SEL
if (plane == 0 && p->eobs[block] == 0) {
#if DISABLE_TRELLISQ_SEARCH
xd->mi[0]->mbmi.txk_type[(blk_row << MAX_MIB_SIZE_LOG2) + blk_col] =
DCT_DCT;
#else
assert(xd->mi[0]->mbmi.txk_type[(blk_row << MAX_MIB_SIZE_LOG2) + blk_col] ==
DCT_DCT);
#endif
if (args->enable_optimize_b) {
xd->mi[0]->mbmi.txk_type[(blk_row << MAX_MIB_SIZE_LOG2) + blk_col] =
DCT_DCT;
} else {
assert(
xd->mi[0]->mbmi.txk_type[(blk_row << MAX_MIB_SIZE_LOG2) + blk_col] ==
DCT_DCT);
}
}
#endif // CONFIG_TXK_SEL
......@@ -892,14 +898,9 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
#if CONFIG_TXK_SEL
if (plane == 0 && p->eobs[block] == 0) {
#if DISABLE_TRELLISQ_SEARCH
xd->mi[0]->mbmi.txk_type[(blk_row << MAX_MIB_SIZE_LOG2) + blk_col] =
DCT_DCT;
#else
assert(
xd->mi[0]->mbmi.txk_type[(blk_row << MAX_MIB_SIZE_LOG2) + blk_col] ==
DCT_DCT);
#endif
}
#endif // CONFIG_TXK_SEL
} else {
......
......@@ -2462,15 +2462,15 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
RD_STATS this_rd_stats;
av1_invalid_rd_stats(&this_rd_stats);
#if DISABLE_TRELLISQ_SEARCH
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_B);
#else
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size,
a, l, 1);
#endif
if (cpi->sf.optimize_coefficients != FULL_TRELLIS_OPT) {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, AV1_XFORM_QUANT_B);
} else {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize,
tx_size, a, l, 1);
}
av1_dist_block(cpi, x, plane, plane_bsize, block, blk_row, blk_col, tx_size,
&this_rd_stats.dist, &this_rd_stats.sse,
OUTPUT_HAS_PREDICTED_PIXELS);
......@@ -2498,17 +2498,17 @@ int64_t av1_search_txk_type(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
x->plane[plane].txb_entropy_ctx[block] = best_txb_ctx;
if (!is_inter_block(mbmi)) {
// intra mode needs decoded result such that the next transform block
// can use it for prediction.
#if DISABLE_TRELLISQ_SEARCH
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_B);
#else
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size,
a, l, 1);
#endif
// intra mode needs decoded result such that the next transform block
// can use it for prediction.
if (cpi->sf.optimize_coefficients != FULL_TRELLIS_OPT) {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, AV1_XFORM_QUANT_B);
} else {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, AV1_XFORM_QUANT_FP);
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize,
tx_size, a, l, 1);
}
av1_inverse_transform_block_facade(xd, plane, block, blk_row, blk_col,
x->plane[plane].eobs[block],
......
......@@ -2102,53 +2102,52 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col,
}
#if !CONFIG_TXK_SEL
// full forward transform and quantization
#if DISABLE_TRELLISQ_SEARCH
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_B);
#else
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_FP);
// full forward transform and quantization
if (cpi->sf.optimize_coefficients == FINAL_PASS_TRELLIS_OPT) {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_B);
} else {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_FP);
// TX-domain results need to shift down to Q2/D10 to match pixel
// domain distortion values which are in Q2^2
#if CONFIG_DAALA_TX
const int shift = (TX_COEFF_DEPTH - 10) * 2;
const int shift = (TX_COEFF_DEPTH - 10) * 2;
#else
const int shift = (MAX_TX_SCALE - av1_get_tx_scale(tx_size)) * 2;
const int shift = (MAX_TX_SCALE - av1_get_tx_scale(tx_size)) * 2;
#endif
tran_low_t *const coeff = BLOCK_OFFSET(x->plane[plane].coeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block);
const int buffer_length = av1_get_max_eob(tx_size);
int64_t tmp_dist;
int64_t tmp;
tran_low_t *const coeff = BLOCK_OFFSET(x->plane[plane].coeff, block);
tran_low_t *const dqcoeff = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block);
const int buffer_length = av1_get_max_eob(tx_size);
int64_t tmp_dist;
int64_t tmp;
#if CONFIG_DAALA_TX
tmp_dist =
av1_highbd_block_error(coeff, dqcoeff, buffer_length, &tmp, xd->bd);
#else
#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
tmp_dist =
av1_highbd_block_error(coeff, dqcoeff, buffer_length, &tmp, xd->bd);
else
#else
#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
tmp_dist =
av1_highbd_block_error(coeff, dqcoeff, buffer_length, &tmp, xd->bd);
else
#endif
tmp_dist = av1_block_error(coeff, dqcoeff, buffer_length, &tmp);
tmp_dist = av1_block_error(coeff, dqcoeff, buffer_length, &tmp);
#endif
tmp_dist = RIGHT_SIGNED_SHIFT(tmp_dist, shift);
tmp_dist = RIGHT_SIGNED_SHIFT(tmp_dist, shift);
if (
if (
#if CONFIG_DIST_8X8
disable_early_skip ||
disable_early_skip ||
#endif
RDCOST(x->rdmult, 0, tmp_dist) + args->this_rd < args->best_rd) {
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size,
a, l, CONFIG_LV_MAP);
} else {
args->exit_early = 1;
return;
RDCOST(x->rdmult, 0, tmp_dist) + args->this_rd < args->best_rd) {
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize,
tx_size, a, l, CONFIG_LV_MAP);
} else {
args->exit_early = 1;
return;
}
}
#endif // DISABLE_TRELLISQ_SEARCH
if (!is_inter_block(mbmi)) {
struct macroblock_plane *const p = &x->plane[plane];
av1_inverse_transform_block_facade(xd, plane, block, blk_row, blk_col,
......@@ -3647,9 +3646,6 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
MACROBLOCKD *xd = &x->e_mbd;
const struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
#if DISABLE_TRELLISQ_SEARCH
(void)fast;
#endif
#if CONFIG_TXK_SEL
av1_search_txk_type(cpi, x, plane, block, blk_row, blk_col, plane_bsize,
tx_size, a, l, 0, rd_stats);
......@@ -3748,63 +3744,63 @@ void av1_tx_block_rd_b(const AV1_COMP *cpi, MACROBLOCK *x, TX_SIZE tx_size,
0, bw, bh);
#endif // CONFIG_HIGHBITDEPTH
#if DISABLE_TRELLISQ_SEARCH
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_B);
if (cpi->sf.optimize_coefficients == FINAL_PASS_TRELLIS_OPT) {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_B);
#else
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_FP);
} else {
av1_xform_quant(cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
AV1_XFORM_QUANT_FP);
// TX-domain results need to shift down to Q2/D10 to match pixel
// domain distortion values which are in Q2^2
#if CONFIG_DAALA_TX
const int shift = (TX_COEFF_DEPTH - 10) * 2;
const int shift = (TX_COEFF_DEPTH - 10) * 2;
#else
const int shift = (MAX_TX_SCALE - av1_get_tx_scale(tx_size)) * 2;
const int shift = (MAX_TX_SCALE - av1_get_tx_scale(tx_size)) * 2;
#endif
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
const int buffer_length = av1_get_max_eob(tx_size);
int64_t tmp_dist, tmp_sse;
tran_low_t *const coeff = BLOCK_OFFSET(p->coeff, block);
const int buffer_length = av1_get_max_eob(tx_size);
int64_t tmp_dist, tmp_sse;
#if CONFIG_DIST_8X8
int blk_w = block_size_wide[plane_bsize];
int blk_h = block_size_high[plane_bsize];
int disable_early_skip =
x->using_dist_8x8 && plane == 0 && blk_w >= 8 && blk_h >= 8 &&
(tx_size == TX_4X4 || tx_size == TX_4X8 || tx_size == TX_8X4) &&
x->tune_metric != AOM_TUNE_PSNR;
int blk_w = block_size_wide[plane_bsize];
int blk_h = block_size_high[plane_bsize];
int disable_early_skip =
x->using_dist_8x8 && plane == 0 && blk_w >= 8 && blk_h >= 8 &&
(tx_size == TX_4X4 || tx_size == TX_4X8 || tx_size == TX_8X4) &&
x->tune_metric != AOM_TUNE_PSNR;
#endif // CONFIG_DIST_8X8
#if CONFIG_DAALA_TX
tmp_dist =
av1_highbd_block_error(coeff, dqcoeff, buffer_length, &tmp_sse, xd->bd);
#else
#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
tmp_dist =
av1_highbd_block_error(coeff, dqcoeff, buffer_length, &tmp_sse, xd->bd);
else
#else
#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
tmp_dist = av1_highbd_block_error(coeff, dqcoeff, buffer_length, &tmp_sse,
xd->bd);
else
#endif
tmp_dist = av1_block_error(coeff, dqcoeff, buffer_length, &tmp_sse);
tmp_dist = av1_block_error(coeff, dqcoeff, buffer_length, &tmp_sse);
#endif
tmp_dist = RIGHT_SIGNED_SHIFT(tmp_dist, shift);
tmp_dist = RIGHT_SIGNED_SHIFT(tmp_dist, shift);
if (
if (
#if CONFIG_DIST_8X8
disable_early_skip ||
disable_early_skip ||
#endif
RDCOST(x->rdmult, 0, tmp_dist) < rd_stats->ref_rdcost) {
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize, tx_size,
a, l, fast);
} else {
rd_stats->rate += rd_stats->zero_rate;
rd_stats->dist += tmp << 4;
rd_stats->skip = 1;
rd_stats->invalid_rate = 1;
return;
RDCOST(x->rdmult, 0, tmp_dist) < rd_stats->ref_rdcost) {
av1_optimize_b(cm, x, plane, blk_row, blk_col, block, plane_bsize,
tx_size, a, l, fast);
} else {
rd_stats->rate += rd_stats->zero_rate;
rd_stats->dist += tmp << 4;
rd_stats->skip = 1;
rd_stats->invalid_rate = 1;
return;
}
}
#endif // DISABLE_TRELLISQ_SEARCH
const int eob = p->eobs[block];
......
......@@ -424,7 +424,13 @@ void av1_set_speed_features_framesize_independent(AV1_COMP *cpi) {
sf->mv.subpel_search_method = SUBPEL_TREE;
sf->mv.subpel_iters_per_step = 2;
sf->mv.subpel_force_stop = 0;
#if DISABLE_TRELLISQ_SEARCH
sf->optimize_coefficients = !is_lossless_requested(&cpi->oxcf)
? FINAL_PASS_TRELLIS_OPT
: NO_TRELLIS_OPT;
#else
sf->optimize_coefficients = !is_lossless_requested(&cpi->oxcf);
#endif // DISABLE_TRELLISQ_SEARCH
sf->mv.reduce_first_step_size = 0;
sf->coeff_prob_appx_step = 1;
sf->mv.auto_mv_step_size = 0;
......@@ -572,8 +578,7 @@ void av1_set_speed_features_framesize_independent(AV1_COMP *cpi) {
cpi->find_fractional_mv_step = av1_find_best_sub_pixel_tree_pruned_evenmore;
}
x->optimize =
sf->optimize_coefficients == FULL_TRELLIS_OPT && oxcf->pass != 1;
x->optimize = sf->optimize_coefficients && oxcf->pass != 1;
#if CONFIG_AOM_QM
// FIXME: trellis not very efficient for quantisation matrices
if (cm->using_qmatrix) x->optimize = 0;
......
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