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 "config/aom_config.h"
14 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
15 #include "test/codec_factory.h"
16 #include "test/encode_test_driver.h"
17 #include "test/i420_video_source.h"
18 #include "test/util.h"
22 const libaom_test::TestMode kTestModeParams
[] =
23 #if CONFIG_REALTIME_ONLY
24 { ::libaom_test::kRealTime
};
26 { ::libaom_test::kRealTime
, ::libaom_test::kOnePassGood
};
30 : public ::libaom_test::CodecTestWith3Params
<libaom_test::TestMode
, int,
32 public ::libaom_test::EncoderTest
{
34 AqSegmentTest() : EncoderTest(GET_PARAM(0)) {}
35 ~AqSegmentTest() override
= default;
37 void SetUp() override
{
38 InitializeConfig(GET_PARAM(1));
39 set_cpu_used_
= GET_PARAM(2);
43 void PreEncodeFrameHook(::libaom_test::VideoSource
*video
,
44 ::libaom_test::Encoder
*encoder
) override
{
45 if (video
->frame() == 0) {
46 encoder
->Control(AOME_SET_CPUUSED
, set_cpu_used_
);
47 encoder
->Control(AV1E_SET_AQ_MODE
, aq_mode_
);
48 encoder
->Control(AV1E_SET_DELTAQ_MODE
, deltaq_mode_
);
49 encoder
->Control(AOME_SET_MAX_INTRA_BITRATE_PCT
, 100);
50 if (mode_
== ::libaom_test::kRealTime
) {
51 encoder
->Control(AV1E_SET_ALLOW_WARPED_MOTION
, 0);
52 encoder
->Control(AV1E_SET_ENABLE_GLOBAL_MOTION
, 0);
53 encoder
->Control(AV1E_SET_ENABLE_OBMC
, 0);
58 void DoTest(int aq_mode
) {
61 cfg_
.kf_max_dist
= 12;
62 cfg_
.rc_min_quantizer
= 8;
63 cfg_
.rc_max_quantizer
= 56;
64 cfg_
.rc_end_usage
= AOM_CBR
;
65 cfg_
.g_lag_in_frames
= 6;
66 cfg_
.rc_buf_initial_sz
= 500;
67 cfg_
.rc_buf_optimal_sz
= 500;
68 cfg_
.rc_buf_sz
= 1000;
69 cfg_
.rc_target_bitrate
= 300;
70 ::libaom_test::I420VideoSource
video("hantro_collage_w352h288.yuv", 352,
72 ASSERT_NO_FATAL_FAILURE(RunLoop(&video
));
80 // Validate that this AQ segmentation mode (1-variance_aq, 2-complexity_aq,
81 // 3-cyclic_refresh_aq) encodes and decodes without a mismatch.
82 TEST_P(AqSegmentTest
, TestNoMisMatch
) { DoTest(GET_PARAM(3)); }
84 #if !CONFIG_REALTIME_ONLY
85 // Validate that this delta q mode
86 // encodes and decodes without a mismatch.
87 TEST_P(AqSegmentTest
, TestNoMisMatchExtDeltaQ
) {
88 cfg_
.rc_end_usage
= AOM_CQ
;
91 ::libaom_test::I420VideoSource
video("hantro_collage_w352h288.yuv", 352, 288,
94 ASSERT_NO_FATAL_FAILURE(RunLoop(&video
));
98 AV1_INSTANTIATE_TEST_SUITE(AqSegmentTest
, ::testing::ValuesIn(kTestModeParams
),
99 ::testing::Range(5, 9), ::testing::Range(0, 4));
101 #if !CONFIG_REALTIME_ONLY
102 class AqSegmentTestLarge
: public AqSegmentTest
{};
104 TEST_P(AqSegmentTestLarge
, TestNoMisMatch
) { DoTest(GET_PARAM(3)); }
106 AV1_INSTANTIATE_TEST_SUITE(AqSegmentTestLarge
,
107 ::testing::Values(::libaom_test::kOnePassGood
),
108 ::testing::Range(3, 5), ::testing::Range(0, 4));