ref: cd0aca91b1f46fe31dfaf4e77bb40169e8d945bc
parent: f0ccdb19f44e2549415fc24b7cc39fa882f5b565
author: Marco Paniconi <marpan@google.com>
date: Fri Jun 26 11:34:35 EDT 2020
vp9-svc: Fix to setting frame size for dynamic resize 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 (cherry picked from commit de4aedaec33c6c29f882f99a740713596713a1f9)
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -3749,13 +3749,17 @@
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);
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -2402,9 +2402,11 @@
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;
}
}
--- a/vp9/encoder/vp9_svc_layercontext.c
+++ b/vp9/encoder/vp9_svc_layercontext.c
@@ -56,6 +56,7 @@
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;
--- a/vp9/encoder/vp9_svc_layercontext.h
+++ b/vp9/encoder/vp9_svc_layercontext.h
@@ -198,6 +198,7 @@
// Flag to indicate SVC is dynamically switched to a single layer.
int single_layer_svc;
+ int resize_set;
} SVC;
struct VP9_COMP;