From 7428cebe4f5d2227bb4bf094bb7e7bd420455533 Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Fri, 21 Nov 2014 12:18:53 -0800 Subject: [PATCH] Rework forward txfm/quantization skip system in RTC coding mode This commit allows more aggressive decision to skip forward transform and quantization for luma component in RTC coding mode. The chroma components remains going through the normal coding routine, since they are not included in the non-RD mode search process. It reduces the runtime cost by 2% - 10%. In speed -6, vidyo1 1000 kbps 16576 b/f, 40.281 dB, 8402 ms -> 16576 b/f, 40.323 dB, 7764 ms nik720p 1000 kbps 33337 b/f, 38.622 dB, 7473 ms -> 33299 b/f, 38.660 dB, 7314 ms dark720p 1000 kbps 33330 b/f, 39.785 dB, 13505 ms -> 33325 b/f, 39.714 dB, 13105 ms The compression performance of speed -6 is improved by 0.44% in PSNR and 1.31% in SSIM. Change-Id: Iae9e3738de6255babea734e5897f29118bebc6d7 --- vp9/encoder/vp9_encodemb.c | 35 +++++++++++++++++++++-------------- vp9/encoder/vp9_pickmode.c | 24 +++++++++--------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index 1946763c4..ef5bb5ace 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -657,27 +657,34 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize, vp9_xform_quant(x, plane, block, plane_bsize, tx_size); #else if (!x->skip_recode) { - if (max_txsize_lookup[plane_bsize] == tx_size) { - if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 0) { - // full forward transform and quantization - if (x->quant_fp) - vp9_xform_quant_fp(x, plane, block, plane_bsize, tx_size); - else - vp9_xform_quant(x, plane, block, plane_bsize, tx_size); - } else if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 2) { - // fast path forward transform and quantization - vp9_xform_quant_dc(x, plane, block, plane_bsize, tx_size); - } else { + if (x->quant_fp) { + // Encoding process for rtc mode + if (x->skip_txfm[0] == 1 && plane == 0) { // skip forward transform p->eobs[block] = 0; *a = *l = 0; return; + } else { + vp9_xform_quant_fp(x, plane, block, plane_bsize, tx_size); } } else { - if (x->quant_fp) - vp9_xform_quant_fp(x, plane, block, plane_bsize, tx_size); - else + if (max_txsize_lookup[plane_bsize] == tx_size) { + int txfm_blk_index = (plane << 2) + (block >> (tx_size << 1)); + if (x->skip_txfm[txfm_blk_index] == 0) { + // full forward transform and quantization + vp9_xform_quant(x, plane, block, plane_bsize, tx_size); + } else if (x->skip_txfm[txfm_blk_index]== 2) { + // fast path forward transform and quantization + vp9_xform_quant_dc(x, plane, block, plane_bsize, tx_size); + } else { + // skip forward transform + p->eobs[block] = 0; + *a = *l = 0; + return; + } + } else { vp9_xform_quant(x, plane, block, plane_bsize, tx_size); + } } } #endif diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c index 23575b0ee..720c73d3d 100644 --- a/vp9/encoder/vp9_pickmode.c +++ b/vp9/encoder/vp9_pickmode.c @@ -265,28 +265,22 @@ static void model_rd_for_sb_y(VP9_COMP *cpi, BLOCK_SIZE bsize, #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { - vp9_model_rd_from_var_lapndz(var, - 1 << num_pels_log2_lookup[bsize], - ac_quant >> (xd->bd - 5), - &rate, - &dist); + vp9_model_rd_from_var_lapndz(var, 1 << num_pels_log2_lookup[bsize], + ac_quant >> (xd->bd - 5), &rate, &dist); } else { - vp9_model_rd_from_var_lapndz(var, - 1 << num_pels_log2_lookup[bsize], - ac_quant >> 3, - &rate, - &dist); + vp9_model_rd_from_var_lapndz(var, 1 << num_pels_log2_lookup[bsize], + ac_quant >> 3, &rate, &dist); } #else - vp9_model_rd_from_var_lapndz(var, - 1 << num_pels_log2_lookup[bsize], - ac_quant >> 3, - &rate, - &dist); + vp9_model_rd_from_var_lapndz(var, 1 << num_pels_log2_lookup[bsize], + ac_quant >> 3, &rate, &dist); #endif // CONFIG_VP9_HIGHBITDEPTH *out_rate_sum += rate; *out_dist_sum += dist << 4; + + if (*out_rate_sum == 0) + x->skip_txfm[0] = 1; } static int get_pred_buffer(PRED_BUFFER *p, int len) { -- 2.40.0