ref: 24b16ce7c9da42b23484174a41d1c5ff2ea4929a
parent: 5786379401a93316a95b3e924c8de33c7c538cf9
author: Marco Paniconi <marpan@google.com>
date: Sun Jul 1 13:26:38 EDT 2018
vp9: Fix to screen content artifact for real-time. Reset segment to base (segment#0) on spatially flat stationary blocks (source_variance = 0). Also increase dc_skip threshold for these blocks. Reduces artifacts on flat areas in screen content mode. Change-Id: I7ee0c80d37536db7896fa74a83f75799f1dcf73d
--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -180,6 +180,8 @@
int sb_pickmode_part;
+ int zero_temp_sad_source;
+
// For each superblock: saves the content value (e.g., low/high sad/sumdiff)
// based on source sad, prior to encoding the frame.
uint8_t content_state_sb;
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1183,6 +1183,7 @@
cpi->content_state_sb_fd[sb_offset] = 0;
}
}
+ if (tmp_sad == 0) x->zero_temp_sad_source = 1;
return tmp_sad;
}
@@ -4950,6 +4951,7 @@
x->skip_low_source_sad = 0;
x->lowvar_highsumdiff = 0;
x->content_state_sb = 0;
+ x->zero_temp_sad_source = 0;
x->sb_use_mv_part = 0;
x->sb_mvcol_part = 0;
x->sb_mvrow_part = 0;
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -350,7 +350,7 @@
struct macroblockd_plane *const pd = &xd->plane[0];
const uint32_t dc_quant = pd->dequant[0];
const uint32_t ac_quant = pd->dequant[1];
- const int64_t dc_thr = dc_quant * dc_quant >> 6;
+ int64_t dc_thr = dc_quant * dc_quant >> 6;
int64_t ac_thr = ac_quant * ac_quant >> 6;
unsigned int var;
int sum;
@@ -414,6 +414,10 @@
assert(tx_size >= TX_8X8);
xd->mi[0]->tx_size = tx_size;
+ if (cpi->oxcf.content == VP9E_CONTENT_SCREEN && x->zero_temp_sad_source &&
+ x->source_variance == 0)
+ dc_thr = dc_thr << 1;
+
// Evaluate if the partition block is a skippable block in Y plane.
{
unsigned int sse16x16[16] = { 0 };
@@ -1605,6 +1609,12 @@
#endif // CONFIG_VP9_HIGHBITDEPTH
x->source_variance =
vp9_get_sby_perpixel_variance(cpi, &x->plane[0].src, bsize);
+
+ if (cpi->oxcf.content == VP9E_CONTENT_SCREEN && mi->segment_id > 0 &&
+ x->zero_temp_sad_source && x->source_variance == 0) {
+ mi->segment_id = 0;
+ vp9_init_plane_quantizers(cpi, x);
+ }
}
#if CONFIG_VP9_TEMPORAL_DENOISING