1 /*
2 * Copyright (c) 2020 The WebRTC 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 #include <vector>
13
14 #include "api/test/create_videocodec_test_fixture.h"
15 #include "api/test/video/function_video_encoder_factory.h"
16 #include "api/video_codecs/sdp_video_format.h"
17 #include "media/base/media_constants.h"
18 #include "media/engine/internal_decoder_factory.h"
19 #include "media/engine/internal_encoder_factory.h"
20 #include "media/engine/simulcast_encoder_adapter.h"
21 #include "test/gtest.h"
22 #include "test/testsupport/file_utils.h"
23
24 namespace webrtc {
25 namespace test {
26 namespace {
27 // Test clips settings.
28 constexpr int kCifWidth = 352;
29 constexpr int kCifHeight = 288;
30 constexpr int kNumFramesLong = 300;
31
CreateConfig(std::string filename)32 VideoCodecTestFixture::Config CreateConfig(std::string filename) {
33 VideoCodecTestFixture::Config config;
34 config.filename = filename;
35 config.filepath = ResourcePath(config.filename, "yuv");
36 config.num_frames = kNumFramesLong;
37 config.use_single_core = true;
38 return config;
39 }
40
TEST(VideoCodecTestAv1,HighBitrate)41 TEST(VideoCodecTestAv1, HighBitrate) {
42 auto config = CreateConfig("foreman_cif");
43 config.SetCodecSettings(cricket::kAv1CodecName, 1, 1, 1, false, true, true,
44 kCifWidth, kCifHeight);
45 config.codec_settings.SetScalabilityMode(ScalabilityMode::kL1T1);
46 config.num_frames = kNumFramesLong;
47 auto fixture = CreateVideoCodecTestFixture(config);
48
49 std::vector<RateProfile> rate_profiles = {{500, 30, 0}};
50
51 std::vector<RateControlThresholds> rc_thresholds = {
52 {12, 1, 0, 1, 0.3, 0.1, 0, 1}};
53
54 std::vector<QualityThresholds> quality_thresholds = {{37, 34, 0.94, 0.91}};
55
56 fixture->RunTest(rate_profiles, &rc_thresholds, &quality_thresholds, nullptr);
57 }
58
TEST(VideoCodecTestAv1,VeryLowBitrate)59 TEST(VideoCodecTestAv1, VeryLowBitrate) {
60 auto config = CreateConfig("foreman_cif");
61 config.SetCodecSettings(cricket::kAv1CodecName, 1, 1, 1, false, true, true,
62 kCifWidth, kCifHeight);
63 config.codec_settings.SetScalabilityMode(ScalabilityMode::kL1T1);
64 auto fixture = CreateVideoCodecTestFixture(config);
65
66 std::vector<RateProfile> rate_profiles = {{50, 30, 0}};
67
68 std::vector<RateControlThresholds> rc_thresholds = {
69 {15, 8, 75, 2, 2, 2, 2, 1}};
70
71 std::vector<QualityThresholds> quality_thresholds = {{28, 24.8, 0.70, 0.55}};
72
73 fixture->RunTest(rate_profiles, &rc_thresholds, &quality_thresholds, nullptr);
74 }
75
76 #if !defined(WEBRTC_ANDROID)
77 constexpr int kHdWidth = 1280;
78 constexpr int kHdHeight = 720;
TEST(VideoCodecTestAv1,Hd)79 TEST(VideoCodecTestAv1, Hd) {
80 auto config = CreateConfig("ConferenceMotion_1280_720_50");
81 config.SetCodecSettings(cricket::kAv1CodecName, 1, 1, 1, false, true, true,
82 kHdWidth, kHdHeight);
83 config.codec_settings.SetScalabilityMode(ScalabilityMode::kL1T1);
84 config.num_frames = kNumFramesLong;
85 auto fixture = CreateVideoCodecTestFixture(config);
86
87 std::vector<RateProfile> rate_profiles = {{1000, 50, 0}};
88
89 std::vector<RateControlThresholds> rc_thresholds = {
90 {13, 3, 0, 1, 0.3, 0.1, 0, 1}};
91
92 std::vector<QualityThresholds> quality_thresholds = {
93 {35.9, 31.5, 0.925, 0.865}};
94
95 fixture->RunTest(rate_profiles, &rc_thresholds, &quality_thresholds, nullptr);
96 }
97 #endif
98
99 } // namespace
100 } // namespace test
101 } // namespace webrtc
102