]> granicus.if.org Git - libvpx/commitdiff
vp9: Fix to screen content artifact for real-time.
authorMarco Paniconi <marpan@google.com>
Mon, 2 Jul 2018 00:26:38 +0000 (17:26 -0700)
committerMarco Paniconi <marpan@google.com>
Mon, 2 Jul 2018 02:28:48 +0000 (19:28 -0700)
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

vp9/encoder/vp9_block.h
vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_pickmode.c

index 724205dd578f2da27b6bad526760776718c81744..c33985b1b560e945bec4ae30880417b1de6cf186 100644 (file)
@@ -180,6 +180,8 @@ struct macroblock {
 
   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;
index 73d888101fb0f920173c140ffbe72b4698ac5106..469c4592117a3ed8bb85e3d074d54367296ccdd6 100644 (file)
@@ -1183,6 +1183,7 @@ static uint64_t avg_source_sad(VP9_COMP *cpi, MACROBLOCK *x, int shift,
       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 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, ThreadData *td,
     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;
index 02d97fc82ad30ff4e38216691f78d1181d0aa328..9fedf4fcc6ff982d4462c0ce4056cbe19a4e8c6b 100644 (file)
@@ -350,7 +350,7 @@ static void model_rd_for_sb_y_large(VP9_COMP *cpi, BLOCK_SIZE bsize,
   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 @@ static void model_rd_for_sb_y_large(VP9_COMP *cpi, BLOCK_SIZE bsize,
   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 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, TileDataEnc *tile_data,
 #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