]> granicus.if.org Git - libvpx/commitdiff
vp9-svc: Enable scene detection and re-encode for SVC.
authorMarco Paniconi <marpan@google.com>
Tue, 15 May 2018 05:56:15 +0000 (22:56 -0700)
committerMarco Paniconi <marpan@google.com>
Wed, 16 May 2018 16:49:48 +0000 (09:49 -0700)
Keep a lower rate threshold for video case.
Also lower the exiting threshold somewhat for screen-content mode.

Change-Id: I79649a36678d802fd4d4080754fd366e78904214

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

index 95bf4622f9f4222f02bee07f16ad26fbade232c1..e41768a8f13298a5a965401f64bd6683bee4274f 100644 (file)
@@ -3724,7 +3724,7 @@ static void encode_without_recode_loop(VP9_COMP *cpi, size_t *size,
   if (cm->show_frame && cpi->oxcf.mode == REALTIME &&
       (cpi->oxcf.rc_mode == VPX_VBR ||
        cpi->oxcf.content == VP9E_CONTENT_SCREEN ||
-       (cpi->oxcf.speed >= 5 && cpi->oxcf.speed < 8 && !cpi->use_svc)))
+       (cpi->oxcf.speed >= 5 && cpi->oxcf.speed < 8)))
     vp9_scene_detection_onepass(cpi);
 
   if (cpi->svc.spatial_layer_id == 0)
index 599337f801b7ceb54c031b854bde00244d3588c0..c349a807aa214c9e050d74543b0a0f4ba68bffbd 100644 (file)
@@ -2426,6 +2426,19 @@ void vp9_scene_detection_onepass(VP9_COMP *cpi) {
       if (cm->frame_type != KEY_FRAME && rc->reset_high_source_sad)
         rc->this_frame_target = rc->avg_frame_bandwidth;
     }
+    // For SVC the new (updated) avg_source_sad[0] for the current superframe
+    // updates the setting for all layers.
+    if (cpi->use_svc) {
+      int sl, tl;
+      SVC *const svc = &cpi->svc;
+      for (sl = 0; sl < svc->number_spatial_layers; ++sl)
+        for (tl = 0; tl < svc->number_temporal_layers; ++tl) {
+          int layer = LAYER_IDS_TO_IDX(sl, tl, svc->number_temporal_layers);
+          LAYER_CONTEXT *const lc = &svc->layer_context[layer];
+          RATE_CONTROL *const lrc = &lc->rc;
+          lrc->avg_source_sad[0] = rc->avg_source_sad[0];
+        }
+    }
     // For VBR, under scene change/high content change, force golden refresh.
     if (cpi->oxcf.rc_mode == VPX_VBR && cm->frame_type != KEY_FRAME &&
         rc->high_source_sad && rc->frames_to_key > 3 &&
@@ -2460,7 +2473,10 @@ int vp9_encodedframe_overshoot(VP9_COMP *cpi, int frame_size, int *q) {
   VP9_COMMON *const cm = &cpi->common;
   RATE_CONTROL *const rc = &cpi->rc;
   int thresh_qp = 3 * (rc->worst_quality >> 2);
-  int thresh_rate = rc->avg_frame_bandwidth * 10;
+  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) {
     double rate_correction_factor =
         cpi->rc.rate_correction_factors[INTER_NORMAL];
index 8f1ec2155f16fc754e2002dfc63647c88a7bdf41..d2842697dae2741ff8b9848bb78c081c4b0867ec 100644 (file)
@@ -539,7 +539,7 @@ static void set_rt_speed_feature_framesize_independent(
     if (cpi->use_svc && cpi->svc.spatial_layer_id > 0) sf->nonrd_keyframe = 1;
     if (cpi->oxcf.pass == 0 && cpi->oxcf.rc_mode == VPX_CBR &&
         cm->frame_type != KEY_FRAME && cpi->resize_state == ORIG &&
-        cpi->oxcf.content == VP9E_CONTENT_SCREEN) {
+        (cpi->use_svc || cpi->oxcf.content == VP9E_CONTENT_SCREEN)) {
       sf->re_encode_overshoot_rt = 1;
     }
     if (cpi->oxcf.rc_mode == VPX_VBR && cpi->oxcf.lag_in_frames > 0 &&