video_decode_accelerator_perf_tests.cc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include <algorithm>
  5. #include <numeric>
  6. #include <vector>
  7. #include "base/command_line.h"
  8. #include "base/files/file_util.h"
  9. #include "base/json/json_writer.h"
  10. #include "base/memory/raw_ptr.h"
  11. #include "base/time/time.h"
  12. #include "build/build_config.h"
  13. #include "media/base/media_switches.h"
  14. #include "media/base/test_data_util.h"
  15. #include "media/gpu/buildflags.h"
  16. #include "media/gpu/test/video.h"
  17. #include "media/gpu/test/video_player/decoder_listener.h"
  18. #include "media/gpu/test/video_player/decoder_wrapper.h"
  19. #include "media/gpu/test/video_player/frame_renderer_dummy.h"
  20. #include "media/gpu/test/video_player/video_player_test_environment.h"
  21. #include "sandbox/linux/services/resource_limits.h"
  22. #include "testing/gtest/include/gtest/gtest.h"
  23. namespace media {
  24. namespace test {
  25. namespace {
  26. // Video decoder perf tests usage message. Make sure to also update the
  27. // documentation under docs/media/gpu/video_decoder_perf_test_usage.md when
  28. // making changes here.
  29. constexpr const char* usage_msg =
  30. R"(usage: video_decode_accelerator_perf_tests
  31. [-v=<level>] [--vmodule=<config>] [--output_folder]
  32. ([--use-legacy]|[--use_vd_vda]) [--linear_output]
  33. [--disable_vaapi_lock]
  34. [--gtest_help] [--help]
  35. [<video path>] [<video metadata path>]
  36. )";
  37. // Video decoder perf tests help message.
  38. const std::string help_msg =
  39. std::string(
  40. R"""(Run the video decode accelerator performance tests on the video
  41. specified by <video path>. If no <video path> is given the default
  42. "test-25fps.h264" video will be used.
  43. The <video metadata path> should specify the location of a json file
  44. containing the video's metadata, such as frame checksums. By default
  45. <video path>.json will be used.
  46. The following arguments are supported:
  47. -v enable verbose mode, e.g. -v=2.
  48. --vmodule enable verbose mode for the specified module,
  49. e.g. --vmodule=*media/gpu*=2.
  50. --output_folder overwrite the output folder used to store
  51. performance metrics, if not specified results
  52. will be stored in the current working directory.
  53. --use-legacy use the legacy VDA-based video decoders.
  54. --use_vd_vda use the new VD-based video decoders with a
  55. wrapper that translates to the VDA interface,
  56. used to test interaction with older components
  57. expecting the VDA interface.
  58. --linear_output use linear buffers as the final output of the
  59. decoder which may require the use of an image
  60. processor internally. This flag only works in
  61. conjunction with --use_vd_vda.
  62. Disabled by default.
  63. --disable_vaapi_lock disable the global VA-API lock if applicable,
  64. i.e., only on devices that use the VA-API with a libva
  65. backend that's known to be thread-safe and only in
  66. portions of the Chrome stack that should be able to
  67. deal with the absence of the lock
  68. (not the VaapiVideoDecodeAccelerator).)""") +
  69. #if defined(ARCH_CPU_ARM_FAMILY)
  70. R"""(
  71. --disable-libyuv use hw format conversion instead of libYUV.
  72. libYUV will be used by default, unless the
  73. video decoder format is not supported;
  74. in that case the code will try to use the
  75. v4l2 image processor.)""" +
  76. #endif // defined(ARCH_CPU_ARM_FAMILY)
  77. R"""(
  78. --gtest_help display the gtest help and exit.
  79. --help display this help and exit.
  80. )""";
  81. media::test::VideoPlayerTestEnvironment* g_env;
  82. // Default output folder used to store performance metrics.
  83. constexpr const base::FilePath::CharType* kDefaultOutputFolder =
  84. FILE_PATH_LITERAL("perf_metrics");
  85. constexpr base::TimeDelta kMultipleDecodersTimeout = base::Seconds(120);
  86. // Struct storing various time-related statistics.
  87. struct PerformanceTimeStats {
  88. PerformanceTimeStats() {}
  89. explicit PerformanceTimeStats(const std::vector<double>& times);
  90. double avg_ms_ = 0.0;
  91. double percentile_25_ms_ = 0.0;
  92. double percentile_50_ms_ = 0.0;
  93. double percentile_75_ms_ = 0.0;
  94. };
  95. PerformanceTimeStats::PerformanceTimeStats(const std::vector<double>& times) {
  96. avg_ms_ = std::accumulate(times.begin(), times.end(), 0.0) / times.size();
  97. std::vector<double> sorted_times = times;
  98. std::sort(sorted_times.begin(), sorted_times.end());
  99. percentile_25_ms_ = sorted_times[sorted_times.size() / 4];
  100. percentile_50_ms_ = sorted_times[sorted_times.size() / 2];
  101. percentile_75_ms_ = sorted_times[(sorted_times.size() * 3) / 4];
  102. }
  103. struct PerformanceMetrics {
  104. // Total measurement duration.
  105. base::TimeDelta total_duration_;
  106. // The number of frames decoded.
  107. size_t frames_decoded_ = 0;
  108. // The overall number of frames decoded per second.
  109. double frames_per_second_ = 0.0;
  110. // The number of frames dropped because of the decoder running behind, only
  111. // relevant for capped performance tests.
  112. size_t frames_dropped_ = 0;
  113. // The percentage of frames dropped because of the decoder running behind,
  114. // only relevant for capped performance tests.
  115. double dropped_frame_percentage_ = 0.0;
  116. // Statistics about the time between subsequent frame deliveries.
  117. PerformanceTimeStats delivery_time_stats_;
  118. // Statistics about the time between decode start and frame deliveries.
  119. PerformanceTimeStats decode_time_stats_;
  120. };
  121. // The performance evaluator can be plugged into the video player to collect
  122. // various performance metrics.
  123. // TODO(dstaessens@) Check and post warning when CPU frequency scaling is
  124. // enabled as this affects test results.
  125. class PerformanceEvaluator : public VideoFrameProcessor {
  126. public:
  127. // Create a new performance evaluator. The caller should makes sure
  128. // |frame_renderer| outlives the performance evaluator.
  129. explicit PerformanceEvaluator(const FrameRendererDummy* const frame_renderer)
  130. : frame_renderer_(frame_renderer) {}
  131. // Interface VideoFrameProcessor
  132. void ProcessVideoFrame(scoped_refptr<const VideoFrame> video_frame,
  133. size_t frame_index) override;
  134. bool WaitUntilDone() override { return true; }
  135. // Start/Stop collecting performance metrics.
  136. void StartMeasuring();
  137. void StopMeasuring();
  138. // Write the collected performance metrics to file.
  139. void WriteMetricsToFile() const;
  140. private:
  141. // Start/end time of the measurement period.
  142. base::TimeTicks start_time_;
  143. base::TimeTicks end_time_;
  144. // Time at which the previous frame was delivered.
  145. base::TimeTicks prev_frame_delivery_time_;
  146. // List of times between subsequent frame deliveries.
  147. std::vector<double> frame_delivery_times_;
  148. // List of times between decode start and frame delivery.
  149. std::vector<double> frame_decode_times_;
  150. // Collection of various performance metrics.
  151. PerformanceMetrics perf_metrics_;
  152. // Frame renderer used to get the dropped frame rate, owned by the creator of
  153. // the performance evaluator.
  154. const raw_ptr<const FrameRendererDummy> frame_renderer_;
  155. };
  156. void PerformanceEvaluator::ProcessVideoFrame(
  157. scoped_refptr<const VideoFrame> video_frame,
  158. size_t frame_index) {
  159. base::TimeTicks now = base::TimeTicks::Now();
  160. base::TimeDelta delivery_time = (now - prev_frame_delivery_time_);
  161. frame_delivery_times_.push_back(delivery_time.InMillisecondsF());
  162. prev_frame_delivery_time_ = now;
  163. base::TimeDelta decode_time = now.since_origin() - video_frame->timestamp();
  164. frame_decode_times_.push_back(decode_time.InMillisecondsF());
  165. perf_metrics_.frames_decoded_++;
  166. }
  167. void PerformanceEvaluator::StartMeasuring() {
  168. start_time_ = base::TimeTicks::Now();
  169. prev_frame_delivery_time_ = start_time_;
  170. }
  171. void PerformanceEvaluator::StopMeasuring() {
  172. end_time_ = base::TimeTicks::Now();
  173. perf_metrics_.total_duration_ = end_time_ - start_time_;
  174. perf_metrics_.frames_per_second_ = perf_metrics_.frames_decoded_ /
  175. perf_metrics_.total_duration_.InSecondsF();
  176. perf_metrics_.frames_dropped_ = frame_renderer_->FramesDropped();
  177. // Calculate the dropped frame percentage.
  178. perf_metrics_.dropped_frame_percentage_ =
  179. static_cast<double>(perf_metrics_.frames_dropped_) /
  180. static_cast<double>(
  181. std::max<size_t>(perf_metrics_.frames_decoded_, 1ul)) *
  182. 100.0;
  183. // Calculate delivery and decode time metrics.
  184. perf_metrics_.delivery_time_stats_ =
  185. PerformanceTimeStats(frame_delivery_times_);
  186. perf_metrics_.decode_time_stats_ = PerformanceTimeStats(frame_decode_times_);
  187. std::cout << "Frames decoded: " << perf_metrics_.frames_decoded_
  188. << std::endl;
  189. std::cout << "Total duration: "
  190. << perf_metrics_.total_duration_.InMillisecondsF() << "ms"
  191. << std::endl;
  192. std::cout << "FPS: " << perf_metrics_.frames_per_second_
  193. << std::endl;
  194. std::cout << "Frames Dropped: " << perf_metrics_.frames_dropped_
  195. << std::endl;
  196. std::cout << "Dropped frame percentage: "
  197. << perf_metrics_.dropped_frame_percentage_ << "%" << std::endl;
  198. std::cout << "Frame delivery time - average: "
  199. << perf_metrics_.delivery_time_stats_.avg_ms_ << "ms" << std::endl;
  200. std::cout << "Frame delivery time - percentile 25: "
  201. << perf_metrics_.delivery_time_stats_.percentile_25_ms_ << "ms"
  202. << std::endl;
  203. std::cout << "Frame delivery time - percentile 50: "
  204. << perf_metrics_.delivery_time_stats_.percentile_50_ms_ << "ms"
  205. << std::endl;
  206. std::cout << "Frame delivery time - percentile 75: "
  207. << perf_metrics_.delivery_time_stats_.percentile_75_ms_ << "ms"
  208. << std::endl;
  209. std::cout << "Frame decode time - average: "
  210. << perf_metrics_.decode_time_stats_.avg_ms_ << "ms" << std::endl;
  211. std::cout << "Frame decode time - percentile 25: "
  212. << perf_metrics_.decode_time_stats_.percentile_25_ms_ << "ms"
  213. << std::endl;
  214. std::cout << "Frame decode time - percentile 50: "
  215. << perf_metrics_.decode_time_stats_.percentile_50_ms_ << "ms"
  216. << std::endl;
  217. std::cout << "Frame decode time - percentile 75: "
  218. << perf_metrics_.decode_time_stats_.percentile_75_ms_ << "ms"
  219. << std::endl;
  220. }
  221. void PerformanceEvaluator::WriteMetricsToFile() const {
  222. base::FilePath output_folder_path = base::FilePath(g_env->OutputFolder());
  223. if (!DirectoryExists(output_folder_path))
  224. base::CreateDirectory(output_folder_path);
  225. output_folder_path = base::MakeAbsoluteFilePath(output_folder_path);
  226. // Write performance metrics to json.
  227. base::Value metrics(base::Value::Type::DICTIONARY);
  228. metrics.SetKey(
  229. "FramesDecoded",
  230. base::Value(base::checked_cast<int>(perf_metrics_.frames_decoded_)));
  231. metrics.SetKey("TotalDurationMs",
  232. base::Value(perf_metrics_.total_duration_.InMillisecondsF()));
  233. metrics.SetKey("FPS", base::Value(perf_metrics_.frames_per_second_));
  234. metrics.SetKey(
  235. "FramesDropped",
  236. base::Value(base::checked_cast<int>(perf_metrics_.frames_dropped_)));
  237. metrics.SetKey("DroppedFramePercentage",
  238. base::Value(perf_metrics_.dropped_frame_percentage_));
  239. metrics.SetKey("FrameDeliveryTimeAverage",
  240. base::Value(perf_metrics_.delivery_time_stats_.avg_ms_));
  241. metrics.SetKey(
  242. "FrameDeliveryTimePercentile25",
  243. base::Value(perf_metrics_.delivery_time_stats_.percentile_25_ms_));
  244. metrics.SetKey(
  245. "FrameDeliveryTimePercentile50",
  246. base::Value(perf_metrics_.delivery_time_stats_.percentile_50_ms_));
  247. metrics.SetKey(
  248. "FrameDeliveryTimePercentile75",
  249. base::Value(perf_metrics_.delivery_time_stats_.percentile_75_ms_));
  250. metrics.SetKey("FrameDecodeTimeAverage",
  251. base::Value(perf_metrics_.decode_time_stats_.avg_ms_));
  252. metrics.SetKey(
  253. "FrameDecodeTimePercentile25",
  254. base::Value(perf_metrics_.decode_time_stats_.percentile_25_ms_));
  255. metrics.SetKey(
  256. "FrameDecodeTimePercentile50",
  257. base::Value(perf_metrics_.decode_time_stats_.percentile_50_ms_));
  258. metrics.SetKey(
  259. "FrameDecodeTimePercentile75",
  260. base::Value(perf_metrics_.decode_time_stats_.percentile_75_ms_));
  261. // Write frame delivery times to json.
  262. base::Value delivery_times(base::Value::Type::LIST);
  263. for (double frame_delivery_time : frame_delivery_times_) {
  264. delivery_times.Append(frame_delivery_time);
  265. }
  266. metrics.SetKey("FrameDeliveryTimes", std::move(delivery_times));
  267. // Write frame decodes times to json.
  268. base::Value decode_times(base::Value::Type::LIST);
  269. for (double frame_decode_time : frame_decode_times_) {
  270. decode_times.Append(frame_decode_time);
  271. }
  272. metrics.SetKey("FrameDecodeTimes", std::move(decode_times));
  273. // Write json to file.
  274. std::string metrics_str;
  275. ASSERT_TRUE(base::JSONWriter::WriteWithOptions(
  276. metrics, base::JSONWriter::OPTIONS_PRETTY_PRINT, &metrics_str));
  277. base::FilePath metrics_file_path = output_folder_path.Append(
  278. g_env->GetTestOutputFilePath().AddExtension(FILE_PATH_LITERAL(".json")));
  279. // Make sure that the directory into which json is saved is created.
  280. LOG_ASSERT(base::CreateDirectory(metrics_file_path.DirName()));
  281. base::File metrics_output_file(
  282. base::FilePath(metrics_file_path),
  283. base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE);
  284. int bytes_written = metrics_output_file.WriteAtCurrentPos(
  285. metrics_str.data(), metrics_str.length());
  286. ASSERT_EQ(bytes_written, static_cast<int>(metrics_str.length()));
  287. VLOG(0) << "Wrote performance metrics to: " << metrics_file_path;
  288. }
  289. // Video decode test class. Performs setup and teardown for each single test.
  290. class VideoDecoderTest : public ::testing::Test {
  291. public:
  292. // Create a new video player instance. |render_frame_rate| is the rate at
  293. // which the video player will simulate rendering frames, if 0 no rendering is
  294. // simulated. The |vsync_rate| is used during simulated rendering, if 0 Vsync
  295. // is disabled.
  296. std::unique_ptr<DecoderListener> CreateDecoderListener(
  297. const Video* video,
  298. uint32_t render_frame_rate = 0,
  299. uint32_t vsync_rate = 0) {
  300. LOG_ASSERT(video);
  301. // Create dummy frame renderer, simulates rendering at specified frame rate.
  302. base::TimeDelta frame_duration;
  303. base::TimeDelta vsync_interval_duration;
  304. if (render_frame_rate > 0) {
  305. frame_duration = base::Seconds(1) / render_frame_rate;
  306. vsync_interval_duration = base::Seconds(1) / vsync_rate;
  307. }
  308. auto frame_renderer =
  309. FrameRendererDummy::Create(frame_duration, vsync_interval_duration);
  310. std::vector<std::unique_ptr<VideoFrameProcessor>> frame_processors;
  311. auto performance_evaluator =
  312. std::make_unique<PerformanceEvaluator>(frame_renderer.get());
  313. performance_evaluator_ = performance_evaluator.get();
  314. frame_processors.push_back(std::move(performance_evaluator));
  315. // Use the new VD-based video decoders if requested.
  316. DecoderWrapperConfig config;
  317. config.implementation = g_env->GetDecoderImplementation();
  318. config.linear_output = g_env->ShouldOutputLinearBuffers();
  319. auto video_player = DecoderListener::Create(
  320. config, std::move(frame_renderer), std::move(frame_processors));
  321. LOG_ASSERT(video_player);
  322. LOG_ASSERT(video_player->Initialize(video));
  323. // Make sure the event timeout is at least as long as the video's duration.
  324. video_player->SetEventWaitTimeout(
  325. std::max(kDefaultEventWaitTimeout, g_env->Video()->GetDuration()));
  326. return video_player;
  327. }
  328. raw_ptr<PerformanceEvaluator> performance_evaluator_;
  329. };
  330. } // namespace
  331. // Play video from start to end while measuring uncapped performance. This test
  332. // will decode a video as fast as possible, and gives an idea about the maximum
  333. // output of the decoder.
  334. TEST_F(VideoDecoderTest, MeasureUncappedPerformance) {
  335. auto tvp = CreateDecoderListener(g_env->Video());
  336. performance_evaluator_->StartMeasuring();
  337. tvp->Play();
  338. EXPECT_TRUE(tvp->WaitForFlushDone());
  339. performance_evaluator_->StopMeasuring();
  340. performance_evaluator_->WriteMetricsToFile();
  341. EXPECT_EQ(tvp->GetFlushDoneCount(), 1u);
  342. EXPECT_EQ(tvp->GetFrameDecodedCount(), g_env->Video()->NumFrames());
  343. }
  344. // Play video from start to end while measuring capped performance. This test
  345. // will simulate rendering the video at its actual frame rate, and will
  346. // calculate the number of frames that were dropped. Vsync is enabled at 60 FPS.
  347. TEST_F(VideoDecoderTest, MeasureCappedPerformance) {
  348. auto tvp =
  349. CreateDecoderListener(g_env->Video(), g_env->Video()->FrameRate(), 60);
  350. performance_evaluator_->StartMeasuring();
  351. tvp->Play();
  352. EXPECT_TRUE(tvp->WaitForFlushDone());
  353. tvp->WaitForRenderer();
  354. performance_evaluator_->StopMeasuring();
  355. performance_evaluator_->WriteMetricsToFile();
  356. EXPECT_EQ(tvp->GetFlushDoneCount(), 1u);
  357. EXPECT_EQ(tvp->GetFrameDecodedCount(), g_env->Video()->NumFrames());
  358. }
  359. // TODO(b/211783279) The |performance_evaluator_| only keeps track of the last
  360. // created decoder. We should instead keep track of multiple evaluators, and
  361. // then decide how to aggregate/report those metrics.
  362. // Play multiple videos simultaneously from start to finish.
  363. TEST_F(VideoDecoderTest, MeasureUncappedPerformance_TenConcurrentDecoders) {
  364. // Set RLIMIT_NOFILE soft limit to its hard limit value.
  365. if (sandbox::ResourceLimits::AdjustCurrent(
  366. RLIMIT_NOFILE, std::numeric_limits<long long int>::max())) {
  367. DPLOG(ERROR) << "Unable to increase soft limit of RLIMIT_NOFILE";
  368. }
  369. constexpr size_t kNumConcurrentDecoders = 10;
  370. std::vector<std::unique_ptr<DecoderListener>> players(kNumConcurrentDecoders);
  371. for (auto&& player : players) {
  372. player = CreateDecoderListener(g_env->Video());
  373. // Increase the timeout for older machines that cannot decode as
  374. // efficiently.
  375. player->SetEventWaitTimeout(kMultipleDecodersTimeout);
  376. }
  377. performance_evaluator_->StartMeasuring();
  378. for (auto&& player : players)
  379. player->Play();
  380. for (auto&& player : players) {
  381. EXPECT_TRUE(player->WaitForFlushDone());
  382. EXPECT_EQ(player->GetFlushDoneCount(), 1u);
  383. EXPECT_EQ(player->GetFrameDecodedCount(), g_env->Video()->NumFrames());
  384. }
  385. performance_evaluator_->StopMeasuring();
  386. performance_evaluator_->WriteMetricsToFile();
  387. }
  388. } // namespace test
  389. } // namespace media
  390. int main(int argc, char** argv) {
  391. // Set the default test data path.
  392. media::test::Video::SetTestDataPath(media::GetTestDataPath());
  393. // Print the help message if requested. This needs to be done before
  394. // initializing gtest, to overwrite the default gtest help message.
  395. base::CommandLine::Init(argc, argv);
  396. base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
  397. LOG_ASSERT(cmd_line);
  398. if (cmd_line->HasSwitch("help")) {
  399. std::cout << media::test::usage_msg << "\n" << media::test::help_msg;
  400. return 0;
  401. }
  402. // Check if a video was specified on the command line.
  403. base::CommandLine::StringVector args = cmd_line->GetArgs();
  404. base::FilePath video_path =
  405. (args.size() >= 1) ? base::FilePath(args[0]) : base::FilePath();
  406. base::FilePath video_metadata_path =
  407. (args.size() >= 2) ? base::FilePath(args[1]) : base::FilePath();
  408. // Parse command line arguments.
  409. base::FilePath::StringType output_folder = media::test::kDefaultOutputFolder;
  410. bool use_legacy = false;
  411. bool use_vd_vda = false;
  412. bool linear_output = false;
  413. std::vector<base::Feature> disabled_features;
  414. std::vector<base::Feature> enabled_features;
  415. #if defined(ARCH_CPU_ARM_FAMILY)
  416. enabled_features.push_back(media::kPreferLibYuvImageProcessor);
  417. #endif // defined(ARCH_CPU_ARM_FAMILY)
  418. media::test::DecoderImplementation implementation =
  419. media::test::DecoderImplementation::kVD;
  420. base::CommandLine::SwitchMap switches = cmd_line->GetSwitches();
  421. for (base::CommandLine::SwitchMap::const_iterator it = switches.begin();
  422. it != switches.end(); ++it) {
  423. if (it->first.find("gtest_") == 0 || // Handled by GoogleTest
  424. it->first == "v" || it->first == "vmodule") { // Handled by Chrome
  425. continue;
  426. }
  427. if (it->first == "output_folder") {
  428. output_folder = it->second;
  429. } else if (it->first == "use-legacy") {
  430. use_legacy = true;
  431. implementation = media::test::DecoderImplementation::kVDA;
  432. } else if (it->first == "use_vd_vda") {
  433. use_vd_vda = true;
  434. implementation = media::test::DecoderImplementation::kVDVDA;
  435. } else if (it->first == "linear_output") {
  436. linear_output = true;
  437. } else if (it->first == "disable_vaapi_lock") {
  438. disabled_features.push_back(media::kGlobalVaapiLock);
  439. #if defined(ARCH_CPU_ARM_FAMILY)
  440. } else if (it->first == "disable-libyuv") {
  441. enabled_features.clear();
  442. #endif // defined(ARCH_CPU_ARM_FAMILY)
  443. } else {
  444. std::cout << "unknown option: --" << it->first << "\n"
  445. << media::test::usage_msg;
  446. return EXIT_FAILURE;
  447. }
  448. }
  449. if (use_legacy && use_vd_vda) {
  450. std::cout << "--use-legacy and --use_vd_vda cannot be enabled together.\n"
  451. << media::test::usage_msg;
  452. return EXIT_FAILURE;
  453. }
  454. if (linear_output && !use_vd_vda) {
  455. std::cout << "--linear_output must be used with the VDVDA (--use_vd_vda)\n"
  456. "implementation.\n"
  457. << media::test::usage_msg;
  458. return EXIT_FAILURE;
  459. }
  460. testing::InitGoogleTest(&argc, argv);
  461. // Add the command line flag for HEVC testing which will be checked by the
  462. // video decoder to allow clear HEVC decoding.
  463. cmd_line->AppendSwitch("enable-clear-hevc-for-testing");
  464. // Set up our test environment.
  465. media::test::VideoPlayerTestEnvironment* test_environment =
  466. media::test::VideoPlayerTestEnvironment::Create(
  467. video_path, video_metadata_path, /*validator_type=*/
  468. media::test::VideoPlayerTestEnvironment::ValidatorType::kNone,
  469. implementation, linear_output, base::FilePath(output_folder),
  470. media::test::FrameOutputConfig(), enabled_features,
  471. disabled_features);
  472. if (!test_environment)
  473. return EXIT_FAILURE;
  474. media::test::g_env = static_cast<media::test::VideoPlayerTestEnvironment*>(
  475. testing::AddGlobalTestEnvironment(test_environment));
  476. return RUN_ALL_TESTS();
  477. }