ref: 01b19a1c3e1ced61033b687082b67fe62fef3459
parent: 4127799a91445b475cb66e5c7c17a46a2c567081
author: Jerome Jiang <jianj@google.com>
date: Fri Mar 30 06:47:41 EDT 2018
Code cleanup for datarate tests. Add/Remove static to functions. Name change. Change-Id: I5de3efc23cd151fe8e70fe67a7a11acfcfa707dc
--- a/test/svc_datarate_test.cc
+++ b/test/svc_datarate_test.cc
@@ -18,12 +18,12 @@
namespace {
-static void assign_layer_bitrates(vpx_codec_enc_cfg_t *const enc_cfg,
- const vpx_svc_extra_cfg_t *svc_params,
- int spatial_layers, int temporal_layers,
- int temporal_layering_mode,
- int *layer_target_avg_bandwidth,
- int64_t *bits_in_buffer_model) {
+void AssignLayerBitrates(vpx_codec_enc_cfg_t *const enc_cfg,
+ const vpx_svc_extra_cfg_t *svc_params,
+ int spatial_layers, int temporal_layers,
+ int temporal_layering_mode,
+ int *layer_target_avg_bandwidth,
+ int64_t *bits_in_buffer_model) {
int sl, spatial_layer_target;
float total = 0;
float alloc_ratio[VPX_MAX_LAYERS] = { 0 };
@@ -66,12 +66,11 @@
}
}
-static void CheckLayerRateTargeting(vpx_codec_enc_cfg_t *const cfg,
- int number_spatial_layers,
- int number_temporal_layers,
- double *file_datarate,
- double thresh_overshoot,
- double thresh_undershoot) {
+void CheckLayerRateTargeting(vpx_codec_enc_cfg_t *const cfg,
+ int number_spatial_layers,
+ int number_temporal_layers, double *file_datarate,
+ double thresh_overshoot,
+ double thresh_undershoot) {
for (int sl = 0; sl < number_spatial_layers; ++sl)
for (int tl = 0; tl < number_temporal_layers; ++tl) {
const int layer = sl * number_temporal_layers + tl;
@@ -265,9 +264,9 @@
// Buffer level should not reset on dynamic bitrate change.
memcpy(bits_in_buffer_model_tmp, bits_in_buffer_model_,
sizeof(bits_in_buffer_model_));
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
memcpy(bits_in_buffer_model_, bits_in_buffer_model_tmp,
sizeof(bits_in_buffer_model_));
@@ -503,9 +502,9 @@
ResetModel();
tune_content_ = 1;
base_speed_setting_ = speed_setting_;
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
CheckLayerRateTargeting(&cfg_, number_spatial_layers_,
number_temporal_layers_, file_datarate_, 0.78, 1.15);
@@ -551,9 +550,9 @@
for (int i = 200; i <= 800; i += 200) {
cfg_.rc_target_bitrate = i;
ResetModel();
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
CheckLayerRateTargeting(&cfg_, number_spatial_layers_,
number_temporal_layers_, file_datarate_, 0.75, 1.2);
@@ -604,9 +603,9 @@
cfg_.rc_target_bitrate = i;
ResetModel();
denoiser_on_ = noise_sen;
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
CheckLayerRateTargeting(&cfg_, number_spatial_layers_,
number_temporal_layers_, file_datarate_, 0.78,
@@ -656,9 +655,9 @@
cfg_.kf_max_dist = j;
key_frame_spacing_ = j;
ResetModel();
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
CheckLayerRateTargeting(&cfg_, number_spatial_layers_,
number_temporal_layers_, file_datarate_, 0.78,
@@ -706,9 +705,9 @@
cfg_.rc_target_bitrate = i;
ResetModel();
constrained_framedrop_ = k;
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
CheckLayerRateTargeting(&cfg_, number_spatial_layers_,
number_temporal_layers_, file_datarate_, 0.75,
@@ -756,9 +755,9 @@
top_sl_height_ = 480;
cfg_.rc_target_bitrate = 800;
ResetModel();
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
CheckLayerRateTargeting(&cfg_, number_spatial_layers_,
number_temporal_layers_, file_datarate_, 0.78, 1.15);
@@ -804,9 +803,9 @@
cfg_.rc_target_bitrate = 800;
ResetModel();
change_bitrate_ = true;
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
CheckLayerRateTargeting(&cfg_, number_spatial_layers_,
number_temporal_layers_, file_datarate_, 0.78, 1.15);
@@ -854,9 +853,9 @@
top_sl_height_ = 480;
cfg_.rc_target_bitrate = 800;
ResetModel();
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
CheckLayerRateTargeting(&cfg_, number_spatial_layers_,
number_temporal_layers_, file_datarate_, 0.78, 1.15);
@@ -902,9 +901,9 @@
cfg_.rc_target_bitrate = 800;
ResetModel();
dynamic_drop_layer_ = true;
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
// Don't check rate targeting on top spatial layer since it will be skipped
// for part of the sequence.
@@ -955,9 +954,9 @@
cfg_.kf_max_dist = j;
key_frame_spacing_ = j;
ResetModel();
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
CheckLayerRateTargeting(&cfg_, number_spatial_layers_,
number_temporal_layers_, file_datarate_, 0.78,
@@ -1007,9 +1006,9 @@
cfg_.rc_target_bitrate = i;
ResetModel();
constrained_framedrop_ = k;
- assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
- cfg_.ts_number_layers, cfg_.temporal_layering_mode,
- layer_target_avg_bandwidth_, bits_in_buffer_model_);
+ AssignLayerBitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
+ cfg_.ts_number_layers, cfg_.temporal_layering_mode,
+ layer_target_avg_bandwidth_, bits_in_buffer_model_);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
CheckLayerRateTargeting(&cfg_, number_spatial_layers_,
number_temporal_layers_, file_datarate_, 0.73,
--- a/test/vp9_datarate_test.cc
+++ b/test/vp9_datarate_test.cc
@@ -67,7 +67,7 @@
// LAST is always update on base/layer 0, GOLDEN is updated on layer 1.
// For this 3 layer example, the 2nd enhancement layer (layer 2) updates
// the altref frame.
- int SetFrameFlags(int frame_num, int num_temp_layers) {
+ static int GetFrameFlags(int frame_num, int num_temp_layers) {
int frame_flags = 0;
if (num_temp_layers == 2) {
if (frame_num % 2 == 0) {
@@ -95,7 +95,7 @@
return frame_flags;
}
- int SetLayerId(int frame_num, int num_temp_layers) {
+ static int SetLayerId(int frame_num, int num_temp_layers) {
int layer_id = 0;
if (num_temp_layers == 2) {
if (frame_num % 2 == 0) {
@@ -143,7 +143,7 @@
}
vpx_svc_layer_id_t layer_id;
layer_id.spatial_layer_id = 0;
- frame_flags_ = SetFrameFlags(video->frame(), cfg_.ts_number_layers);
+ frame_flags_ = GetFrameFlags(video->frame(), cfg_.ts_number_layers);
layer_id.temporal_layer_id =
SetLayerId(video->frame(), cfg_.ts_number_layers);
encoder->Control(VP9E_SET_SVC_LAYER_ID, &layer_id);