va_intel.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. // Copyright (C) 2015, Itseez, Inc., all rights reserved.
  5. // Third party copyrights are property of their respective owners.
  6. #ifndef OPENCV_CORE_VA_INTEL_HPP
  7. #define OPENCV_CORE_VA_INTEL_HPP
  8. #ifndef __cplusplus
  9. # error va_intel.hpp header must be compiled as C++
  10. #endif
  11. #include "opencv2/core.hpp"
  12. #include "ocl.hpp"
  13. #if defined(HAVE_VA)
  14. # include "va/va.h"
  15. #else // HAVE_VA
  16. # if !defined(_VA_H_)
  17. typedef void* VADisplay;
  18. typedef unsigned int VASurfaceID;
  19. # endif // !_VA_H_
  20. #endif // HAVE_VA
  21. namespace cv { namespace va_intel {
  22. /** @addtogroup core_va_intel
  23. This section describes Intel VA-API/OpenCL (CL-VA) interoperability.
  24. To enable basic VA interoperability build OpenCV with libva library integration enabled: `-DWITH_VA=ON` (corresponding dev package should be installed).
  25. To enable advanced CL-VA interoperability support on Intel HW, enable option: `-DWITH_VA_INTEL=ON` (OpenCL integration should be enabled which is the default setting). Special runtime environment should be set up in order to use this feature: correct combination of [libva](https://github.com/intel/libva), [OpenCL runtime](https://github.com/intel/compute-runtime) and [media driver](https://github.com/intel/media-driver) should be installed.
  26. Check usage example for details: samples/va_intel/va_intel_interop.cpp
  27. */
  28. //! @{
  29. /////////////////// CL-VA Interoperability Functions ///////////////////
  30. namespace ocl {
  31. using namespace cv::ocl;
  32. // TODO static functions in the Context class
  33. /** @brief Creates OpenCL context from VA.
  34. @param display - VADisplay for which CL interop should be established.
  35. @param tryInterop - try to set up for interoperability, if true; set up for use slow copy if false.
  36. @return Returns reference to OpenCL Context
  37. */
  38. CV_EXPORTS Context& initializeContextFromVA(VADisplay display, bool tryInterop = true);
  39. } // namespace cv::va_intel::ocl
  40. /** @brief Converts InputArray to VASurfaceID object.
  41. @param display - VADisplay object.
  42. @param src - source InputArray.
  43. @param surface - destination VASurfaceID object.
  44. @param size - size of image represented by VASurfaceID object.
  45. */
  46. CV_EXPORTS void convertToVASurface(VADisplay display, InputArray src, VASurfaceID surface, Size size);
  47. /** @brief Converts VASurfaceID object to OutputArray.
  48. @param display - VADisplay object.
  49. @param surface - source VASurfaceID object.
  50. @param size - size of image represented by VASurfaceID object.
  51. @param dst - destination OutputArray.
  52. */
  53. CV_EXPORTS void convertFromVASurface(VADisplay display, VASurfaceID surface, Size size, OutputArray dst);
  54. //! @}
  55. }} // namespace cv::va_intel
  56. #endif /* OPENCV_CORE_VA_INTEL_HPP */