]> granicus.if.org Git - libvpx/commitdiff
vp9-svc: Fix to setting frame size for dynamic resize
authorMarco Paniconi <marpan@google.com>
Fri, 26 Jun 2020 22:34:35 +0000 (15:34 -0700)
committerMarco Paniconi <marpan@google.com>
Sat, 27 Jun 2020 00:08:54 +0000 (17:08 -0700)
For svc with dynamic resize (only for single_layer_svc mode),
add flag to indicate resized width/height has already been set,
otherwise on the resized/trigger frame (resize_pending=1), the
wrong resolution may be set if oxcf->width/height is different
than layer width/height in single_layer_svc mode.

Change-Id: I24403ee93fc96b830a9bf7c66d763a48762cdcb4

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

index 2780c73843c61b1ba1abdcd003a05fb03e4a112c..06dadc42a679f8eb05ec8a1b70fc7bf9da9e57bd 100644 (file)
@@ -3749,13 +3749,17 @@ static void set_frame_size(VP9_COMP *cpi) {
 
   if (oxcf->pass == 0 && oxcf->rc_mode == VPX_CBR &&
       oxcf->resize_mode == RESIZE_DYNAMIC && cpi->resize_pending != 0) {
-    oxcf->scaled_frame_width =
-        (oxcf->width * cpi->resize_scale_num) / cpi->resize_scale_den;
-    oxcf->scaled_frame_height =
-        (oxcf->height * cpi->resize_scale_num) / cpi->resize_scale_den;
-    // There has been a change in frame size.
-    vp9_set_size_literal(cpi, oxcf->scaled_frame_width,
-                         oxcf->scaled_frame_height);
+    // For SVC scaled width/height will have been set (svc->resize_set=1)
+    // in get_svc_params based on the layer width/height.
+    if (!cpi->use_svc || !cpi->svc.resize_set) {
+      oxcf->scaled_frame_width =
+          (oxcf->width * cpi->resize_scale_num) / cpi->resize_scale_den;
+      oxcf->scaled_frame_height =
+          (oxcf->height * cpi->resize_scale_num) / cpi->resize_scale_den;
+      // There has been a change in frame size.
+      vp9_set_size_literal(cpi, oxcf->scaled_frame_width,
+                           oxcf->scaled_frame_height);
+    }
 
     // TODO(agrange) Scale cpi->max_mv_magnitude if frame-size has changed.
     set_mv_search_params(cpi);
index 34dd618acf6322e0ff727d61f780d12f7347342e..3beb9f41f9b1c50445bb471aa59f629c82021717 100644 (file)
@@ -2405,9 +2405,11 @@ void vp9_rc_get_svc_params(VP9_COMP *cpi) {
                            lc->scaling_factor_num_resize,
                            lc->scaling_factor_den_resize, &width, &height);
       vp9_set_size_literal(cpi, width, height);
+      svc->resize_set = 1;
     }
   } else {
     cpi->resize_pending = 0;
+    svc->resize_set = 0;
   }
 }
 
index 27dc8ec50ff228830eead903bc7c89990618faaf..d85b3632cd59a72d24c6793da0c5e56ff3f39e21 100644 (file)
@@ -56,6 +56,7 @@ void vp9_init_layer_context(VP9_COMP *const cpi) {
   svc->num_encoded_top_layer = 0;
   svc->simulcast_mode = 0;
   svc->single_layer_svc = 0;
+  svc->resize_set = 0;
 
   for (i = 0; i < REF_FRAMES; ++i) {
     svc->fb_idx_spatial_layer_id[i] = 0xff;
index 7e46500b58d52fec4851b558ae6498188c9c443f..e7d9712aae25836e0ab2cd7232b2688b07b68408 100644 (file)
@@ -198,6 +198,7 @@ typedef struct SVC {
 
   // Flag to indicate SVC is dynamically switched to a single layer.
   int single_layer_svc;
+  int resize_set;
 } SVC;
 
 struct VP9_COMP;