shithub: libvpx

Download patch

ref: 4b0422ad096c64bef9d7f972c092f5090510bdc1
parent: 31326b5bbd37bd461ad354d993a02f85b7761b1f
author: Marco Paniconi <[email protected]>
date: Mon Mar 30 05:16:09 EDT 2020

rtc: Increase resize limit resoln for rtc

Increase resize limit to avoid resized frame
from going below 320x180.

Change-Id: If736ac3fac4731b47844e4d8c771ecf5c66550de

--- a/test/resize_test.cc
+++ b/test/resize_test.cc
@@ -610,11 +610,11 @@
 // Run at low bitrate, with resize_allowed = 1, and verify that we get
 // one resize down event.
 TEST_P(ResizeRealtimeTest, TestInternalResizeDown) {
-  ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
-                                       30, 1, 0, 299);
+  ::libvpx_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30, 1,
+                                       0, 299);
   DefaultConfig();
-  cfg_.g_w = 352;
-  cfg_.g_h = 288;
+  cfg_.g_w = 640;
+  cfg_.g_h = 480;
   change_bitrate_ = false;
   mismatch_psnr_ = 0.0;
   mismatch_nframes_ = 0;
@@ -648,11 +648,11 @@
 // Start at low target bitrate, raise the bitrate in the middle of the clip,
 // scaling-up should occur after bitrate changed.
 TEST_P(ResizeRealtimeTest, TestInternalResizeDownUpChangeBitRate) {
-  ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
-                                       30, 1, 0, 359);
+  ::libvpx_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30, 1,
+                                       0, 400);
   DefaultConfig();
-  cfg_.g_w = 352;
-  cfg_.g_h = 288;
+  cfg_.g_w = 640;
+  cfg_.g_h = 480;
   change_bitrate_ = true;
   mismatch_psnr_ = 0.0;
   mismatch_nframes_ = 0;
--- a/test/svc_datarate_test.cc
+++ b/test/svc_datarate_test.cc
@@ -337,7 +337,7 @@
     } else if (dynamic_drop_layer_ && single_layer_resize_) {
       // Change layer bitrates to set top layers to 0. This will trigger skip
       // encoding/dropping of top spatial layers.
-      if (video->frame() == 10) {
+      if (video->frame() == 2) {
         cfg_.rc_target_bitrate -=
             (cfg_.layer_target_bitrate[1] + cfg_.layer_target_bitrate[2]);
         middle_bitrate_ = cfg_.layer_target_bitrate[1];
@@ -348,9 +348,9 @@
         cfg_.layer_target_bitrate[0] = 30;
         cfg_.rc_target_bitrate = cfg_.layer_target_bitrate[0];
         encoder->Config(&cfg_);
-      } else if (video->frame() == 300) {
+      } else if (video->frame() == 100) {
         // Set base spatial layer to very high to go back up to original size.
-        cfg_.layer_target_bitrate[0] = 300;
+        cfg_.layer_target_bitrate[0] = 400;
         cfg_.rc_target_bitrate = cfg_.layer_target_bitrate[0];
         encoder->Config(&cfg_);
       }
@@ -838,7 +838,7 @@
 // the fly switching to 1 spatial layer with dynamic resize enabled.
 // The resizer will resize the single layer down and back up again, as the
 // bitrate goes back up.
-TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc3SL_SingleLayerResize) {
+TEST_P(DatarateOnePassCbrSvcSingleBR, OnePassCbrSvc2SL_SingleLayerResize) {
   SetSvcConfig(2, 1);
   cfg_.rc_buf_initial_sz = 500;
   cfg_.rc_buf_optimal_sz = 500;
@@ -850,10 +850,10 @@
   cfg_.rc_dropframe_thresh = 30;
   cfg_.kf_max_dist = 9999;
   cfg_.rc_resize_allowed = 1;
-  ::libvpx_test::I420VideoSource video("niklas_640_480_30.yuv", 640, 480, 30, 1,
-                                       0, 400);
-  top_sl_width_ = 640;
-  top_sl_height_ = 480;
+  ::libvpx_test::I420VideoSource video("desktop_office1.1280_720-020.yuv", 1280,
+                                       720, 15, 1, 0, 300);
+  top_sl_width_ = 1280;
+  top_sl_height_ = 720;
   cfg_.rc_target_bitrate = 800;
   ResetModel();
   dynamic_drop_layer_ = true;
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -2657,8 +2657,9 @@
   RESIZE_ACTION resize_action = NO_RESIZE;
   int avg_qp_thr1 = 70;
   int avg_qp_thr2 = 50;
-  int min_width = 320;
-  int min_height = 180;
+  // Don't allow for resized frame to go below 320x180, resize in steps of 3/4.
+  int min_width = (320 * 4) / 3;
+  int min_height = (180 * 4) / 3;
   int down_size_on = 1;
   cpi->resize_scale_num = 1;
   cpi->resize_scale_den = 1;
@@ -2670,7 +2671,7 @@
   }
 
   // No resizing down if frame size is below some limit.
-  if (cm->width * cm->height <= min_width * min_height) down_size_on = 0;
+  if ((cm->width * cm->height) < min_width * min_height) down_size_on = 0;
 
 #if CONFIG_VP9_TEMPORAL_DENOISING
   // If denoiser is on, apply a smaller qp threshold.