| Index: source/libvpx/test/datarate_test.cc
|
| diff --git a/source/libvpx/test/datarate_test.cc b/source/libvpx/test/datarate_test.cc
|
| index 9a8f014b8b4a081b0912fe917abe2c7616b46fe7..b6cae790398274365201de321cb2547f134fb09f 100644
|
| --- a/source/libvpx/test/datarate_test.cc
|
| +++ b/source/libvpx/test/datarate_test.cc
|
| @@ -761,6 +761,8 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
|
| first_drop_ = 0;
|
| bits_total_ = 0;
|
| duration_ = 0.0;
|
| + mismatch_psnr_ = 0.0;
|
| + mismatch_nframes_ = 0;
|
| }
|
| virtual void BeginPassHook(unsigned int /*pass*/) {
|
| }
|
| @@ -781,6 +783,7 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
|
| encoder->Control(VP8E_SET_CPUUSED, speed_setting_);
|
| encoder->Control(VP9E_SET_TILE_COLUMNS, 0);
|
| 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();
|
| timebase_ = static_cast<double>(tb.num) / tb.den;
|
| @@ -816,6 +819,18 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
|
| 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_;
|
| int64_t bits_in_buffer_model_;
|
| double timebase_;
|
| @@ -828,6 +843,8 @@ class DatarateOnePassCbrSvc : public ::libvpx_test::EncoderTest,
|
| size_t bits_in_last_frame_;
|
| vpx_svc_extra_cfg_t svc_params_;
|
| int speed_setting_;
|
| + double mismatch_psnr_;
|
| + int mismatch_nframes_;
|
| };
|
| static void assign_layer_bitrates(vpx_codec_enc_cfg_t *const enc_cfg,
|
| 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,
|
| }
|
|
|
| // 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) {
|
| cfg_.rc_buf_initial_sz = 500;
|
| cfg_.rc_buf_optimal_sz = 500;
|
| @@ -882,6 +899,7 @@ TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc) {
|
| cfg_.ts_rate_decimator[1] = 2;
|
| cfg_.ts_rate_decimator[2] = 1;
|
| cfg_.g_error_resilient = 1;
|
| + cfg_.g_threads = 1;
|
| cfg_.temporal_layering_mode = 3;
|
| svc_params_.scaling_factor_num[0] = 144;
|
| svc_params_.scaling_factor_den[0] = 288;
|
| @@ -905,9 +923,50 @@ TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc) {
|
| << " 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);
|
| }
|
| }
|
|
|
| +// 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);
|
| VP9_INSTANTIATE_TEST_CASE(DatarateTestVP9Large,
|
| ::testing::Values(::libvpx_test::kOnePassGood,
|
|
|