History

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.

Marco Paniconi committed 6 years ago

Commit cd0aca91 parent f0ccdb14 files · +15 −7Browse files

Unified · Split

4 files
  1. vp9/encoder/vp9_encoder.c +11 −7
  2. vp9/encoder/vp9_ratectrl.c +2 −0
  3. vp9/encoder/vp9_svc_layercontext.c +1 −0
  4. vp9/encoder/vp9_svc_layercontext.h +1 −0
vp9/encoder/vp9_encoder.c+11−7
@@ -3749,13 +3749,17 @@ static void set_frame_size(VP9_COMP *cpi) { · 3748 unmodified lines
37493749
37503750 if (oxcf->pass == 0 && oxcf->rc_mode == VPX_CBR &&
37513751 oxcf->resize_mode == RESIZE_DYNAMIC && cpi->resize_pending != 0) {
3752− oxcf->scaled_frame_width =
3753− (oxcf->width * cpi->resize_scale_num) / cpi->resize_scale_den;
3754− oxcf->scaled_frame_height =
3755− (oxcf->height * cpi->resize_scale_num) / cpi->resize_scale_den;
3756− // There has been a change in frame size.
3757− vp9_set_size_literal(cpi, oxcf->scaled_frame_width,
3758− oxcf->scaled_frame_height);
3752+ // For SVC scaled width/height will have been set (svc->resize_set=1)
3753+ // in get_svc_params based on the layer width/height.
3754+ if (!cpi->use_svc || !cpi->svc.resize_set) {
3755+ oxcf->scaled_frame_width =
3756+ (oxcf->width * cpi->resize_scale_num) / cpi->resize_scale_den;
3757+ oxcf->scaled_frame_height =
3758+ (oxcf->height * cpi->resize_scale_num) / cpi->resize_scale_den;
3759+ // There has been a change in frame size.
3760+ vp9_set_size_literal(cpi, oxcf->scaled_frame_width,
3761+ oxcf->scaled_frame_height);
3762+ }
37593763
37603764 // TODO(agrange) Scale cpi->max_mv_magnitude if frame-size has changed.
37613765 set_mv_search_params(cpi);
vp9/encoder/vp9_ratectrl.c+2−0
@@ -2402,9 +2402,11 @@ void vp9_rc_get_svc_params(VP9_COMP *cpi) { · 2401 unmodified lines
24022402 lc->scaling_factor_num_resize,
24032403 lc->scaling_factor_den_resize, &width, &height);
24042404 vp9_set_size_literal(cpi, width, height);
2405+ svc->resize_set = 1;
24052406 }
24062407 } else {
24072408 cpi->resize_pending = 0;
2409+ svc->resize_set = 0;
24082410 }
24092411 }
24102412
vp9/encoder/vp9_svc_layercontext.c+1−0
@@ -56,6 +56,7 @@ void vp9_init_layer_context(VP9_COMP *const cpi) { · 55 unmodified lines
5656 svc->num_encoded_top_layer = 0;
5757 svc->simulcast_mode = 0;
5858 svc->single_layer_svc = 0;
59+ svc->resize_set = 0;
5960
6061 for (i = 0; i < REF_FRAMES; ++i) {
6162 svc->fb_idx_spatial_layer_id[i] = 0xff;
vp9/encoder/vp9_svc_layercontext.h+1−0
@@ -198,6 +198,7 @@ typedef struct SVC { · 197 unmodified lines
198198
199199 // Flag to indicate SVC is dynamically switched to a single layer.
200200 int single_layer_svc;
201+ int resize_set;
201202 } SVC;
202203
203204 struct VP9_COMP;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t