• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
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.
10  */
11 
12 #include "config/aom_config.h"
13 
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"
19 
20 namespace {
21 
22 const libaom_test::TestMode kTestModeParams[] =
23 #if CONFIG_REALTIME_ONLY
24     { ::libaom_test::kRealTime };
25 #else
26     { ::libaom_test::kRealTime, ::libaom_test::kOnePassGood };
27 #endif
28 
29 class AqSegmentTest
30     : public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode, int,
31                                                  int>,
32       public ::libaom_test::EncoderTest {
33  protected:
AqSegmentTest()34   AqSegmentTest() : EncoderTest(GET_PARAM(0)) {}
~AqSegmentTest()35   virtual ~AqSegmentTest() {}
36 
SetUp()37   virtual void SetUp() {
38     InitializeConfig(GET_PARAM(1));
39     set_cpu_used_ = GET_PARAM(2);
40     aq_mode_ = 0;
41   }
42 
PreEncodeFrameHook(::libaom_test::VideoSource * video,::libaom_test::Encoder * encoder)43   virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
44                                   ::libaom_test::Encoder *encoder) {
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);
54       }
55     }
56   }
57 
DoTest(int aq_mode)58   void DoTest(int aq_mode) {
59     aq_mode_ = aq_mode;
60     deltaq_mode_ = 0;
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,
71                                          288, 30, 1, 0, 15);
72     ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
73   }
74 
75   int set_cpu_used_;
76   int aq_mode_;
77   int deltaq_mode_;
78 };
79 
80 // Validate that this AQ segmentation mode (1-variance_aq, 2-complexity_aq,
81 // 3-cyclic_refresh_aq) encodes and decodes without a mismatch.
TEST_P(AqSegmentTest,TestNoMisMatch)82 TEST_P(AqSegmentTest, TestNoMisMatch) { DoTest(GET_PARAM(3)); }
83 
84 #if !CONFIG_REALTIME_ONLY
85 // Validate that this delta q mode
86 // encodes and decodes without a mismatch.
TEST_P(AqSegmentTest,TestNoMisMatchExtDeltaQ)87 TEST_P(AqSegmentTest, TestNoMisMatchExtDeltaQ) {
88   cfg_.rc_end_usage = AOM_CQ;
89   aq_mode_ = 0;
90   deltaq_mode_ = 2;
91   ::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
92                                        30, 1, 0, 15);
93 
94   ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
95 }
96 #endif
97 
98 AV1_INSTANTIATE_TEST_SUITE(AqSegmentTest, ::testing::ValuesIn(kTestModeParams),
99                            ::testing::Range(5, 9), ::testing::Range(0, 4));
100 
101 #if !CONFIG_REALTIME_ONLY
102 class AqSegmentTestLarge : public AqSegmentTest {};
103 
TEST_P(AqSegmentTestLarge,TestNoMisMatch)104 TEST_P(AqSegmentTestLarge, TestNoMisMatch) { DoTest(GET_PARAM(3)); }
105 
106 AV1_INSTANTIATE_TEST_SUITE(AqSegmentTestLarge,
107                            ::testing::Values(::libaom_test::kOnePassGood),
108                            ::testing::Range(3, 5), ::testing::Range(0, 4));
109 #endif
110 }  // namespace
111