gapi_streaming_source_perf_tests.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. //
  5. // Copyright (C) 2021 Intel Corporation
  6. #ifdef HAVE_ONEVPL
  7. #include "../perf_precomp.hpp"
  8. #include "../../test/common/gapi_tests_common.hpp"
  9. #include <opencv2/gapi/streaming/onevpl/source.hpp>
  10. #include <opencv2/gapi/streaming/cap.hpp>
  11. namespace opencv_test
  12. {
  13. using namespace perf;
  14. const std::string files[] = {
  15. "highgui/video/big_buck_bunny.h265",
  16. "highgui/video/big_buck_bunny.h264",
  17. "highgui/video/sample_322x242_15frames.yuv420p.libx265.mp4",
  18. };
  19. const std::string codec[] = {
  20. "MFX_CODEC_HEVC",
  21. "MFX_CODEC_AVC",
  22. "",
  23. };
  24. using source_t = std::string;
  25. using codec_t = std::string;
  26. using accel_mode_t = std::string;
  27. using source_description_t = std::tuple<source_t, codec_t, accel_mode_t>;
  28. class OneVPLSourcePerfTest : public TestPerfParams<source_description_t> {};
  29. class VideoCapSourcePerfTest : public TestPerfParams<source_t> {};
  30. PERF_TEST_P_(OneVPLSourcePerfTest, TestPerformance)
  31. {
  32. using namespace cv::gapi::wip::onevpl;
  33. const auto params = GetParam();
  34. source_t src = findDataFile(get<0>(params));
  35. codec_t type = get<1>(params);
  36. accel_mode_t mode = get<2>(params);
  37. std::vector<CfgParam> cfg_params {
  38. CfgParam::create_implementation("MFX_IMPL_TYPE_HARDWARE"),
  39. };
  40. if (!type.empty()) {
  41. cfg_params.push_back(CfgParam::create_decoder_id(type.c_str()));
  42. }
  43. if (!mode.empty()) {
  44. cfg_params.push_back(CfgParam::create_acceleration_mode(mode.c_str()));
  45. }
  46. auto source_ptr = cv::gapi::wip::make_onevpl_src(src, cfg_params);
  47. cv::gapi::wip::Data out;
  48. TEST_CYCLE()
  49. {
  50. source_ptr->pull(out);
  51. }
  52. SANITY_CHECK_NOTHING();
  53. }
  54. PERF_TEST_P_(VideoCapSourcePerfTest, TestPerformance)
  55. {
  56. using namespace cv::gapi::wip;
  57. source_t src = findDataFile(GetParam());
  58. auto source_ptr = make_src<GCaptureSource>(src);
  59. Data out;
  60. TEST_CYCLE()
  61. {
  62. source_ptr->pull(out);
  63. }
  64. SANITY_CHECK_NOTHING();
  65. }
  66. INSTANTIATE_TEST_CASE_P(Streaming, OneVPLSourcePerfTest,
  67. Values(source_description_t(files[0], codec[0], ""),
  68. source_description_t(files[0], codec[0], "MFX_ACCEL_MODE_VIA_D3D11"),
  69. source_description_t(files[1], codec[1], ""),
  70. source_description_t(files[1], codec[1], "MFX_ACCEL_MODE_VIA_D3D11"),
  71. source_description_t(files[2], codec[2], ""),
  72. source_description_t(files[2], codec[2], "MFX_ACCEL_MODE_VIA_D3D11")));
  73. INSTANTIATE_TEST_CASE_P(Streaming, VideoCapSourcePerfTest,
  74. Values(files[0],
  75. files[1],
  76. files[2]));
  77. } // namespace opencv_test
  78. #endif // HAVE_ONEVPL