tor-browser

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

videocodec_test_videotoolbox.cc (3361B)


      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 <utility>
     13 #include <vector>
     14 
     15 #include "api/test/create_videocodec_test_fixture.h"
     16 #include "api/test/videocodec_test_fixture.h"
     17 #include "api/video_codecs/h264_profile_level_id.h"
     18 #include "media/base/media_constants.h"
     19 #include "modules/video_coding/codecs/test/objc_codec_factory_helper.h"
     20 #include "modules/video_coding/codecs/test/videocodec_test_fixture_impl.h"
     21 #include "test/gtest.h"
     22 #include "test/testsupport/file_utils.h"
     23 
     24 namespace webrtc {
     25 namespace test {
     26 
     27 namespace {
     28 const int kForemanNumFrames = 300;
     29 
     30 VideoCodecTestFixture::Config CreateConfig() {
     31  VideoCodecTestFixture::Config config;
     32  config.filename = "foreman_cif";
     33  config.filepath = ResourcePath(config.filename, "yuv");
     34  config.num_frames = kForemanNumFrames;
     35  return config;
     36 }
     37 
     38 std::unique_ptr<VideoCodecTestFixture> CreateTestFixtureWithConfig(
     39    VideoCodecTestFixture::Config config) {
     40  auto decoder_factory = CreateObjCDecoderFactory();
     41  auto encoder_factory = CreateObjCEncoderFactory();
     42  return CreateVideoCodecTestFixture(config, std::move(decoder_factory),
     43                                     std::move(encoder_factory));
     44 }
     45 }  // namespace
     46 
     47 // TODO(webrtc:9099): Disabled until the issue is fixed.
     48 // HW codecs don't work on simulators. Only run these tests on device.
     49 // #if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
     50 // #define MAYBE_TEST TEST
     51 // #else
     52 #define MAYBE_TEST(s, name) TEST(s, DISABLED_##name)
     53 // #endif
     54 
     55 // TODO(kthelgason): Use RC Thresholds when the internal bitrateAdjuster is no
     56 // longer in use.
     57 MAYBE_TEST(VideoCodecTestVideoToolbox, ForemanCif500kbpsH264CBP) {
     58  const auto frame_checker =
     59      std::make_unique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
     60  auto config = CreateConfig();
     61  config.SetCodecSettings(webrtc::kH264CodecName, 1, 1, 1, false, false, false,
     62                          352, 288);
     63  config.encoded_frame_checker = frame_checker.get();
     64  auto fixture = CreateTestFixtureWithConfig(config);
     65 
     66  std::vector<RateProfile> rate_profiles = {{500, 30, 0}};
     67 
     68  std::vector<QualityThresholds> quality_thresholds = {{33, 29, 0.9, 0.82}};
     69 
     70  fixture->RunTest(rate_profiles, nullptr, &quality_thresholds, nullptr);
     71 }
     72 
     73 MAYBE_TEST(VideoCodecTestVideoToolbox, ForemanCif500kbpsH264CHP) {
     74  const auto frame_checker =
     75      std::make_unique<VideoCodecTestFixtureImpl::H264KeyframeChecker>();
     76  auto config = CreateConfig();
     77  config.h264_codec_settings.profile = H264Profile::kProfileConstrainedHigh;
     78  config.SetCodecSettings(webrtc::kH264CodecName, 1, 1, 1, false, false, false,
     79                          352, 288);
     80  config.encoded_frame_checker = frame_checker.get();
     81  auto fixture = CreateTestFixtureWithConfig(config);
     82 
     83  std::vector<RateProfile> rate_profiles = {{500, 30, 0}};
     84 
     85  std::vector<QualityThresholds> quality_thresholds = {{33, 30, 0.91, 0.83}};
     86 
     87  fixture->RunTest(rate_profiles, nullptr, &quality_thresholds, nullptr);
     88 }
     89 
     90 }  // namespace test
     91 }  // namespace webrtc