shithub: libvpx

Download patch

ref: b0027b96aeb3051a8c81fc980c24f1eace0931a0
parent: 16eba81f6955adf8b60fd7a71b775ee004f970ba
author: Marco <[email protected]>
date: Fri Nov 20 05:12:11 EST 2015

vp9-svc: Fix to allow setting qp-max/min per spatial and temporal layer.

Change-Id: Ic0ec32c1d7f7c08c9f956592dccbfd9060b1f624

--- a/test/datarate_test.cc
+++ b/test/datarate_test.cc
@@ -770,7 +770,7 @@
                                   ::libvpx_test::Encoder *encoder) {
     if (video->frame() == 0) {
       int i;
-      for (i = 0; i < 2; ++i) {
+      for (i = 0; i < VPX_MAX_LAYERS; ++i) {
         svc_params_.max_quantizers[i] = 63;
         svc_params_.min_quantizers[i] = 0;
       }
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -1393,8 +1393,8 @@
           LAYER_IDS_TO_IDX(sl, tl, cpi->svc.number_temporal_layers);
       LAYER_CONTEXT *lc =
           &cpi->svc.layer_context[layer];
-      lc->max_q = params->max_quantizers[sl];
-      lc->min_q = params->min_quantizers[sl];
+      lc->max_q = params->max_quantizers[layer];
+      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];
     }
--- a/vpx/src/svc_encodeframe.c
+++ b/vpx/src/svc_encodeframe.c
@@ -385,7 +385,7 @@
                              vpx_codec_iface_t *iface,
                              vpx_codec_enc_cfg_t *enc_cfg) {
   vpx_codec_err_t res;
-  int i;
+  int i, sl , tl;
   SvcInternal_t *const si = get_svc_internal(svc_ctx);
   if (svc_ctx == NULL || codec_ctx == NULL || iface == NULL ||
       enc_cfg == NULL) {
@@ -423,11 +423,14 @@
     svc_ctx->temporal_layers = 2;
   }
 
-  for (i = 0; i < VPX_SS_MAX_LAYERS; ++i) {
-    si->svc_params.max_quantizers[i] = MAX_QUANTIZER;
-    si->svc_params.min_quantizers[i] = 0;
-    si->svc_params.scaling_factor_num[i] = DEFAULT_SCALE_FACTORS_NUM[i];
-    si->svc_params.scaling_factor_den[i] = DEFAULT_SCALE_FACTORS_DEN[i];
+  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;
+      si->svc_params.max_quantizers[i] = MAX_QUANTIZER;
+      si->svc_params.min_quantizers[i] = 0;
+      si->svc_params.scaling_factor_num[sl] = DEFAULT_SCALE_FACTORS_NUM[sl];
+      si->svc_params.scaling_factor_den[sl] = DEFAULT_SCALE_FACTORS_DEN[sl];
+    }
   }
 
   // Parse aggregate command line options. Options must start with