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
157 // skip forward transform and quantization157 // skip forward transform and quantization
158 uint8_t skip_txfm[MAX_MB_PLANE << 2];158 uint8_t skip_txfm[MAX_MB_PLANE << 2];
159#define SKIP_TXFM_NONE 0159#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
160#define SKIP_TXFM_AC_DC 1163#define SKIP_TXFM_AC_DC 1
161#define SKIP_TXFM_AC_ONLY 2164#define SKIP_TXFM_AC_ONLY 2
162 165
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
745 MODE_INFO *const mi = xd->mi[0];745 MODE_INFO *const mi = xd->mi[0];
746 int64_t rd1, rd2, rd;746 int64_t rd1, rd2, rd;
747 int rate;747 int rate;
748 int64_t dist;748 int64_t dist = INT64_MAX;
749 int64_t sse;749 int64_t sse = INT64_MAX;
750 const int coeff_ctx =750 const int coeff_ctx =
751 combine_entropy_contexts(args->t_left[blk_row], args->t_above[blk_col]);751 combine_entropy_contexts(args->t_left[blk_row], args->t_above[blk_col]);
752 struct buf_2d *recon = args->this_recon;752 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
799 if (max_txsize_lookup[plane_bsize] == tx_size)799 if (max_txsize_lookup[plane_bsize] == tx_size)
800 skip_txfm_flag = x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))];800 skip_txfm_flag = x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))];
801 801
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
802 if (skip_txfm_flag == SKIP_TXFM_NONE ||809 if (skip_txfm_flag == SKIP_TXFM_NONE ||
803 (recon && skip_txfm_flag == SKIP_TXFM_AC_ONLY)) {810 (recon && skip_txfm_flag == SKIP_TXFM_AC_ONLY)) {
804 // full forward transform and quantization811 // 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
827 dist = VPXMAX(0, sse - dc_correct);834 dist = VPXMAX(0, sse - dc_correct);
828 }835 }
829 } else {836 } else {
830 // SKIP_TXFM_AC_DC837 assert(0 && "allow_skip_txfm_ac_dc does not allow 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 }
841 }838 }
842 }839 }
843 840
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
940 sf->enable_tpl_model = oxcf->enable_tpl_model;940 sf->enable_tpl_model = oxcf->enable_tpl_model;
941 sf->prune_ref_frame_for_rect_partitions = 0;941 sf->prune_ref_frame_for_rect_partitions = 0;
942 sf->temporal_filter_search_method = MESH;942 sf->temporal_filter_search_method = MESH;
943 sf->allow_skip_txfm_ac_dc = 0;
943 944
944 for (i = 0; i < TX_SIZES; i++) {945 for (i = 0; i < TX_SIZES; i++) {
945 sf->intra_y_mode_mask[i] = INTRA_ALL;946 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
612 // For real-time mode: force DC only under intra search when content612 // For real-time mode: force DC only under intra search when content
613 // does not have high souce SAD.613 // does not have high souce SAD.
614 int rt_intra_dc_only_low_content;614 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;
615} SPEED_FEATURES;621} SPEED_FEATURES;
616 622
617struct VP9_COMP;623struct 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