From 3cb9c5ffe93f32d3299389f3e756941524e2b223 Mon Sep 17 00:00:00 2001 From: Marco Paniconi Date: Wed, 21 Mar 2018 10:56:09 -0700 Subject: [PATCH] vp9-svc: Fix to sample encoder Get the correct computation of number of input layers to account for frame drops. Change-Id: I39637381e1981b53c930da67a5c525191de6907d --- examples/vp9_spatial_svc_encoder.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/examples/vp9_spatial_svc_encoder.c b/examples/vp9_spatial_svc_encoder.c index ccc9ebdd8..4531a9ea4 100644 --- a/examples/vp9_spatial_svc_encoder.c +++ b/examples/vp9_spatial_svc_encoder.c @@ -670,7 +670,10 @@ int main(int argc, const char **argv) { 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 @@ int main(int argc, const char **argv) { ++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 @@ int main(int argc, const char **argv) { 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]; -- 2.40.0