diff --git a/test/datarate_test.cc b/test/datarate_test.cc index c5e6f9b6e..e29eb97d0 100644 --- a/test/datarate_test.cc +++ b/test/datarate_test.cc @@ -1455,7 +1455,7 @@ class DatarateOnePassCbrSvc if (constrained_framedrop_) { vpx_svc_frame_drop_t svc_drop_frame; - svc_drop_frame.framedrop_mode = 1; + svc_drop_frame.framedrop_mode = CONSTRAINED_LAYER_DROP; for (i = 0; i < number_spatial_layers_; i++) svc_drop_frame.framedrop_thresh[i] = 30; encoder->Control(VP9E_SET_SVC_FRAME_DROP_LAYER, &svc_drop_frame); diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 36cd480e6..aa9c3bf46 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -4624,12 +4624,14 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, size_t *size, (!cpi->use_svc || !cpi->svc.layer_context[cpi->svc.temporal_layer_id].is_key_frame)) { int svc_prev_layer_dropped = 0; - // In the contrained framedrop mode for svc (framedrop_mode = 1), if the - // previous spatial layer was dropped, drop the current spatial layer. + // In the contrained framedrop mode for svc (framedrop_mode = + // CONSTRAINED_LAYER_DROP), if the previous spatial layer was dropped, drop + // the current spatial layer. if (cpi->use_svc && cpi->svc.spatial_layer_id > 0 && cpi->svc.drop_spatial_layer[cpi->svc.spatial_layer_id - 1]) svc_prev_layer_dropped = 1; - if ((svc_prev_layer_dropped && cpi->svc.framedrop_mode) || + if ((svc_prev_layer_dropped && + cpi->svc.framedrop_mode == CONSTRAINED_LAYER_DROP) || vp9_rc_drop_frame(cpi)) { vp9_rc_postencode_update_drop_frame(cpi); cpi->ext_refresh_frame_flags_pending = 0; diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index d6d5db47e..b5f1a5c5c 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -395,14 +395,14 @@ void vp9_rc_init(const VP9EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) { static int check_buffer(VP9_COMP *cpi, int drop_mark) { SVC *svc = &cpi->svc; - if (!cpi->use_svc || !cpi->svc.framedrop_mode) { + if (!cpi->use_svc || cpi->svc.framedrop_mode == LAYER_DROP) { RATE_CONTROL *const rc = &cpi->rc; return (rc->buffer_level <= drop_mark); } else { int i; - // For SVC in the constrained framedrop mode (svc->framedrop_mode = 1): - // the condition on buffer (to drop frame) is checked on current and - // upper spatial layers. + // For SVC in the constrained framedrop mode (svc->framedrop_mode = + // CONSTRAINED_LAYER_DROP): the condition on buffer (to drop frame) is + // checked on current and upper spatial layers. for (i = svc->spatial_layer_id; i < svc->number_spatial_layers; ++i) { const int layer = LAYER_IDS_TO_IDX(i, svc->temporal_layer_id, svc->number_temporal_layers); diff --git a/vp9/encoder/vp9_svc_layercontext.c b/vp9/encoder/vp9_svc_layercontext.c index 1d36999b4..531a5d4bc 100644 --- a/vp9/encoder/vp9_svc_layercontext.c +++ b/vp9/encoder/vp9_svc_layercontext.c @@ -39,7 +39,7 @@ void vp9_init_layer_context(VP9_COMP *const cpi) { svc->non_reference_frame = 0; svc->skip_enhancement_layer = 0; svc->disable_inter_layer_pred = INTER_LAYER_PRED_ON; - svc->framedrop_mode = 0; + svc->framedrop_mode = LAYER_DROP; for (i = 0; i < REF_FRAMES; ++i) svc->ref_frame_index[i] = -1; for (sl = 0; sl < oxcf->ss_number_layers; ++sl) { diff --git a/vp9/encoder/vp9_svc_layercontext.h b/vp9/encoder/vp9_svc_layercontext.h index 841b9b30c..a7fa26924 100644 --- a/vp9/encoder/vp9_svc_layercontext.h +++ b/vp9/encoder/vp9_svc_layercontext.h @@ -115,7 +115,7 @@ typedef struct SVC { int last_layer_dropped[VPX_MAX_LAYERS]; int drop_spatial_layer[VPX_MAX_LAYERS]; int framedrop_thresh[VPX_MAX_LAYERS]; - int framedrop_mode; + SVC_LAYER_DROP_MODE framedrop_mode; INTER_LAYER_PRED disable_inter_layer_pred; } SVC; diff --git a/vpx/vp8cx.h b/vpx/vp8cx.h index 32ddd492e..860cce686 100644 --- a/vpx/vp8cx.h +++ b/vpx/vp8cx.h @@ -748,7 +748,7 @@ typedef struct vpx_svc_layer_id { int temporal_layer_id; /**< Temporal layer id number. */ } vpx_svc_layer_id_t; -/*!\brief vp9 svc frame flag parameters. +/*!\brief vp9 svc frame flag parameters. * * This defines the frame flags and buffer indices for each spatial layer for * svc encoding. @@ -763,7 +763,18 @@ typedef struct vpx_svc_ref_frame_config { int alt_fb_idx[VPX_TS_MAX_LAYERS]; /**< Altref buffer index. */ } vpx_svc_ref_frame_config_t; -/*!\brief vp9 svc frame dropping parameters. +/*!\brief VP9 svc frame dropping mode. + * + * This defines the frame drop mode for SVC. + * + */ +typedef enum { + LAYER_DROP, /**< Any spatial layer can drop. */ + CONSTRAINED_LAYER_DROP + /**< Upper layers are constrained to drop if current layer drops. */ +} SVC_LAYER_DROP_MODE; + +/*!\brief vp9 svc frame dropping parameters. * * This defines the frame drop thresholds for each spatial layer, and the * the frame dropping mode: 0 = layer based frame dropping (default), @@ -772,7 +783,8 @@ typedef struct vpx_svc_ref_frame_config { */ typedef struct vpx_svc_frame_drop { int framedrop_thresh[VPX_SS_MAX_LAYERS]; /**< Frame drop thresholds */ - int framedrop_mode; /**< Layer-based or constrained dropping. */ + SVC_LAYER_DROP_MODE + framedrop_mode; /**< Layer-based or constrained dropping. */ } vpx_svc_frame_drop_t; /*!\cond */