summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Jiang <jianj@google.com>2017-10-18 19:39:26 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-10-18 19:39:26 +0000
commit401e6d48bfd3cbf74a41da724d05c989e207662b (patch)
tree623e29a650924c2e264fe9428ca48b0fce9779de
parentec2fced451c634b73055631617e0dd5b8e26b9ed (diff)
parentbd6d82e881a40b8cbb57188df8b166d550a2e241 (diff)
downloadlibvpx-401e6d48bfd3cbf74a41da724d05c989e207662b.tar
libvpx-401e6d48bfd3cbf74a41da724d05c989e207662b.tar.gz
libvpx-401e6d48bfd3cbf74a41da724d05c989e207662b.tar.bz2
libvpx-401e6d48bfd3cbf74a41da724d05c989e207662b.zip
Merge "Add datarate test for vp8 ROI."
-rw-r--r--test/datarate_test.cc70
-rw-r--r--test/encode_test_driver.h7
2 files changed, 77 insertions, 0 deletions
diff --git a/test/datarate_test.cc b/test/datarate_test.cc
index 7b0d62818..7ae761fd4 100644
--- a/test/datarate_test.cc
+++ b/test/datarate_test.cc
@@ -44,6 +44,7 @@ class DatarateTestLarge
denoiser_offon_test_ = 0;
denoiser_offon_period_ = -1;
gf_boost_ = 0;
+ use_roi_ = 0;
}
virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
@@ -54,6 +55,12 @@ class DatarateTestLarge
encoder->Control(VP8E_SET_GF_CBR_BOOST_PCT, gf_boost_);
}
+#if CONFIG_VP8_ENCODER
+ if (use_roi_ == 1) {
+ encoder->Control(VP8E_SET_ROI_MAP, &roi_);
+ }
+#endif
+
if (denoiser_offon_test_) {
ASSERT_GT(denoiser_offon_period_, 0)
<< "denoiser_offon_period_ is not positive.";
@@ -145,6 +152,8 @@ class DatarateTestLarge
int denoiser_offon_period_;
int set_cpu_used_;
int gf_boost_;
+ int use_roi_;
+ vpx_roi_map_t roi_;
};
#if CONFIG_TEMPORAL_DENOISING
@@ -414,6 +423,67 @@ TEST_P(DatarateTestRealTime, DropFramesMultiThreads) {
<< " The datarate for the file missed the target!";
}
+TEST_P(DatarateTestRealTime, RegionOfInterest) {
+ denoiser_on_ = 0;
+ cfg_.rc_buf_initial_sz = 500;
+ cfg_.rc_dropframe_thresh = 0;
+ cfg_.rc_max_quantizer = 56;
+ cfg_.rc_end_usage = VPX_CBR;
+ // Encode using multiple threads.
+ cfg_.g_threads = 2;
+
+ ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
+ 30, 1, 0, 300);
+ cfg_.rc_target_bitrate = 450;
+ cfg_.g_w = 352;
+ cfg_.g_h = 288;
+
+ ResetModel();
+
+ // Set ROI parameters
+ use_roi_ = 1;
+ memset(&roi_, 0, sizeof(roi_));
+
+ roi_.rows = (cfg_.g_h + 15) / 16;
+ roi_.cols = (cfg_.g_w + 15) / 16;
+
+ roi_.delta_q[0] = 0;
+ roi_.delta_q[1] = -20;
+ roi_.delta_q[2] = 0;
+ roi_.delta_q[3] = 0;
+
+ roi_.delta_lf[0] = 0;
+ roi_.delta_lf[1] = -20;
+ roi_.delta_lf[2] = 0;
+ roi_.delta_lf[3] = 0;
+
+ roi_.static_threshold[0] = 0;
+ roi_.static_threshold[1] = 1000;
+ roi_.static_threshold[2] = 0;
+ roi_.static_threshold[3] = 0;
+
+ // Use 2 states: 1 is center square, 0 is the rest.
+ roi_.roi_map =
+ (uint8_t *)calloc(roi_.rows * roi_.cols, sizeof(*roi_.roi_map));
+ for (unsigned int i = 0; i < roi_.rows; ++i) {
+ for (unsigned int j = 0; j < roi_.cols; ++j) {
+ if (i > (roi_.rows >> 2) && i < ((roi_.rows * 3) >> 2) &&
+ j > (roi_.cols >> 2) && j < ((roi_.cols * 3) >> 2)) {
+ roi_.roi_map[i * roi_.cols + j] = 1;
+ }
+ }
+ }
+
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+ ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_ * 0.95)
+ << " The datarate for the file exceeds the target!";
+
+ ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.4)
+ << " The datarate for the file missed the target!";
+
+ free(roi_.roi_map);
+}
+
TEST_P(DatarateTestRealTime, GFBoost) {
denoiser_on_ = 0;
cfg_.rc_buf_initial_sz = 500;
diff --git a/test/encode_test_driver.h b/test/encode_test_driver.h
index 08a57ad77..1b4a5a671 100644
--- a/test/encode_test_driver.h
+++ b/test/encode_test_driver.h
@@ -139,6 +139,13 @@ class Encoder {
}
#endif
+#if CONFIG_VP8_ENCODER
+ void Control(int ctrl_id, vpx_roi_map_t *arg) {
+ const vpx_codec_err_t res = vpx_codec_control_(&encoder_, ctrl_id, arg);
+ ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
+ }
+#endif
+
void Config(const vpx_codec_enc_cfg_t *cfg) {
const vpx_codec_err_t res = vpx_codec_enc_config_set(&encoder_, cfg);
ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();