tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

videocodec_test_openh264.cc (3187B)


      1 /*
      2 *  Copyright (c) 2017 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/videocodec_test_fixture.h"
     16 #include "media/base/media_constants.h"
     17 #include "modules/video_coding/codecs/h264/include/h264_globals.h"
     18 #include "modules/video_coding/codecs/test/videocodec_test_fixture_impl.h"
     19 #include "test/gtest.h"
     20 #include "test/testsupport/file_utils.h"
     21 
     22 namespace webrtc {
     23 namespace test {
     24 
     25 namespace {
     26 // Codec settings.
     27 const int kCifWidth = 352;
     28 const int kCifHeight = 288;
     29 const int kNumFrames = 100;
     30 
     31 VideoCodecTestFixture::Config CreateConfig() {
     32  VideoCodecTestFixture::Config config;
     33  config.filename = "foreman_cif";
     34  config.filepath = ResourcePath(config.filename, "yuv");
     35  config.num_frames = kNumFrames;
     36  // Only allow encoder/decoder to use single core, for predictability.
     37  config.use_single_core = true;
     38  return config;
     39 }
     40 }  // namespace
     41 
     42 TEST(VideoCodecTestOpenH264, ConstantHighBitrate) {
     43  auto frame_checker =
     44      std::make_unique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
     45  auto config = CreateConfig();
     46  config.SetCodecSettings(webrtc::kH264CodecName, 1, 1, 1, false, true, false,
     47                          kCifWidth, kCifHeight);
     48  config.encoded_frame_checker = frame_checker.get();
     49  auto fixture = CreateVideoCodecTestFixture(config);
     50 
     51  std::vector<RateProfile> rate_profiles = {{500, 30, 0}};
     52 
     53  std::vector<RateControlThresholds> rc_thresholds = {
     54      {5, 1, 0, 0.1, 0.2, 0.1, 0, 1}};
     55 
     56  std::vector<QualityThresholds> quality_thresholds = {{37, 35, 0.93, 0.91}};
     57 
     58  fixture->RunTest(rate_profiles, &rc_thresholds, &quality_thresholds, nullptr);
     59 }
     60 
     61 // H264: Enable SingleNalUnit packetization mode. Encoder should split
     62 // large frames into multiple slices and limit length of NAL units.
     63 TEST(VideoCodecTestOpenH264, SingleNalUnit) {
     64  auto frame_checker =
     65      std::make_unique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
     66  auto config = CreateConfig();
     67  config.h264_codec_settings.packetization_mode =
     68      H264PacketizationMode::SingleNalUnit;
     69  config.max_payload_size_bytes = 500;
     70  config.SetCodecSettings(webrtc::kH264CodecName, 1, 1, 1, false, true, false,
     71                          kCifWidth, kCifHeight);
     72  config.encoded_frame_checker = frame_checker.get();
     73  auto fixture = CreateVideoCodecTestFixture(config);
     74 
     75  std::vector<RateProfile> rate_profiles = {{500, 30, 0}};
     76 
     77  std::vector<RateControlThresholds> rc_thresholds = {
     78      {5, 1, 0, 0.1, 0.2, 0.1, 0, 1}};
     79 
     80  std::vector<QualityThresholds> quality_thresholds = {{37, 35, 0.93, 0.91}};
     81 
     82  BitstreamThresholds bs_thresholds = {config.max_payload_size_bytes};
     83 
     84  fixture->RunTest(rate_profiles, &rc_thresholds, &quality_thresholds,
     85                   &bs_thresholds);
     86 }
     87 
     88 }  // namespace test
     89 }  // namespace webrtc