2 * Copyright (c) 2017 The WebM project authors. All Rights Reserved.
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.
13 #include "third_party/googletest/src/include/gtest/gtest.h"
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"
21 #define MAX_EXTREME_MV 1
22 #define MIN_EXTREME_MV 2
25 const libvpx_test::TestMode kEncodingModeVectors[] = {
26 ::libvpx_test::kTwoPassGood, ::libvpx_test::kOnePassGood,
27 ::libvpx_test::kRealTime
31 const int kCpuUsedVectors[] = { 0, 1, 2, 3, 4, 5, 6 };
33 // MV test modes: 1 - always use maximum MV; 2 - always use minimum MV.
34 const int kMVTestModes[] = { MAX_EXTREME_MV, MIN_EXTREME_MV };
36 class MotionVectorTestLarge
37 : public ::libvpx_test::EncoderTest,
38 public ::libvpx_test::CodecTestWith3Params<libvpx_test::TestMode, int,
41 MotionVectorTestLarge()
42 : EncoderTest(GET_PARAM(0)), encoding_mode_(GET_PARAM(1)),
43 cpu_used_(GET_PARAM(2)), mv_test_mode_(GET_PARAM(3)) {}
45 virtual ~MotionVectorTestLarge() {}
47 virtual void SetUp() {
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;
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;
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);
76 libvpx_test::TestMode encoding_mode_;
81 TEST_P(MotionVectorTestLarge, OverallTest) {
82 cfg_.rc_target_bitrate = 24000;
84 init_flags_ = VPX_CODEC_USE_PSNR;
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,
91 ASSERT_NE(video.get(), nullptr);
92 ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
95 VP9_INSTANTIATE_TEST_SUITE(MotionVectorTestLarge,
96 ::testing::ValuesIn(kEncodingModeVectors),
97 ::testing::ValuesIn(kCpuUsedVectors),
98 ::testing::ValuesIn(kMVTestModes));