• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2017, 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 <memory>
13 
14 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
15 
16 #include "test/codec_factory.h"
17 #include "test/encode_test_driver.h"
18 #include "test/util.h"
19 #include "test/yuv_video_source.h"
20 
21 namespace {
22 #define MAX_EXTREME_MV 1
23 #define MIN_EXTREME_MV 2
24 
25 // Encoding modes
26 const libaom_test::TestMode kEncodingModeVectors[] = {
27   ::libaom_test::kTwoPassGood,
28   ::libaom_test::kOnePassGood,
29 };
30 
31 // Encoding speeds
32 const int kCpuUsedVectors[] = { 1, 5 };
33 
34 // MV test modes: 1 - always use maximum MV; 2 - always use minimum MV.
35 const int kMVTestModes[] = { MAX_EXTREME_MV, MIN_EXTREME_MV };
36 
37 class MotionVectorTestLarge
38     : public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode, int,
39                                                  int>,
40       public ::libaom_test::EncoderTest {
41  protected:
MotionVectorTestLarge()42   MotionVectorTestLarge()
43       : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)),
44         cpu_used_(GET_PARAM(2)), mv_test_mode_(GET_PARAM(3)) {}
45 
~MotionVectorTestLarge()46   virtual ~MotionVectorTestLarge() {}
47 
SetUp()48   virtual void SetUp() {
49     InitializeConfig();
50     SetMode(encoding_mode_);
51     if (encoding_mode_ != ::libaom_test::kRealTime) {
52       cfg_.g_lag_in_frames = 3;
53       cfg_.rc_end_usage = AOM_VBR;
54     } else {
55       cfg_.g_lag_in_frames = 0;
56       cfg_.rc_end_usage = AOM_CBR;
57       cfg_.rc_buf_sz = 1000;
58       cfg_.rc_buf_initial_sz = 500;
59       cfg_.rc_buf_optimal_sz = 600;
60     }
61   }
62 
PreEncodeFrameHook(::libaom_test::VideoSource * video,::libaom_test::Encoder * encoder)63   virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
64                                   ::libaom_test::Encoder *encoder) {
65     if (video->frame() == 0) {
66       encoder->Control(AOME_SET_CPUUSED, cpu_used_);
67       encoder->Control(AV1E_ENABLE_MOTION_VECTOR_UNIT_TEST, mv_test_mode_);
68       if (encoding_mode_ != ::libaom_test::kRealTime) {
69         encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1);
70         encoder->Control(AOME_SET_ARNR_MAXFRAMES, 7);
71         encoder->Control(AOME_SET_ARNR_STRENGTH, 5);
72       }
73     }
74   }
75 
76   libaom_test::TestMode encoding_mode_;
77   int cpu_used_;
78   int mv_test_mode_;
79 };
80 
TEST_P(MotionVectorTestLarge,OverallTest)81 TEST_P(MotionVectorTestLarge, OverallTest) {
82   int width = 3840;
83   int height = 2160;
84 
85   // Reduce the test clip's resolution while testing on 32-bit system.
86   if (sizeof(void *) == 4) {
87     width = 2048;
88     height = 360;
89   }
90 
91   cfg_.rc_target_bitrate = 24000;
92   cfg_.g_profile = 0;
93   init_flags_ = AOM_CODEC_USE_PSNR;
94 
95   std::unique_ptr<libaom_test::VideoSource> video;
96   video.reset(new libaom_test::YUVVideoSource(
97       "niklas_640_480_30.yuv", AOM_IMG_FMT_I420, width, height, 30, 1, 0, 3));
98 
99   ASSERT_TRUE(video.get() != NULL);
100   ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
101 }
102 
103 AV1_INSTANTIATE_TEST_CASE(MotionVectorTestLarge,
104                           ::testing::ValuesIn(kEncodingModeVectors),
105                           ::testing::ValuesIn(kCpuUsedVectors),
106                           ::testing::ValuesIn(kMVTestModes));
107 }  // namespace
108