Add dr prediction test
[aom.git] / test / altref_test.cc
blobdabb1475a86a8c54b75a49fbe5cf718343593d8a
1 /*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
12 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
13 #include "test/codec_factory.h"
14 #include "test/encode_test_driver.h"
15 #include "test/i420_video_source.h"
16 #include "test/util.h"
17 namespace {
19 class AltRefForcedKeyTestLarge
20 : public ::libaom_test::CodecTestWith2Params<libaom_test::TestMode, int>,
21 public ::libaom_test::EncoderTest {
22 protected:
23 AltRefForcedKeyTestLarge()
24 : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)),
25 cpu_used_(GET_PARAM(2)), forced_kf_frame_num_(1), frame_num_(0) {}
26 virtual ~AltRefForcedKeyTestLarge() {}
28 virtual void SetUp() {
29 InitializeConfig();
30 SetMode(encoding_mode_);
31 cfg_.rc_end_usage = AOM_VBR;
32 cfg_.g_threads = 0;
35 virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
36 ::libaom_test::Encoder *encoder) {
37 if (video->frame() == 0) {
38 encoder->Control(AOME_SET_CPUUSED, cpu_used_);
39 encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1);
40 #if CONFIG_AV1_ENCODER
41 // override test default for tile columns if necessary.
42 if (GET_PARAM(0) == &libaom_test::kAV1) {
43 encoder->Control(AV1E_SET_TILE_COLUMNS, 6);
45 #endif
47 frame_flags_ =
48 (video->frame() == forced_kf_frame_num_) ? AOM_EFLAG_FORCE_KF : 0;
51 virtual void FramePktHook(const aom_codec_cx_pkt_t *pkt) {
52 if (frame_num_ == forced_kf_frame_num_) {
53 ASSERT_TRUE(!!(pkt->data.frame.flags & AOM_FRAME_IS_KEY))
54 << "Frame #" << frame_num_ << " isn't a keyframe!";
56 ++frame_num_;
59 ::libaom_test::TestMode encoding_mode_;
60 int cpu_used_;
61 unsigned int forced_kf_frame_num_;
62 unsigned int frame_num_;
65 TEST_P(AltRefForcedKeyTestLarge, Frame1IsKey) {
66 const aom_rational timebase = { 1, 30 };
67 const int lag_values[] = { 3, 15, 25, -1 };
69 forced_kf_frame_num_ = 1;
70 for (int i = 0; lag_values[i] != -1; ++i) {
71 frame_num_ = 0;
72 cfg_.g_lag_in_frames = lag_values[i];
73 libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
74 timebase.den, timebase.num, 0, 30);
75 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
79 TEST_P(AltRefForcedKeyTestLarge, ForcedFrameIsKey) {
80 const aom_rational timebase = { 1, 30 };
81 const int lag_values[] = { 3, 15, 25, -1 };
83 for (int i = 0; lag_values[i] != -1; ++i) {
84 frame_num_ = 0;
85 forced_kf_frame_num_ = lag_values[i] - 1;
86 cfg_.g_lag_in_frames = lag_values[i];
87 libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
88 timebase.den, timebase.num, 0, 30);
89 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
93 AV1_INSTANTIATE_TEST_CASE(AltRefForcedKeyTestLarge,
94 ::testing::Values(::libaom_test::kOnePassGood),
95 ::testing::Values(2, 5));
97 } // namespace