From d748cfdad2378fc488fb5df4411adf5f2d5b99c9 Mon Sep 17 00:00:00 2001 From: Marco Paniconi Date: Fri, 31 Aug 2018 15:42:19 -0700 Subject: [PATCH] vp9-svc: Add first_spatial_layer_to_encode per superframe VP9E_SET_SVC_LAYER_ID sets the first spatial layer to encoder per superframe, so add this parameter to svc encoder. This is needed, for example, to properly set is_key_frame for spatial layers when base spatial layer is skipped encoded. Change-Id: Ifd4ac77f539197ec021e62f4c624a6cc79d64f43 --- vp9/encoder/vp9_ratectrl.c | 2 ++ vp9/encoder/vp9_svc_layercontext.h | 2 ++ vp9/vp9_cx_iface.c | 1 + 3 files changed, 5 insertions(+) diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 70613c9eb..c0eafdebd 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -2003,6 +2003,8 @@ void vp9_rc_get_svc_params(VP9_COMP *cpi) { int target = rc->avg_frame_bandwidth; int layer = LAYER_IDS_TO_IDX(svc->spatial_layer_id, svc->temporal_layer_id, svc->number_temporal_layers); + if (svc->first_spatial_layer_to_encode) + svc->layer_context[svc->temporal_layer_id].is_key_frame = 0; // Periodic key frames is based on the super-frame counter // (svc.current_superframe), also only base spatial layer is key frame. // Key frame is set for any of the following: very first frame, frame flags diff --git a/vp9/encoder/vp9_svc_layercontext.h b/vp9/encoder/vp9_svc_layercontext.h index cb2884e22..60fb7da75 100644 --- a/vp9/encoder/vp9_svc_layercontext.h +++ b/vp9/encoder/vp9_svc_layercontext.h @@ -175,6 +175,8 @@ typedef struct SVC { int use_set_ref_frame_config; int temporal_layer_id_per_spatial[VPX_SS_MAX_LAYERS]; + + int first_spatial_layer_to_encode; } SVC; struct VP9_COMP; diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c index d7ed514c1..074415b7f 100644 --- a/vp9/vp9_cx_iface.c +++ b/vp9/vp9_cx_iface.c @@ -1449,6 +1449,7 @@ static vpx_codec_err_t ctrl_set_svc_layer_id(vpx_codec_alg_priv_t *ctx, int sl; svc->spatial_layer_to_encode = data->spatial_layer_id; + svc->first_spatial_layer_to_encode = data->spatial_layer_id; // TODO(jianj): Deprecated to be removed. svc->temporal_layer_id = data->temporal_layer_id; // Allow for setting temporal layer per spatial layer for superframe. -- 2.40.0