1 /*############################################################################ 2 # Copyright Intel Corporation 3 # 4 # SPDX-License-Identifier: MIT 5 ############################################################################*/ 6 7 #ifndef __MFXDEFS_H__ 8 #define __MFXDEFS_H__ 9 10 #define MFX_VERSION_MAJOR 2 11 #define MFX_VERSION_MINOR 6 12 13 // MFX_VERSION - version of API that 'assumed' by build may be provided externally 14 // if it omitted then latest stable API derived from Major.Minor is assumed 15 16 17 #if !defined(MFX_VERSION) 18 #define MFX_VERSION (MFX_VERSION_MAJOR * 1000 + MFX_VERSION_MINOR) 19 #else 20 #undef MFX_VERSION_MAJOR 21 #define MFX_VERSION_MAJOR ((MFX_VERSION) / 1000) 22 23 #undef MFX_VERSION_MINOR 24 #define MFX_VERSION_MINOR ((MFX_VERSION) % 1000) 25 #endif 26 27 /*! The corresponding version of the Intel(r) Media SDK legacy API that is used as a basis 28 for the current API. */ 29 30 #define MFX_LEGACY_VERSION 1035 31 32 33 #ifdef __cplusplus 34 extern "C" 35 { 36 #endif /* __cplusplus */ 37 38 /* In preprocessor syntax # symbol has stringize meaning, 39 so to expand some macro to preprocessor pragma we need to use 40 special compiler dependent construction */ 41 42 #if defined(_MSC_VER) 43 #define MFX_PRAGMA_IMPL(x) __pragma(x) 44 #else 45 #define MFX_PRAGMA_IMPL(x) _Pragma(#x) 46 #endif 47 48 #define MFX_PACK_BEGIN_X(x) MFX_PRAGMA_IMPL(pack(push, x)) 49 #define MFX_PACK_END() MFX_PRAGMA_IMPL(pack(pop)) 50 51 /* The general rule for alignment is following: 52 - structures with pointers have 4/8 bytes alignment on 32/64 bit systems 53 - structures with fields of type mfxU64/mfxF64 (unsigned long long / double) 54 have alignment 8 bytes on 64 bit and 32 bit Windows, on Linux alignment is 4 bytes 55 - all the rest structures are 4 bytes aligned 56 - there are several exceptions: some structs which had 4-byte alignment were extended 57 with pointer / long type fields; such structs have 4-byte alignment to keep binary 58 compatibility with previously release API */ 59 60 #define MFX_PACK_BEGIN_USUAL_STRUCT() MFX_PACK_BEGIN_X(4) 61 62 /* 64-bit LP64 data model */ 63 #if defined(_WIN64) || defined(__LP64__) 64 #define MFX_PACK_BEGIN_STRUCT_W_PTR() MFX_PACK_BEGIN_X(8) 65 #define MFX_PACK_BEGIN_STRUCT_W_L_TYPE() MFX_PACK_BEGIN_X(8) 66 /* 32-bit ILP32 data model Windows* (Intel(r) architecture) */ 67 #elif defined(_WIN32) || defined(_M_IX86) && !defined(__unix__) 68 #define MFX_PACK_BEGIN_STRUCT_W_PTR() MFX_PACK_BEGIN_X(4) 69 #define MFX_PACK_BEGIN_STRUCT_W_L_TYPE() MFX_PACK_BEGIN_X(8) 70 /* 32-bit ILP32 data model Linux* */ 71 #elif defined(__ILP32__) 72 #define MFX_PACK_BEGIN_STRUCT_W_PTR() MFX_PACK_BEGIN_X(4) 73 #define MFX_PACK_BEGIN_STRUCT_W_L_TYPE() MFX_PACK_BEGIN_X(4) 74 #else 75 #error Unknown packing 76 #endif 77 78 #ifdef _WIN32 79 #define MFX_CDECL __cdecl 80 #define MFX_STDCALL __stdcall 81 #else 82 #define MFX_CDECL 83 #define MFX_STDCALL 84 #endif /* _WIN32 */ 85 86 #define MFX_INFINITE 0xFFFFFFFF 87 88 #ifndef MFX_DEPRECATED_OFF 89 #if defined(__cplusplus) && __cplusplus >= 201402L 90 #define MFX_DEPRECATED [[deprecated]] 91 #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg [[deprecated]] 92 #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) 93 #elif defined(__clang__) 94 #define MFX_DEPRECATED __attribute__((deprecated)) 95 #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg __attribute__((deprecated)) 96 #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) 97 #elif defined(__INTEL_COMPILER) 98 #if (defined(_WIN32) || defined(_WIN64)) 99 #define MFX_DEPRECATED __declspec(deprecated) 100 #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg 101 #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) __pragma(deprecated(arg)) 102 #elif defined(__unix__) 103 #define MFX_DEPRECATED __attribute__((deprecated)) 104 #if defined(__cplusplus) 105 #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg __attribute__((deprecated)) 106 #else 107 #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg 108 #endif 109 #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) 110 #endif 111 #elif defined(_MSC_VER) && _MSC_VER > 1200 // VS 6 doesn't support deprecation 112 #define MFX_DEPRECATED __declspec(deprecated) 113 #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg 114 #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) __pragma(deprecated(arg)) 115 #elif defined(__GNUC__) 116 #define MFX_DEPRECATED __attribute__((deprecated)) 117 #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg __attribute__((deprecated)) 118 #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) 119 #else 120 #define MFX_DEPRECATED 121 #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg 122 #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) 123 #endif 124 #else 125 #define MFX_DEPRECATED 126 #define MFX_DEPRECATED_ENUM_FIELD_INSIDE(arg) arg 127 #define MFX_DEPRECATED_ENUM_FIELD_OUTSIDE(arg) 128 #endif 129 130 typedef unsigned char mfxU8; /*!< Unsigned integer, 8 bit type. */ 131 typedef char mfxI8; /*!< Signed integer, 8 bit type. */ 132 typedef short mfxI16; /*!< Signed integer, 16 bit type. */ 133 typedef unsigned short mfxU16; /*!< Unsigned integer, 16 bit type. */ 134 typedef unsigned int mfxU32; /*!< Unsigned integer, 32 bit type. */ 135 typedef int mfxI32; /*!< Signed integer, 32 bit type. */ 136 #if defined( _WIN32 ) || defined ( _WIN64 ) 137 typedef unsigned long mfxUL32; /*!< Unsigned integer, 32 bit type. */ 138 typedef long mfxL32; /*!< Signed integer, 32 bit type. */ 139 #else 140 typedef unsigned int mfxUL32; /*!< Unsigned integer, 32 bit type. */ 141 typedef int mfxL32; /*!< Signed integer, 32 bit type. */ 142 #endif 143 typedef float mfxF32; /*!< Single-precision floating point, 32 bit type. */ 144 typedef double mfxF64; /*!< Double-precision floating point, 64 bit type. */ 145 typedef unsigned long long mfxU64; /*!< Unsigned integer, 64 bit type. */ 146 typedef long long mfxI64; /*!< Signed integer, 64 bit type. */ 147 typedef void* mfxHDL; /*!< Handle type. */ 148 typedef mfxHDL mfxMemId; /*!< Memory ID type. */ 149 typedef void* mfxThreadTask; /*!< Thread task type. */ 150 typedef char mfxChar; /*!< UTF-8 byte. */ 151 152 /* MFX structures version info */ 153 MFX_PACK_BEGIN_USUAL_STRUCT() 154 /*! Introduce the field Version for any structure. 155 Assumed that any structure changes are backward binary compatible. 156 mfxStructVersion starts from {1,0} for any new API structures. If mfxStructVersion is 157 added to the existent legacy structure (replacing reserved fields) it starts from {1, 1}. 158 */ 159 typedef union { 160 /*! Structure with Major and Minor fields. */ 161 /*! @struct Anonymous */ 162 struct { 163 /*! @{ 164 @name Major and Minor fields 165 Anonymous structure with Major and Minor fields. Minor number is incremented when reserved fields are used. Major number is incremented when the size of structure is increased. */ 166 mfxU8 Minor; /*!< Minor number of the correspondent structure. */ 167 mfxU8 Major; /*!< Major number of the correspondent structure. */ 168 /*! @} */ 169 }; 170 mfxU16 Version; /*!< Structure version number. */ 171 } mfxStructVersion; 172 MFX_PACK_END() 173 174 #define MFX_STRUCT_VERSION(MAJOR, MINOR) (256*(MAJOR) + (MINOR)) 175 176 177 #define MFX_VARIANT_VERSION MFX_STRUCT_VERSION(1, 0) 178 179 /*! The mfxDataType enumerates data type for mfxDataType. */ 180 typedef enum { 181 MFX_DATA_TYPE_UNSET = 0, /*!< Undefined type. */ 182 MFX_DATA_TYPE_U8, /*!< 8-bit unsigned integer. */ 183 MFX_DATA_TYPE_I8, /*!< 8-bit signed integer. */ 184 MFX_DATA_TYPE_U16, /*!< 16-bit unsigned integer. */ 185 MFX_DATA_TYPE_I16, /*!< 16-bit signed integer. */ 186 MFX_DATA_TYPE_U32, /*!< 32-bit unsigned integer. */ 187 MFX_DATA_TYPE_I32, /*!< 32-bit signed integer. */ 188 MFX_DATA_TYPE_U64, /*!< 64-bit unsigned integer. */ 189 MFX_DATA_TYPE_I64, /*!< 64-bit signed integer. */ 190 MFX_DATA_TYPE_F32, /*!< 32-bit single precision floating point. */ 191 MFX_DATA_TYPE_F64, /*!< 64-bit double precision floating point. */ 192 }mfxDataType; 193 194 /*! The mfxVariantType enumerator data types for mfxVariantType. */ 195 typedef enum { 196 MFX_VARIANT_TYPE_UNSET = MFX_DATA_TYPE_UNSET, /*!< Undefined type. */ 197 MFX_VARIANT_TYPE_U8 = MFX_DATA_TYPE_U8, /*!< 8-bit unsigned integer. */ 198 MFX_VARIANT_TYPE_I8 = MFX_DATA_TYPE_I8, /*!< 8-bit signed integer. */ 199 MFX_VARIANT_TYPE_U16 = MFX_DATA_TYPE_U16, /*!< 16-bit unsigned integer. */ 200 MFX_VARIANT_TYPE_I16 = MFX_DATA_TYPE_I16, /*!< 16-bit signed integer. */ 201 MFX_VARIANT_TYPE_U32 = MFX_DATA_TYPE_U32, /*!< 32-bit unsigned integer. */ 202 MFX_VARIANT_TYPE_I32 = MFX_DATA_TYPE_I32, /*!< 32-bit signed integer. */ 203 MFX_VARIANT_TYPE_U64 = MFX_DATA_TYPE_U64, /*!< 64-bit unsigned integer. */ 204 MFX_VARIANT_TYPE_I64 = MFX_DATA_TYPE_I64, /*!< 64-bit signed integer. */ 205 MFX_VARIANT_TYPE_F32 = MFX_DATA_TYPE_F32, /*!< 32-bit single precision floating point. */ 206 MFX_VARIANT_TYPE_F64 = MFX_DATA_TYPE_F64, /*!< 64-bit double precision floating point. */ 207 MFX_VARIANT_TYPE_PTR, /*!< Generic type pointer. */ 208 } mfxVariantType; 209 210 MFX_PACK_BEGIN_STRUCT_W_PTR() 211 /*! The mfxVariantType enumerator data types for mfxVariant type. */ 212 typedef struct { 213 mfxStructVersion Version; /*!< Version of the structure. */ 214 mfxVariantType Type; /*!< Value type. */ 215 /*! Value data holder. */ 216 union data { 217 mfxU8 U8; /*!< mfxU8 data. */ 218 mfxI8 I8; /*!< mfxI8 data. */ 219 mfxU16 U16; /*!< mfxU16 data. */ 220 mfxI16 I16; /*!< mfxI16 data. */ 221 mfxU32 U32; /*!< mfxU32 data. */ 222 mfxI32 I32; /*!< mfxI32 data. */ 223 mfxU64 U64; /*!< mfxU64 data. */ 224 mfxI64 I64; /*!< mfxI64 data. */ 225 mfxF32 F32; /*!< mfxF32 data. */ 226 mfxF64 F64; /*!< mfxF64 data. */ 227 mfxHDL Ptr; /*!< Pointer. When this points to a string the string must be null terminated. */ 228 } Data; /*!< Value data member. */ 229 } mfxVariant; 230 MFX_PACK_END() 231 232 MFX_PACK_BEGIN_USUAL_STRUCT() 233 /*! Represents a range of unsigned values. */ 234 typedef struct { 235 mfxU32 Min; /*!< Minimal value of the range. */ 236 mfxU32 Max; /*!< Maximal value of the range. */ 237 mfxU32 Step; /*!< Value increment. */ 238 } mfxRange32U; 239 MFX_PACK_END() 240 241 242 /*! Represents a pair of numbers of type mfxI16. */ 243 typedef struct { 244 mfxI16 x; /*!< First number. */ 245 mfxI16 y; /*!< Second number. */ 246 } mfxI16Pair; 247 248 /*! Represents pair of handles of type mfxHDL. */ 249 typedef struct { 250 mfxHDL first; /*!< First handle. */ 251 mfxHDL second; /*!< Second handle. */ 252 } mfxHDLPair; 253 254 255 /*********************************************************************************\ 256 Error message 257 \*********************************************************************************/ 258 /*! @enum mfxStatus Itemizes status codes returned by API functions. */ 259 typedef enum 260 { 261 /* no error */ 262 MFX_ERR_NONE = 0, /*!< No error. */ 263 /* reserved for unexpected errors */ 264 MFX_ERR_UNKNOWN = -1, /*!< Unknown error. */ 265 266 /* error codes <0 */ 267 MFX_ERR_NULL_PTR = -2, /*!< Null pointer. */ 268 MFX_ERR_UNSUPPORTED = -3, /*!< Unsupported feature. */ 269 MFX_ERR_MEMORY_ALLOC = -4, /*!< Failed to allocate memory. */ 270 MFX_ERR_NOT_ENOUGH_BUFFER = -5, /*!< Insufficient buffer at input/output. */ 271 MFX_ERR_INVALID_HANDLE = -6, /*!< Invalid handle. */ 272 MFX_ERR_LOCK_MEMORY = -7, /*!< Failed to lock the memory block. */ 273 MFX_ERR_NOT_INITIALIZED = -8, /*!< Member function called before initialization. */ 274 MFX_ERR_NOT_FOUND = -9, /*!< The specified object is not found. */ 275 MFX_ERR_MORE_DATA = -10, /*!< Expect more data at input. */ 276 MFX_ERR_MORE_SURFACE = -11, /*!< Expect more surface at output. */ 277 MFX_ERR_ABORTED = -12, /*!< Operation aborted. */ 278 MFX_ERR_DEVICE_LOST = -13, /*!< Lose the hardware acceleration device. */ 279 MFX_ERR_INCOMPATIBLE_VIDEO_PARAM = -14, /*!< Incompatible video parameters. */ 280 MFX_ERR_INVALID_VIDEO_PARAM = -15, /*!< Invalid video parameters. */ 281 MFX_ERR_UNDEFINED_BEHAVIOR = -16, /*!< Undefined behavior. */ 282 MFX_ERR_DEVICE_FAILED = -17, /*!< Device operation failure. */ 283 MFX_ERR_MORE_BITSTREAM = -18, /*!< Expect more bitstream buffers at output. */ 284 MFX_ERR_GPU_HANG = -21, /*!< Device operation failure caused by GPU hang. */ 285 MFX_ERR_REALLOC_SURFACE = -22, /*!< Bigger output surface required. */ 286 MFX_ERR_RESOURCE_MAPPED = -23, /*!< Write access is already acquired and user requested 287 another write access, or read access with MFX_MEMORY_NO_WAIT flag. */ 288 MFX_ERR_NOT_IMPLEMENTED = -24, /*!< Feature or function not implemented. */ 289 /* warnings >0 */ 290 MFX_WRN_IN_EXECUTION = 1, /*!< The previous asynchronous operation is in execution. */ 291 MFX_WRN_DEVICE_BUSY = 2, /*!< The hardware acceleration device is busy. */ 292 MFX_WRN_VIDEO_PARAM_CHANGED = 3, /*!< The video parameters are changed during decoding. */ 293 MFX_WRN_PARTIAL_ACCELERATION = 4, /*!< Software acceleration is used. */ 294 MFX_WRN_INCOMPATIBLE_VIDEO_PARAM = 5, /*!< Incompatible video parameters. */ 295 MFX_WRN_VALUE_NOT_CHANGED = 6, /*!< The value is saturated based on its valid range. */ 296 MFX_WRN_OUT_OF_RANGE = 7, /*!< The value is out of valid range. */ 297 MFX_WRN_FILTER_SKIPPED = 10, /*!< One of requested filters has been skipped. */ 298 /* low-delay partial output */ 299 MFX_ERR_NONE_PARTIAL_OUTPUT = 12, /*!< Frame is not ready, but bitstream contains partial output. */ 300 301 MFX_WRN_ALLOC_TIMEOUT_EXPIRED = 13, /*!< Timeout expired for internal frame allocation. */ 302 303 /* threading statuses */ 304 MFX_TASK_DONE = MFX_ERR_NONE, /*!< Task has been completed. */ 305 MFX_TASK_WORKING = 8, /*!< There is some more work to do. */ 306 MFX_TASK_BUSY = 9, /*!< Task is waiting for resources. */ 307 308 /* plug-in statuses */ 309 MFX_ERR_MORE_DATA_SUBMIT_TASK = -10000, /*!< Return MFX_ERR_MORE_DATA but submit internal asynchronous task. */ 310 311 } mfxStatus; 312 313 314 MFX_PACK_BEGIN_USUAL_STRUCT() 315 /*! Represents Globally Unique Identifier (GUID) with memory layout 316 compliant to RFC 4122. See https://www.rfc-editor.org/info/rfc4122 for details. */ 317 typedef struct 318 { 319 mfxU8 Data[16]; /*!< Array to keep GUID. */ 320 } mfxGUID; 321 MFX_PACK_END() 322 323 324 325 // Application 326 #if defined(MFX_DISPATCHER_EXPOSED_PREFIX) 327 328 #include "mfxdispatcherprefixedfunctions.h" 329 330 #endif // MFX_DISPATCHER_EXPOSED_PREFIX 331 332 333 #ifdef __cplusplus 334 } 335 #endif /* __cplusplus */ 336 337 #endif /* __MFXDEFS_H__ */ 338