Commit 606ac45b authored by John Koleszar's avatar John Koleszar

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
parent b25ebf7d
......@@ -109,6 +109,7 @@ void EncoderTest::RunLoop(VideoSource *video) {
again = video->img() != NULL;
PreEncodeFrameHook(video);
PreEncodeFrameHook(video, &encoder);
encoder.EncodeFrame(video, flags_);
CxDataIterator iter = encoder.GetCxData();
......
......@@ -101,6 +101,11 @@ class Encoder {
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 @@ class EncoderTest {
// 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) {}
......
......@@ -24,15 +24,19 @@ class KeyframeTest : public ::libvpx_test::EncoderTest,
kf_count_ = 0;
kf_count_max_ = INT_MAX;
kf_do_force_kf_ = false;
set_cpu_used_ = 0;
}
virtual bool Continue() {
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 @@ class KeyframeTest : public ::libvpx_test::EncoderTest,
int kf_count_;
int kf_count_max_;
std::vector<vpx_codec_pts_t> kf_pts_list_;
int set_cpu_used_;
};
TEST_P(KeyframeTest, TestRandomVideoSource) {
......@@ -101,6 +106,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
// 0 and 30.
......
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