| 1 |
/*############################################################################ |
| 2 |
# Copyright (C) Intel Corporation |
| 3 |
# |
| 4 |
# SPDX-License-Identifier: MIT |
| 5 |
############################################################################*/ |
| 6 |
|
| 7 |
#include "vpl/mfx_dispatcher_vpl.h" |
| 8 |
|
| 9 |
#include <assert.h> |
| 10 |
|
| 11 |
#include <regex> |
| 12 |
|
| 13 |
// implementation of config context (mfxConfig) |
| 14 |
// each loader instance can have one or more configs |
| 15 |
// associated with it - used for filtering implementations |
| 16 |
// based on what they support (codec types, etc.) |
| 17 |
ConfigCtxVPL::ConfigCtxVPL() |
| 18 |
: m_propVar(), |
| 19 |
m_propRange32U(), |
| 20 |
m_implName(), |
| 21 |
m_implLicense(), |
| 22 |
m_implKeywords(), |
| 23 |
m_deviceIdStr(), |
| 24 |
m_implFunctionName(), |
| 25 |
m_extDevLUID8U(), |
| 26 |
m_extDevNameStr(), |
| 27 |
m_extBuf() { |
| 28 |
// initially set Type = unset (invalid) |
| 29 |
// if valid property string and value are passed in, |
| 30 |
// this will be updated |
| 31 |
// otherwise loader will ignore this cfg during EnumImplementations |
| 32 |
for (mfxU32 idx = 0; idx < NUM_TOTAL_FILTER_PROPS; idx++) { |
| 33 |
m_propVar[idx].Version.Version = MFX_VARIANT_VERSION; |
| 34 |
m_propVar[idx].Type = MFX_VARIANT_TYPE_UNSET; |
| 35 |
m_propVar[idx].Data.U64 = 0; |
| 36 |
} |
| 37 |
|
| 38 |
m_parentLoader = nullptr; |
| 39 |
return; |
| 40 |
} |
| 41 |
|
| 42 |
ConfigCtxVPL::~ConfigCtxVPL() { |
| 43 |
return; |
| 44 |
} |
| 45 |
|
| 46 |
struct PropVariant { |
| 47 |
const char *Name; |
| 48 |
mfxVariantType Type; |
| 49 |
}; |
| 50 |
|
| 51 |
enum PropIdx { |
| 52 |
// settable config properties for mfxImplDescription |
| 53 |
ePropMain_Impl = 0, |
| 54 |
ePropMain_AccelerationMode, |
| 55 |
ePropMain_ApiVersion, |
| 56 |
ePropMain_ApiVersion_Major, |
| 57 |
ePropMain_ApiVersion_Minor, |
| 58 |
ePropMain_ImplName, |
| 59 |
ePropMain_License, |
| 60 |
ePropMain_Keywords, |
| 61 |
ePropMain_VendorID, |
| 62 |
ePropMain_VendorImplID, |
| 63 |
ePropMain_PoolAllocationPolicy, |
| 64 |
|
| 65 |
// settable config properties for mfxDeviceDescription |
| 66 |
ePropDevice_DeviceID, |
| 67 |
ePropDevice_DeviceIDStr, |
| 68 |
ePropDevice_MediaAdapterType, |
| 69 |
|
| 70 |
// settable config properties for mfxDecoderDescription |
| 71 |
ePropDec_CodecID, |
| 72 |
ePropDec_MaxcodecLevel, |
| 73 |
ePropDec_Profile, |
| 74 |
ePropDec_MemHandleType, |
| 75 |
ePropDec_Width, |
| 76 |
ePropDec_Height, |
| 77 |
ePropDec_ColorFormats, |
| 78 |
|
| 79 |
// settable config properties for mfxEncoderDescription |
| 80 |
ePropEnc_CodecID, |
| 81 |
ePropEnc_MaxcodecLevel, |
| 82 |
ePropEnc_BiDirectionalPrediction, |
| 83 |
ePropEnc_ReportedStats, |
| 84 |
ePropEnc_Profile, |
| 85 |
ePropEnc_MemHandleType, |
| 86 |
ePropEnc_Width, |
| 87 |
ePropEnc_Height, |
| 88 |
ePropEnc_ColorFormats, |
| 89 |
|
| 90 |
// settable config properties for mfxVPPDescription |
| 91 |
ePropVPP_FilterFourCC, |
| 92 |
ePropVPP_MaxDelayInFrames, |
| 93 |
ePropVPP_MemHandleType, |
| 94 |
ePropVPP_Width, |
| 95 |
ePropVPP_Height, |
| 96 |
ePropVPP_InFormat, |
| 97 |
ePropVPP_OutFormat, |
| 98 |
|
| 99 |
// settable config properties for mfxExtendedDeviceId |
| 100 |
ePropExtDev_VendorID, |
| 101 |
ePropExtDev_DeviceID, |
| 102 |
ePropExtDev_PCIDomain, |
| 103 |
ePropExtDev_PCIBus, |
| 104 |
ePropExtDev_PCIDevice, |
| 105 |
ePropExtDev_PCIFunction, |
| 106 |
ePropExtDev_DeviceLUID, |
| 107 |
ePropExtDev_LUIDDeviceNodeMask, |
| 108 |
ePropExtDev_DRMRenderNodeNum, |
| 109 |
ePropExtDev_DRMPrimaryNodeNum, |
| 110 |
ePropExtDev_RevisionID, |
| 111 |
ePropExtDev_DeviceName, |
| 112 |
|
| 113 |
// special properties not part of description struct |
| 114 |
ePropSpecial_HandleType, |
| 115 |
ePropSpecial_Handle, |
| 116 |
ePropSpecial_NumThread, |
| 117 |
ePropSpecial_DeviceCopy, |
| 118 |
ePropSpecial_ExtBuffer, |
| 119 |
ePropSpecial_DXGIAdapterIndex, |
| 120 |
|
| 121 |
// functions which must report as implemented |
| 122 |
ePropFunc_FunctionName, |
| 123 |
|
| 124 |
// number of entries (always last) |
| 125 |
eProp_TotalProps |
| 126 |
}; |
| 127 |
|
| 128 |
// leave table formatting alone |
| 129 |
// clang-format off |
| 130 |
|
| 131 |
// order must align exactly with PropIdx list |
| 132 |
// to avoid mismatches, this should be automated (e.g. pre-processor step) |
| 133 |
static const PropVariant PropIdxTab[] = { |
| 134 |
{ "ePropMain_Impl", MFX_VARIANT_TYPE_U32 }, |
| 135 |
{ "ePropMain_AccelerationMode", MFX_VARIANT_TYPE_U32 }, |
| 136 |
{ "ePropMain_ApiVersion", MFX_VARIANT_TYPE_U32 }, |
| 137 |
{ "ePropMain_ApiVersion_Major", MFX_VARIANT_TYPE_U16 }, |
| 138 |
{ "ePropMain_ApiVersion_Minor", MFX_VARIANT_TYPE_U16 }, |
| 139 |
{ "ePropMain_ImplName", MFX_VARIANT_TYPE_PTR }, |
| 140 |
{ "ePropMain_License", MFX_VARIANT_TYPE_PTR }, |
| 141 |
{ "ePropMain_Keywords", MFX_VARIANT_TYPE_PTR }, |
| 142 |
{ "ePropMain_VendorID", MFX_VARIANT_TYPE_U32 }, |
| 143 |
{ "ePropMain_VendorImplID", MFX_VARIANT_TYPE_U32 }, |
| 144 |
{ "ePropMain_PoolAllocationPolicy", MFX_VARIANT_TYPE_U32 }, |
| 145 |
|
| 146 |
{ "ePropDevice_DeviceID", MFX_VARIANT_TYPE_U16 }, |
| 147 |
{ "ePropDevice_DeviceIDStr", MFX_VARIANT_TYPE_PTR }, |
| 148 |
{ "ePropDevice_MediaAdapterType", MFX_VARIANT_TYPE_U16 }, |
| 149 |
|
| 150 |
{ "ePropDec_CodecID", MFX_VARIANT_TYPE_U32 }, |
| 151 |
{ "ePropDec_MaxcodecLevel", MFX_VARIANT_TYPE_U16 }, |
| 152 |
{ "ePropDec_Profile", MFX_VARIANT_TYPE_U32 }, |
| 153 |
{ "ePropDec_MemHandleType", MFX_VARIANT_TYPE_U32 }, |
| 154 |
{ "ePropDec_Width", MFX_VARIANT_TYPE_PTR }, |
| 155 |
{ "ePropDec_Height", MFX_VARIANT_TYPE_PTR }, |
| 156 |
{ "ePropDec_ColorFormats", MFX_VARIANT_TYPE_U32 }, |
| 157 |
|
| 158 |
{ "ePropEnc_CodecID", MFX_VARIANT_TYPE_U32 }, |
| 159 |
{ "ePropEnc_MaxcodecLevel", MFX_VARIANT_TYPE_U16 }, |
| 160 |
{ "ePropEnc_BiDirectionalPrediction", MFX_VARIANT_TYPE_U16 }, |
| 161 |
{ "ePropEnc_ReportedStats", MFX_VARIANT_TYPE_U16 }, |
| 162 |
{ "ePropEnc_Profile", MFX_VARIANT_TYPE_U32 }, |
| 163 |
{ "ePropEnc_MemHandleType", MFX_VARIANT_TYPE_U32 }, |
| 164 |
{ "ePropEnc_Width", MFX_VARIANT_TYPE_PTR }, |
| 165 |
{ "ePropEnc_Height", MFX_VARIANT_TYPE_PTR }, |
| 166 |
{ "ePropEnc_ColorFormats", MFX_VARIANT_TYPE_U32 }, |
| 167 |
|
| 168 |
{ "ePropVPP_FilterFourCC", MFX_VARIANT_TYPE_U32 }, |
| 169 |
{ "ePropVPP_MaxDelayInFrames", MFX_VARIANT_TYPE_U16 }, |
| 170 |
{ "ePropVPP_MemHandleType", MFX_VARIANT_TYPE_U32 }, |
| 171 |
{ "ePropVPP_Width", MFX_VARIANT_TYPE_PTR }, |
| 172 |
{ "ePropVPP_Height", MFX_VARIANT_TYPE_PTR }, |
| 173 |
{ "ePropVPP_InFormat", MFX_VARIANT_TYPE_U32 }, |
| 174 |
{ "ePropVPP_OutFormat", MFX_VARIANT_TYPE_U32 }, |
| 175 |
|
| 176 |
{ "ePropExtDev_VendorID", MFX_VARIANT_TYPE_U16 }, |
| 177 |
{ "ePropExtDev_DeviceID", MFX_VARIANT_TYPE_U16 }, |
| 178 |
{ "ePropExtDev_PCIDomain", MFX_VARIANT_TYPE_U32 }, |
| 179 |
{ "ePropExtDev_PCIBus", MFX_VARIANT_TYPE_U32 }, |
| 180 |
{ "ePropExtDev_PCIDevice", MFX_VARIANT_TYPE_U32 }, |
| 181 |
{ "ePropExtDev_PCIFunction", MFX_VARIANT_TYPE_U32 }, |
| 182 |
{ "ePropExtDev_DeviceLUID", MFX_VARIANT_TYPE_PTR }, |
| 183 |
{ "ePropExtDev_LUIDDeviceNodeMask", MFX_VARIANT_TYPE_U32 }, |
| 184 |
{ "ePropExtDev_DRMRenderNodeNum", MFX_VARIANT_TYPE_U32 }, |
| 185 |
{ "ePropExtDev_DRMPrimaryNodeNum", MFX_VARIANT_TYPE_U32 }, |
| 186 |
{ "ePropExtDev_RevisionID", MFX_VARIANT_TYPE_U16 }, |
| 187 |
{ "ePropExtDev_DeviceName", MFX_VARIANT_TYPE_PTR }, |
| 188 |
|
| 189 |
{ "ePropSpecial_HandleType", MFX_VARIANT_TYPE_U32 }, |
| 190 |
{ "ePropSpecial_Handle", MFX_VARIANT_TYPE_PTR }, |
| 191 |
{ "ePropSpecial_NumThread", MFX_VARIANT_TYPE_U32 }, |
| 192 |
{ "ePropSpecial_DeviceCopy", MFX_VARIANT_TYPE_U16 }, |
| 193 |
{ "ePropSpecial_ExtBuffer", MFX_VARIANT_TYPE_PTR }, |
| 194 |
{ "ePropSpecial_DXGIAdapterIndex", MFX_VARIANT_TYPE_U32 }, |
| 195 |
|
| 196 |
{ "ePropFunc_FunctionName", MFX_VARIANT_TYPE_PTR }, |
| 197 |
}; |
| 198 |
|
| 199 |
// end table formatting |
| 200 |
// clang-format on |
| 201 |
|
| 202 |
// sanity check - property table and indexes must have same number of entries |
| 203 |
static_assert((sizeof(PropIdxTab) / sizeof(PropVariant)) == eProp_TotalProps, |
| 204 |
"PropIdx and PropIdxTab are misaligned"); |
| 205 |
|
| 206 |
static_assert(NUM_TOTAL_FILTER_PROPS == eProp_TotalProps, |
| 207 |
"NUM_TOTAL_FILTER_PROPS and eProp_TotalProps are misaligned"); |
| 208 |
|
| 209 |
mfxStatus ConfigCtxVPL::ValidateAndSetProp(mfxI32 idx, mfxVariant value) { |
| 210 |
if (idx < 0 || idx >= eProp_TotalProps) |
| 211 |
return MFX_ERR_NOT_FOUND; |
| 212 |
|
| 213 |
if (value.Type != PropIdxTab[idx].Type) |
| 214 |
return MFX_ERR_UNSUPPORTED; |
| 215 |
|
| 216 |
m_propVar[idx].Version.Version = MFX_VARIANT_VERSION; |
| 217 |
m_propVar[idx].Type = value.Type; |
| 218 |
|
| 219 |
if (value.Type == MFX_VARIANT_TYPE_PTR) { |
| 220 |
if (value.Data.Ptr == nullptr) { |
| 221 |
// unset property to avoid possibly dereferencing null if app ignores error code |
| 222 |
m_propVar[idx].Type = MFX_VARIANT_TYPE_UNSET; |
| 223 |
return MFX_ERR_NULL_PTR; |
| 224 |
} |
| 225 |
|
| 226 |
// local ptr for copying from array |
| 227 |
mfxU8 *pU8 = (mfxU8 *)(value.Data.Ptr); |
| 228 |
|
| 229 |
mfxExtBuffer *extBuf = nullptr; |
| 230 |
|
| 231 |
// save copy of data passed by pointer, into object of the appropriate type |
| 232 |
switch (idx) { |
| 233 |
case ePropDec_Width: |
| 234 |
m_propRange32U[PROP_RANGE_DEC_W] = *((mfxRange32U *)(value.Data.Ptr)); |
| 235 |
m_propVar[idx].Data.Ptr = &(m_propRange32U[PROP_RANGE_DEC_W]); |
| 236 |
break; |
| 237 |
case ePropDec_Height: |
| 238 |
m_propRange32U[PROP_RANGE_DEC_H] = *((mfxRange32U *)(value.Data.Ptr)); |
| 239 |
m_propVar[idx].Data.Ptr = &(m_propRange32U[PROP_RANGE_DEC_H]); |
| 240 |
break; |
| 241 |
case ePropEnc_Width: |
| 242 |
m_propRange32U[PROP_RANGE_ENC_W] = *((mfxRange32U *)(value.Data.Ptr)); |
| 243 |
m_propVar[idx].Data.Ptr = &(m_propRange32U[PROP_RANGE_ENC_W]); |
| 244 |
break; |
| 245 |
case ePropEnc_Height: |
| 246 |
m_propRange32U[PROP_RANGE_ENC_H] = *((mfxRange32U *)(value.Data.Ptr)); |
| 247 |
m_propVar[idx].Data.Ptr = &(m_propRange32U[PROP_RANGE_ENC_H]); |
| 248 |
break; |
| 249 |
case ePropVPP_Width: |
| 250 |
m_propRange32U[PROP_RANGE_VPP_W] = *((mfxRange32U *)(value.Data.Ptr)); |
| 251 |
m_propVar[idx].Data.Ptr = &(m_propRange32U[PROP_RANGE_VPP_W]); |
| 252 |
break; |
| 253 |
case ePropVPP_Height: |
| 254 |
m_propRange32U[PROP_RANGE_VPP_H] = *((mfxRange32U *)(value.Data.Ptr)); |
| 255 |
m_propVar[idx].Data.Ptr = &(m_propRange32U[PROP_RANGE_VPP_H]); |
| 256 |
break; |
| 257 |
case ePropSpecial_Handle: |
| 258 |
m_propVar[idx].Data.Ptr = (mfxHDL)(value.Data.Ptr); |
| 259 |
break; |
| 260 |
case ePropMain_ImplName: |
| 261 |
m_implName = (char *)(value.Data.Ptr); |
| 262 |
m_propVar[idx].Data.Ptr = &(m_implName); |
| 263 |
break; |
| 264 |
case ePropMain_License: |
| 265 |
m_implLicense = (char *)(value.Data.Ptr); |
| 266 |
m_propVar[idx].Data.Ptr = &(m_implLicense); |
| 267 |
break; |
| 268 |
case ePropMain_Keywords: |
| 269 |
m_implKeywords = (char *)(value.Data.Ptr); |
| 270 |
m_propVar[idx].Data.Ptr = &(m_implKeywords); |
| 271 |
break; |
| 272 |
case ePropDevice_DeviceIDStr: |
| 273 |
m_deviceIdStr = (char *)(value.Data.Ptr); |
| 274 |
m_propVar[idx].Data.Ptr = &(m_deviceIdStr); |
| 275 |
break; |
| 276 |
case ePropFunc_FunctionName: |
| 277 |
// no need to save Data.Ptr - parsed in main loop |
| 278 |
m_implFunctionName = (char *)(value.Data.Ptr); |
| 279 |
break; |
| 280 |
case ePropExtDev_DeviceLUID: |
| 281 |
for (mfxU32 j = 0; j < 8; j++) |
| 282 |
m_extDevLUID8U[j] = pU8[j]; |
| 283 |
m_propVar[idx].Data.Ptr = &(m_extDevLUID8U[0]); |
| 284 |
break; |
| 285 |
case ePropExtDev_DeviceName: |
| 286 |
m_extDevNameStr = (char *)(value.Data.Ptr); |
| 287 |
m_propVar[idx].Data.Ptr = &(m_extDevNameStr); |
| 288 |
break; |
| 289 |
case ePropSpecial_ExtBuffer: |
| 290 |
// Don't assume anything about the lifetime of input mfxExtBuffer in Data.Ptr |
| 291 |
// Instead, we copy the full extBuf into a vector owned by ConfixCtxVPL and will pass this to MFXInitialize() |
| 292 |
// if app calls MFXSetConfigFilterProperty('ExtBuffer') again with a different extBuf, the old copy will be overwritten |
| 293 |
SetExtBuf((mfxExtBuffer *)(value.Data.Ptr)); |
| 294 |
|
| 295 |
if (GetExtBuf(&extBuf)) |
| 296 |
m_propVar[idx].Data.Ptr = extBuf; |
| 297 |
break; |
| 298 |
default: |
| 299 |
break; |
| 300 |
} |
| 301 |
} |
| 302 |
else { |
| 303 |
m_propVar[idx].Data = value.Data; |
| 304 |
} |
| 305 |
|
| 306 |
return MFX_ERR_NONE; |
| 307 |
} |
| 308 |
|
| 309 |
mfxStatus ConfigCtxVPL::SetFilterPropertyDec(std::list<std::string> &propParsedString, |
| 310 |
mfxVariant value) { |
| 311 |
std::string nextProp; |
| 312 |
|
| 313 |
nextProp = GetNextProp(propParsedString); |
| 314 |
|
| 315 |
// no settable top-level members |
| 316 |
if (nextProp != "decoder") |
| 317 |
return MFX_ERR_NOT_FOUND; |
| 318 |
|
| 319 |
// parse 'decoder' |
| 320 |
nextProp = GetNextProp(propParsedString); |
| 321 |
if (nextProp == "CodecID") { |
| 322 |
return ValidateAndSetProp(ePropDec_CodecID, value); |
| 323 |
} |
| 324 |
else if (nextProp == "MaxcodecLevel") { |
| 325 |
return ValidateAndSetProp(ePropDec_MaxcodecLevel, value); |
| 326 |
} |
| 327 |
else if (nextProp != "decprofile") { |
| 328 |
return MFX_ERR_NOT_FOUND; |
| 329 |
} |
| 330 |
|
| 331 |
// parse 'decprofile' |
| 332 |
nextProp = GetNextProp(propParsedString); |
| 333 |
if (nextProp == "Profile") { |
| 334 |
return ValidateAndSetProp(ePropDec_Profile, value); |
| 335 |
} |
| 336 |
else if (nextProp != "decmemdesc") { |
| 337 |
return MFX_ERR_NOT_FOUND; |
| 338 |
} |
| 339 |
|
| 340 |
// parse 'decmemdesc' |
| 341 |
nextProp = GetNextProp(propParsedString); |
| 342 |
if (nextProp == "MemHandleType") { |
| 343 |
return ValidateAndSetProp(ePropDec_MemHandleType, value); |
| 344 |
} |
| 345 |
else if (nextProp == "Width") { |
| 346 |
return ValidateAndSetProp(ePropDec_Width, value); |
| 347 |
} |
| 348 |
else if (nextProp == "Height") { |
| 349 |
return ValidateAndSetProp(ePropDec_Height, value); |
| 350 |
} |
| 351 |
else if (nextProp == "ColorFormat" || nextProp == "ColorFormats") { |
| 352 |
return ValidateAndSetProp(ePropDec_ColorFormats, value); |
| 353 |
} |
| 354 |
|
| 355 |
// end of mfxDecoderDescription options |
| 356 |
return MFX_ERR_NOT_FOUND; |
| 357 |
} |
| 358 |
|
| 359 |
mfxStatus ConfigCtxVPL::SetFilterPropertyEnc(std::list<std::string> &propParsedString, |
| 360 |
mfxVariant value) { |
| 361 |
std::string nextProp; |
| 362 |
|
| 363 |
nextProp = GetNextProp(propParsedString); |
| 364 |
|
| 365 |
// no settable top-level members |
| 366 |
if (nextProp != "encoder") |
| 367 |
return MFX_ERR_NOT_FOUND; |
| 368 |
|
| 369 |
// parse 'encoder' |
| 370 |
nextProp = GetNextProp(propParsedString); |
| 371 |
if (nextProp == "CodecID") { |
| 372 |
return ValidateAndSetProp(ePropEnc_CodecID, value); |
| 373 |
} |
| 374 |
else if (nextProp == "MaxcodecLevel") { |
| 375 |
return ValidateAndSetProp(ePropEnc_MaxcodecLevel, value); |
| 376 |
} |
| 377 |
else if (nextProp == "BiDirectionalPrediction") { |
| 378 |
return ValidateAndSetProp(ePropEnc_BiDirectionalPrediction, value); |
| 379 |
} |
| 380 |
#ifdef ONEVPL_EXPERIMENTAL |
| 381 |
else if (nextProp == "ReportedStats") { |
| 382 |
return ValidateAndSetProp(ePropEnc_ReportedStats, value); |
| 383 |
} |
| 384 |
#endif |
| 385 |
else if (nextProp != "encprofile") { |
| 386 |
return MFX_ERR_NOT_FOUND; |
| 387 |
} |
| 388 |
|
| 389 |
// parse 'encprofile' |
| 390 |
nextProp = GetNextProp(propParsedString); |
| 391 |
if (nextProp == "Profile") { |
| 392 |
return ValidateAndSetProp(ePropEnc_Profile, value); |
| 393 |
} |
| 394 |
else if (nextProp != "encmemdesc") { |
| 395 |
return MFX_ERR_NOT_FOUND; |
| 396 |
} |
| 397 |
|
| 398 |
// parse 'encmemdesc' |
| 399 |
nextProp = GetNextProp(propParsedString); |
| 400 |
if (nextProp == "MemHandleType") { |
| 401 |
return ValidateAndSetProp(ePropEnc_MemHandleType, value); |
| 402 |
} |
| 403 |
else if (nextProp == "Width") { |
| 404 |
return ValidateAndSetProp(ePropEnc_Width, value); |
| 405 |
} |
| 406 |
else if (nextProp == "Height") { |
| 407 |
return ValidateAndSetProp(ePropEnc_Height, value); |
| 408 |
} |
| 409 |
else if (nextProp == "ColorFormat" || nextProp == "ColorFormats") { |
| 410 |
return ValidateAndSetProp(ePropEnc_ColorFormats, value); |
| 411 |
} |
| 412 |
|
| 413 |
// end of mfxEncoderDescription options |
| 414 |
return MFX_ERR_NOT_FOUND; |
| 415 |
} |
| 416 |
|
| 417 |
mfxStatus ConfigCtxVPL::SetFilterPropertyVPP(std::list<std::string> &propParsedString, |
| 418 |
mfxVariant value) { |
| 419 |
std::string nextProp; |
| 420 |
|
| 421 |
nextProp = GetNextProp(propParsedString); |
| 422 |
|
| 423 |
// no settable top-level members |
| 424 |
if (nextProp != "filter") |
| 425 |
return MFX_ERR_NOT_FOUND; |
| 426 |
|
| 427 |
// parse 'filter' |
| 428 |
nextProp = GetNextProp(propParsedString); |
| 429 |
if (nextProp == "FilterFourCC") { |
| 430 |
return ValidateAndSetProp(ePropVPP_FilterFourCC, value); |
| 431 |
} |
| 432 |
else if (nextProp == "MaxDelayInFrames") { |
| 433 |
return ValidateAndSetProp(ePropVPP_MaxDelayInFrames, value); |
| 434 |
} |
| 435 |
else if (nextProp != "memdesc") { |
| 436 |
return MFX_ERR_NOT_FOUND; |
| 437 |
} |
| 438 |
|
| 439 |
// parse 'memdesc' |
| 440 |
nextProp = GetNextProp(propParsedString); |
| 441 |
if (nextProp == "MemHandleType") { |
| 442 |
return ValidateAndSetProp(ePropVPP_MemHandleType, value); |
| 443 |
} |
| 444 |
else if (nextProp == "Width") { |
| 445 |
return ValidateAndSetProp(ePropVPP_Width, value); |
| 446 |
} |
| 447 |
else if (nextProp == "Height") { |
| 448 |
return ValidateAndSetProp(ePropVPP_Height, value); |
| 449 |
} |
| 450 |
else if (nextProp != "format") { |
| 451 |
return MFX_ERR_NOT_FOUND; |
| 452 |
} |
| 453 |
|
| 454 |
// parse 'format' |
| 455 |
nextProp = GetNextProp(propParsedString); |
| 456 |
if (nextProp == "InFormat") { |
| 457 |
return ValidateAndSetProp(ePropVPP_InFormat, value); |
| 458 |
} |
| 459 |
else if (nextProp == "OutFormat" || nextProp == "OutFormats") { |
| 460 |
return ValidateAndSetProp(ePropVPP_OutFormat, value); |
| 461 |
} |
| 462 |
|
| 463 |
// end of mfxVPPDescription options |
| 464 |
return MFX_ERR_NOT_FOUND; |
| 465 |
} |
| 466 |
|
| 467 |
// return codes (from spec): |
| 468 |
// MFX_ERR_NOT_FOUND - name contains unknown parameter name |
| 469 |
// MFX_ERR_UNSUPPORTED - value data type != parameter with provided name |
| 470 |
mfxStatus ConfigCtxVPL::SetFilterProperty(const mfxU8 *name, mfxVariant value) { |
| 471 |
if (!name) |
| 472 |
return MFX_ERR_NULL_PTR; |
| 473 |
|
| 474 |
std::list<std::string> propParsedString; |
| 475 |
|
| 476 |
// parse property string into individual properties, |
| 477 |
// separated by '.' |
| 478 |
std::stringstream prop((char *)name); |
| 479 |
std::string s; |
| 480 |
propParsedString.clear(); |
| 481 |
while (getline(prop, s, '.')) { |
| 482 |
propParsedString.push_back(s); |
| 483 |
} |
| 484 |
|
| 485 |
// get first property descriptor |
| 486 |
std::string nextProp = GetNextProp(propParsedString); |
| 487 |
|
| 488 |
// check for special-case properties, not part of mfxImplDescription |
| 489 |
if (nextProp == "mfxHandleType") { |
| 490 |
return ValidateAndSetProp(ePropSpecial_HandleType, value); |
| 491 |
} |
| 492 |
else if (nextProp == "mfxHDL") { |
| 493 |
return ValidateAndSetProp(ePropSpecial_Handle, value); |
| 494 |
} |
| 495 |
else if (nextProp == "NumThread") { |
| 496 |
return ValidateAndSetProp(ePropSpecial_NumThread, value); |
| 497 |
} |
| 498 |
#ifdef ONEVPL_EXPERIMENTAL |
| 499 |
else if (nextProp == "DeviceCopy") { |
| 500 |
return ValidateAndSetProp(ePropSpecial_DeviceCopy, value); |
| 501 |
} |
| 502 |
#endif |
| 503 |
else if (nextProp == "ExtBuffer") { |
| 504 |
return ValidateAndSetProp(ePropSpecial_ExtBuffer, value); |
| 505 |
} |
| 506 |
else if (nextProp == "DXGIAdapterIndex") { |
| 507 |
#if defined(_WIN32) || defined(_WIN64) |
| 508 |
// this property is only valid on Windows |
| 509 |
return ValidateAndSetProp(ePropSpecial_DXGIAdapterIndex, value); |
| 510 |
#else |
| 511 |
return MFX_ERR_NOT_FOUND; |
| 512 |
#endif |
| 513 |
} |
| 514 |
|
| 515 |
// to require that a specific function is implemented, use the property name |
| 516 |
// "mfxImplementedFunctions.FunctionsName" |
| 517 |
if (nextProp == "mfxImplementedFunctions") { |
| 518 |
nextProp = GetNextProp(propParsedString); |
| 519 |
if (nextProp == "FunctionsName") { |
| 520 |
return ValidateAndSetProp(ePropFunc_FunctionName, value); |
| 521 |
} |
| 522 |
return MFX_ERR_NOT_FOUND; |
| 523 |
} |
| 524 |
|
| 525 |
#ifdef ONEVPL_EXPERIMENTAL |
| 526 |
// extended device ID properties must begin with mfxExtendedDeviceId |
| 527 |
if (nextProp == "mfxExtendedDeviceId") { |
| 528 |
nextProp = GetNextProp(propParsedString); |
| 529 |
if (nextProp == "VendorID") { |
| 530 |
return ValidateAndSetProp(ePropExtDev_VendorID, value); |
| 531 |
} |
| 532 |
else if (nextProp == "DeviceID") { |
| 533 |
return ValidateAndSetProp(ePropExtDev_DeviceID, value); |
| 534 |
} |
| 535 |
else if (nextProp == "PCIDomain") { |
| 536 |
return ValidateAndSetProp(ePropExtDev_PCIDomain, value); |
| 537 |
} |
| 538 |
else if (nextProp == "PCIBus") { |
| 539 |
return ValidateAndSetProp(ePropExtDev_PCIBus, value); |
| 540 |
} |
| 541 |
else if (nextProp == "PCIDevice") { |
| 542 |
return ValidateAndSetProp(ePropExtDev_PCIDevice, value); |
| 543 |
} |
| 544 |
else if (nextProp == "PCIFunction") { |
| 545 |
return ValidateAndSetProp(ePropExtDev_PCIFunction, value); |
| 546 |
} |
| 547 |
else if (nextProp == "DeviceLUID") { |
| 548 |
return ValidateAndSetProp(ePropExtDev_DeviceLUID, value); |
| 549 |
} |
| 550 |
else if (nextProp == "LUIDDeviceNodeMask") { |
| 551 |
return ValidateAndSetProp(ePropExtDev_LUIDDeviceNodeMask, value); |
| 552 |
} |
| 553 |
else if (nextProp == "DRMRenderNodeNum") { |
| 554 |
return ValidateAndSetProp(ePropExtDev_DRMRenderNodeNum, value); |
| 555 |
} |
| 556 |
else if (nextProp == "DRMPrimaryNodeNum") { |
| 557 |
return ValidateAndSetProp(ePropExtDev_DRMPrimaryNodeNum, value); |
| 558 |
} |
| 559 |
else if (nextProp == "RevisionID") { |
| 560 |
return ValidateAndSetProp(ePropExtDev_RevisionID, value); |
| 561 |
} |
| 562 |
else if (nextProp == "DeviceName") { |
| 563 |
return ValidateAndSetProp(ePropExtDev_DeviceName, value); |
| 564 |
} |
| 565 |
return MFX_ERR_NOT_FOUND; |
| 566 |
} |
| 567 |
#endif |
| 568 |
|
| 569 |
// standard properties must begin with "mfxImplDescription" |
| 570 |
if (nextProp != "mfxImplDescription") { |
| 571 |
return MFX_ERR_NOT_FOUND; |
| 572 |
} |
| 573 |
|
| 574 |
// get next property descriptor |
| 575 |
nextProp = GetNextProp(propParsedString); |
| 576 |
|
| 577 |
// property is a top-level member of mfxImplDescription |
| 578 |
if (nextProp == "Impl") { |
| 579 |
return ValidateAndSetProp(ePropMain_Impl, value); |
| 580 |
} |
| 581 |
else if (nextProp == "AccelerationMode") { |
| 582 |
return ValidateAndSetProp(ePropMain_AccelerationMode, value); |
| 583 |
} |
| 584 |
else if (nextProp == "mfxSurfacePoolMode") { |
| 585 |
return ValidateAndSetProp(ePropMain_PoolAllocationPolicy, value); |
| 586 |
} |
| 587 |
else if (nextProp == "ApiVersion") { |
| 588 |
// ApiVersion may be passed as single U32 (Version) or two U16's (Major, Minor) |
| 589 |
nextProp = GetNextProp(propParsedString); |
| 590 |
if (nextProp == "Version") |
| 591 |
return ValidateAndSetProp(ePropMain_ApiVersion, value); |
| 592 |
else if (nextProp == "Major") |
| 593 |
return ValidateAndSetProp(ePropMain_ApiVersion_Major, value); |
| 594 |
else if (nextProp == "Minor") |
| 595 |
return ValidateAndSetProp(ePropMain_ApiVersion_Minor, value); |
| 596 |
else |
| 597 |
return MFX_ERR_NOT_FOUND; |
| 598 |
} |
| 599 |
else if (nextProp == "VendorID") { |
| 600 |
return ValidateAndSetProp(ePropMain_VendorID, value); |
| 601 |
} |
| 602 |
else if (nextProp == "ImplName") { |
| 603 |
return ValidateAndSetProp(ePropMain_ImplName, value); |
| 604 |
} |
| 605 |
else if (nextProp == "License") { |
| 606 |
return ValidateAndSetProp(ePropMain_License, value); |
| 607 |
} |
| 608 |
else if (nextProp == "Keywords") { |
| 609 |
return ValidateAndSetProp(ePropMain_Keywords, value); |
| 610 |
} |
| 611 |
else if (nextProp == "VendorImplID") { |
| 612 |
return ValidateAndSetProp(ePropMain_VendorImplID, value); |
| 613 |
} |
| 614 |
|
| 615 |
// property is a member of mfxDeviceDescription |
| 616 |
if (nextProp == "mfxDeviceDescription") { |
| 617 |
nextProp = GetNextProp(propParsedString); |
| 618 |
// old version of table in spec had extra "device", just skip if present |
| 619 |
if (nextProp == "device") |
| 620 |
nextProp = GetNextProp(propParsedString); |
| 621 |
|
| 622 |
// special case - deviceID may be passed as U16 (default) or string (since API 2.4) |
| 623 |
// for compatibility, both are supported (value.Type distinguishes between them) |
| 624 |
if (nextProp == "DeviceID") { |
| 625 |
if (value.Type == MFX_VARIANT_TYPE_PTR) |
| 626 |
return ValidateAndSetProp(ePropDevice_DeviceIDStr, value); |
| 627 |
else |
| 628 |
return ValidateAndSetProp(ePropDevice_DeviceID, value); |
| 629 |
} |
| 630 |
|
| 631 |
if (nextProp == "MediaAdapterType") { |
| 632 |
return ValidateAndSetProp(ePropDevice_MediaAdapterType, value); |
| 633 |
} |
| 634 |
|
| 635 |
return MFX_ERR_NOT_FOUND; |
| 636 |
} |
| 637 |
|
| 638 |
// property is a member of mfxDecoderDescription |
| 639 |
if (nextProp == "mfxDecoderDescription") { |
| 640 |
return SetFilterPropertyDec(propParsedString, value); |
| 641 |
} |
| 642 |
|
| 643 |
if (nextProp == "mfxEncoderDescription") { |
| 644 |
return SetFilterPropertyEnc(propParsedString, value); |
| 645 |
} |
| 646 |
|
| 647 |
if (nextProp == "mfxVPPDescription") { |
| 648 |
return SetFilterPropertyVPP(propParsedString, value); |
| 649 |
} |
| 650 |
|
| 651 |
return MFX_ERR_NOT_FOUND; |
| 652 |
} |
| 653 |
|
| 654 |
#define CHECK_IDX(idxA, idxB, numB) \ |
| 655 |
if ((idxB) == (numB)) { \ |
| 656 |
(idxA)++; \ |
| 657 |
(idxB) = 0; \ |
| 658 |
continue; \ |
| 659 |
} |
| 660 |
|
| 661 |
mfxStatus ConfigCtxVPL::GetFlatDescriptionsDec(const mfxImplDescription *libImplDesc, |
| 662 |
std::list<DecConfig> &decConfigList) { |
| 663 |
mfxU32 codecIdx = 0; |
| 664 |
mfxU32 profileIdx = 0; |
| 665 |
mfxU32 memIdx = 0; |
| 666 |
mfxU32 outFmtIdx = 0; |
| 667 |
|
| 668 |
DecCodec *decCodec = nullptr; |
| 669 |
DecProfile *decProfile = nullptr; |
| 670 |
DecMemDesc *decMemDesc = nullptr; |
| 671 |
|
| 672 |
while (codecIdx < libImplDesc->Dec.NumCodecs) { |
| 673 |
DecConfig dc = {}; |
| 674 |
|
| 675 |
decCodec = &(libImplDesc->Dec.Codecs[codecIdx]); |
| 676 |
dc.CodecID = decCodec->CodecID; |
| 677 |
dc.MaxcodecLevel = decCodec->MaxcodecLevel; |
| 678 |
CHECK_IDX(codecIdx, profileIdx, decCodec->NumProfiles); |
| 679 |
|
| 680 |
decProfile = &(decCodec->Profiles[profileIdx]); |
| 681 |
dc.Profile = decProfile->Profile; |
| 682 |
CHECK_IDX(profileIdx, memIdx, decProfile->NumMemTypes); |
| 683 |
|
| 684 |
decMemDesc = &(decProfile->MemDesc[memIdx]); |
| 685 |
dc.MemHandleType = decMemDesc->MemHandleType; |
| 686 |
dc.Width = decMemDesc->Width; |
| 687 |
dc.Height = decMemDesc->Height; |
| 688 |
CHECK_IDX(memIdx, outFmtIdx, decMemDesc->NumColorFormats); |
| 689 |
|
| 690 |
dc.ColorFormat = decMemDesc->ColorFormats[outFmtIdx]; |
| 691 |
outFmtIdx++; |
| 692 |
|
| 693 |
// we have a valid, unique description - add to list |
| 694 |
decConfigList.push_back(dc); |
| 695 |
} |
| 696 |
|
| 697 |
if (decConfigList.empty()) |
| 698 |
return MFX_ERR_INVALID_VIDEO_PARAM; |
| 699 |
|
| 700 |
return MFX_ERR_NONE; |
| 701 |
} |
| 702 |
|
| 703 |
mfxStatus ConfigCtxVPL::GetFlatDescriptionsEnc(const mfxImplDescription *libImplDesc, |
| 704 |
std::list<EncConfig> &encConfigList) { |
| 705 |
mfxU32 codecIdx = 0; |
| 706 |
mfxU32 profileIdx = 0; |
| 707 |
mfxU32 memIdx = 0; |
| 708 |
mfxU32 inFmtIdx = 0; |
| 709 |
|
| 710 |
EncCodec *encCodec = nullptr; |
| 711 |
EncProfile *encProfile = nullptr; |
| 712 |
EncMemDesc *encMemDesc = nullptr; |
| 713 |
|
| 714 |
#ifdef ONEVPL_EXPERIMENTAL |
| 715 |
// ReportedStats was added with API 2.7 under ONEVPL_EXPERIMENTAL. |
| 716 |
// When it is promoted to production API, MFX_ENCODERDESCRIPTION_VERSION should be bumped up |
| 717 |
// and we should check mfxEncoderDescription.Version instead to know whether ReportedStats |
| 718 |
// is a valid field (taken from reserved[] space). |
| 719 |
// Until then, best we can do is to check the overall API version for this impl. |
| 720 |
mfxVersion reqApiVersionReportedStats = {}; |
| 721 |
reqApiVersionReportedStats.Major = 2; |
| 722 |
reqApiVersionReportedStats.Minor = 7; |
| 723 |
#endif |
| 724 |
|
| 725 |
while (codecIdx < libImplDesc->Enc.NumCodecs) { |
| 726 |
EncConfig ec = {}; |
| 727 |
|
| 728 |
encCodec = &(libImplDesc->Enc.Codecs[codecIdx]); |
| 729 |
ec.CodecID = encCodec->CodecID; |
| 730 |
ec.MaxcodecLevel = encCodec->MaxcodecLevel; |
| 731 |
ec.BiDirectionalPrediction = encCodec->BiDirectionalPrediction; |
| 732 |
|
| 733 |
#ifdef ONEVPL_EXPERIMENTAL |
| 734 |
// see comment above about checking mfxEncoderDescription version once this is moved out |
| 735 |
// of experimental API |
| 736 |
if (libImplDesc->ApiVersion.Version >= reqApiVersionReportedStats.Version) |
| 737 |
ec.ReportedStats = encCodec->ReportedStats; |
| 738 |
#endif |
| 739 |
|
| 740 |
CHECK_IDX(codecIdx, profileIdx, encCodec->NumProfiles); |
| 741 |
|
| 742 |
encProfile = &(encCodec->Profiles[profileIdx]); |
| 743 |
ec.Profile = encProfile->Profile; |
| 744 |
CHECK_IDX(profileIdx, memIdx, encProfile->NumMemTypes); |
| 745 |
|
| 746 |
encMemDesc = &(encProfile->MemDesc[memIdx]); |
| 747 |
ec.MemHandleType = encMemDesc->MemHandleType; |
| 748 |
ec.Width = encMemDesc->Width; |
| 749 |
ec.Height = encMemDesc->Height; |
| 750 |
CHECK_IDX(memIdx, inFmtIdx, encMemDesc->NumColorFormats); |
| 751 |
|
| 752 |
ec.ColorFormat = encMemDesc->ColorFormats[inFmtIdx]; |
| 753 |
inFmtIdx++; |
| 754 |
|
| 755 |
// we have a valid, unique description - add to list |
| 756 |
encConfigList.push_back(ec); |
| 757 |
} |
| 758 |
|
| 759 |
if (encConfigList.empty()) |
| 760 |
return MFX_ERR_INVALID_VIDEO_PARAM; |
| 761 |
|
| 762 |
return MFX_ERR_NONE; |
| 763 |
} |
| 764 |
|
| 765 |
mfxStatus ConfigCtxVPL::GetFlatDescriptionsVPP(const mfxImplDescription *libImplDesc, |
| 766 |
std::list<VPPConfig> &vppConfigList) { |
| 767 |
mfxU32 filterIdx = 0; |
| 768 |
mfxU32 memIdx = 0; |
| 769 |
mfxU32 inFmtIdx = 0; |
| 770 |
mfxU32 outFmtIdx = 0; |
| 771 |
|
| 772 |
VPPFilter *vppFilter = nullptr; |
| 773 |
VPPMemDesc *vppMemDesc = nullptr; |
| 774 |
VPPFormat *vppFormat = nullptr; |
| 775 |
|
| 776 |
while (filterIdx < libImplDesc->VPP.NumFilters) { |
| 777 |
VPPConfig vc = {}; |
| 778 |
|
| 779 |
vppFilter = &(libImplDesc->VPP.Filters[filterIdx]); |
| 780 |
vc.FilterFourCC = vppFilter->FilterFourCC; |
| 781 |
vc.MaxDelayInFrames = vppFilter->MaxDelayInFrames; |
| 782 |
CHECK_IDX(filterIdx, memIdx, vppFilter->NumMemTypes); |
| 783 |
|
| 784 |
vppMemDesc = &(vppFilter->MemDesc[memIdx]); |
| 785 |
vc.MemHandleType = vppMemDesc->MemHandleType; |
| 786 |
vc.Width = vppMemDesc->Width; |
| 787 |
vc.Height = vppMemDesc->Height; |
| 788 |
CHECK_IDX(memIdx, inFmtIdx, vppMemDesc->NumInFormats); |
| 789 |
|
| 790 |
vppFormat = &(vppMemDesc->Formats[inFmtIdx]); |
| 791 |
vc.InFormat = vppFormat->InFormat; |
| 792 |
CHECK_IDX(inFmtIdx, outFmtIdx, vppFormat->NumOutFormat); |
| 793 |
|
| 794 |
vc.OutFormat = vppFormat->OutFormats[outFmtIdx]; |
| 795 |
outFmtIdx++; |
| 796 |
|
| 797 |
// we have a valid, unique description - add to list |
| 798 |
vppConfigList.push_back(vc); |
| 799 |
} |
| 800 |
|
| 801 |
if (vppConfigList.empty()) |
| 802 |
return MFX_ERR_INVALID_VIDEO_PARAM; |
| 803 |
|
| 804 |
return MFX_ERR_NONE; |
| 805 |
} |
| 806 |
|
| 807 |
#define CHECK_PROP(idx, type, val) \ |
| 808 |
if ((cfgPropsAll[(idx)].Type != MFX_VARIANT_TYPE_UNSET) && \ |
| 809 |
(cfgPropsAll[(idx)].Data.type != val)) \ |
| 810 |
isCompatible = false; |
| 811 |
|
| 812 |
mfxStatus ConfigCtxVPL::CheckPropsGeneral(const mfxVariant cfgPropsAll[], |
| 813 |
const mfxImplDescription *libImplDesc) { |
| 814 |
bool isCompatible = true; |
| 815 |
|
| 816 |
// check if this implementation includes |
| 817 |
// all of the required top-level properties |
| 818 |
CHECK_PROP(ePropMain_Impl, U32, libImplDesc->Impl); |
| 819 |
CHECK_PROP(ePropMain_VendorID, U32, libImplDesc->VendorID); |
| 820 |
CHECK_PROP(ePropMain_VendorImplID, U32, libImplDesc->VendorImplID); |
| 821 |
|
| 822 |
// check API version in calling function since major and minor may be passed |
| 823 |
// in separate cfg objects |
| 824 |
|
| 825 |
if (libImplDesc->AccelerationModeDescription.NumAccelerationModes > 0) { |
| 826 |
if (cfgPropsAll[ePropMain_AccelerationMode].Type != MFX_VARIANT_TYPE_UNSET) { |
| 827 |
// check all supported modes if list is filled out |
| 828 |
mfxU16 numModes = libImplDesc->AccelerationModeDescription.NumAccelerationModes; |
| 829 |
mfxAccelerationMode modeRequested = |
| 830 |
(mfxAccelerationMode)(cfgPropsAll[ePropMain_AccelerationMode].Data.U32); |
| 831 |
auto *modeTab = libImplDesc->AccelerationModeDescription.Mode; |
| 832 |
|
| 833 |
auto *m = std::find(modeTab, modeTab + numModes, modeRequested); |
| 834 |
if (m == modeTab + numModes) |
| 835 |
isCompatible = false; |
| 836 |
} |
| 837 |
} |
| 838 |
else { |
| 839 |
// check default mode |
| 840 |
CHECK_PROP(ePropMain_AccelerationMode, U32, libImplDesc->AccelerationMode); |
| 841 |
} |
| 842 |
|
| 843 |
if (cfgPropsAll[ePropMain_PoolAllocationPolicy].Type != MFX_VARIANT_TYPE_UNSET) { |
| 844 |
// mfxPoolAllocationPolicy added with struct version 1.2 |
| 845 |
mfxU16 numPolicies = 0; |
| 846 |
if (libImplDesc->Version.Version >= MFX_STRUCT_VERSION(1, 2)) |
| 847 |
numPolicies = libImplDesc->PoolPolicies.NumPoolPolicies; |
| 848 |
|
| 849 |
// check all supported policies if list is filled out |
| 850 |
// if structure is not present (old version) numPolicies will be 0, so skipped |
| 851 |
if (isCompatible == true && numPolicies > 0) { |
| 852 |
mfxPoolAllocationPolicy policyRequested = |
| 853 |
(mfxPoolAllocationPolicy)(cfgPropsAll[ePropMain_PoolAllocationPolicy].Data.U32); |
| 854 |
auto *policyTab = libImplDesc->PoolPolicies.Policy; |
| 855 |
|
| 856 |
auto *m = std::find(policyTab, policyTab + numPolicies, policyRequested); |
| 857 |
if (m == policyTab + numPolicies) |
| 858 |
isCompatible = false; |
| 859 |
} |
| 860 |
else { |
| 861 |
isCompatible = false; |
| 862 |
} |
| 863 |
} |
| 864 |
|
| 865 |
// check string: ImplName (string match) |
| 866 |
if (cfgPropsAll[ePropMain_ImplName].Type != MFX_VARIANT_TYPE_UNSET) { |
| 867 |
std::string filtName = *(std::string *)(cfgPropsAll[ePropMain_ImplName].Data.Ptr); |
| 868 |
std::string implName = libImplDesc->ImplName; |
| 869 |
if (filtName != implName) |
| 870 |
isCompatible = false; |
| 871 |
} |
| 872 |
|
| 873 |
// check string: License (tokenized) |
| 874 |
if (cfgPropsAll[ePropMain_License].Type != MFX_VARIANT_TYPE_UNSET) { |
| 875 |
std::string license = *(std::string *)(cfgPropsAll[ePropMain_License].Data.Ptr); |
| 876 |
if (CheckPropString(libImplDesc->License, license) != MFX_ERR_NONE) |
| 877 |
isCompatible = false; |
| 878 |
} |
| 879 |
|
| 880 |
// check string: Keywords (tokenized) |
| 881 |
if (cfgPropsAll[ePropMain_Keywords].Type != MFX_VARIANT_TYPE_UNSET) { |
| 882 |
std::string keywords = *(std::string *)(cfgPropsAll[ePropMain_Keywords].Data.Ptr); |
| 883 |
if (CheckPropString(libImplDesc->Keywords, keywords) != MFX_ERR_NONE) |
| 884 |
isCompatible = false; |
| 885 |
} |
| 886 |
|
| 887 |
// check DeviceID - stored as char*, but passed in for filtering as U16 |
| 888 |
// convert both to unsigned ints and compare |
| 889 |
if (cfgPropsAll[ePropDevice_DeviceID].Type != MFX_VARIANT_TYPE_UNSET) { |
| 890 |
unsigned int implDeviceID = 0; |
| 891 |
try { |
| 892 |
implDeviceID = std::stoi(libImplDesc->Dev.DeviceID, 0, 16); |
| 893 |
} |
| 894 |
catch (...) { |
| 895 |
return MFX_ERR_UNSUPPORTED; |
| 896 |
} |
| 897 |
|
| 898 |
unsigned int filtDeviceID = (unsigned int)(cfgPropsAll[ePropDevice_DeviceID].Data.U16); |
| 899 |
if (implDeviceID != filtDeviceID) |
| 900 |
isCompatible = false; |
| 901 |
} |
| 902 |
|
| 903 |
if (cfgPropsAll[ePropDevice_DeviceIDStr].Type != MFX_VARIANT_TYPE_UNSET) { |
| 904 |
// since API 2.4 - pass DeviceID as string (do string match) |
| 905 |
std::string filtDeviceID = *(std::string *)(cfgPropsAll[ePropDevice_DeviceIDStr].Data.Ptr); |
| 906 |
std::string implDeviceID = libImplDesc->Dev.DeviceID; |
| 907 |
if (filtDeviceID != implDeviceID) |
| 908 |
isCompatible = false; |
| 909 |
} |
| 910 |
|
| 911 |
// mfxDeviceDescription.MediaAdapterType introduced in API 2.5, structure version 1.1 |
| 912 |
// do not check this for MSDK libs (allow it to pass) |
| 913 |
if (libImplDesc->ApiVersion.Major >= 2) { |
| 914 |
if (cfgPropsAll[ePropDevice_MediaAdapterType].Type != MFX_VARIANT_TYPE_UNSET) { |
| 915 |
if (libImplDesc->Dev.Version.Version < MFX_STRUCT_VERSION(1, 1)) |
| 916 |
isCompatible = false; |
| 917 |
|
| 918 |
CHECK_PROP(ePropDevice_MediaAdapterType, U16, libImplDesc->Dev.MediaAdapterType); |
| 919 |
} |
| 920 |
} |
| 921 |
|
| 922 |
if (isCompatible == true) |
| 923 |
return MFX_ERR_NONE; |
| 924 |
|
| 925 |
return MFX_ERR_UNSUPPORTED; |
| 926 |
} |
| 927 |
|
| 928 |
mfxStatus ConfigCtxVPL::CheckPropsDec(const mfxVariant cfgPropsAll[], |
| 929 |
std::list<DecConfig> decConfigList) { |
| 930 |
auto it = decConfigList.begin(); |
| 931 |
while (it != decConfigList.end()) { |
| 932 |
DecConfig dc = (DecConfig)(*it); |
| 933 |
bool isCompatible = true; |
| 934 |
|
| 935 |
// check if this decode description includes |
| 936 |
// all of the required decoder properties |
| 937 |
CHECK_PROP(ePropDec_CodecID, U32, dc.CodecID); |
| 938 |
CHECK_PROP(ePropDec_MaxcodecLevel, U16, dc.MaxcodecLevel); |
| 939 |
CHECK_PROP(ePropDec_Profile, U32, dc.Profile); |
| 940 |
CHECK_PROP(ePropDec_MemHandleType, U32, dc.MemHandleType); |
| 941 |
CHECK_PROP(ePropDec_ColorFormats, U32, dc.ColorFormat); |
| 942 |
|
| 943 |
// special handling for properties passed via pointer |
| 944 |
if (cfgPropsAll[ePropDec_Width].Type != MFX_VARIANT_TYPE_UNSET) { |
| 945 |
mfxRange32U width = {}; |
| 946 |
if (cfgPropsAll[ePropDec_Width].Data.Ptr) |
| 947 |
width = *((mfxRange32U *)(cfgPropsAll[ePropDec_Width].Data.Ptr)); |
| 948 |
|
| 949 |
if ((width.Max > dc.Width.Max) || (width.Min < dc.Width.Min) || |
| 950 |
(width.Step < dc.Width.Step)) |
| 951 |
isCompatible = false; |
| 952 |
} |
| 953 |
|
| 954 |
if (cfgPropsAll[ePropDec_Height].Type != MFX_VARIANT_TYPE_UNSET) { |
| 955 |
mfxRange32U height = {}; |
| 956 |
if (cfgPropsAll[ePropDec_Height].Data.Ptr) |
| 957 |
height = *((mfxRange32U *)(cfgPropsAll[ePropDec_Height].Data.Ptr)); |
| 958 |
|
| 959 |
if ((height.Max > dc.Height.Max) || (height.Min < dc.Height.Min) || |
| 960 |
(height.Step < dc.Height.Step)) |
| 961 |
isCompatible = false; |
| 962 |
} |
| 963 |
|
| 964 |
if (isCompatible == true) |
| 965 |
return MFX_ERR_NONE; |
| 966 |
|
| 967 |
it++; |
| 968 |
} |
| 969 |
|
| 970 |
return MFX_ERR_UNSUPPORTED; |
| 971 |
} |
| 972 |
|
| 973 |
mfxStatus ConfigCtxVPL::CheckPropsEnc(const mfxVariant cfgPropsAll[], |
| 974 |
std::list<EncConfig> encConfigList) { |
| 975 |
auto it = encConfigList.begin(); |
| 976 |
while (it != encConfigList.end()) { |
| 977 |
EncConfig ec = (EncConfig)(*it); |
| 978 |
bool isCompatible = true; |
| 979 |
|
| 980 |
// check if this encode description includes |
| 981 |
// all of the required encoder properties |
| 982 |
CHECK_PROP(ePropEnc_CodecID, U32, ec.CodecID); |
| 983 |
CHECK_PROP(ePropEnc_MaxcodecLevel, U16, ec.MaxcodecLevel); |
| 984 |
CHECK_PROP(ePropEnc_BiDirectionalPrediction, U16, ec.BiDirectionalPrediction); |
| 985 |
CHECK_PROP(ePropEnc_Profile, U32, ec.Profile); |
| 986 |
CHECK_PROP(ePropEnc_MemHandleType, U32, ec.MemHandleType); |
| 987 |
CHECK_PROP(ePropEnc_ColorFormats, U32, ec.ColorFormat); |
| 988 |
|
| 989 |
// special handling for properties passed via pointer |
| 990 |
if (cfgPropsAll[ePropEnc_Width].Type != MFX_VARIANT_TYPE_UNSET) { |
| 991 |
mfxRange32U width = {}; |
| 992 |
if (cfgPropsAll[ePropEnc_Width].Data.Ptr) |
| 993 |
width = *((mfxRange32U *)(cfgPropsAll[ePropEnc_Width].Data.Ptr)); |
| 994 |
|
| 995 |
if ((width.Max > ec.Width.Max) || (width.Min < ec.Width.Min) || |
| 996 |
(width.Step < ec.Width.Step)) |
| 997 |
isCompatible = false; |
| 998 |
} |
| 999 |
|
| 1000 |
if (cfgPropsAll[ePropEnc_Height].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1001 |
mfxRange32U height = {}; |
| 1002 |
if (cfgPropsAll[ePropEnc_Height].Data.Ptr) |
| 1003 |
height = *((mfxRange32U *)(cfgPropsAll[ePropEnc_Height].Data.Ptr)); |
| 1004 |
|
| 1005 |
if ((height.Max > ec.Height.Max) || (height.Min < ec.Height.Min) || |
| 1006 |
(height.Step < ec.Height.Step)) |
| 1007 |
isCompatible = false; |
| 1008 |
} |
| 1009 |
|
| 1010 |
if (cfgPropsAll[ePropEnc_ReportedStats].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1011 |
mfxU16 requestedStats = cfgPropsAll[ePropEnc_ReportedStats].Data.U16; |
| 1012 |
|
| 1013 |
// ReportedStats is a logical OR of one or more flags: MFX_ENCODESTATS_LEVEL_xxx |
| 1014 |
if ((requestedStats & ec.ReportedStats) != requestedStats) |
| 1015 |
isCompatible = false; |
| 1016 |
} |
| 1017 |
|
| 1018 |
if (isCompatible == true) |
| 1019 |
return MFX_ERR_NONE; |
| 1020 |
|
| 1021 |
it++; |
| 1022 |
} |
| 1023 |
|
| 1024 |
return MFX_ERR_UNSUPPORTED; |
| 1025 |
} |
| 1026 |
|
| 1027 |
mfxStatus ConfigCtxVPL::CheckPropsVPP(const mfxVariant cfgPropsAll[], |
| 1028 |
std::list<VPPConfig> vppConfigList) { |
| 1029 |
auto it = vppConfigList.begin(); |
| 1030 |
while (it != vppConfigList.end()) { |
| 1031 |
VPPConfig vc = (VPPConfig)(*it); |
| 1032 |
bool isCompatible = true; |
| 1033 |
|
| 1034 |
// check if this filter description includes |
| 1035 |
// all of the required VPP properties |
| 1036 |
CHECK_PROP(ePropVPP_FilterFourCC, U32, vc.FilterFourCC); |
| 1037 |
CHECK_PROP(ePropVPP_MaxDelayInFrames, U16, vc.MaxDelayInFrames); |
| 1038 |
CHECK_PROP(ePropVPP_MemHandleType, U32, vc.MemHandleType); |
| 1039 |
CHECK_PROP(ePropVPP_InFormat, U32, vc.InFormat); |
| 1040 |
CHECK_PROP(ePropVPP_OutFormat, U32, vc.OutFormat); |
| 1041 |
|
| 1042 |
// special handling for properties passed via pointer |
| 1043 |
if (cfgPropsAll[ePropVPP_Width].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1044 |
mfxRange32U width = {}; |
| 1045 |
if (cfgPropsAll[ePropVPP_Width].Data.Ptr) |
| 1046 |
width = *((mfxRange32U *)(cfgPropsAll[ePropVPP_Width].Data.Ptr)); |
| 1047 |
|
| 1048 |
if ((width.Max > vc.Width.Max) || (width.Min < vc.Width.Min) || |
| 1049 |
(width.Step < vc.Width.Step)) |
| 1050 |
isCompatible = false; |
| 1051 |
} |
| 1052 |
|
| 1053 |
if (cfgPropsAll[ePropVPP_Height].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1054 |
mfxRange32U height = {}; |
| 1055 |
if (cfgPropsAll[ePropVPP_Height].Data.Ptr) |
| 1056 |
height = *((mfxRange32U *)(cfgPropsAll[ePropVPP_Height].Data.Ptr)); |
| 1057 |
|
| 1058 |
if ((height.Max > vc.Height.Max) || (height.Min < vc.Height.Min) || |
| 1059 |
(height.Step < vc.Height.Step)) |
| 1060 |
isCompatible = false; |
| 1061 |
} |
| 1062 |
|
| 1063 |
if (isCompatible == true) |
| 1064 |
return MFX_ERR_NONE; |
| 1065 |
|
| 1066 |
it++; |
| 1067 |
} |
| 1068 |
|
| 1069 |
return MFX_ERR_UNSUPPORTED; |
| 1070 |
} |
| 1071 |
|
| 1072 |
#ifdef ONEVPL_EXPERIMENTAL |
| 1073 |
mfxStatus ConfigCtxVPL::CheckPropsExtDevID(const mfxVariant cfgPropsAll[], |
| 1074 |
const mfxExtendedDeviceId *libImplExtDevID) { |
| 1075 |
bool isCompatible = true; |
| 1076 |
|
| 1077 |
// check if this implementation includes |
| 1078 |
// all of the required extended device ID properties |
| 1079 |
CHECK_PROP(ePropExtDev_VendorID, U16, libImplExtDevID->VendorID); |
| 1080 |
CHECK_PROP(ePropExtDev_DeviceID, U16, libImplExtDevID->DeviceID); |
| 1081 |
|
| 1082 |
CHECK_PROP(ePropExtDev_PCIDomain, U32, libImplExtDevID->PCIDomain); |
| 1083 |
CHECK_PROP(ePropExtDev_PCIBus, U32, libImplExtDevID->PCIBus); |
| 1084 |
CHECK_PROP(ePropExtDev_PCIDevice, U32, libImplExtDevID->PCIDevice); |
| 1085 |
CHECK_PROP(ePropExtDev_PCIFunction, U32, libImplExtDevID->PCIFunction); |
| 1086 |
|
| 1087 |
// check DeviceLUID, require LUIDValid == true |
| 1088 |
if (cfgPropsAll[ePropExtDev_DeviceLUID].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1089 |
// LUID filter is passed as ptr to 8-byte array, which was saved in local copy |
| 1090 |
mfxU8 *pU8 = (mfxU8 *)(cfgPropsAll[ePropExtDev_DeviceLUID].Data.Ptr); |
| 1091 |
if (libImplExtDevID->LUIDValid) { |
| 1092 |
for (mfxU32 j = 0; j < 8; j++) { |
| 1093 |
if (pU8[j] != libImplExtDevID->DeviceLUID[j]) |
| 1094 |
isCompatible = false; |
| 1095 |
} |
| 1096 |
} |
| 1097 |
else { |
| 1098 |
isCompatible = false; |
| 1099 |
} |
| 1100 |
} |
| 1101 |
|
| 1102 |
// check LUIDDeviceNodeMask, require LUIDValid == true |
| 1103 |
if (cfgPropsAll[ePropExtDev_LUIDDeviceNodeMask].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1104 |
if (libImplExtDevID->LUIDValid) { |
| 1105 |
CHECK_PROP(ePropExtDev_LUIDDeviceNodeMask, U32, libImplExtDevID->LUIDDeviceNodeMask); |
| 1106 |
} |
| 1107 |
else { |
| 1108 |
isCompatible = false; |
| 1109 |
} |
| 1110 |
} |
| 1111 |
|
| 1112 |
// check DRMRenderNodeNum |
| 1113 |
if (cfgPropsAll[ePropExtDev_DRMRenderNodeNum].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1114 |
if (libImplExtDevID->DRMRenderNodeNum != 0) { |
| 1115 |
CHECK_PROP(ePropExtDev_DRMRenderNodeNum, U32, libImplExtDevID->DRMRenderNodeNum); |
| 1116 |
} |
| 1117 |
else { |
| 1118 |
isCompatible = false; |
| 1119 |
} |
| 1120 |
} |
| 1121 |
|
| 1122 |
// check DRMPrimaryNodeNum |
| 1123 |
if (cfgPropsAll[ePropExtDev_DRMPrimaryNodeNum].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1124 |
if (libImplExtDevID->DRMRenderNodeNum != 0x7FFFFFFF) { |
| 1125 |
CHECK_PROP(ePropExtDev_DRMPrimaryNodeNum, U32, libImplExtDevID->DRMPrimaryNodeNum); |
| 1126 |
} |
| 1127 |
else { |
| 1128 |
isCompatible = false; |
| 1129 |
} |
| 1130 |
} |
| 1131 |
|
| 1132 |
CHECK_PROP(ePropExtDev_RevisionID, U16, libImplExtDevID->RevisionID); |
| 1133 |
|
| 1134 |
// check string: DeviceName (string match) |
| 1135 |
if (cfgPropsAll[ePropExtDev_DeviceName].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1136 |
std::string filtName = *(std::string *)(cfgPropsAll[ePropExtDev_DeviceName].Data.Ptr); |
| 1137 |
std::string implName = libImplExtDevID->DeviceName; |
| 1138 |
if (filtName != implName) |
| 1139 |
isCompatible = false; |
| 1140 |
} |
| 1141 |
|
| 1142 |
if (isCompatible == true) |
| 1143 |
return MFX_ERR_NONE; |
| 1144 |
|
| 1145 |
return MFX_ERR_UNSUPPORTED; |
| 1146 |
} |
| 1147 |
#endif |
| 1148 |
|
| 1149 |
// implString = string from implDesc - one or more comma-separated tokens |
| 1150 |
// filtString = string user is looking for - one or more comma-separated tokens |
| 1151 |
// we parse filtString into tokens, then check if all of them are present in implString |
| 1152 |
mfxStatus ConfigCtxVPL::CheckPropString(const mfxChar *implString, const std::string filtString) { |
| 1153 |
std::list<std::string> tokenString; |
| 1154 |
std::string s; |
| 1155 |
|
| 1156 |
// parse implString string into tokens, separated by ',' |
| 1157 |
std::stringstream implSS((char *)implString); |
| 1158 |
while (getline(implSS, s, ',')) { |
| 1159 |
tokenString.push_back(s); |
| 1160 |
} |
| 1161 |
|
| 1162 |
// parse filtString string into tokens, separated by ',' |
| 1163 |
// check that each token is present in implString, otherwise return error |
| 1164 |
std::stringstream filtSS(filtString); |
| 1165 |
while (getline(filtSS, s, ',')) { |
| 1166 |
if (std::find(tokenString.begin(), tokenString.end(), s) == tokenString.end()) |
| 1167 |
return MFX_ERR_UNSUPPORTED; |
| 1168 |
} |
| 1169 |
|
| 1170 |
return MFX_ERR_NONE; |
| 1171 |
} |
| 1172 |
|
| 1173 |
mfxStatus ConfigCtxVPL::ValidateConfig(const mfxImplDescription *libImplDesc, |
| 1174 |
const mfxImplementedFunctions *libImplFuncs, |
| 1175 |
#ifdef ONEVPL_EXPERIMENTAL |
| 1176 |
const mfxExtendedDeviceId *libImplExtDevID, |
| 1177 |
#endif |
| 1178 |
std::list<ConfigCtxVPL *> configCtxList, |
| 1179 |
LibType libType, |
| 1180 |
SpecialConfig *specialConfig) { |
| 1181 |
mfxU32 idx; |
| 1182 |
bool decRequested = false; |
| 1183 |
bool encRequested = false; |
| 1184 |
bool vppRequested = false; |
| 1185 |
bool extDevRequested = false; |
| 1186 |
|
| 1187 |
bool bImplValid = true; |
| 1188 |
|
| 1189 |
if (!libImplDesc) |
| 1190 |
return MFX_ERR_NULL_PTR; |
| 1191 |
|
| 1192 |
std::list<DecConfig> decConfigList; |
| 1193 |
std::list<EncConfig> encConfigList; |
| 1194 |
std::list<VPPConfig> vppConfigList; |
| 1195 |
|
| 1196 |
// generate "flat" descriptions of each combination |
| 1197 |
// (e.g. multiple profiles from the same codec) |
| 1198 |
GetFlatDescriptionsDec(libImplDesc, decConfigList); |
| 1199 |
GetFlatDescriptionsEnc(libImplDesc, encConfigList); |
| 1200 |
GetFlatDescriptionsVPP(libImplDesc, vppConfigList); |
| 1201 |
|
| 1202 |
// list of functions required to be implemented |
| 1203 |
std::list<std::string> implFunctionList; |
| 1204 |
implFunctionList.clear(); |
| 1205 |
|
| 1206 |
// check requested API version |
| 1207 |
mfxVersion reqVersion = {}; |
| 1208 |
bool bVerSetMajor = false; |
| 1209 |
bool bVerSetMinor = false; |
| 1210 |
|
| 1211 |
// clear list of extension buffers |
| 1212 |
specialConfig->bIsSet_ExtBuffer = false; |
| 1213 |
specialConfig->ExtBuffers.clear(); |
| 1214 |
|
| 1215 |
// iterate through all filters and populate cfgPropsAll |
| 1216 |
auto it = configCtxList.begin(); |
| 1217 |
|
| 1218 |
while (it != configCtxList.end()) { |
| 1219 |
ConfigCtxVPL *config = (*it); |
| 1220 |
it++; |
| 1221 |
|
| 1222 |
// initially all properties are unset |
| 1223 |
mfxVariant cfgPropsAll[eProp_TotalProps] = {}; |
| 1224 |
for (idx = 0; idx < eProp_TotalProps; idx++) { |
| 1225 |
cfgPropsAll[idx].Type = MFX_VARIANT_TYPE_UNSET; |
| 1226 |
} |
| 1227 |
|
| 1228 |
for (idx = 0; idx < eProp_TotalProps; idx++) { |
| 1229 |
// ignore unset properties |
| 1230 |
if (config->m_propVar[idx].Type == MFX_VARIANT_TYPE_UNSET) |
| 1231 |
continue; |
| 1232 |
|
| 1233 |
// if property is required function, add to list which will be checked below |
| 1234 |
if (idx == ePropFunc_FunctionName) { |
| 1235 |
implFunctionList.push_back(config->m_implFunctionName); |
| 1236 |
continue; |
| 1237 |
} |
| 1238 |
|
| 1239 |
cfgPropsAll[idx].Type = config->m_propVar[idx].Type; |
| 1240 |
cfgPropsAll[idx].Data = config->m_propVar[idx].Data; |
| 1241 |
|
| 1242 |
if (idx >= ePropDec_CodecID && idx <= ePropDec_ColorFormats) |
| 1243 |
decRequested = true; |
| 1244 |
else if (idx >= ePropEnc_CodecID && idx <= ePropEnc_ColorFormats) |
| 1245 |
encRequested = true; |
| 1246 |
else if (idx >= ePropVPP_FilterFourCC && idx <= ePropVPP_OutFormat) |
| 1247 |
vppRequested = true; |
| 1248 |
else if (idx >= ePropExtDev_VendorID && idx <= ePropExtDev_DeviceName) |
| 1249 |
extDevRequested = true; |
| 1250 |
} |
| 1251 |
|
| 1252 |
// if already marked invalid, no need to check props again |
| 1253 |
// however we still need to iterate over all of the config objects |
| 1254 |
// to get any non-filtering properties (returned in SpecialConfig) |
| 1255 |
if (bImplValid == true) { |
| 1256 |
if (CheckPropsGeneral(cfgPropsAll, libImplDesc)) |
| 1257 |
bImplValid = false; |
| 1258 |
|
| 1259 |
#ifdef ONEVPL_EXPERIMENTAL |
| 1260 |
if (extDevRequested) { |
| 1261 |
// fail if extDevID is not available (null) or if prop is not supported |
| 1262 |
if (!libImplExtDevID || CheckPropsExtDevID(cfgPropsAll, libImplExtDevID)) |
| 1263 |
bImplValid = false; |
| 1264 |
} |
| 1265 |
#else |
| 1266 |
if (extDevRequested) |
| 1267 |
bImplValid = false; |
| 1268 |
#endif |
| 1269 |
|
| 1270 |
// MSDK RT compatibility mode (1.x) does not provide Dec/Enc/VPP caps |
| 1271 |
// ignore these filters if set (do not use them to _exclude_ the library) |
| 1272 |
if (libType != LibTypeMSDK) { |
| 1273 |
if (decRequested && CheckPropsDec(cfgPropsAll, decConfigList)) |
| 1274 |
bImplValid = false; |
| 1275 |
|
| 1276 |
if (encRequested && CheckPropsEnc(cfgPropsAll, encConfigList)) |
| 1277 |
bImplValid = false; |
| 1278 |
|
| 1279 |
if (vppRequested && CheckPropsVPP(cfgPropsAll, vppConfigList)) |
| 1280 |
bImplValid = false; |
| 1281 |
} |
| 1282 |
} |
| 1283 |
|
| 1284 |
// update any special (including non-filtering) properties, for use by caller |
| 1285 |
// if multiple cfg objects set the same non-filtering property, the last (most recent) one is used |
| 1286 |
if (cfgPropsAll[ePropSpecial_HandleType].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1287 |
specialConfig->deviceHandleType = |
| 1288 |
(mfxHandleType)cfgPropsAll[ePropSpecial_HandleType].Data.U32; |
| 1289 |
specialConfig->bIsSet_deviceHandleType = true; |
| 1290 |
} |
| 1291 |
|
| 1292 |
if (cfgPropsAll[ePropSpecial_Handle].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1293 |
specialConfig->deviceHandle = (mfxHDL)cfgPropsAll[ePropSpecial_Handle].Data.Ptr; |
| 1294 |
specialConfig->bIsSet_deviceHandle = true; |
| 1295 |
} |
| 1296 |
|
| 1297 |
if (cfgPropsAll[ePropSpecial_NumThread].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1298 |
specialConfig->NumThread = cfgPropsAll[ePropSpecial_NumThread].Data.U32; |
| 1299 |
specialConfig->bIsSet_NumThread = true; |
| 1300 |
} |
| 1301 |
|
| 1302 |
if (cfgPropsAll[ePropSpecial_DeviceCopy].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1303 |
specialConfig->DeviceCopy = cfgPropsAll[ePropSpecial_DeviceCopy].Data.U16; |
| 1304 |
specialConfig->bIsSet_DeviceCopy = true; |
| 1305 |
} |
| 1306 |
|
| 1307 |
if (cfgPropsAll[ePropSpecial_DXGIAdapterIndex].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1308 |
specialConfig->dxgiAdapterIdx = |
| 1309 |
(mfxU32)cfgPropsAll[ePropSpecial_DXGIAdapterIndex].Data.U32; |
| 1310 |
specialConfig->bIsSet_dxgiAdapterIdx = true; |
| 1311 |
} |
| 1312 |
|
| 1313 |
if (cfgPropsAll[ePropMain_AccelerationMode].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1314 |
specialConfig->accelerationMode = |
| 1315 |
(mfxAccelerationMode)cfgPropsAll[ePropMain_AccelerationMode].Data.U32; |
| 1316 |
specialConfig->bIsSet_accelerationMode = true; |
| 1317 |
} |
| 1318 |
|
| 1319 |
if (cfgPropsAll[ePropSpecial_ExtBuffer].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1320 |
specialConfig->ExtBuffers.push_back( |
| 1321 |
(mfxExtBuffer *)cfgPropsAll[ePropSpecial_ExtBuffer].Data.Ptr); |
| 1322 |
specialConfig->bIsSet_ExtBuffer = true; |
| 1323 |
} |
| 1324 |
|
| 1325 |
// special handling for API version which may be passed either as single U32 (Version) |
| 1326 |
// or two U16 (Major, Minor) which could come in separate cfg objects |
| 1327 |
if (cfgPropsAll[ePropMain_ApiVersion].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1328 |
reqVersion.Version = (mfxU32)cfgPropsAll[ePropMain_ApiVersion].Data.U32; |
| 1329 |
bVerSetMajor = true; |
| 1330 |
bVerSetMinor = true; |
| 1331 |
} |
| 1332 |
else { |
| 1333 |
if (cfgPropsAll[ePropMain_ApiVersion_Major].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1334 |
reqVersion.Major = (mfxU32)cfgPropsAll[ePropMain_ApiVersion_Major].Data.U16; |
| 1335 |
bVerSetMajor = true; |
| 1336 |
} |
| 1337 |
|
| 1338 |
if (cfgPropsAll[ePropMain_ApiVersion_Minor].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1339 |
reqVersion.Minor = (mfxU32)cfgPropsAll[ePropMain_ApiVersion_Minor].Data.U16; |
| 1340 |
bVerSetMinor = true; |
| 1341 |
} |
| 1342 |
} |
| 1343 |
} |
| 1344 |
|
| 1345 |
if (bVerSetMajor && bVerSetMinor) { |
| 1346 |
// require both Major and Minor to be set if filtering this way |
| 1347 |
if (libImplDesc->ApiVersion.Version < reqVersion.Version) |
| 1348 |
bImplValid = false; |
| 1349 |
|
| 1350 |
specialConfig->ApiVersion.Version = reqVersion.Version; |
| 1351 |
specialConfig->bIsSet_ApiVersion = true; |
| 1352 |
} |
| 1353 |
|
| 1354 |
if (bImplValid == false) |
| 1355 |
return MFX_ERR_UNSUPPORTED; |
| 1356 |
|
| 1357 |
// check whether required functions are implemented |
| 1358 |
if (!implFunctionList.empty()) { |
| 1359 |
if (!libImplFuncs) { |
| 1360 |
// library did not provide list of implemented functions |
| 1361 |
return MFX_ERR_UNSUPPORTED; |
| 1362 |
} |
| 1363 |
|
| 1364 |
auto fn = implFunctionList.begin(); |
| 1365 |
while (fn != implFunctionList.end()) { |
| 1366 |
std::string fnName = (*fn++); |
| 1367 |
mfxU32 fnIdx; |
| 1368 |
|
| 1369 |
// search for fnName in list of implemented functions |
| 1370 |
for (fnIdx = 0; fnIdx < libImplFuncs->NumFunctions; fnIdx++) { |
| 1371 |
if (fnName == libImplFuncs->FunctionsName[fnIdx]) |
| 1372 |
break; |
| 1373 |
} |
| 1374 |
|
| 1375 |
if (fnIdx == libImplFuncs->NumFunctions) |
| 1376 |
return MFX_ERR_UNSUPPORTED; |
| 1377 |
} |
| 1378 |
} |
| 1379 |
|
| 1380 |
return MFX_ERR_NONE; |
| 1381 |
} |
| 1382 |
|
| 1383 |
bool ConfigCtxVPL::CheckLowLatencyConfig(std::list<ConfigCtxVPL *> configCtxList, |
| 1384 |
SpecialConfig *specialConfig) { |
| 1385 |
mfxU32 idx; |
| 1386 |
bool bLowLatency = true; |
| 1387 |
|
| 1388 |
// initially all properties are unset |
| 1389 |
mfxVariant cfgPropsAll[eProp_TotalProps] = {}; |
| 1390 |
for (idx = 0; idx < eProp_TotalProps; idx++) |
| 1391 |
cfgPropsAll[idx].Type = MFX_VARIANT_TYPE_UNSET; |
| 1392 |
|
| 1393 |
// iterate through all filters and populate cfgPropsAll |
| 1394 |
// for purposes of low-latency enabling, we check the last (most recent) value of each filter |
| 1395 |
// property, in the case that multiple mfxConfig objects were created |
| 1396 |
// preferred usage is just to create one mfxConfig and set all of the required props in it |
| 1397 |
// Exception: there can be more than one ExtBuffer attached via multiple mfxConfig objects (API >= 2.7) |
| 1398 |
|
| 1399 |
// clear list of extension buffers |
| 1400 |
specialConfig->bIsSet_ExtBuffer = false; |
| 1401 |
specialConfig->ExtBuffers.clear(); |
| 1402 |
|
| 1403 |
auto it = configCtxList.begin(); |
| 1404 |
while (it != configCtxList.end()) { |
| 1405 |
ConfigCtxVPL *config = (*it); |
| 1406 |
it++; |
| 1407 |
|
| 1408 |
for (idx = 0; idx < eProp_TotalProps; idx++) { |
| 1409 |
// ignore unset properties |
| 1410 |
if (config->m_propVar[idx].Type == MFX_VARIANT_TYPE_UNSET) |
| 1411 |
continue; |
| 1412 |
|
| 1413 |
cfgPropsAll[idx].Type = config->m_propVar[idx].Type; |
| 1414 |
cfgPropsAll[idx].Data = config->m_propVar[idx].Data; |
| 1415 |
|
| 1416 |
if (idx == ePropSpecial_ExtBuffer) { |
| 1417 |
specialConfig->ExtBuffers.push_back( |
| 1418 |
(mfxExtBuffer *)cfgPropsAll[ePropSpecial_ExtBuffer].Data.Ptr); |
| 1419 |
specialConfig->bIsSet_ExtBuffer = true; |
| 1420 |
} |
| 1421 |
} |
| 1422 |
} |
| 1423 |
|
| 1424 |
for (mfxU32 idx = 0; idx < eProp_TotalProps; idx++) { |
| 1425 |
switch (idx) { |
| 1426 |
case ePropMain_Impl: |
| 1427 |
if (cfgPropsAll[idx].Type == MFX_VARIANT_TYPE_U32) { |
| 1428 |
if (cfgPropsAll[idx].Data.U32 == MFX_IMPL_TYPE_HARDWARE) |
| 1429 |
continue; |
| 1430 |
} |
| 1431 |
bLowLatency = false; |
| 1432 |
break; |
| 1433 |
|
| 1434 |
case ePropMain_ImplName: |
| 1435 |
if (cfgPropsAll[idx].Type == MFX_VARIANT_TYPE_PTR && cfgPropsAll[idx].Data.Ptr) { |
| 1436 |
std::string s = *(std::string *)(cfgPropsAll[idx].Data.Ptr); |
| 1437 |
if (s == "mfx-gen") |
| 1438 |
continue; |
| 1439 |
} |
| 1440 |
bLowLatency = false; |
| 1441 |
break; |
| 1442 |
|
| 1443 |
case ePropMain_VendorID: |
| 1444 |
if (cfgPropsAll[idx].Type == MFX_VARIANT_TYPE_U32) { |
| 1445 |
if (cfgPropsAll[idx].Data.U32 == 0x8086) |
| 1446 |
continue; |
| 1447 |
} |
| 1448 |
bLowLatency = false; |
| 1449 |
break; |
| 1450 |
|
| 1451 |
// application must set AccelerationMode for lowlatency - will be passed to RT in MFXInitialize() |
| 1452 |
case ePropMain_AccelerationMode: |
| 1453 |
if (cfgPropsAll[idx].Type == MFX_VARIANT_TYPE_U32) { |
| 1454 |
specialConfig->accelerationMode = |
| 1455 |
(mfxAccelerationMode)cfgPropsAll[ePropMain_AccelerationMode].Data.U32; |
| 1456 |
specialConfig->bIsSet_accelerationMode = true; |
| 1457 |
continue; |
| 1458 |
} |
| 1459 |
bLowLatency = false; |
| 1460 |
break; |
| 1461 |
|
| 1462 |
// application may set ApiVersion with lowlatency, but not required |
| 1463 |
case ePropMain_ApiVersion: |
| 1464 |
if (cfgPropsAll[ePropMain_ApiVersion].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1465 |
specialConfig->ApiVersion.Version = |
| 1466 |
(mfxU32)cfgPropsAll[ePropMain_ApiVersion].Data.U32; |
| 1467 |
specialConfig->bIsSet_ApiVersion = true; |
| 1468 |
} |
| 1469 |
break; |
| 1470 |
|
| 1471 |
// following are non-filtering properties - they may be set here or not (don't affect low latency) |
| 1472 |
case ePropSpecial_HandleType: |
| 1473 |
if (cfgPropsAll[ePropSpecial_HandleType].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1474 |
specialConfig->deviceHandleType = |
| 1475 |
(mfxHandleType)cfgPropsAll[ePropSpecial_HandleType].Data.U32; |
| 1476 |
specialConfig->bIsSet_deviceHandleType = true; |
| 1477 |
} |
| 1478 |
break; |
| 1479 |
|
| 1480 |
case ePropSpecial_Handle: |
| 1481 |
if (cfgPropsAll[ePropSpecial_Handle].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1482 |
specialConfig->deviceHandle = (mfxHDL)cfgPropsAll[ePropSpecial_Handle].Data.Ptr; |
| 1483 |
specialConfig->bIsSet_deviceHandle = true; |
| 1484 |
} |
| 1485 |
break; |
| 1486 |
|
| 1487 |
case ePropSpecial_NumThread: |
| 1488 |
if (cfgPropsAll[ePropSpecial_NumThread].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1489 |
specialConfig->NumThread = cfgPropsAll[ePropSpecial_NumThread].Data.U32; |
| 1490 |
specialConfig->bIsSet_NumThread = true; |
| 1491 |
} |
| 1492 |
break; |
| 1493 |
|
| 1494 |
case ePropSpecial_DeviceCopy: |
| 1495 |
if (cfgPropsAll[ePropSpecial_DeviceCopy].Type != MFX_VARIANT_TYPE_UNSET) { |
| 1496 |
specialConfig->DeviceCopy = cfgPropsAll[ePropSpecial_DeviceCopy].Data.U16; |
| 1497 |
specialConfig->bIsSet_DeviceCopy = true; |
| 1498 |
} |
| 1499 |
break; |
| 1500 |
|
| 1501 |
case ePropSpecial_ExtBuffer: |
| 1502 |
// extBufs were already pushed into the overall list, above |
| 1503 |
break; |
| 1504 |
|
| 1505 |
// will be passed to RT in MFXInitialize(), if unset will be 0 |
| 1506 |
case ePropSpecial_DXGIAdapterIndex: |
| 1507 |
if (cfgPropsAll[idx].Type == MFX_VARIANT_TYPE_U32) { |
| 1508 |
specialConfig->dxgiAdapterIdx = |
| 1509 |
(mfxU32)cfgPropsAll[ePropSpecial_DXGIAdapterIndex].Data.U32; |
| 1510 |
specialConfig->bIsSet_dxgiAdapterIdx = true; |
| 1511 |
continue; |
| 1512 |
} |
| 1513 |
break; |
| 1514 |
|
| 1515 |
default: |
| 1516 |
if (cfgPropsAll[idx].Type != MFX_VARIANT_TYPE_UNSET) |
| 1517 |
bLowLatency = false; |
| 1518 |
break; |
| 1519 |
} |
| 1520 |
} |
| 1521 |
|
| 1522 |
return bLowLatency; |
| 1523 |
} |
| 1524 |
|
| 1525 |
#include <gst/gst.h> |
| 1526 |
|
| 1527 |
bool ConfigCtxVPL::ParseDeviceIDx86(mfxChar *cDeviceID, mfxU32 &deviceID, mfxU32 &adapterIdx) { |
| 1528 |
std::string strDevID(cDeviceID); |
| 1529 |
// XXX: std::regex is crashing on Windows + gcc |
| 1530 |
#if 0 |
| 1531 |
std::regex reDevIDAll("[0-9a-fA-F]+/[0-9]+"); |
| 1532 |
std::regex reDevIDMin("[0-9a-fA-F]+"); |
| 1533 |
#else |
| 1534 |
static const gchar *reDevIDAll = "[0-9a-fA-F]+/[0-9]+"; |
| 1535 |
static const gchar *reDevIDMin = "[0-9a-fA-F]+"; |
| 1536 |
|
| 1537 |
if (!cDeviceID) |
| 1538 |
return false; |
| 1539 |
#endif |
| 1540 |
|
| 1541 |
deviceID = DEVICE_ID_UNKNOWN; |
| 1542 |
adapterIdx = ADAPTER_IDX_UNKNOWN; |
| 1543 |
|
| 1544 |
bool bHasAdapterIdx = false; |
| 1545 |
#if 0 |
| 1546 |
if (std::regex_match(strDevID, reDevIDAll)) { |
| 1547 |
// check for DeviceID in format "devID/adapterIdx" |
| 1548 |
// devID = hex value |
| 1549 |
// adapterIdx = decimal integer |
| 1550 |
bHasAdapterIdx = true; |
| 1551 |
} |
| 1552 |
else if (std::regex_match(strDevID, reDevIDMin)) { |
| 1553 |
// check for DeviceID in format "devID" |
| 1554 |
// (no adpaterIdx) |
| 1555 |
bHasAdapterIdx = false; |
| 1556 |
} |
| 1557 |
else { |
| 1558 |
// invalid format |
| 1559 |
return false; |
| 1560 |
} |
| 1561 |
#else |
| 1562 |
if (g_regex_match_simple(reDevIDAll, cDeviceID, |
| 1563 |
(GRegexCompileFlags)0, (GRegexMatchFlags)0)) { |
| 1564 |
// check for DeviceID in format "devID/adapterIdx" |
| 1565 |
// devID = hex value |
| 1566 |
// adapterIdx = decimal integer |
| 1567 |
bHasAdapterIdx = true; |
| 1568 |
} |
| 1569 |
else if (g_regex_match_simple(reDevIDMin, cDeviceID, |
| 1570 |
(GRegexCompileFlags)0, (GRegexMatchFlags)0)) { |
| 1571 |
// check for DeviceID in format "devID" |
| 1572 |
// (no adpaterIdx) |
| 1573 |
bHasAdapterIdx = false; |
| 1574 |
} |
| 1575 |
else { |
| 1576 |
// invalid format |
| 1577 |
return false; |
| 1578 |
} |
| 1579 |
#endif |
| 1580 |
|
| 1581 |
// get deviceID (value before the slash, if present) |
| 1582 |
try { |
| 1583 |
deviceID = std::stoi(strDevID, 0, 16); |
| 1584 |
} |
| 1585 |
catch (...) { |
| 1586 |
return false; |
| 1587 |
} |
| 1588 |
|
| 1589 |
if (bHasAdapterIdx) { |
| 1590 |
// get adapter index (value after the slash) |
| 1591 |
size_t idx = strDevID.rfind('/'); |
| 1592 |
if (idx == std::string::npos) |
| 1593 |
return false; |
| 1594 |
|
| 1595 |
try { |
| 1596 |
adapterIdx = std::stoi(strDevID.substr(idx + 1)); |
| 1597 |
} |
| 1598 |
catch (...) { |
| 1599 |
return false; |
| 1600 |
} |
| 1601 |
} |
| 1602 |
|
| 1603 |
return true; |
| 1604 |
} |