diff options
author | Jerome Jiang <jianj@google.com> | 2021-06-15 12:54:13 -0700 |
---|---|---|
committer | Jerome Jiang <jianj@google.com> | 2021-06-18 14:47:43 -0700 |
commit | 1f45e7b07ec839dae7a90455e00c3b2d553ea772 (patch) | |
tree | fff259b82c74f3c0caf5842d11f01dc6fe94a988 /test | |
parent | 338013712e516d07388651437918e6328ea909f5 (diff) | |
download | libvpx-1f45e7b07ec839dae7a90455e00c3b2d553ea772.tar libvpx-1f45e7b07ec839dae7a90455e00c3b2d553ea772.tar.gz libvpx-1f45e7b07ec839dae7a90455e00c3b2d553ea772.tar.bz2 libvpx-1f45e7b07ec839dae7a90455e00c3b2d553ea772.zip |
vp9 rc: add vbr to rtc rate control library
Change-Id: I3d2565572c2b905966d60bcaa6e5e6f057b1bd51
Diffstat (limited to 'test')
-rw-r--r-- | test/ratectrl_rtc_test.cc | 104 | ||||
-rw-r--r-- | test/test-data.mk | 2 |
2 files changed, 95 insertions, 11 deletions
diff --git a/test/ratectrl_rtc_test.cc b/test/ratectrl_rtc_test.cc index 58bfac3a7..e9a9f15e9 100644 --- a/test/ratectrl_rtc_test.cc +++ b/test/ratectrl_rtc_test.cc @@ -32,6 +32,7 @@ struct FrameInfo { info.bytes_used; return is; } + int frame_id; int spatial_id; int temporal_id; @@ -48,24 +49,32 @@ struct FrameInfo { // This test runs the rate control interface and compare against ground truth // generated by encoders. // Settings for the encoder: -// For 1 layer: +// For 1 layer CBR: +// - AQ_Mode 0 +// - Disable golden refresh +// - Bitrate x 2 at frame/superframe 200 +// - Bitrate / 4 at frame/superframe 400 +// examples/vpx_temporal_svc_encoder gipsrec_motion1.1280_720.yuv out vp9 +// 1280 720 1 30 7 0 0 1 0 1000 // +// For 1 layer VBR: +// - Set rc_end_usage to VPX_VBR +// - AQ Mode 0 +// - Disable vp9_compute_frame_low_motion in vp9_encoder.c // examples/vpx_temporal_svc_encoder gipsrec_motion1.1280_720.yuv out vp9 // 1280 720 1 30 7 0 0 1 0 1000 // // For SVC (3 temporal layers, 3 spatial layers): -// +// - AQ_Mode 0 +// - Disable golden refresh +// - Bitrate x 2 at frame/superframe 200 +// - Bitrate / 4 at frame/superframe 400 // examples/vp9_spatial_svc_encoder -f 10000 -w 1280 -h 720 -t 1/30 -sl 3 // -k 10000 -bl 100,140,200,250,350,500,450,630,900 -b 1600 --rc-end-usage=1 // --lag-in-frames=0 --passes=1 --speed=7 --threads=1 // --temporal-layering-mode=3 -aq 1 -rcstat 1 // gipsrec_motion1.1280_720.yuv -o out.webm // -// - AQ_Mode 0 -// - Disable golden refresh -// - Bitrate x 2 at frame/superframe 200 -// - Bitrate / 4 at frame/superframe 400 -// // The generated file includes: // frame number, spatial layer ID, temporal layer ID, base QP, target // bandwidth, buffer level, loopfilter level, encoded frame size @@ -77,8 +86,8 @@ class RcInterfaceTest : public ::testing::Test { virtual ~RcInterfaceTest() {} protected: - void RunOneLayer() { - SetConfigOneLayer(); + void RunOneLayerCBR() { + SetConfigOneLayerCBR(); rc_api_ = libvpx::VP9RateControlRTC::Create(rc_cfg_); FrameInfo frame_info; libvpx::VP9FrameParamsQpRTC frame_params; @@ -144,8 +153,58 @@ class RcInterfaceTest : public ::testing::Test { } } + void RunOneLayerVBR() { + SetConfigOneLayerVBR(); + rc_api_ = libvpx::VP9RateControlRTC::Create(rc_cfg_); + FrameInfo frame_info; + libvpx::VP9FrameParamsQpRTC frame_params; + frame_params.frame_type = KEY_FRAME; + frame_params.spatial_layer_id = 0; + frame_params.temporal_layer_id = 0; + std::ifstream one_layer_file; + one_layer_file.open(libvpx_test::GetDataPath() + + "/rc_interface_test_one_layer_vbr"); + ASSERT_TRUE(one_layer_file.good()); + for (size_t i = 0; i < kNumFrame; i++) { + one_layer_file >> frame_info; + if (frame_info.frame_id > 0) frame_params.frame_type = INTER_FRAME; + ASSERT_EQ(frame_info.spatial_id, 0); + ASSERT_EQ(frame_info.temporal_id, 0); + rc_api_->ComputeQP(frame_params); + ASSERT_EQ(rc_api_->GetQP(), frame_info.base_q); + ASSERT_EQ(rc_api_->GetLoopfilterLevel(), frame_info.filter_level_); + rc_api_->PostEncodeUpdate(frame_info.bytes_used); + } + } + + void RunOneLayerVBRPeriodicKey() { + SetConfigOneLayerVBRPeriodicKey(); + rc_api_ = libvpx::VP9RateControlRTC::Create(rc_cfg_); + FrameInfo frame_info; + libvpx::VP9FrameParamsQpRTC frame_params; + frame_params.frame_type = KEY_FRAME; + frame_params.spatial_layer_id = 0; + frame_params.temporal_layer_id = 0; + std::ifstream one_layer_file; + one_layer_file.open(libvpx_test::GetDataPath() + + "/rc_interface_test_one_layer_vbr_periodic_key"); + ASSERT_TRUE(one_layer_file.good()); + for (size_t i = 0; i < kNumFrame; i++) { + one_layer_file >> frame_info; + if (frame_info.frame_id > 0) frame_params.frame_type = INTER_FRAME; + if (frame_info.frame_id % rc_cfg_.key_freq == 0) + frame_params.frame_type = KEY_FRAME; + ASSERT_EQ(frame_info.spatial_id, 0); + ASSERT_EQ(frame_info.temporal_id, 0); + rc_api_->ComputeQP(frame_params); + ASSERT_EQ(rc_api_->GetQP(), frame_info.base_q); + ASSERT_EQ(rc_api_->GetLoopfilterLevel(), frame_info.filter_level_); + rc_api_->PostEncodeUpdate(frame_info.bytes_used); + } + } + private: - void SetConfigOneLayer() { + void SetConfig() { rc_cfg_.width = 1280; rc_cfg_.height = 720; rc_cfg_.max_quantizer = 52; @@ -167,6 +226,24 @@ class RcInterfaceTest : public ::testing::Test { rc_cfg_.min_quantizers[0] = 2; } + void SetConfigOneLayerCBR() { + SetConfig(); + rc_cfg_.rc_mode = VPX_CBR; + rc_cfg_.key_freq = 3000; + } + + void SetConfigOneLayerVBR() { + SetConfig(); + rc_cfg_.rc_mode = VPX_VBR; + rc_cfg_.key_freq = 3000; + } + + void SetConfigOneLayerVBRPeriodicKey() { + SetConfig(); + rc_cfg_.rc_mode = VPX_VBR; + rc_cfg_.key_freq = 300; + } + void SetConfigSVC() { rc_cfg_.width = 1280; rc_cfg_.height = 720; @@ -182,6 +259,7 @@ class RcInterfaceTest : public ::testing::Test { rc_cfg_.framerate = 30.0; rc_cfg_.ss_number_layers = 3; rc_cfg_.ts_number_layers = 3; + rc_cfg_.rc_mode = VPX_CBR; rc_cfg_.scaling_factor_num[0] = 1; rc_cfg_.scaling_factor_den[0] = 4; @@ -217,7 +295,11 @@ class RcInterfaceTest : public ::testing::Test { libvpx::VP9RateControlRtcConfig rc_cfg_; }; -TEST_F(RcInterfaceTest, OneLayer) { RunOneLayer(); } +TEST_F(RcInterfaceTest, OneLayerCBR) { RunOneLayerCBR(); } + +TEST_F(RcInterfaceTest, OneLayerVBR) { RunOneLayerVBR(); } + +TEST_F(RcInterfaceTest, OneLayerVBRPeriodicKey) { RunOneLayerVBRPeriodicKey(); } TEST_F(RcInterfaceTest, SVC) { RunSVC(); } } // namespace diff --git a/test/test-data.mk b/test/test-data.mk index 744901b11..379fc6e7a 100644 --- a/test/test-data.mk +++ b/test/test-data.mk @@ -28,6 +28,8 @@ LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += rush_hour_444.y4m LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += screendata.y4m LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += niklas_640_480_30.yuv LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += rc_interface_test_one_layer +LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += rc_interface_test_one_layer_vbr +LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += rc_interface_test_one_layer_vbr_periodic_key LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += rc_interface_test_svc LIBVPX_TEST_DATA-$(CONFIG_VP9_ENCODER) += bus_352x288_420_f20_b8.yuv |