]> granicus.if.org Git - libvpx/commitdiff
vp9: Disable re_encode_overshoot feature for speed >= 6.
authorMarco Paniconi <marpan@google.com>
Thu, 2 Aug 2018 16:22:58 +0000 (09:22 -0700)
committerMarco Paniconi <marpan@google.com>
Thu, 2 Aug 2018 18:36:13 +0000 (11:36 -0700)
For real-time screen content mode: for speed >= 6 disable
the re_encode_overshoot feature. This means for speed >= 6
the Q and rate control is reset on slide changes based on
the scene/slide detection and the current Q (and not on a
first pass encoded frame at current Q).

This reduces encode time on slide changes, but may be less
accurate in deciding when to reset/max-out the Q.

Change-Id: Id0fdcafd55bc43bd8b3afee211e524f37c8ddce6

vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_ratectrl.c
vp9/encoder/vp9_speed_features.c

index 868a6249a13e3dab486e82f64d5a7ea9e80e9802..fa4571ceabfd4ce1a97f2d86d54da06c7d26f95c 100644 (file)
@@ -4052,6 +4052,18 @@ static int encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
     vp9_svc_assert_constraints_pattern(cpi);
   }
 
+  if (!cpi->sf.re_encode_overshoot_rt &&
+      (cpi->rc.high_source_sad ||
+       (cpi->use_svc && cpi->svc.high_source_sad_superframe))) {
+    // Check if this high_source_sad (scene/slide change) frame should be
+    // encoded at high/max QP, and if so, set the q and adjust some rate
+    // control parameters.
+    if (vp9_encodedframe_overshoot(cpi, -1, &q)) {
+      vp9_set_quantizer(cm, q);
+      vp9_set_variance_partition_thresholds(cpi, q, 0);
+    }
+  }
+
   // Variance adaptive and in frame q adjustment experiments are mutually
   // exclusive.
   if (cpi->oxcf.aq_mode == VARIANCE_AQ) {
index ec969e0cc32afc718356810b70bfa140b018cf74..695b155266427cddf5bad92e46bc4bfb39e5c566 100644 (file)
@@ -2803,15 +2803,22 @@ void vp9_scene_detection_onepass(VP9_COMP *cpi) {
 
 // Test if encoded frame will significantly overshoot the target bitrate, and
 // if so, set the QP, reset/adjust some rate control parameters, and return 1.
+// frame_size = -1 means frame has not been encoded.
 int vp9_encodedframe_overshoot(VP9_COMP *cpi, int frame_size, int *q) {
   VP9_COMMON *const cm = &cpi->common;
   RATE_CONTROL *const rc = &cpi->rc;
+  SPEED_FEATURES *const sf = &cpi->sf;
   int thresh_qp = 7 * (rc->worst_quality >> 3);
   int thresh_rate = rc->avg_frame_bandwidth << 3;
   // Lower rate threshold for video.
   if (cpi->oxcf.content != VP9E_CONTENT_SCREEN)
     thresh_rate = rc->avg_frame_bandwidth << 2;
-  if (cm->base_qindex < thresh_qp && frame_size > thresh_rate) {
+  // If this decision is not based on an encoded frame size but just on
+  // scene/slide change detection (i.e., re_encode_overshoot_rt = 0), adjust the
+  // qp_thresh and skip the (frame_size > thresh_rate) condition in this case.
+  if (!sf->re_encode_overshoot_rt) thresh_qp = rc->worst_quality >> 1;
+  if ((!sf->re_encode_overshoot_rt || frame_size > thresh_rate) &&
+      cm->base_qindex < thresh_qp) {
     double rate_correction_factor =
         cpi->rc.rate_correction_factors[INTER_NORMAL];
     const int target_size = cpi->rc.avg_frame_bandwidth;
@@ -2827,7 +2834,8 @@ int vp9_encodedframe_overshoot(VP9_COMP *cpi, int frame_size, int *q) {
     // 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
     // use rd-based intra mode selection for small blocks.
-    if (frame_size > (thresh_rate << 1) && cpi->svc.spatial_layer_id == 0) {
+    if (sf->re_encode_overshoot_rt && frame_size > (thresh_rate << 1) &&
+        cpi->svc.spatial_layer_id == 0) {
       MODE_INFO **mi = cm->mi_grid_visible;
       int sum_intra_usage = 0;
       int mi_row, mi_col;
index fb3d231e94622462368559e0080d98c85432d39b..347139011d6aabbf1814818a1008d91f19e6ae22 100644 (file)
@@ -581,6 +581,7 @@ static void set_rt_speed_feature_framesize_independent(
   }
 
   if (speed >= 6) {
+    sf->re_encode_overshoot_rt = 0;
     if (cpi->oxcf.rc_mode == VPX_VBR && cpi->oxcf.lag_in_frames > 0) {
       sf->use_altref_onepass = 1;
       sf->use_compound_nonrd_pickmode = 1;