shithub: libvpx

Download patch

ref: 3cb9c5ffe93f32d3299389f3e756941524e2b223
parent: 62c47475325915008e3f9cca6b636aeca07ab607
author: Marco Paniconi <marpan@google.com>
date: Wed Mar 21 06:56:09 EDT 2018

vp9-svc: Fix to sample encoder

Get the correct computation of number of input
layers to account for frame drops.

Change-Id: I39637381e1981b53c930da67a5c525191de6907d

--- a/examples/vp9_spatial_svc_encoder.c
+++ b/examples/vp9_spatial_svc_encoder.c
@@ -670,7 +670,10 @@
     die("Failed to initialize encoder\n");
 
 #if OUTPUT_RC_STATS
+  rc.window_count = 1;
   rc.window_size = 15;  // Silence a static analysis warning.
+  rc.avg_st_encoding_bitrate = 0.0;
+  rc.variance_st_encoding_bitrate = 0.0;
   if (svc_ctx.output_rc_stat) {
     set_rate_control_stats(&rc, &enc_cfg);
     framerate = enc_cfg.g_timebase.den / enc_cfg.g_timebase.num;
@@ -763,6 +766,17 @@
         ++rc.layer_input_frames[sl * enc_cfg.ts_number_layers +
                                 layer_id.temporal_layer_id];
       }
+    } else {
+      // For the fixed pattern SVC, temporal layer is given by superframe count.
+      unsigned int tl = 0;
+      if (enc_cfg.ts_number_layers == 2)
+        tl = (frame_cnt % 2 != 0);
+      else if (enc_cfg.ts_number_layers == 3) {
+        if (frame_cnt % 2 != 0) tl = 2;
+        if ((frame_cnt > 1) && ((frame_cnt - 2) % 4 == 0)) tl = 1;
+      }
+      for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl)
+        ++rc.layer_input_frames[sl * enc_cfg.ts_number_layers + tl];
     }
 
     vpx_usec_timer_start(&timer);
@@ -805,8 +819,6 @@
                   VP9E_TEMPORAL_LAYERING_MODE_BYPASS) {
                 int num_layers_encoded = 0;
                 for (sl = 0; sl < enc_cfg.ss_number_layers; ++sl) {
-                  ++rc.layer_input_frames[sl * enc_cfg.ts_number_layers +
-                                          layer_id.temporal_layer_id];
                   sizes[sl] = 0;
                   if (cx_pkt->data.frame.spatial_layer_encoded[sl]) {
                     sizes[sl] = sizes_parsed[num_layers_encoded];