shithub: libvpx

Download patch

ref: 462a7c9f0a62780602d3979c3cfa968e38e45306
parent: 4508eb3123bd9b65a099715ea143680d268ad2ff
parent: 8ce67d714a6f1be586dcdd26524756d113b203f5
author: Jacky Chen <[email protected]>
date: Thu Jul 28 16:21:30 EDT 2016

Merge "vp9 svc: Enable different speed setting for each spatial layer."

--- a/test/datarate_test.cc
+++ b/test/datarate_test.cc
@@ -795,7 +795,9 @@
 class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
     public ::libvpx_test::CodecTestWith2Params<libvpx_test::TestMode, int> {
  public:
-  DatarateOnePassCbrSvc() : EncoderTest(GET_PARAM(0)) {}
+  DatarateOnePassCbrSvc() : EncoderTest(GET_PARAM(0)) {
+    memset(&svc_params_, 0, sizeof(svc_params_));
+  }
   virtual ~DatarateOnePassCbrSvc() {}
  protected:
   virtual void SetUp() {
@@ -823,6 +825,10 @@
       for (i = 0; i < VPX_MAX_LAYERS; ++i) {
         svc_params_.max_quantizers[i] = 63;
         svc_params_.min_quantizers[i] = 0;
+      }
+      svc_params_.speed_per_layer[0] = 5;
+      for (i = 1; i < VPX_SS_MAX_LAYERS; ++i) {
+        svc_params_.speed_per_layer[i] = 7;
       }
       encoder->Control(VP9E_SET_SVC, 1);
       encoder->Control(VP9E_SET_SVC_PARAMETERS, &svc_params_);
--- a/vp9/encoder/vp9_svc_layercontext.c
+++ b/vp9/encoder/vp9_svc_layercontext.c
@@ -135,7 +135,7 @@
         CHECK_MEM_ERROR(cm, lc->consec_zero_mv,
                         vpx_malloc(consec_zero_mv_size));
         memset(lc->consec_zero_mv, 0, consec_zero_mv_size);
-       }
+      }
     }
   }
 
@@ -293,6 +293,11 @@
   cpi->twopass = lc->twopass;
   cpi->oxcf.target_bandwidth = lc->target_bandwidth;
   cpi->alt_ref_source = lc->alt_ref_source;
+  // Check if it is one_pass_cbr_svc mode and lc->speed > 0 (real-time mode
+  // does not use speed = 0).
+  if (is_one_pass_cbr_svc(cpi) && lc->speed > 0) {
+    cpi->oxcf.speed = lc->speed;
+  }
   // Reset the frames_since_key and frames_to_key counters to their values
   // before the layer restore. Keep these defined for the stream (not layer).
   if (cpi->svc.number_temporal_layers > 1 ||
--- a/vp9/encoder/vp9_svc_layercontext.h
+++ b/vp9/encoder/vp9_svc_layercontext.h
@@ -46,6 +46,7 @@
   signed char *map;
   uint8_t *last_coded_q_map;
   uint8_t *consec_zero_mv;
+  uint8_t speed;
 } LAYER_CONTEXT;
 
 typedef struct {
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -1437,6 +1437,7 @@
       lc->min_q = params->min_quantizers[layer];
       lc->scaling_factor_num = params->scaling_factor_num[sl];
       lc->scaling_factor_den = params->scaling_factor_den[sl];
+      lc->speed = params->speed_per_layer[sl];
     }
   }
 
--- a/vpx/src/svc_encodeframe.c
+++ b/vpx/src/svc_encodeframe.c
@@ -410,7 +410,9 @@
   for (sl = 0; sl < VPX_SS_MAX_LAYERS; ++sl) {
     si->svc_params.scaling_factor_num[sl] = DEFAULT_SCALE_FACTORS_NUM[sl];
     si->svc_params.scaling_factor_den[sl] = DEFAULT_SCALE_FACTORS_DEN[sl];
+    si->svc_params.speed_per_layer[sl] = svc_ctx->speed;
   }
+
   for (tl = 0; tl < svc_ctx->temporal_layers; ++tl) {
     for (sl = 0; sl < svc_ctx->spatial_layers; ++sl) {
       i = sl * svc_ctx->temporal_layers + tl;
--- a/vpx/vpx_encoder.h
+++ b/vpx/vpx_encoder.h
@@ -715,6 +715,7 @@
   int min_quantizers[VPX_MAX_LAYERS];     /**< Min Q for each layer */
   int scaling_factor_num[VPX_MAX_LAYERS]; /**< Scaling factor-numerator */
   int scaling_factor_den[VPX_MAX_LAYERS]; /**< Scaling factor-denominator */
+  int speed_per_layer[VPX_MAX_LAYERS];    /**< Speed setting for each sl */
   int temporal_layering_mode;             /**< Temporal layering mode */
 } vpx_svc_extra_cfg_t;