1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2017, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #include <memory>
13*77c1e3ccSAndroid Build Coastguard Worker
14*77c1e3ccSAndroid Build Coastguard Worker #include "gtest/gtest.h"
15*77c1e3ccSAndroid Build Coastguard Worker
16*77c1e3ccSAndroid Build Coastguard Worker #include "test/codec_factory.h"
17*77c1e3ccSAndroid Build Coastguard Worker #include "test/encode_test_driver.h"
18*77c1e3ccSAndroid Build Coastguard Worker #include "test/util.h"
19*77c1e3ccSAndroid Build Coastguard Worker #include "test/yuv_video_source.h"
20*77c1e3ccSAndroid Build Coastguard Worker
21*77c1e3ccSAndroid Build Coastguard Worker namespace {
22*77c1e3ccSAndroid Build Coastguard Worker #define MAX_EXTREME_MV 1
23*77c1e3ccSAndroid Build Coastguard Worker #define MIN_EXTREME_MV 2
24*77c1e3ccSAndroid Build Coastguard Worker
25*77c1e3ccSAndroid Build Coastguard Worker // Encoding modes
26*77c1e3ccSAndroid Build Coastguard Worker const libaom_test::TestMode kEncodingModeVectors[] = {
27*77c1e3ccSAndroid Build Coastguard Worker ::libaom_test::kTwoPassGood,
28*77c1e3ccSAndroid Build Coastguard Worker ::libaom_test::kOnePassGood,
29*77c1e3ccSAndroid Build Coastguard Worker };
30*77c1e3ccSAndroid Build Coastguard Worker
31*77c1e3ccSAndroid Build Coastguard Worker // Encoding speeds
32*77c1e3ccSAndroid Build Coastguard Worker const int kCpuUsedVectors[] = { 1, 5 };
33*77c1e3ccSAndroid Build Coastguard Worker
34*77c1e3ccSAndroid Build Coastguard Worker // MV test modes: 1 - always use maximum MV; 2 - always use minimum MV.
35*77c1e3ccSAndroid Build Coastguard Worker const int kMVTestModes[] = { MAX_EXTREME_MV, MIN_EXTREME_MV };
36*77c1e3ccSAndroid Build Coastguard Worker
37*77c1e3ccSAndroid Build Coastguard Worker class MotionVectorTestLarge
38*77c1e3ccSAndroid Build Coastguard Worker : public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode, int,
39*77c1e3ccSAndroid Build Coastguard Worker int>,
40*77c1e3ccSAndroid Build Coastguard Worker public ::libaom_test::EncoderTest {
41*77c1e3ccSAndroid Build Coastguard Worker protected:
MotionVectorTestLarge()42*77c1e3ccSAndroid Build Coastguard Worker MotionVectorTestLarge()
43*77c1e3ccSAndroid Build Coastguard Worker : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)),
44*77c1e3ccSAndroid Build Coastguard Worker cpu_used_(GET_PARAM(2)), mv_test_mode_(GET_PARAM(3)) {}
45*77c1e3ccSAndroid Build Coastguard Worker
46*77c1e3ccSAndroid Build Coastguard Worker ~MotionVectorTestLarge() override = default;
47*77c1e3ccSAndroid Build Coastguard Worker
SetUp()48*77c1e3ccSAndroid Build Coastguard Worker void SetUp() override {
49*77c1e3ccSAndroid Build Coastguard Worker InitializeConfig(encoding_mode_);
50*77c1e3ccSAndroid Build Coastguard Worker if (encoding_mode_ != ::libaom_test::kRealTime) {
51*77c1e3ccSAndroid Build Coastguard Worker cfg_.g_lag_in_frames = 3;
52*77c1e3ccSAndroid Build Coastguard Worker } else {
53*77c1e3ccSAndroid Build Coastguard Worker cfg_.rc_buf_sz = 1000;
54*77c1e3ccSAndroid Build Coastguard Worker cfg_.rc_buf_initial_sz = 500;
55*77c1e3ccSAndroid Build Coastguard Worker cfg_.rc_buf_optimal_sz = 600;
56*77c1e3ccSAndroid Build Coastguard Worker }
57*77c1e3ccSAndroid Build Coastguard Worker }
58*77c1e3ccSAndroid Build Coastguard Worker
PreEncodeFrameHook(::libaom_test::VideoSource * video,::libaom_test::Encoder * encoder)59*77c1e3ccSAndroid Build Coastguard Worker void PreEncodeFrameHook(::libaom_test::VideoSource *video,
60*77c1e3ccSAndroid Build Coastguard Worker ::libaom_test::Encoder *encoder) override {
61*77c1e3ccSAndroid Build Coastguard Worker if (video->frame() == 0) {
62*77c1e3ccSAndroid Build Coastguard Worker encoder->Control(AOME_SET_CPUUSED, cpu_used_);
63*77c1e3ccSAndroid Build Coastguard Worker encoder->Control(AV1E_ENABLE_MOTION_VECTOR_UNIT_TEST, mv_test_mode_);
64*77c1e3ccSAndroid Build Coastguard Worker if (encoding_mode_ != ::libaom_test::kRealTime) {
65*77c1e3ccSAndroid Build Coastguard Worker encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1);
66*77c1e3ccSAndroid Build Coastguard Worker encoder->Control(AOME_SET_ARNR_MAXFRAMES, 7);
67*77c1e3ccSAndroid Build Coastguard Worker encoder->Control(AOME_SET_ARNR_STRENGTH, 5);
68*77c1e3ccSAndroid Build Coastguard Worker }
69*77c1e3ccSAndroid Build Coastguard Worker }
70*77c1e3ccSAndroid Build Coastguard Worker }
71*77c1e3ccSAndroid Build Coastguard Worker
72*77c1e3ccSAndroid Build Coastguard Worker libaom_test::TestMode encoding_mode_;
73*77c1e3ccSAndroid Build Coastguard Worker int cpu_used_;
74*77c1e3ccSAndroid Build Coastguard Worker int mv_test_mode_;
75*77c1e3ccSAndroid Build Coastguard Worker };
76*77c1e3ccSAndroid Build Coastguard Worker
TEST_P(MotionVectorTestLarge,OverallTest)77*77c1e3ccSAndroid Build Coastguard Worker TEST_P(MotionVectorTestLarge, OverallTest) {
78*77c1e3ccSAndroid Build Coastguard Worker int width = 3840;
79*77c1e3ccSAndroid Build Coastguard Worker int height = 2160;
80*77c1e3ccSAndroid Build Coastguard Worker
81*77c1e3ccSAndroid Build Coastguard Worker // Reduce the test clip's resolution while testing on 32-bit system.
82*77c1e3ccSAndroid Build Coastguard Worker if (sizeof(void *) == 4) {
83*77c1e3ccSAndroid Build Coastguard Worker width = 2048;
84*77c1e3ccSAndroid Build Coastguard Worker height = 360;
85*77c1e3ccSAndroid Build Coastguard Worker }
86*77c1e3ccSAndroid Build Coastguard Worker
87*77c1e3ccSAndroid Build Coastguard Worker cfg_.rc_target_bitrate = 24000;
88*77c1e3ccSAndroid Build Coastguard Worker cfg_.g_profile = 0;
89*77c1e3ccSAndroid Build Coastguard Worker init_flags_ = AOM_CODEC_USE_PSNR;
90*77c1e3ccSAndroid Build Coastguard Worker
91*77c1e3ccSAndroid Build Coastguard Worker std::unique_ptr<libaom_test::VideoSource> video;
92*77c1e3ccSAndroid Build Coastguard Worker video.reset(new libaom_test::YUVVideoSource(
93*77c1e3ccSAndroid Build Coastguard Worker "niklas_640_480_30.yuv", AOM_IMG_FMT_I420, width, height, 30, 1, 0, 3));
94*77c1e3ccSAndroid Build Coastguard Worker
95*77c1e3ccSAndroid Build Coastguard Worker ASSERT_NE(video, nullptr);
96*77c1e3ccSAndroid Build Coastguard Worker ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
97*77c1e3ccSAndroid Build Coastguard Worker }
98*77c1e3ccSAndroid Build Coastguard Worker
99*77c1e3ccSAndroid Build Coastguard Worker AV1_INSTANTIATE_TEST_SUITE(MotionVectorTestLarge,
100*77c1e3ccSAndroid Build Coastguard Worker ::testing::ValuesIn(kEncodingModeVectors),
101*77c1e3ccSAndroid Build Coastguard Worker ::testing::ValuesIn(kCpuUsedVectors),
102*77c1e3ccSAndroid Build Coastguard Worker ::testing::ValuesIn(kMVTestModes));
103*77c1e3ccSAndroid Build Coastguard Worker } // namespace
104