|
| 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) 2015, Itseez, Inc., all rights reserved. |
| 6 | +// Third party copyrights are property of their respective owners. |
| 7 | + |
| 8 | +#ifndef __OPENCV_CORE_VAAPI_HPP__ |
| 9 | +#define __OPENCV_CORE_VAAPI_HPP__ |
| 10 | + |
| 11 | +#ifndef __cplusplus |
| 12 | +# error vaapi.hpp header must be compiled as C++ |
| 13 | +#endif |
| 14 | + |
| 15 | +#include "opencv2/core.hpp" |
| 16 | +#include "ocl.hpp" |
| 17 | + |
| 18 | +#if defined(HAVE_VAAPI) |
| 19 | +# include "va/va.h" |
| 20 | +#else // HAVE_VAAPI |
| 21 | +# if !defined(_VA_H_) |
| 22 | + typedef void* VADisplay; |
| 23 | + typedef unsigned int VASurfaceID; |
| 24 | +# endif // !_VA_H_ |
| 25 | +#endif // HAVE_VAAPI |
| 26 | + |
| 27 | +namespace cv { namespace vaapi { |
| 28 | + |
| 29 | +/** @addtogroup core_vaapi |
| 30 | +This section describes CL-VA (VA-API) interoperability. |
| 31 | +
|
| 32 | +To enable CL-VA interoperability support, configure OpenCV using CMake with WITH_VAAPI=ON . Currently VA-API is |
| 33 | +supported on Linux only. You should also install Intel Media Server Studio (MSS) to use this feature. You may |
| 34 | +have to specify the path(s) to MSS components for cmake in environment variables: VAAPI_MSDK_ROOT for Media SDK |
| 35 | +(default is "/opt/intel/mediasdk"), and VAAPI_IOCL_ROOT for Intel OpenCL (default is "/opt/intel/opencl"). |
| 36 | +
|
| 37 | +To use VA-API interoperability you should first create VADisplay (libva), and then call initializeContextFromVA() |
| 38 | +function to create OpenCL context and set up interoperability. |
| 39 | +*/ |
| 40 | +//! @{ |
| 41 | + |
| 42 | +/////////////////// CL-VA Interoperability Functions /////////////////// |
| 43 | + |
| 44 | +namespace ocl { |
| 45 | +using namespace cv::ocl; |
| 46 | + |
| 47 | +// TODO static functions in the Context class |
| 48 | +/** @brief Creates OpenCL context from VA. |
| 49 | +@param display - VADisplay for which CL interop should be established. |
| 50 | +@return Returns reference to OpenCL Context |
| 51 | + */ |
| 52 | +CV_EXPORTS Context& initializeContextFromVA(VADisplay display); |
| 53 | + |
| 54 | +} // namespace cv::vaapi::ocl |
| 55 | + |
| 56 | +/** @brief Converts InputArray to VASurfaceID object. |
| 57 | +@param src - source InputArray. |
| 58 | +@param surface - destination VASurfaceID object. |
| 59 | +@param size - size of image represented by VASurfaceID object. |
| 60 | + */ |
| 61 | +CV_EXPORTS void convertToVASurface(InputArray src, VASurfaceID surface, Size size); |
| 62 | + |
| 63 | +/** @brief Converts VASurfaceID object to OutputArray. |
| 64 | +@param surface - source VASurfaceID object. |
| 65 | +@param size - size of image represented by VASurfaceID object. |
| 66 | +@param dst - destination OutputArray. |
| 67 | + */ |
| 68 | +CV_EXPORTS void convertFromVASurface(VASurfaceID surface, Size size, OutputArray dst); |
| 69 | + |
| 70 | +//! @} |
| 71 | + |
| 72 | +}} // namespace cv::vaapi |
| 73 | + |
| 74 | +#endif /* __OPENCV_CORE_VAAPI_HPP__ */ |
0 commit comments