Commit c9426aaa authored by Marco's avatar Marco

Add unittest for SVC 1pass CBR mode with 4 threads.

Change-Id: I2b25d495d0dd3eedea31aa12cb908a90480f25de
parent 2808dd12
...@@ -761,6 +761,8 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest, ...@@ -761,6 +761,8 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
first_drop_ = 0; first_drop_ = 0;
bits_total_ = 0; bits_total_ = 0;
duration_ = 0.0; duration_ = 0.0;
mismatch_psnr_ = 0.0;
mismatch_nframes_ = 0;
} }
virtual void BeginPassHook(unsigned int /*pass*/) { virtual void BeginPassHook(unsigned int /*pass*/) {
} }
...@@ -781,6 +783,7 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest, ...@@ -781,6 +783,7 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
encoder->Control(VP8E_SET_CPUUSED, speed_setting_); encoder->Control(VP8E_SET_CPUUSED, speed_setting_);
encoder->Control(VP9E_SET_TILE_COLUMNS, 0); encoder->Control(VP9E_SET_TILE_COLUMNS, 0);
encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 300); encoder->Control(VP8E_SET_MAX_INTRA_BITRATE_PCT, 300);
encoder->Control(VP9E_SET_TILE_COLUMNS, (cfg_.g_threads >> 1));
} }
const vpx_rational_t tb = video->timebase(); const vpx_rational_t tb = video->timebase();
timebase_ = static_cast<double>(tb.num) / tb.den; timebase_ = static_cast<double>(tb.num) / tb.den;
...@@ -816,6 +819,18 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest, ...@@ -816,6 +819,18 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
file_datarate_ = file_size_in_kb / duration_; file_datarate_ = file_size_in_kb / duration_;
} }
} }
virtual void MismatchHook(const vpx_image_t *img1,
const vpx_image_t *img2) {
double mismatch_psnr = compute_psnr(img1, img2);
mismatch_psnr_ += mismatch_psnr;
++mismatch_nframes_;
}
unsigned int GetMismatchFrames() {
return mismatch_nframes_;
}
vpx_codec_pts_t last_pts_; vpx_codec_pts_t last_pts_;
int64_t bits_in_buffer_model_; int64_t bits_in_buffer_model_;
double timebase_; double timebase_;
...@@ -828,6 +843,8 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest, ...@@ -828,6 +843,8 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
size_t bits_in_last_frame_; size_t bits_in_last_frame_;
vpx_svc_extra_cfg_t svc_params_; vpx_svc_extra_cfg_t svc_params_;
int speed_setting_; int speed_setting_;
double mismatch_psnr_;
int mismatch_nframes_;
}; };
static void assign_layer_bitrates(vpx_codec_enc_cfg_t *const enc_cfg, static void assign_layer_bitrates(vpx_codec_enc_cfg_t *const enc_cfg,
const vpx_svc_extra_cfg_t *svc_params, const vpx_svc_extra_cfg_t *svc_params,
...@@ -867,7 +884,7 @@ static void assign_layer_bitrates(vpx_codec_enc_cfg_t *const enc_cfg, ...@@ -867,7 +884,7 @@ static void assign_layer_bitrates(vpx_codec_enc_cfg_t *const enc_cfg,
} }
// Check basic rate targeting for 1 pass CBR SVC: 2 spatial layers and // Check basic rate targeting for 1 pass CBR SVC: 2 spatial layers and
// 3 temporal layers. // 3 temporal layers. Run CIF clip with 1 thread.
TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc) { TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc) {
cfg_.rc_buf_initial_sz = 500; cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500; cfg_.rc_buf_optimal_sz = 500;
...@@ -882,6 +899,7 @@ TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc) { ...@@ -882,6 +899,7 @@ TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc) {
cfg_.ts_rate_decimator[1] = 2; cfg_.ts_rate_decimator[1] = 2;
cfg_.ts_rate_decimator[2] = 1; cfg_.ts_rate_decimator[2] = 1;
cfg_.g_error_resilient = 1; cfg_.g_error_resilient = 1;
cfg_.g_threads = 1;
cfg_.temporal_layering_mode = 3; cfg_.temporal_layering_mode = 3;
svc_params_.scaling_factor_num[0] = 144; svc_params_.scaling_factor_num[0] = 144;
svc_params_.scaling_factor_den[0] = 288; svc_params_.scaling_factor_den[0] = 288;
...@@ -905,9 +923,50 @@ TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc) { ...@@ -905,9 +923,50 @@ TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc) {
<< " The datarate for the file exceeds the target by too much!"; << " The datarate for the file exceeds the target by too much!";
ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.15) ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.15)
<< " The datarate for the file is lower than the target by too much!"; << " The datarate for the file is lower than the target by too much!";
EXPECT_EQ(GetMismatchFrames(), (unsigned int) 0);
} }
} }
// Check basic rate targeting for 1 pass CBR SVC: 2 spatial layers and
// 3 temporal layers. Run HD clip with 4 threads.
TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc4threads) {
cfg_.rc_buf_initial_sz = 500;
cfg_.rc_buf_optimal_sz = 500;
cfg_.rc_buf_sz = 1000;
cfg_.rc_min_quantizer = 0;
cfg_.rc_max_quantizer = 63;
cfg_.rc_end_usage = VPX_CBR;
cfg_.g_lag_in_frames = 0;
cfg_.ss_number_layers = 2;
cfg_.ts_number_layers = 3;
cfg_.ts_rate_decimator[0] = 4;
cfg_.ts_rate_decimator[1] = 2;
cfg_.ts_rate_decimator[2] = 1;
cfg_.g_error_resilient = 1;
cfg_.g_threads = 4;
cfg_.temporal_layering_mode = 3;
svc_params_.scaling_factor_num[0] = 144;
svc_params_.scaling_factor_den[0] = 288;
svc_params_.scaling_factor_num[1] = 288;
svc_params_.scaling_factor_den[1] = 288;
// TODO(wonkap/marpan): No frame drop for now, we need to implement correct
// frame dropping for SVC.
cfg_.rc_dropframe_thresh = 0;
::libvpx_test::I420VideoSource video("niklas_1280_720_30.y4m", 1280, 720,
30, 1, 0, 300);
cfg_.rc_target_bitrate = 800;
ResetModel();
assign_layer_bitrates(&cfg_, &svc_params_, cfg_.ss_number_layers,
cfg_.ts_number_layers, cfg_.temporal_layering_mode,
cfg_.rc_target_bitrate);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.85)
<< " The datarate for the file exceeds the target by too much!";
ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.15)
<< " The datarate for the file is lower than the target by too much!";
EXPECT_EQ(GetMismatchFrames(), (unsigned int) 0);
}
VP8_INSTANTIATE_TEST_CASE(DatarateTestLarge, ALL_TEST_MODES); VP8_INSTANTIATE_TEST_CASE(DatarateTestLarge, ALL_TEST_MODES);
VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9Large, VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9Large,
::testing::Values(::libvpx_test::kOnePassGood, ::testing::Values(::libvpx_test::kOnePassGood,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment