Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 1 | /* |
James Zern | b7c05bd | 2024-06-11 19:15:10 -0700 | [diff] [blame^] | 2 | * Copyright (c) 2017, Alliance for Open Media. All rights reserved. |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 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. |
Johann | 123e8a6 | 2017-12-28 14:40:49 -0800 | [diff] [blame] | 10 | */ |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 11 | |
sarahparker | 270a7ff | 2018-11-02 13:22:27 -0700 | [diff] [blame] | 12 | #include <memory> |
| 13 | |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 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[] = { |
Johann | f152ff6 | 2018-02-08 14:33:07 -0800 | [diff] [blame] | 27 | ::libaom_test::kTwoPassGood, |
| 28 | ::libaom_test::kOnePassGood, |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | // Encoding speeds |
Yaowu Xu | 022dc47 | 2017-05-03 17:37:21 -0700 | [diff] [blame] | 32 | const int kCpuUsedVectors[] = { 1, 5 }; |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 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 |
Sebastien Alaiwan | 4322bc1 | 2017-06-05 10:18:28 +0200 | [diff] [blame] | 38 | : public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode, int, |
| 39 | int>, |
| 40 | public ::libaom_test::EncoderTest { |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 41 | protected: |
| 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 | |
James Zern | f1fa1eb | 2023-07-25 15:34:13 -0700 | [diff] [blame] | 46 | ~MotionVectorTestLarge() override = default; |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 47 | |
James Zern | faa2dcf | 2023-07-24 18:29:51 -0700 | [diff] [blame] | 48 | void SetUp() override { |
Wan-Teh Chang | fddea51 | 2021-02-18 17:08:38 -0800 | [diff] [blame] | 49 | InitializeConfig(encoding_mode_); |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 50 | if (encoding_mode_ != ::libaom_test::kRealTime) { |
| 51 | cfg_.g_lag_in_frames = 3; |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 52 | } else { |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 53 | cfg_.rc_buf_sz = 1000; |
| 54 | cfg_.rc_buf_initial_sz = 500; |
| 55 | cfg_.rc_buf_optimal_sz = 600; |
| 56 | } |
| 57 | } |
| 58 | |
James Zern | faa2dcf | 2023-07-24 18:29:51 -0700 | [diff] [blame] | 59 | void PreEncodeFrameHook(::libaom_test::VideoSource *video, |
| 60 | ::libaom_test::Encoder *encoder) override { |
Yunqing Wang | 51b282d | 2018-10-01 16:25:34 -0700 | [diff] [blame] | 61 | if (video->frame() == 0) { |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 62 | encoder->Control(AOME_SET_CPUUSED, cpu_used_); |
| 63 | encoder->Control(AV1E_ENABLE_MOTION_VECTOR_UNIT_TEST, mv_test_mode_); |
| 64 | if (encoding_mode_ != ::libaom_test::kRealTime) { |
| 65 | encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1); |
| 66 | encoder->Control(AOME_SET_ARNR_MAXFRAMES, 7); |
| 67 | encoder->Control(AOME_SET_ARNR_STRENGTH, 5); |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | libaom_test::TestMode encoding_mode_; |
| 73 | int cpu_used_; |
| 74 | int mv_test_mode_; |
| 75 | }; |
| 76 | |
| 77 | TEST_P(MotionVectorTestLarge, OverallTest) { |
Yunqing Wang | ffbc6a4 | 2017-04-27 12:45:39 -0700 | [diff] [blame] | 78 | int width = 3840; |
| 79 | int height = 2160; |
| 80 | |
Yunqing Wang | 23aaaa9 | 2017-05-04 17:24:25 -0700 | [diff] [blame] | 81 | // Reduce the test clip's resolution while testing on 32-bit system. |
Yunqing Wang | ffbc6a4 | 2017-04-27 12:45:39 -0700 | [diff] [blame] | 82 | if (sizeof(void *) == 4) { |
Yaowu Xu | 69ac7bf | 2017-10-20 01:32:21 +0000 | [diff] [blame] | 83 | width = 2048; |
Hui Su | a47994b | 2018-01-02 12:12:47 -0800 | [diff] [blame] | 84 | height = 360; |
Yunqing Wang | ffbc6a4 | 2017-04-27 12:45:39 -0700 | [diff] [blame] | 85 | } |
Yunqing Wang | ffbc6a4 | 2017-04-27 12:45:39 -0700 | [diff] [blame] | 86 | |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 87 | cfg_.rc_target_bitrate = 24000; |
| 88 | cfg_.g_profile = 0; |
| 89 | init_flags_ = AOM_CODEC_USE_PSNR; |
| 90 | |
sarahparker | 270a7ff | 2018-11-02 13:22:27 -0700 | [diff] [blame] | 91 | std::unique_ptr<libaom_test::VideoSource> video; |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 92 | video.reset(new libaom_test::YUVVideoSource( |
Yaowu Xu | 022dc47 | 2017-05-03 17:37:21 -0700 | [diff] [blame] | 93 | "niklas_640_480_30.yuv", AOM_IMG_FMT_I420, width, height, 30, 1, 0, 3)); |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 94 | |
James Zern | 9dea04e | 2022-04-28 13:18:36 -0700 | [diff] [blame] | 95 | ASSERT_NE(video, nullptr); |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 96 | ASSERT_NO_FATAL_FAILURE(RunLoop(video.get())); |
| 97 | } |
| 98 | |
chiyotsai | 9dfac72 | 2020-07-07 17:43:02 -0700 | [diff] [blame] | 99 | AV1_INSTANTIATE_TEST_SUITE(MotionVectorTestLarge, |
| 100 | ::testing::ValuesIn(kEncodingModeVectors), |
| 101 | ::testing::ValuesIn(kCpuUsedVectors), |
| 102 | ::testing::ValuesIn(kMVTestModes)); |
Yunqing Wang | ff4fa06 | 2017-04-21 10:56:08 -0700 | [diff] [blame] | 103 | } // namespace |