]> granicus.if.org Git - libvpx/blob - test/vp9_motion_vector_test.cc
svc: turn off use_base_mv on non base layer.
[libvpx] / test / vp9_motion_vector_test.cc
1 /*
2  *  Copyright (c) 2017 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10
11 #include <memory>
12
13 #include "third_party/googletest/src/include/gtest/gtest.h"
14
15 #include "test/codec_factory.h"
16 #include "test/encode_test_driver.h"
17 #include "test/util.h"
18 #include "test/yuv_video_source.h"
19
20 namespace {
21 #define MAX_EXTREME_MV 1
22 #define MIN_EXTREME_MV 2
23
24 // Encoding modes
25 const libvpx_test::TestMode kEncodingModeVectors[] = {
26   ::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood,
27   ::libvpx_test::kRealTime
28 };
29
30 // Encoding speeds
31 const int kCpuUsedVectors[] = { 0, 1, 2, 3, 4, 5, 6 };
32
33 // MV test modes: 1 - always use maximum MV; 2 - always use minimum MV.
34 const int kMVTestModes[] = { MAX_EXTREME_MV, MIN_EXTREME_MV };
35
36 class MotionVectorTestLarge
37     : public ::libvpx_test::EncoderTest,
38       public ::libvpx_test::CodecTestWith3Params<libvpx_test::TestMode, int,
39                                                  int> {
40  protected:
41   MotionVectorTestLarge()
42       : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)),
43         cpu_used_(GET_PARAM(2)), mv_test_mode_(GET_PARAM(3)) {}
44
45   virtual ~MotionVectorTestLarge() {}
46
47   virtual void SetUp() {
48     InitializeConfig();
49     SetMode(encoding_mode_);
50     if (encoding_mode_ != ::libvpx_test::kRealTime) {
51       cfg_.g_lag_in_frames = 3;
52       cfg_.rc_end_usage = VPX_VBR;
53     } else {
54       cfg_.g_lag_in_frames = 0;
55       cfg_.rc_end_usage = VPX_CBR;
56       cfg_.rc_buf_sz = 1000;
57       cfg_.rc_buf_initial_sz = 500;
58       cfg_.rc_buf_optimal_sz = 600;
59     }
60   }
61
62   virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
63                                   ::libvpx_test::Encoder *encoder) {
64     if (video->frame() == 0) {
65       encoder->Control(VP8E_SET_CPUUSED, cpu_used_);
66       encoder->Control(VP9E_ENABLE_MOTION_VECTOR_UNIT_TEST, mv_test_mode_);
67       if (encoding_mode_ != ::libvpx_test::kRealTime) {
68         encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 1);
69         encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7);
70         encoder->Control(VP8E_SET_ARNR_STRENGTH, 5);
71         encoder->Control(VP8E_SET_ARNR_TYPE, 3);
72       }
73     }
74   }
75
76   libvpx_test::TestMode encoding_mode_;
77   int cpu_used_;
78   int mv_test_mode_;
79 };
80
81 TEST_P(MotionVectorTestLarge, OverallTest) {
82   cfg_.rc_target_bitrate = 24000;
83   cfg_.g_profile = 0;
84   init_flags_ = VPX_CODEC_USE_PSNR;
85
86   std::unique_ptr<libvpx_test::VideoSource> video;
87   video.reset(new libvpx_test::YUVVideoSource(
88       "niklas_640_480_30.yuv", VPX_IMG_FMT_I420, 3840, 2160,  // 2048, 1080,
89       30, 1, 0, 5));
90
91   ASSERT_NE(video.get(), nullptr);
92   ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
93 }
94
95 VP9_INSTANTIATE_TEST_SUITE(MotionVectorTestLarge,
96                            ::testing::ValuesIn(kEncodingModeVectors),
97                            ::testing::ValuesIn(kCpuUsedVectors),
98                            ::testing::ValuesIn(kMVTestModes));
99 }  // namespace