History

Merge "Disallow skipping transform and quantization" into main

Cheng Chen committed 5 years ago

Commit 7c5574a2 parents bd53f0c fe1c7d24 files · +20 −13Browse files

Unified · Split

4 files
  1. vp9/encoder/vp9_block.h +3 −0
  2. vp9/encoder/vp9_rdopt.c +10 −13
  3. vp9/encoder/vp9_speed_features.c +1 −0
  4. vp9/encoder/vp9_speed_features.h +6 −0
vp9/encoder/vp9_block.h+3−0
@@ -157,6 +157,9 @@ struct macroblock { · 156 unmodified lines
157157 // skip forward transform and quantization
158158 uint8_t skip_txfm[MAX_MB_PLANE << 2];
159159 #define SKIP_TXFM_NONE 0
160+// TODO(chengchen): consider remove SKIP_TXFM_AC_DC from vp9 completely
161+// since it increases risks of bad perceptual quality.
162+// https://crbug.com/webm/1729
160163 #define SKIP_TXFM_AC_DC 1
161164 #define SKIP_TXFM_AC_ONLY 2
162165
vp9/encoder/vp9_rdopt.c+10−13
@@ -745,8 +745,8 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, · 744 unmodified lines
745745 MODE_INFO *const mi = xd->mi[0];
746746 int64_t rd1, rd2, rd;
747747 int rate;
748− int64_t dist;
749− int64_t sse;
748+ int64_t dist = INT64_MAX;
749+ int64_t sse = INT64_MAX;
750750 const int coeff_ctx =
751751 combine_entropy_contexts(args->t_left[blk_row], args->t_above[blk_col]);
752752 struct buf_2d *recon = args->this_recon;
@@ -799,6 +799,13 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, · 46 unmodified lines
799799 if (max_txsize_lookup[plane_bsize] == tx_size)
800800 skip_txfm_flag = x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))];
801801
802+ // This reduces the risk of bad perceptual quality due to bad prediction.
803+ // We always force the encoder to perform transform and quantization.
804+ if (!args->cpi->sf.allow_skip_txfm_ac_dc &&
805+ skip_txfm_flag == SKIP_TXFM_AC_DC) {
806+ skip_txfm_flag = SKIP_TXFM_NONE;
807+ }
808+
802809 if (skip_txfm_flag == SKIP_TXFM_NONE ||
803810 (recon && skip_txfm_flag == SKIP_TXFM_AC_ONLY)) {
804811 // full forward transform and quantization
@@ -827,17 +834,7 @@ static void block_rd_txfm(int plane, int block, int blk_row, int blk_col, · 22 unmodified lines
827834 dist = VPXMAX(0, sse - dc_correct);
828835 }
829836 } else {
830− // SKIP_TXFM_AC_DC
831− // skip forward transform. Because this is handled here, the quantization
832− // does not need to do it.
833− x->plane[plane].eobs[block] = 0;
834− sse = x->bsse[(plane << 2) + (block >> (tx_size << 1))] << 4;
835− dist = sse;
836− if (recon) {
837− uint8_t *rec_ptr = &recon->buf[4 * (blk_row * recon->stride + blk_col)];
838− copy_block_visible(xd, pd, dst, dst_stride, rec_ptr, recon->stride,
839− blk_row, blk_col, plane_bsize, tx_bsize);
840− }
837+ assert(0 && "allow_skip_txfm_ac_dc does not allow SKIP_TXFM_AC_DC.");
841838 }
842839 }
843840
vp9/encoder/vp9_speed_features.c+1−0
@@ -940,6 +940,7 @@ void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi, int speed) { · 939 unmodified lines
940940 sf->enable_tpl_model = oxcf->enable_tpl_model;
941941 sf->prune_ref_frame_for_rect_partitions = 0;
942942 sf->temporal_filter_search_method = MESH;
943+ sf->allow_skip_txfm_ac_dc = 0;
943944
944945 for (i = 0; i < TX_SIZES; i++) {
945946 sf->intra_y_mode_mask[i] = INTRA_ALL;
vp9/encoder/vp9_speed_features.h+6−0
@@ -612,6 +612,12 @@ typedef struct SPEED_FEATURES { · 611 unmodified lines
612612 // For real-time mode: force DC only under intra search when content
613613 // does not have high souce SAD.
614614 int rt_intra_dc_only_low_content;
615+
616+ // The encoder has a feature that skips forward transform and quantization
617+ // based on a model rd estimation to reduce encoding time.
618+ // However, this feature is dangerous since it could lead to bad perceptual
619+ // quality. This flag is added to guard the feature.
620+ int allow_skip_txfm_ac_dc;
615621 } SPEED_FEATURES;
616622
617623 struct VP9_COMP;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t