ref: 606ac45b2f16094540ad0616a1b79ae3c8f7ec79
parent: b25ebf7dde596eacebe807e305044a74ccb55d57
author: John Koleszar <jkoleszar@google.com>
date: Tue Jul 10 11:43:44 EDT 2012
keyframe_test: use a fixed speed step for realtime The lower complexity modes may not generate a keyframe automatically. This behavior was found when running under Valgrind, as the slow performance caused the speed selection to pick lower complexities than when running natively. Instead, use a fixed complexity for the realtime auto keyframe test. Affected tests: AllModes/KeyframeTest.TestAutoKeyframe/0 Change-Id: I44e3f44e125ad587c293ab5ece29511d7023be9b
--- a/test/encode_test_driver.cc
+++ b/test/encode_test_driver.cc
@@ -109,6 +109,7 @@
again = video->img() != NULL;
PreEncodeFrameHook(video);
+ PreEncodeFrameHook(video, &encoder);
encoder.EncodeFrame(video, flags_);
CxDataIterator iter = encoder.GetCxData();
--- a/test/encode_test_driver.h
+++ b/test/encode_test_driver.h
@@ -101,6 +101,11 @@
EncodeFrame(video, 0);
}
+ void Control(int ctrl_id, int arg) {
+ const vpx_codec_err_t res = vpx_codec_control_(&encoder_, ctrl_id, arg);
+ ASSERT_EQ(VPX_CODEC_OK, res) << EncoderError();
+ }
+
void set_deadline(unsigned long deadline) {
deadline_ = deadline;
}
@@ -158,6 +163,7 @@
// Hook to be called before encoding a frame.
virtual void PreEncodeFrameHook(VideoSource *video) {}
+ virtual void PreEncodeFrameHook(VideoSource *video, Encoder *encoder) {}
// Hook to be called on every compressed data packet.
virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {}
--- a/test/keyframe_test.cc
+++ b/test/keyframe_test.cc
@@ -24,6 +24,7 @@
kf_count_ = 0;
kf_count_max_ = INT_MAX;
kf_do_force_kf_ = false;
+ set_cpu_used_ = 0;
}
virtual bool Continue() {
@@ -30,9 +31,12 @@
return !HasFatalFailure() && !abort_;
}
- virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video) {
+ virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
+ ::libvpx_test::Encoder *encoder) {
if (kf_do_force_kf_)
flags_ = (video->frame() % 3) ? 0 : VPX_EFLAG_FORCE_KF;
+ if (set_cpu_used_ && video->frame() == 1)
+ encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
}
virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
@@ -47,6 +51,7 @@
int kf_count_;
int kf_count_max_;
std::vector<vpx_codec_pts_t> kf_pts_list_;
+ int set_cpu_used_;
};
TEST_P(KeyframeTest, TestRandomVideoSource) {
@@ -100,6 +105,13 @@
TEST_P(KeyframeTest, TestAutoKeyframe) {
cfg_.kf_mode = VPX_KF_AUTO;
kf_do_force_kf_ = false;
+
+ // Force a deterministic speed step in Real Time mode, as the faster modes
+ // may not produce a keyframe like we expect. This is necessary when running
+ // on very slow environments (like Valgrind). The step -11 was determined
+ // experimentally as the fastest mode that still throws the keyframe.
+ if (deadline_ == VPX_DL_REALTIME)
+ set_cpu_used_ = -11;
// This clip has a cut scene every 30 frames -> Frame 0, 30, 60, 90, 120.
// I check only the first 40 frames to make sure there's a keyframe at frame
--
⑨