/* * Copyright (c) 2012 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/ #include <climits> #include <cstring> #include <vector> #include"gtest/gtest.h" #include"test/codec_factory.h" #include"test/encode_test_driver.h" #include"test/i420_video_source.h" #include"test/util.h" #include"./vpx_config.h" #include"vpx/vp8cx.h" #include"vpx/vpx_codec.h" #include"vpx/vpx_encoder.h" #include"vpx/vpx_image.h"
namespace {
class KeyframeTest
: public ::libvpx_test::EncoderTest, public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> { protected:
KeyframeTest() : EncoderTest(GET_PARAM(0)) {}
~KeyframeTest() override = default;
bool kf_do_force_kf_; int kf_count_; int kf_count_max_;
std::vector<vpx_codec_pts_t> kf_pts_list_; int set_cpu_used_;
};
TEST_P(KeyframeTest, TestRandomVideoSource) { // Validate that encoding the RandomVideoSource produces multiple keyframes. // This validates the results of the TestDisableKeyframes test.
kf_count_max_ = 2; // early exit successful tests.
// In realtime mode - auto placed keyframes are exceedingly rare, don't // bother with this check if(GetParam() > 0) if (GET_PARAM(1) > 0) {
EXPECT_GT(kf_count_, 1);
}
}
// verify that every third frame is a keyframe. for (std::vector<vpx_codec_pts_t>::const_iterator iter = kf_pts_list_.begin();
iter != kf_pts_list_.end(); ++iter) {
ASSERT_EQ(0, *iter % 3) << "Unexpected keyframe at frame " << *iter;
}
}
// 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.
::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 40);
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
// In realtime mode - auto placed keyframes are exceedingly rare, don't // bother with this check if (GET_PARAM(1) > 0) {
EXPECT_EQ(2u, kf_pts_list_.size()) << " Not the right number of keyframes ";
}
// Verify that keyframes match the file keyframes in the file. for (std::vector<vpx_codec_pts_t>::const_iterator iter = kf_pts_list_.begin();
iter != kf_pts_list_.end(); ++iter) { if (deadline_ == VPX_DL_REALTIME && *iter > 0)
EXPECT_EQ(0, (*iter - 1) % 30)
<< "Unexpected keyframe at frame " << *iter; else
EXPECT_EQ(0, *iter % 30) << "Unexpected keyframe at frame " << *iter;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.