]> granicus.if.org Git - libvpx/commitdiff
vp8: Limit Q change for screen content CBR mode
authorMarco Paniconi <marpan@google.com>
Tue, 5 Feb 2019 18:54:28 +0000 (10:54 -0800)
committerMarco Paniconi <marpan@google.com>
Tue, 12 Feb 2019 19:22:35 +0000 (11:22 -0800)
Add last_q[] to layer context, and add limit on
Q change from previous layer/frame. For now put
hard limit of 12 for decrease.

For 1 pass CBR sreen content mode.

Change-Id: Ifb972c9b6831440c80b1cb07a054c577ece930ec

vp8/encoder/onyx_if.c
vp8/encoder/onyx_int.h
vp8/encoder/ratectrl.c

index 07be0d98908c51e559ab8a53571d324ae3504472..a30821ac1983e495c5ed0c7822f0c42f938c3bc2 100644 (file)
@@ -218,6 +218,8 @@ static void save_layer_context(VP8_COMP *cpi) {
   lc->frames_since_last_drop_overshoot = cpi->frames_since_last_drop_overshoot;
   lc->force_maxqp = cpi->force_maxqp;
   lc->last_frame_percent_intra = cpi->last_frame_percent_intra;
+  lc->last_q[0] = cpi->last_q[0];
+  lc->last_q[1] = cpi->last_q[1];
 
   memcpy(lc->count_mb_ref_frame_usage, cpi->mb.count_mb_ref_frame_usage,
          sizeof(cpi->mb.count_mb_ref_frame_usage));
@@ -255,6 +257,8 @@ static void restore_layer_context(VP8_COMP *cpi, const int layer) {
   cpi->frames_since_last_drop_overshoot = lc->frames_since_last_drop_overshoot;
   cpi->force_maxqp = lc->force_maxqp;
   cpi->last_frame_percent_intra = lc->last_frame_percent_intra;
+  cpi->last_q[0] = lc->last_q[0];
+  cpi->last_q[1] = lc->last_q[1];
 
   memcpy(cpi->mb.count_mb_ref_frame_usage, lc->count_mb_ref_frame_usage,
          sizeof(cpi->mb.count_mb_ref_frame_usage));
index 5189d43380a4c10548f119758d698e3f1fd60971..a4e3f2f7902abe3bd2066bf5229b930c01cbcd94 100644 (file)
@@ -257,6 +257,7 @@ typedef struct {
 
   int count_mb_ref_frame_usage[MAX_REF_FRAMES];
 
+  int last_q[2];
 } LAYER_CONTEXT;
 
 typedef struct VP8_COMP {
index d7badeb5a3ccb749d60e18e900b8485731e396b3..dbd76edad05e18b0071b17f8a3805f3f5f909e2f 100644 (file)
@@ -1125,6 +1125,14 @@ void vp8_update_rate_correction_factors(VP8_COMP *cpi, int damp_var) {
   }
 }
 
+static int limit_q_cbr_inter(int last_q, int current_q) {
+  int limit_down = 12;
+  if (last_q - current_q > limit_down)
+    return (last_q - limit_down);
+  else
+    return current_q;
+}
+
 int vp8_regulate_q(VP8_COMP *cpi, int target_bits_per_frame) {
   int Q = cpi->active_worst_quality;
 
@@ -1264,6 +1272,12 @@ int vp8_regulate_q(VP8_COMP *cpi, int target_bits_per_frame) {
     }
   }
 
+  // Limit decrease in Q for 1 pass CBR screen content mode.
+  if (cpi->common.frame_type != KEY_FRAME && cpi->pass == 0 &&
+      cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER &&
+      cpi->oxcf.screen_content_mode)
+    Q = limit_q_cbr_inter(cpi->last_q[1], Q);
+
   return Q;
 }