shithub: libvpx

Download patch

ref: 70b86af22e0b99c7bbfefa99646bada0a22b77cc
parent: 382afcab988bad359b8fa4892aae1f11b5200b74
author: Jerome Jiang <jianj@google.com>
date: Wed Mar 28 12:23:26 EDT 2018

VP9 SVC: Add enum type for framedrop_mode.

Change-Id: I3d4697b00729553e0860762b9264e29b8a89b9d4

--- a/test/datarate_test.cc
+++ b/test/datarate_test.cc
@@ -1455,7 +1455,7 @@
 
       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);
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -4624,12 +4624,14 @@
       (!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;
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -395,14 +395,14 @@
 
 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);
--- a/vp9/encoder/vp9_svc_layercontext.c
+++ b/vp9/encoder/vp9_svc_layercontext.c
@@ -39,7 +39,7 @@
   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) {
--- a/vp9/encoder/vp9_svc_layercontext.h
+++ b/vp9/encoder/vp9_svc_layercontext.h
@@ -115,7 +115,7 @@
   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;
--- a/vpx/vp8cx.h
+++ b/vpx/vp8cx.h
@@ -748,7 +748,7 @@
   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,8 +763,19 @@
   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),
  * 1 = constrained dropping where current layer drop forces all upper
@@ -772,7 +783,8 @@
  */
 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 */