blob: 2d897caf7ad9d18b212ebe21712f8fbf7e8f0d54 [file] [log] [blame]
Yunqing Wangff4fa062017-04-21 10:56:08 -07001/*
James Zernb7c05bd2024-06-11 19:15:10 -07002 * Copyright (c) 2017, Alliance for Open Media. All rights reserved.
Yunqing Wangff4fa062017-04-21 10:56:08 -07003 *
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.
Johann123e8a62017-12-28 14:40:49 -080010 */
Yunqing Wangff4fa062017-04-21 10:56:08 -070011
sarahparker270a7ff2018-11-02 13:22:27 -070012#include <memory>
13
Yunqing Wangff4fa062017-04-21 10:56:08 -070014#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
21namespace {
22#define MAX_EXTREME_MV 1
23#define MIN_EXTREME_MV 2
24
25// Encoding modes
26const libaom_test::TestMode kEncodingModeVectors[] = {
Johannf152ff62018-02-08 14:33:07 -080027 ::libaom_test::kTwoPassGood,
28 ::libaom_test::kOnePassGood,
Yunqing Wangff4fa062017-04-21 10:56:08 -070029};
30
31// Encoding speeds
Yaowu Xu022dc472017-05-03 17:37:21 -070032const int kCpuUsedVectors[] = { 1, 5 };
Yunqing Wangff4fa062017-04-21 10:56:08 -070033
34// MV test modes: 1 - always use maximum MV; 2 - always use minimum MV.
35const int kMVTestModes[] = { MAX_EXTREME_MV, MIN_EXTREME_MV };
36
37class MotionVectorTestLarge
Sebastien Alaiwan4322bc12017-06-05 10:18:28 +020038 : public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode, int,
39 int>,
40 public ::libaom_test::EncoderTest {
Yunqing Wangff4fa062017-04-21 10:56:08 -070041 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 Zernf1fa1eb2023-07-25 15:34:13 -070046 ~MotionVectorTestLarge() override = default;
Yunqing Wangff4fa062017-04-21 10:56:08 -070047
James Zernfaa2dcf2023-07-24 18:29:51 -070048 void SetUp() override {
Wan-Teh Changfddea512021-02-18 17:08:38 -080049 InitializeConfig(encoding_mode_);
Yunqing Wangff4fa062017-04-21 10:56:08 -070050 if (encoding_mode_ != ::libaom_test::kRealTime) {
51 cfg_.g_lag_in_frames = 3;
Yunqing Wangff4fa062017-04-21 10:56:08 -070052 } else {
Yunqing Wangff4fa062017-04-21 10:56:08 -070053 cfg_.rc_buf_sz = 1000;
54 cfg_.rc_buf_initial_sz = 500;
55 cfg_.rc_buf_optimal_sz = 600;
56 }
57 }
58
James Zernfaa2dcf2023-07-24 18:29:51 -070059 void PreEncodeFrameHook(::libaom_test::VideoSource *video,
60 ::libaom_test::Encoder *encoder) override {
Yunqing Wang51b282d2018-10-01 16:25:34 -070061 if (video->frame() == 0) {
Yunqing Wangff4fa062017-04-21 10:56:08 -070062 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
77TEST_P(MotionVectorTestLarge, OverallTest) {
Yunqing Wangffbc6a42017-04-27 12:45:39 -070078 int width = 3840;
79 int height = 2160;
80
Yunqing Wang23aaaa92017-05-04 17:24:25 -070081 // Reduce the test clip's resolution while testing on 32-bit system.
Yunqing Wangffbc6a42017-04-27 12:45:39 -070082 if (sizeof(void *) == 4) {
Yaowu Xu69ac7bf2017-10-20 01:32:21 +000083 width = 2048;
Hui Sua47994b2018-01-02 12:12:47 -080084 height = 360;
Yunqing Wangffbc6a42017-04-27 12:45:39 -070085 }
Yunqing Wangffbc6a42017-04-27 12:45:39 -070086
Yunqing Wangff4fa062017-04-21 10:56:08 -070087 cfg_.rc_target_bitrate = 24000;
88 cfg_.g_profile = 0;
89 init_flags_ = AOM_CODEC_USE_PSNR;
90
sarahparker270a7ff2018-11-02 13:22:27 -070091 std::unique_ptr<libaom_test::VideoSource> video;
Yunqing Wangff4fa062017-04-21 10:56:08 -070092 video.reset(new libaom_test::YUVVideoSource(
Yaowu Xu022dc472017-05-03 17:37:21 -070093 "niklas_640_480_30.yuv", AOM_IMG_FMT_I420, width, height, 30, 1, 0, 3));
Yunqing Wangff4fa062017-04-21 10:56:08 -070094
James Zern9dea04e2022-04-28 13:18:36 -070095 ASSERT_NE(video, nullptr);
Yunqing Wangff4fa062017-04-21 10:56:08 -070096 ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
97}
98
chiyotsai9dfac722020-07-07 17:43:02 -070099AV1_INSTANTIATE_TEST_SUITE(MotionVectorTestLarge,
100 ::testing::ValuesIn(kEncodingModeVectors),
101 ::testing::ValuesIn(kCpuUsedVectors),
102 ::testing::ValuesIn(kMVTestModes));
Yunqing Wangff4fa062017-04-21 10:56:08 -0700103} // namespace