]> granicus.if.org Git - libvpx/commitdiff
vp9: Modify logic for flat blocks in nonrd-pickmode.
authorMarco Paniconi <marpan@google.com>
Tue, 24 Jul 2018 18:34:42 +0000 (11:34 -0700)
committerMarco Paniconi <marpan@google.com>
Tue, 24 Jul 2018 22:21:09 +0000 (15:21 -0700)
For real-time screen content mode: when slide change
is detected, for spatially flat blocks (source_variance = 0) on
the re-encoded frame, skip inter modes (so force intra) if
non-zero temporal variance is detected for the coding block.
Add flag to keep track of re-encoded frame at max Q.
Reduces artifacts on slide change.

Change-Id: I28151f412aba6ab8cb03f30087c7ce16d443654b

vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_pickmode.c
vp9/encoder/vp9_ratectrl.c
vp9/encoder/vp9_ratectrl.h

index de5519dce8655e04e2cc8872a799b8deaf7e47f6..ed2c17702069680791d3a5edd7fadd5d1f32c20f 100644 (file)
@@ -3985,6 +3985,7 @@ static int encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
   // (need to check encoding time cost for doing this for speed 8).
   cpi->rc.high_source_sad = 0;
   cpi->rc.hybrid_intra_scene_change = 0;
+  cpi->rc.re_encode_maxq_scene_change = 0;
   if (cm->show_frame && cpi->oxcf.mode == REALTIME &&
       (cpi->oxcf.rc_mode == VPX_VBR ||
        cpi->oxcf.content == VP9E_CONTENT_SCREEN ||
index 8248d12e66c705f7e9b93487f4b9641938f862ae..fa7cf8c26e418ee22adab356486075c95a06f376 100644 (file)
@@ -1827,7 +1827,9 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, TileDataEnc *tile_data,
     if (!(cpi->ref_frame_flags & flag_list[ref_frame])) continue;
 
     if (sf->short_circuit_flat_blocks && x->source_variance == 0 &&
-        frame_mv[this_mode][ref_frame].as_int != 0) {
+        (frame_mv[this_mode][ref_frame].as_int != 0 ||
+         (svc->spatial_layer_id == 0 && cpi->rc.re_encode_maxq_scene_change &&
+          !x->zero_temp_sad_source))) {
       continue;
     }
 
index 22ae7266b4571ffe0c3cb941df1e0329cc358d8e..9bf8458902711243a5d920ef7b5f7e1974f2b593 100644 (file)
@@ -364,6 +364,7 @@ void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) {
   rc->reset_high_source_sad = 0;
   rc->high_source_sad_lagindex = -1;
   rc->hybrid_intra_scene_change = 0;
+  rc->re_encode_maxq_scene_change = 0;
   rc->alt_ref_gf_group = 0;
   rc->last_frame_is_src_altref = 0;
   rc->fac_active_worst_inter = 150;
@@ -2813,6 +2814,7 @@ int vp9_encodedframe_overshoot(VP9_COMP *cpi, int frame_size, int *q) {
     // Force a re-encode, and for now use max-QP.
     *q = cpi->rc.worst_quality;
     cpi->cyclic_refresh->counter_encode_maxq_scene_change = 0;
+    cpi->rc.re_encode_maxq_scene_change = 1;
     // If the frame_size is much larger than the threshold (big content change)
     // and the encoded frame used alot of Intra modes, then force hybrid_intra
     // encoding for the re-encode on this scene change. hybrid_intra will
index 373c6a3aa7c38fba9c22d7d52df37c47704c0030..cf37117f964ccafaee859339a881ce5a698fd759 100644 (file)
@@ -190,6 +190,7 @@ typedef struct {
   int high_source_sad;
   int count_last_scene_change;
   int hybrid_intra_scene_change;
+  int re_encode_maxq_scene_change;
   int avg_frame_low_motion;
   int af_ratio_onepass_vbr;
   int force_qpmin;