1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
|
/*############################################################################
# Copyright Intel Corporation
#
# SPDX-License-Identifier: MIT
############################################################################*/
#ifndef __MFXMEMORY_H__
#define __MFXMEMORY_H__
#include "mfxsession.h"
#include "mfxstructures.h"
#ifdef __cplusplus
extern "C"
{
#endif
/*!
@brief
Returns surface which can be used as input for VPP.
VPP should be initialized before this call.
Surface should be released with mfxFrameSurface1::FrameInterface.Release(...) after usage. The value of mfxFrameSurface1::Data.Locked for the returned surface is 0.
@param[in] session Session handle.
@param[out] surface Pointer is set to valid mfxFrameSurface1 object.
@return
MFX_ERR_NONE The function completed successfully. \n
MFX_ERR_NULL_PTR If double-pointer to the @p surface is NULL. \n
MFX_ERR_INVALID_HANDLE If @p session was not initialized. \n
MFX_ERR_NOT_INITIALIZED If VPP was not initialized (allocator needs to know surface size from somewhere). \n
MFX_ERR_MEMORY_ALLOC In case of any other internal allocation error. \n
MFX_WRN_ALLOC_TIMEOUT_EXPIRED In case of waiting timeout expired (if set with mfxExtAllocationHints).
@since This function is available since API version 2.0.
*/
mfxStatus MFX_CDECL MFXMemory_GetSurfaceForVPP(mfxSession session, mfxFrameSurface1** surface);
/*!
@brief
Returns surface which can be used as output of VPP.
VPP should be initialized before this call.
Surface should be released with mfxFrameSurface1::FrameInterface.Release(...) after usage. The value of mfxFrameSurface1::Data.Locked for the returned surface is 0.
@param[in] session Session handle.
@param[out] surface Pointer is set to valid mfxFrameSurface1 object.
@return
MFX_ERR_NONE The function completed successfully. \n
MFX_ERR_NULL_PTR If double-pointer to the @p surface is NULL. \n
MFX_ERR_INVALID_HANDLE If @p session was not initialized. \n
MFX_ERR_NOT_INITIALIZED If VPP was not initialized (allocator needs to know surface size from somewhere). \n
MFX_ERR_MEMORY_ALLOC In case of any other internal allocation error. \n
MFX_WRN_ALLOC_TIMEOUT_EXPIRED In case of waiting timeout expired (if set with mfxExtAllocationHints).
@since This function is available since API version 2.1.
*/
mfxStatus MFX_CDECL MFXMemory_GetSurfaceForVPPOut(mfxSession session, mfxFrameSurface1** surface);
/*! Alias for MFXMemory_GetSurfaceForVPP function. */
#define MFXMemory_GetSurfaceForVPPIn MFXMemory_GetSurfaceForVPP
/*!
@brief
Returns a surface which can be used as input for the encoder.
Encoder should be initialized before this call.
Surface should be released with mfxFrameSurface1::FrameInterface.Release(...) after usage. The value of mfxFrameSurface1::Data.Locked for the returned surface is 0.
@param[in] session Session handle.
@param[out] surface Pointer is set to valid mfxFrameSurface1 object.
@return
MFX_ERR_NONE The function completed successfully.\n
MFX_ERR_NULL_PTR If surface is NULL.\n
MFX_ERR_INVALID_HANDLE If session was not initialized.\n
MFX_ERR_NOT_INITIALIZED If the encoder was not initialized (allocator needs to know surface size from somewhere).\n
MFX_ERR_MEMORY_ALLOC In case of any other internal allocation error. \n
MFX_WRN_ALLOC_TIMEOUT_EXPIRED In case of waiting timeout expired (if set with mfxExtAllocationHints).
@since This function is available since API version 2.0.
*/
mfxStatus MFX_CDECL MFXMemory_GetSurfaceForEncode(mfxSession session, mfxFrameSurface1** surface);
/*!
@brief
Returns a surface which can be used as output of the decoder.
Decoder should be initialized before this call.
Surface should be released with mfxFrameSurface1::FrameInterface.Release(...) after usage. The value of mfxFrameSurface1::Data.Locked for the returned surface is 0.'
@note This function was added to simplify transition from legacy surface management to the proposed internal allocation approach.
Previously, the user allocated surfaces for the working pool and fed them to the decoder using DecodeFrameAsync calls. With MFXMemory_GetSurfaceForDecode
it is possible to change the existing pipeline by just changing the source of work surfaces.
Newly developed applications should prefer direct usage of DecodeFrameAsync with internal allocation.
@param[in] session Session handle.
@param[out] surface Pointer is set to valid mfxFrameSurface1 object.
@return
MFX_ERR_NONE The function completed successfully.\n
MFX_ERR_NULL_PTR If surface is NULL.\n
MFX_ERR_INVALID_HANDLE If session was not initialized.\n
MFX_ERR_NOT_INITIALIZED If the decoder was not initialized (allocator needs to know surface size from somewhere).\n
MFX_ERR_MEMORY_ALLOC Other internal allocation error. \n
MFX_WRN_ALLOC_TIMEOUT_EXPIRED In case of waiting timeout expired (if set with mfxExtAllocationHints).
@since This function is available since API version 2.0.
*/
mfxStatus MFX_CDECL MFXMemory_GetSurfaceForDecode(mfxSession session, mfxFrameSurface1** surface);
#ifdef ONEVPL_EXPERIMENTAL
MFX_PACK_BEGIN_STRUCT_W_PTR()
typedef struct {
mfxSurfaceInterface SurfaceInterface;
mfxHDL texture2D; /*!< Pointer to texture, type ID3D11Texture2D* */
mfxHDL reserved[7];
} mfxSurfaceD3D11Tex2D;
MFX_PACK_END()
MFX_PACK_BEGIN_STRUCT_W_PTR()
typedef struct {
mfxSurfaceInterface SurfaceInterface;
mfxHDL vaDisplay; /*!< Object of type VADisplay. */
mfxU32 vaSurfaceID; /*!< Object of type VASurfaceID. */
mfxU32 reserved1;
mfxHDL reserved[6];
} mfxSurfaceVAAPI;
MFX_PACK_END()
MFX_PACK_BEGIN_STRUCT_W_PTR()
/*!
Optional extension buffer, which can be attached to mfxSurfaceHeader::ExtParam
(second parameter of mfxFrameSurfaceInterface::Export) in order to pass OCL parameters
during mfxFrameSurface1 exporting to OCL surface.
If buffer is not provided all resources will be created by oneAPI Video Processing Library (oneVPL) RT internally.
*/
typedef struct {
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_EXPORT_SHARING_DESC_OCL. */
mfxHDL ocl_context; /*!< Object of type cl_context (OpenCL context). */
mfxHDL ocl_command_queue; /*!< Object of type cl_command_queue (OpenCL command queue). */
mfxHDL reserved[8];
} mfxExtSurfaceOpenCLImg2DExportDescription;
MFX_PACK_END()
MFX_PACK_BEGIN_STRUCT_W_PTR()
typedef struct {
mfxSurfaceInterface SurfaceInterface;
mfxHDL ocl_context; /*!< Object of type cl_context (OpenCL context). */
mfxHDL ocl_command_queue; /*!< Object of type cl_command_queue (OpenCL command queue). */
mfxHDL ocl_image[4]; /*!< Object of type cl_mem[4] (array of 4 OpenCL 2D images). */
mfxU32 ocl_image_num; /*!< Number of valid images (planes), depends on color format. */
mfxHDL reserved[8];
} mfxSurfaceOpenCLImg2D;
MFX_PACK_END()
MFX_PACK_BEGIN_STRUCT_W_PTR()
/*!
Optional extension buffer, which can be attached to mfxSurfaceHeader::ExtParam
(second parameter of mfxFrameSurfaceInterface::Export) in order to pass D3D12 parameters
during mfxFrameSurface1 exporting to D3D12 resource.
If buffer is not provided all resources will be created by oneAPI Video Processing Library (oneVPL) RT internally.
*/
typedef struct {
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_EXPORT_SHARING_DESC_D3D12. */
mfxHDL d3d12Device; /*!< Pointer to D3D12 Device, type ID3D12Device*. */
mfxHDL reserved[9];
} mfxExtSurfaceD3D12Tex2DExportDescription;
MFX_PACK_END()
MFX_PACK_BEGIN_STRUCT_W_PTR()
typedef struct {
mfxSurfaceInterface SurfaceInterface;
mfxHDL texture2D; /*!< Pointer to D3D12 resource, type ID3D12Resource*. */
mfxHDL reserved[7];
} mfxSurfaceD3D12Tex2D;
MFX_PACK_END()
MFX_PACK_BEGIN_STRUCT_W_PTR()
/*!
Optional extension buffer, which can be attached to mfxSurfaceHeader::ExtParam
(second parameter of mfxFrameSurfaceInterface::Export) in order to pass Vulkan parameters
during mfxFrameSurface1 exporting to Vulkan surface.
If buffer is not provided all resources will be created by oneAPI Video Processing Library (oneVPL) RT internally.
*/
typedef struct {
mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_EXPORT_SHARING_DESC_VULKAN. */
mfxHDL instance; /*!< Object of type VkInstance (Vulkan instance). */
mfxHDL physicalDevice; /*!< Object of type VkPhysicalDevice (Vulkan physical device). */
mfxHDL device; /*!< Object of type VkDevice (Vulkan device). */
mfxHDL reserved[7];
} mfxExtSurfaceVulkanImg2DExportDescription;
MFX_PACK_END()
MFX_PACK_BEGIN_STRUCT_W_PTR()
typedef struct {
mfxSurfaceInterface SurfaceInterface;
mfxHDL instance; /*!< Object of type VkInstance (Vulkan instance). */
mfxHDL physicalDevice; /*!< Object of type VkPhysicalDevice (Vulkan physical device). */
mfxHDL device; /*!< Object of type VkDevice (Vulkan device). */
mfxHDL image2D; /*!< Object of type VkImage (Vulkan 2D images). */
mfxHDL image2DMemory; /*!< Object of type VkDeviceMemory (Vulkan device memory). */
mfxHDL reserved[10];
} mfxSurfaceVulkanImg2D;
MFX_PACK_END()
/*! The mfxSurfaceComponent enumerator specifies the internal surface pool to use when importing surfaces. */
typedef enum {
MFX_SURFACE_COMPONENT_UNKNOWN = 0, /*!< Unknown surface component. */
MFX_SURFACE_COMPONENT_ENCODE = 1, /*!< Shared surface for encoding. */
MFX_SURFACE_COMPONENT_DECODE = 2, /*!< Shared surface for decoding. */
MFX_SURFACE_COMPONENT_VPP_INPUT = 3, /*!< Shared surface for VPP input. */
MFX_SURFACE_COMPONENT_VPP_OUTPUT = 4, /*!< Shared surface for VPP output. */
} mfxSurfaceComponent;
/*! The current version of mfxSurfaceTypesSupported structure. */
#define MFX_SURFACETYPESSUPPORTED_VERSION MFX_STRUCT_VERSION(1, 0)
MFX_PACK_BEGIN_STRUCT_W_PTR()
/*! This structure describes the supported surface types and modes. */
typedef struct {
mfxStructVersion Version; /*!< Version of the structure. */
mfxU16 NumSurfaceTypes; /*!< Number of supported surface types. */
struct surftype {
mfxSurfaceType SurfaceType; /*!< Supported surface type. */
mfxU32 reserved[6]; /*!< Reserved for future use. */
mfxU16 NumSurfaceComponents; /*!< Number of supported surface components. */
struct surfcomp {
mfxSurfaceComponent SurfaceComponent; /*!< Supported surface component. */
mfxU32 SurfaceFlags; /*!< Supported surface flags for this component (may be OR'd). */
mfxU32 reserved[7]; /*!< Reserved for future use. */
} *SurfaceComponents;
} *SurfaceTypes;
mfxU32 reserved[4]; /*!< Reserved for future use. */
} mfxSurfaceTypesSupported;
MFX_PACK_END()
#define MFX_MEMORYINTERFACE_VERSION MFX_STRUCT_VERSION(1, 0)
MFX_PACK_BEGIN_STRUCT_W_PTR()
/* Specifies memory interface. */
typedef struct mfxMemoryInterface {
mfxHDL Context; /*!< The context of the memory interface. User should not touch (change, set, null) this pointer. */
mfxStructVersion Version; /*!< The version of the structure. */
/*!
@brief
Imports an application-provided surface into mfxFrameSurface1 which may be used as input for encoding or video processing.
@param[in] memory_interface Valid memory interface.
@param[in] surf_component Surface component type. Required for allocating new surfaces from the appropriate pool.
@param[in,out] external_surface Pointer to the mfxSurfaceXXX object describing the surface to be imported. All fields in
mfxSurfaceHeader must be set by the application. mfxSurfaceHeader::SurfaceType is
read by oneVPL runtime to determine which particular mfxSurfaceXXX structure is supplied.
For example, if mfxSurfaceXXX::SurfaceType == MFX_SURFACE_TYPE_D3D11_TEX2D, then the handle
will be interpreted as an object of type mfxSurfaceD3D11Tex2D. The application should
set or clear other fields as specified in the corresponding structure description.
After successful import, the value of mfxSurfaceHeader::SurfaceFlags will be replaced with the actual
import type. It can be used to determine which import type (with or without copy) took place in the case
of initial default setting, or if multiple import flags were OR'ed.
All external sync operations on the ext_surface must be completed before calling this function.
@param[out] imported_surface Pointer to a valid mfxFrameSurface1 object containing the imported frame.
imported_surface may be passed as an input to Encode or VPP processing operations.
@return
MFX_ERR_NONE The function completed successfully.\n
MFX_ERR_NULL_PTR If ext_surface or imported_surface are NULL.\n
MFX_ERR_INVALID_HANDLE If the corresponding session was not initialized.\n
MFX_ERR_UNSUPPORTED If surf_component is not one of [MFX_SURFACE_COMPONENT_ENCODE, MFX_SURFACE_COMPONENT_VPP_INPUT], or if
mfxSurfaceHeader::SurfaceType is not supported by oneVPL runtime for this operation.\n
@since This function is available since API version 2.10.
*/
/* For reference with Export flow please search for mfxFrameSurfaceInterface::Export. */
mfxStatus (MFX_CDECL *ImportFrameSurface)(struct mfxMemoryInterface* memory_interface, mfxSurfaceComponent surf_component, mfxSurfaceHeader* external_surface, mfxFrameSurface1** imported_surface);
mfxHDL reserved[16];
} mfxMemoryInterface;
MFX_PACK_END()
/*! Alias for returning interface of type mfxMemoryInterface. */
#define MFXGetMemoryInterface(session, piface) MFXVideoCORE_GetHandle((session), MFX_HANDLE_MEMORY_INTERFACE, (mfxHDL *)(piface))
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif
|