| 1 |
/* |
| 2 |
* Copyright (c) 2017-2021, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
//! |
| 23 |
//! \file media_libva_caps.cpp |
| 24 |
//! \brief This file implements the base C++ class/interface for media capbilities. |
| 25 |
//! |
| 26 |
|
| 27 |
#include "hwinfo_linux.h" |
| 28 |
#include "linux_system_info.h" |
| 29 |
#include "media_libva_util.h" |
| 30 |
#include "media_libva_vp.h" |
| 31 |
#include "media_libva_common.h" |
| 32 |
#include "media_libva_caps.h" |
| 33 |
#include "media_libva_caps_cp_interface.h" |
| 34 |
#include "media_ddi_decode_const.h" |
| 35 |
#include "media_ddi_encode_const.h" |
| 36 |
#include "media_ddi_prot.h" |
| 37 |
#include "media_libva_caps_factory.h" |
| 38 |
#include "drm_fourcc.h" |
| 39 |
|
| 40 |
typedef MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT> CapsFactory; |
| 41 |
|
| 42 |
#ifdef ANDROID |
| 43 |
#include <va/va_android.h> |
| 44 |
#endif |
| 45 |
|
| 46 |
#include "set" |
| 47 |
|
| 48 |
#ifndef VA_ENCRYPTION_TYPE_NONE |
| 49 |
#define VA_ENCRYPTION_TYPE_NONE 0x00000000 |
| 50 |
#endif |
| 51 |
|
| 52 |
|
| 53 |
const uint32_t MediaLibvaCaps::m_decSliceMode[2] = |
| 54 |
{ |
| 55 |
VA_DEC_SLICE_MODE_NORMAL, |
| 56 |
VA_DEC_SLICE_MODE_BASE |
| 57 |
}; |
| 58 |
|
| 59 |
const uint32_t MediaLibvaCaps::m_decProcessMode[2] = |
| 60 |
{ |
| 61 |
VA_DEC_PROCESSING_NONE, |
| 62 |
VA_DEC_PROCESSING |
| 63 |
}; |
| 64 |
|
| 65 |
const uint32_t MediaLibvaCaps::m_encRcMode[m_numEncRcMode] = |
| 66 |
{ |
| 67 |
VA_RC_CQP, VA_RC_CBR, VA_RC_VBR, |
| 68 |
VA_RC_CBR | VA_RC_MB, VA_RC_VBR | VA_RC_MB, |
| 69 |
VA_RC_ICQ, VA_RC_VCM, VA_RC_QVBR, VA_RC_AVBR |
| 70 |
#if VA_CHECK_VERSION(1, 10, 0) |
| 71 |
, VA_RC_TCBRC |
| 72 |
#endif |
| 73 |
}; |
| 74 |
|
| 75 |
const uint32_t MediaLibvaCaps::m_vpSurfaceAttr[m_numVpSurfaceAttr] = |
| 76 |
{ |
| 77 |
VA_FOURCC('I', '4', '2', '0'), |
| 78 |
VA_FOURCC('Y', 'V', '1', '2'), |
| 79 |
VA_FOURCC('Y', 'U', 'Y', '2'), |
| 80 |
VA_FOURCC('4', '2', '2', 'H'), |
| 81 |
VA_FOURCC('4', '2', '2', 'V'), |
| 82 |
VA_FOURCC('R', 'G', 'B', 'A'), |
| 83 |
VA_FOURCC('B', 'G', 'R', 'A'), |
| 84 |
VA_FOURCC('R', 'G', 'B', 'P'), |
| 85 |
VA_FOURCC('R', 'G', 'B', 'X'), |
| 86 |
VA_FOURCC('P', '0', '1', '0'), |
| 87 |
VA_FOURCC('R', 'G', '2', '4'), |
| 88 |
VA_FOURCC_ARGB, |
| 89 |
VA_FOURCC_ABGR, |
| 90 |
VA_FOURCC_A2R10G10B10, |
| 91 |
VA_FOURCC_A2B10G10R10, |
| 92 |
VA_FOURCC_X2R10G10B10, |
| 93 |
VA_FOURCC_X2B10G10R10, |
| 94 |
VA_FOURCC_AYUV, |
| 95 |
VA_FOURCC_Y210, |
| 96 |
VA_FOURCC_Y410, |
| 97 |
VA_FOURCC_P012, |
| 98 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 99 |
VA_FOURCC_Y212, |
| 100 |
VA_FOURCC_Y412, |
| 101 |
#endif |
| 102 |
#if VA_CHECK_VERSION(1, 13, 0) |
| 103 |
VA_FOURCC_XYUV, |
| 104 |
#else |
| 105 |
0, |
| 106 |
#endif |
| 107 |
}; |
| 108 |
|
| 109 |
const uint32_t MediaLibvaCaps::m_jpegSurfaceAttr[m_numJpegSurfaceAttr] = |
| 110 |
{ |
| 111 |
VA_FOURCC_NV12, |
| 112 |
VA_FOURCC_IMC3, |
| 113 |
VA_FOURCC_Y800, |
| 114 |
VA_FOURCC_411P, |
| 115 |
VA_FOURCC_422H, |
| 116 |
VA_FOURCC_422V, |
| 117 |
VA_FOURCC_444P, |
| 118 |
VA_FOURCC_RGBP |
| 119 |
}; |
| 120 |
|
| 121 |
const uint32_t MediaLibvaCaps::m_jpegEncSurfaceAttr[m_numJpegEncSurfaceAttr] = |
| 122 |
{ |
| 123 |
VA_FOURCC_NV12, |
| 124 |
VA_FOURCC_YUY2, |
| 125 |
VA_FOURCC_UYVY, |
| 126 |
VA_FOURCC_Y800, |
| 127 |
VA_FOURCC_ABGR |
| 128 |
}; |
| 129 |
|
| 130 |
MediaLibvaCaps::MediaLibvaCaps(DDI_MEDIA_CONTEXT *mediaCtx) |
| 131 |
{ |
| 132 |
m_mediaCtx = mediaCtx; |
| 133 |
m_CapsCp = Create_MediaLibvaCapsCpInterface(mediaCtx, this); |
| 134 |
if (m_CapsCp) |
| 135 |
{ |
| 136 |
m_isEntryptSupported = m_CapsCp->IsDecEncryptionSupported(m_mediaCtx); |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
MediaLibvaCaps::~MediaLibvaCaps() |
| 141 |
{ |
| 142 |
FreeAttributeList(); |
| 143 |
Delete_MediaLibvaCapsCpInterface(m_CapsCp); |
| 144 |
m_CapsCp = nullptr; |
| 145 |
} |
| 146 |
|
| 147 |
bool MediaLibvaCaps::CheckEntrypointCodecType(VAEntrypoint entrypoint, CodecType codecType) |
| 148 |
{ |
| 149 |
switch (codecType) |
| 150 |
{ |
| 151 |
case videoEncode: |
| 152 |
if((entrypoint == VAEntrypointEncSlice) |
| 153 |
|| (entrypoint == VAEntrypointEncSliceLP) |
| 154 |
|| (entrypoint == VAEntrypointEncPicture) |
| 155 |
|| (entrypoint == VAEntrypointFEI) |
| 156 |
|| (entrypoint == VAEntrypointStats)) |
| 157 |
{ |
| 158 |
return true; |
| 159 |
} |
| 160 |
else |
| 161 |
{ |
| 162 |
return false; |
| 163 |
} |
| 164 |
break; |
| 165 |
case videoDecode: |
| 166 |
return (entrypoint == VAEntrypointVLD); |
| 167 |
case videoProcess: |
| 168 |
if(entrypoint == VAEntrypointVideoProc) |
| 169 |
{ |
| 170 |
return true; |
| 171 |
} |
| 172 |
else |
| 173 |
{ |
| 174 |
return false; |
| 175 |
} |
| 176 |
break; |
| 177 |
case videoProtect: |
| 178 |
{ |
| 179 |
DdiMediaProtected *prot = DdiMediaProtected::GetInstance(DDI_PROTECTED_CONTENT); |
| 180 |
if (prot && prot->CheckEntrypointSupported(entrypoint)) |
| 181 |
{ |
| 182 |
return true; |
| 183 |
} |
| 184 |
return false; |
| 185 |
} |
| 186 |
break; |
| 187 |
default: |
| 188 |
DDI_ASSERTMESSAGE("DDI: Unsupported codecType"); |
| 189 |
return false; |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
VAStatus MediaLibvaCaps::AddDecConfig(uint32_t slicemode, uint32_t encryptType, uint32_t processType) |
| 194 |
{ |
| 195 |
m_decConfigs.emplace_back(slicemode, encryptType, processType); |
| 196 |
return VA_STATUS_SUCCESS; |
| 197 |
} |
| 198 |
|
| 199 |
VAStatus MediaLibvaCaps::AddEncConfig(uint32_t rcMode, uint32_t feiFunction) |
| 200 |
{ |
| 201 |
m_encConfigs.emplace_back(rcMode, feiFunction); |
| 202 |
return VA_STATUS_SUCCESS; |
| 203 |
} |
| 204 |
|
| 205 |
VAStatus MediaLibvaCaps::AddVpConfig(uint32_t attrib) |
| 206 |
{ |
| 207 |
m_vpConfigs.emplace_back(attrib); |
| 208 |
return VA_STATUS_SUCCESS; |
| 209 |
} |
| 210 |
|
| 211 |
VAStatus MediaLibvaCaps::GetProfileEntrypointFromConfigId( |
| 212 |
VAConfigID configId, |
| 213 |
VAProfile *profile, |
| 214 |
VAEntrypoint *entrypoint, |
| 215 |
int32_t *profileTableIdx) |
| 216 |
{ |
| 217 |
DDI_CHK_NULL(profile, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 218 |
DDI_CHK_NULL(entrypoint, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 219 |
DDI_CHK_NULL(profileTableIdx, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 220 |
CodecType codecType; |
| 221 |
|
| 222 |
int32_t configOffset = 0; |
| 223 |
if((configId < (DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE + m_decConfigs.size())) ) |
| 224 |
{ |
| 225 |
configOffset = configId - DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE; |
| 226 |
codecType = videoDecode; |
| 227 |
} |
| 228 |
else if( (configId >= DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE) && (configId < (DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE + m_encConfigs.size())) ) |
| 229 |
{ |
| 230 |
configOffset = configId - DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE; |
| 231 |
codecType = videoEncode; |
| 232 |
} |
| 233 |
else if( (configId >= DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE) && (configId < (DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE + m_vpConfigs.size()))) |
| 234 |
{ |
| 235 |
configOffset = configId - DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE; |
| 236 |
codecType = videoProcess; |
| 237 |
} |
| 238 |
else if( m_CapsCp->IsCpConfigId(configId) ) |
| 239 |
{ |
| 240 |
configOffset = configId - DDI_CP_GEN_CONFIG_ATTRIBUTES_BASE; |
| 241 |
codecType = videoProtect; |
| 242 |
} |
| 243 |
else |
| 244 |
{ |
| 245 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 246 |
} |
| 247 |
|
| 248 |
int32_t i; |
| 249 |
for (i = 0; i < m_profileEntryCount; i++) |
| 250 |
{ |
| 251 |
if (CheckEntrypointCodecType(m_profileEntryTbl[i].m_entrypoint, codecType)) |
| 252 |
{ |
| 253 |
int32_t configStart = m_profileEntryTbl[i].m_configStartIdx; |
| 254 |
int32_t configEnd = m_profileEntryTbl[i].m_configStartIdx + m_profileEntryTbl[i].m_configNum; |
| 255 |
if (configOffset >= configStart && configOffset < configEnd) |
| 256 |
{ |
| 257 |
break; |
| 258 |
} |
| 259 |
} |
| 260 |
} |
| 261 |
|
| 262 |
if (i == m_profileEntryCount) |
| 263 |
{ |
| 264 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 265 |
} |
| 266 |
else |
| 267 |
{ |
| 268 |
*entrypoint = m_profileEntryTbl[i].m_entrypoint; |
| 269 |
*profile = m_profileEntryTbl[i].m_profile; |
| 270 |
*profileTableIdx = i; |
| 271 |
} |
| 272 |
return VA_STATUS_SUCCESS; |
| 273 |
} |
| 274 |
|
| 275 |
VAStatus MediaLibvaCaps::AddProfileEntry( |
| 276 |
VAProfile profile, |
| 277 |
VAEntrypoint entrypoint, |
| 278 |
AttribMap *attributeList, |
| 279 |
int32_t configStartIdx, |
| 280 |
int32_t configNum) |
| 281 |
{ |
| 282 |
if (m_profileEntryCount >= m_maxProfileEntries) |
| 283 |
{ |
| 284 |
DDI_ASSERTMESSAGE("Invalid profile entrypoint number"); |
| 285 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 286 |
} |
| 287 |
m_profileEntryTbl[m_profileEntryCount].m_profile = profile; |
| 288 |
m_profileEntryTbl[m_profileEntryCount].m_entrypoint = entrypoint; |
| 289 |
m_profileEntryTbl[m_profileEntryCount].m_attributes = attributeList; |
| 290 |
m_profileEntryTbl[m_profileEntryCount].m_configStartIdx = configStartIdx; |
| 291 |
m_profileEntryTbl[m_profileEntryCount].m_configNum = configNum; |
| 292 |
m_profileEntryCount++; |
| 293 |
|
| 294 |
return VA_STATUS_SUCCESS; |
| 295 |
} |
| 296 |
|
| 297 |
int32_t MediaLibvaCaps::GetProfileTableIdx(VAProfile profile, VAEntrypoint entrypoint) |
| 298 |
{ |
| 299 |
// initialize ret value to "invalid profile" |
| 300 |
int32_t ret = -1; |
| 301 |
for (int32_t i = 0; i < m_profileEntryCount; i++) |
| 302 |
{ |
| 303 |
if (m_profileEntryTbl[i].m_profile == profile) |
| 304 |
{ |
| 305 |
//there are such profile , but no such entrypoint |
| 306 |
ret = -2; |
| 307 |
if(m_profileEntryTbl[i].m_entrypoint == entrypoint) |
| 308 |
{ |
| 309 |
return i; |
| 310 |
} |
| 311 |
} |
| 312 |
} |
| 313 |
|
| 314 |
return ret; |
| 315 |
} |
| 316 |
|
| 317 |
VAStatus MediaLibvaCaps::CreateAttributeList(AttribMap **attributeList) |
| 318 |
{ |
| 319 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 320 |
|
| 321 |
*attributeList = MOS_New(AttribMap); |
| 322 |
DDI_CHK_NULL(*attributeList, "Null pointer", VA_STATUS_ERROR_ALLOCATION_FAILED); |
| 323 |
m_attributeLists.push_back(*attributeList); |
| 324 |
|
| 325 |
return VA_STATUS_SUCCESS; |
| 326 |
} |
| 327 |
|
| 328 |
int32_t MediaLibvaCaps::GetAttributeIndex(std::vector<VAConfigAttrib> *attribList, VAConfigAttribType type) |
| 329 |
{ |
| 330 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 331 |
uint32_t attribSize = attribList->size(); |
| 332 |
for (uint32_t i = 0; i < attribSize; i++) |
| 333 |
{ |
| 334 |
if ((*attribList)[i].type == type) |
| 335 |
{ |
| 336 |
return i; |
| 337 |
} |
| 338 |
} |
| 339 |
return -1; |
| 340 |
|
| 341 |
} |
| 342 |
|
| 343 |
VAStatus MediaLibvaCaps::SetAttribute( |
| 344 |
std::vector<VAConfigAttrib> *attributeList, |
| 345 |
VAConfigAttribType type, |
| 346 |
uint32_t value) |
| 347 |
{ |
| 348 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 349 |
int32_t index = GetAttributeIndex(attributeList, type); |
| 350 |
if (index >= 0) |
| 351 |
{ |
| 352 |
(*attributeList)[index].value = value; |
| 353 |
return VA_STATUS_SUCCESS; |
| 354 |
} |
| 355 |
else |
| 356 |
{ |
| 357 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
VAStatus MediaLibvaCaps::SetAttribute( |
| 362 |
VAProfile profile, |
| 363 |
VAEntrypoint entrypoint, |
| 364 |
VAConfigAttribType type, |
| 365 |
uint32_t value) |
| 366 |
{ |
| 367 |
int32_t idx = GetProfileTableIdx(profile, entrypoint); |
| 368 |
DDI_CHK_LARGER(idx, -1, "Didn't find the profile table", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 369 |
|
| 370 |
auto attribList = m_profileEntryTbl[idx].m_attributes; |
| 371 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 372 |
|
| 373 |
(*attribList)[type] = value; |
| 374 |
return VA_STATUS_SUCCESS; |
| 375 |
} |
| 376 |
|
| 377 |
VAStatus MediaLibvaCaps::FreeAttributeList() |
| 378 |
{ |
| 379 |
uint32_t attribListCount = m_attributeLists.size(); |
| 380 |
for (uint32_t i = 0; i < attribListCount; i++) |
| 381 |
{ |
| 382 |
m_attributeLists[i]->clear(); |
| 383 |
MOS_Delete(m_attributeLists[i]); |
| 384 |
m_attributeLists[i] = nullptr; |
| 385 |
} |
| 386 |
m_attributeLists.clear(); |
| 387 |
return VA_STATUS_SUCCESS; |
| 388 |
} |
| 389 |
|
| 390 |
VAStatus MediaLibvaCaps::CheckEncRTFormat( |
| 391 |
VAProfile profile, |
| 392 |
VAEntrypoint entrypoint, |
| 393 |
VAConfigAttrib* attrib) |
| 394 |
{ |
| 395 |
DDI_CHK_NULL(attrib, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 396 |
|
| 397 |
attrib->type = VAConfigAttribRTFormat; |
| 398 |
if (profile == VAProfileJPEGBaseline) |
| 399 |
{ |
| 400 |
attrib->value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV400 | VA_RT_FORMAT_YUV411 | VA_RT_FORMAT_RGB16 | VA_RT_FORMAT_RGB32; |
| 401 |
} |
| 402 |
else if(profile == VAProfileHEVCMain10 || profile == VAProfileHEVCSccMain10) |
| 403 |
{ |
| 404 |
attrib->value = VA_RT_FORMAT_YUV420_10; |
| 405 |
} |
| 406 |
else if(profile == VAProfileHEVCMain12) |
| 407 |
{ |
| 408 |
attrib->value = VA_RT_FORMAT_YUV420_12; |
| 409 |
} |
| 410 |
else if(profile == VAProfileHEVCMain422_10) |
| 411 |
{ |
| 412 |
attrib->value = VA_RT_FORMAT_YUV422_10; |
| 413 |
} |
| 414 |
else if(profile == VAProfileHEVCMain422_12) |
| 415 |
{ |
| 416 |
attrib->value = VA_RT_FORMAT_YUV422_12; |
| 417 |
} |
| 418 |
else if(profile == VAProfileHEVCMain444 || profile == VAProfileHEVCSccMain444) |
| 419 |
{ |
| 420 |
attrib->value = VA_RT_FORMAT_YUV444; |
| 421 |
} |
| 422 |
else if(profile == VAProfileHEVCMain444_10 || profile == VAProfileHEVCSccMain444_10) |
| 423 |
{ |
| 424 |
attrib->value = VA_RT_FORMAT_YUV444_10; |
| 425 |
} |
| 426 |
else |
| 427 |
{ |
| 428 |
attrib->value = VA_RT_FORMAT_YUV420; |
| 429 |
} |
| 430 |
|
| 431 |
EncodeFormat format = Others; |
| 432 |
EncodeType type = entrypoint == VAEntrypointEncSliceLP ? Vdenc : DualPipe; |
| 433 |
struct EncodeFormatTable* encodeFormatTable = m_encodeFormatTable; |
| 434 |
|
| 435 |
if(IsAvcProfile(profile)) |
| 436 |
{ |
| 437 |
format = AVC; |
| 438 |
} |
| 439 |
else if(IsHevcProfile(profile)) |
| 440 |
{ |
| 441 |
format = HEVC; |
| 442 |
} |
| 443 |
else if(IsVp9Profile(profile)) |
| 444 |
{ |
| 445 |
format = VP9; |
| 446 |
} |
| 447 |
|
| 448 |
for(uint32_t i = 0; i < m_encodeFormatCount && encodeFormatTable != nullptr; encodeFormatTable++, i++) |
| 449 |
{ |
| 450 |
if(encodeFormatTable->encodeFormat == format |
| 451 |
&& encodeFormatTable->encodeType == type) |
| 452 |
{ |
| 453 |
attrib->value = encodeFormatTable->colorFormat; |
| 454 |
break; |
| 455 |
} |
| 456 |
} |
| 457 |
|
| 458 |
return VA_STATUS_SUCCESS; |
| 459 |
} |
| 460 |
|
| 461 |
VAStatus MediaLibvaCaps::CheckAttribList( |
| 462 |
VAProfile profile, |
| 463 |
VAEntrypoint entrypoint, |
| 464 |
VAConfigAttrib* attrib, |
| 465 |
int32_t numAttribs) |
| 466 |
{ |
| 467 |
int32_t idx = GetProfileTableIdx(profile, entrypoint); |
| 468 |
if(idx < 0) |
| 469 |
{ |
| 470 |
return VA_STATUS_ERROR_INVALID_VALUE; |
| 471 |
} |
| 472 |
|
| 473 |
DdiMediaProtected *prot = DdiMediaProtected::GetInstance(DDI_PROTECTED_CONTENT); |
| 474 |
if (prot && |
| 475 |
prot->CheckEntrypointSupported(entrypoint) && |
| 476 |
prot->CheckAttribList(profile, entrypoint, attrib, numAttribs)) |
| 477 |
{ |
| 478 |
return VA_STATUS_SUCCESS; |
| 479 |
} |
| 480 |
|
| 481 |
for(int32_t j = 0; j < numAttribs; j ++) |
| 482 |
{ |
| 483 |
bool isValidAttrib = false; |
| 484 |
|
| 485 |
//temp solution for MV tools, after tool change, it should be removed |
| 486 |
if(attrib[j].type == VAConfigAttribEncDynamicScaling |
| 487 |
||attrib[j].type == VAConfigAttribEncRateControlExt |
| 488 |
||attrib[j].type == VAConfigAttribEncTileSupport) |
| 489 |
{ |
| 490 |
if(attrib[j].value == VA_ATTRIB_NOT_SUPPORTED) |
| 491 |
{ |
| 492 |
isValidAttrib = true; |
| 493 |
continue; |
| 494 |
} |
| 495 |
} |
| 496 |
|
| 497 |
if (m_profileEntryTbl[idx].m_attributes->find(attrib[j].type) != |
| 498 |
m_profileEntryTbl[idx].m_attributes->end()) |
| 499 |
{ |
| 500 |
isValidAttrib = false; |
| 501 |
|
| 502 |
if(attrib[j].value == m_configAttribNone) |
| 503 |
{ |
| 504 |
isValidAttrib = true; |
| 505 |
continue; |
| 506 |
} |
| 507 |
if(attrib[j].type == VAConfigAttribRTFormat |
| 508 |
||attrib[j].type == VAConfigAttribDecSliceMode |
| 509 |
||attrib[j].type == VAConfigAttribDecJPEG |
| 510 |
||attrib[j].type == VAConfigAttribRateControl |
| 511 |
||attrib[j].type == VAConfigAttribEncPackedHeaders |
| 512 |
||attrib[j].type == VAConfigAttribEncIntraRefresh |
| 513 |
||attrib[j].type == VAConfigAttribFEIFunctionType |
| 514 |
||attrib[j].type == VAConfigAttribEncryption) |
| 515 |
{ |
| 516 |
if(((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] & attrib[j].value) == attrib[j].value) |
| 517 |
{ |
| 518 |
isValidAttrib = true; |
| 519 |
continue; |
| 520 |
} |
| 521 |
else if(attrib[j].type == VAConfigAttribRTFormat) |
| 522 |
{ |
| 523 |
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; |
| 524 |
} |
| 525 |
} |
| 526 |
else if((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] == attrib[j].value) |
| 527 |
{ |
| 528 |
isValidAttrib = true; |
| 529 |
continue; |
| 530 |
} |
| 531 |
else if(attrib[j].type == VAConfigAttribEncSliceStructure) |
| 532 |
{ |
| 533 |
if(((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] & attrib[j].value) == attrib[j].value) |
| 534 |
{ |
| 535 |
isValidAttrib = true; |
| 536 |
continue; |
| 537 |
} |
| 538 |
|
| 539 |
if((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS) |
| 540 |
{ |
| 541 |
if((attrib[j].value & VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS) |
| 542 |
||(attrib[j].value & VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS) |
| 543 |
||(attrib[j].value & VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS) |
| 544 |
||(attrib[j].value & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS)) |
| 545 |
{ |
| 546 |
isValidAttrib = true; |
| 547 |
continue; |
| 548 |
} |
| 549 |
} |
| 550 |
else if ((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] & |
| 551 |
(VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS | VA_ENC_SLICE_STRUCTURE_MAX_SLICE_SIZE)) |
| 552 |
{ |
| 553 |
if((attrib[j].value & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS) |
| 554 |
||(attrib[j].value & VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS) |
| 555 |
||(attrib[j].value & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS)) |
| 556 |
{ |
| 557 |
isValidAttrib = true; |
| 558 |
continue; |
| 559 |
} |
| 560 |
} |
| 561 |
} |
| 562 |
else if((attrib[j].type == VAConfigAttribMaxPictureWidth) |
| 563 |
|| (attrib[j].type == VAConfigAttribMaxPictureHeight) |
| 564 |
|| (attrib[j].type == VAConfigAttribEncROI) |
| 565 |
|| (attrib[j].type == VAConfigAttribEncDirtyRect)) |
| 566 |
{ |
| 567 |
if(attrib[j].value <= (*m_profileEntryTbl[idx].m_attributes)[attrib[j].type]) |
| 568 |
{ |
| 569 |
isValidAttrib = true; |
| 570 |
continue; |
| 571 |
} |
| 572 |
} |
| 573 |
else if(attrib[j].type == VAConfigAttribEncMaxRefFrames) |
| 574 |
{ |
| 575 |
if(((attrib[j].value & 0xffff) <= ((*m_profileEntryTbl[idx].m_attributes)[attrib[j].type] & 0xffff)) |
| 576 |
&&(attrib[j].value <= (*m_profileEntryTbl[idx].m_attributes)[attrib[j].type])) //high16 bit can compare with this way |
| 577 |
{ |
| 578 |
isValidAttrib = true; |
| 579 |
continue; |
| 580 |
} |
| 581 |
} |
| 582 |
else if(attrib[j].type == VAConfigAttribEncJPEG) |
| 583 |
{ |
| 584 |
VAConfigAttribValEncJPEG jpegValue, jpegSetValue; |
| 585 |
jpegValue.value = attrib[j].value; |
| 586 |
jpegSetValue.value = (*m_profileEntryTbl[idx].m_attributes)[attrib[j].type]; |
| 587 |
if((jpegValue.bits.max_num_quantization_tables <= jpegSetValue.bits.max_num_quantization_tables) |
| 588 |
&&(jpegValue.bits.max_num_huffman_tables <= jpegSetValue.bits.max_num_huffman_tables) |
| 589 |
&&(jpegValue.bits.max_num_scans <= jpegSetValue.bits.max_num_scans) |
| 590 |
&&(jpegValue.bits.max_num_components <= jpegSetValue.bits.max_num_components)) |
| 591 |
{ |
| 592 |
isValidAttrib = true; |
| 593 |
continue; |
| 594 |
} |
| 595 |
} |
| 596 |
|
| 597 |
} |
| 598 |
//should be removed after msdk remove VAConfigAttribSpatialResidual attributes for VPP |
| 599 |
else if((profile == VAProfileNone) |
| 600 |
&& (entrypoint == VAEntrypointVideoProc) |
| 601 |
&& (attrib[j].type == VAConfigAttribSpatialClipping)) |
| 602 |
{ |
| 603 |
isValidAttrib = true; |
| 604 |
continue; |
| 605 |
} |
| 606 |
else if((profile == VAProfileNone) |
| 607 |
&& (attrib[j].type == VAConfigAttribStats)) |
| 608 |
{ |
| 609 |
isValidAttrib = true; |
| 610 |
continue; |
| 611 |
} |
| 612 |
|
| 613 |
if(!isValidAttrib) |
| 614 |
{ |
| 615 |
return VA_STATUS_ERROR_INVALID_VALUE; |
| 616 |
} |
| 617 |
} |
| 618 |
return VA_STATUS_SUCCESS; |
| 619 |
} |
| 620 |
|
| 621 |
VAStatus MediaLibvaCaps::GetGeneralConfigAttrib(VAConfigAttrib* attrib) |
| 622 |
{ |
| 623 |
DDI_CHK_NULL(attrib, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 624 |
|
| 625 |
VAStatus status = VA_STATUS_SUCCESS; |
| 626 |
#if VA_CHECK_VERSION(1, 10, 0) |
| 627 |
if (attrib->type == VAConfigAttribContextPriority) |
| 628 |
{ |
| 629 |
attrib->value = CONTEXT_PRIORITY_MAX; |
| 630 |
} |
| 631 |
else |
| 632 |
#endif |
| 633 |
{ |
| 634 |
status = VA_ATTRIB_NOT_SUPPORTED; |
| 635 |
} |
| 636 |
return status; |
| 637 |
} |
| 638 |
|
| 639 |
VAStatus MediaLibvaCaps::CreateEncAttributes( |
| 640 |
VAProfile profile, |
| 641 |
VAEntrypoint entrypoint, |
| 642 |
AttribMap **attributeList) |
| 643 |
{ |
| 644 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 645 |
|
| 646 |
VAStatus status = CreateAttributeList(attributeList); |
| 647 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 648 |
|
| 649 |
auto attribList = *attributeList; |
| 650 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 651 |
|
| 652 |
VAConfigAttrib attrib; |
| 653 |
attrib.type = VAConfigAttribRTFormat; |
| 654 |
status = CheckEncRTFormat(profile, entrypoint, &attrib); |
| 655 |
DDI_CHK_RET(status, "Failed to Check Encode RT Format!"); |
| 656 |
(*attribList)[attrib.type] = attrib.value; |
| 657 |
|
| 658 |
attrib.type = VAConfigAttribMaxPictureWidth; |
| 659 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 660 |
VAConfigAttribMaxPictureWidth, &attrib.value); |
| 661 |
if(IsMpeg2Profile(profile)) |
| 662 |
{ |
| 663 |
attrib.value = CODEC_2K_MAX_PIC_WIDTH; |
| 664 |
} |
| 665 |
(*attribList)[attrib.type] = attrib.value; |
| 666 |
|
| 667 |
attrib.type = VAConfigAttribMaxPictureHeight; |
| 668 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 669 |
VAConfigAttribMaxPictureHeight, &attrib.value); |
| 670 |
if(IsMpeg2Profile(profile)) |
| 671 |
{ |
| 672 |
attrib.value = CODEC_2K_MAX_PIC_HEIGHT; |
| 673 |
} |
| 674 |
(*attribList)[attrib.type] = attrib.value; |
| 675 |
|
| 676 |
if (profile == VAProfileJPEGBaseline) |
| 677 |
{ |
| 678 |
attrib.type = VAConfigAttribEncJPEG; |
| 679 |
VAConfigAttribValEncJPEG jpegAttribVal; |
| 680 |
jpegAttribVal.bits.arithmatic_coding_mode = 0; |
| 681 |
jpegAttribVal.bits.progressive_dct_mode = 0; |
| 682 |
jpegAttribVal.bits.non_interleaved_mode = 0; |
| 683 |
jpegAttribVal.bits.differential_mode = 0; |
| 684 |
jpegAttribVal.bits.max_num_components = jpegNumComponent; |
| 685 |
jpegAttribVal.bits.max_num_scans = 1; |
| 686 |
jpegAttribVal.bits.max_num_huffman_tables = JPEG_MAX_NUM_HUFF_TABLE_INDEX; |
| 687 |
jpegAttribVal.bits.max_num_quantization_tables = JPEG_MAX_QUANT_TABLE; |
| 688 |
attrib.value = jpegAttribVal.value; |
| 689 |
(*attribList)[attrib.type] = attrib.value; |
| 690 |
} |
| 691 |
|
| 692 |
attrib.type = VAConfigAttribEncQualityRange; |
| 693 |
if (profile == VAProfileJPEGBaseline) |
| 694 |
{ |
| 695 |
// JPEG has no target usage. |
| 696 |
attrib.value = 1; |
| 697 |
} |
| 698 |
else |
| 699 |
{ |
| 700 |
attrib.value = NUM_TARGET_USAGE_MODES - 1;// Indicates TUs from 1 upto the value reported are supported |
| 701 |
} |
| 702 |
(*attribList)[attrib.type] = attrib.value; |
| 703 |
|
| 704 |
attrib.type = VAConfigAttribEncPackedHeaders; |
| 705 |
attrib.value = VA_ATTRIB_NOT_SUPPORTED; |
| 706 |
if ((IsAvcProfile(profile))||(IsHevcProfile(profile))) |
| 707 |
{ |
| 708 |
attrib.value = VA_ENC_PACKED_HEADER_PICTURE | |
| 709 |
VA_ENC_PACKED_HEADER_SEQUENCE | |
| 710 |
VA_ENC_PACKED_HEADER_SLICE | |
| 711 |
VA_ENC_PACKED_HEADER_RAW_DATA | |
| 712 |
VA_ENC_PACKED_HEADER_MISC; |
| 713 |
} |
| 714 |
else if (IsMpeg2Profile(profile)) |
| 715 |
{ |
| 716 |
attrib.value = VA_ENC_PACKED_HEADER_RAW_DATA; |
| 717 |
} |
| 718 |
else if(IsJpegProfile(profile)) |
| 719 |
{ |
| 720 |
attrib.value = VA_ENC_PACKED_HEADER_RAW_DATA; |
| 721 |
} |
| 722 |
else if(IsVp9Profile(profile)) |
| 723 |
{ |
| 724 |
attrib.value = VA_ENC_PACKED_HEADER_RAW_DATA; |
| 725 |
} |
| 726 |
else if(IsVp8Profile(profile)) |
| 727 |
{ |
| 728 |
attrib.value = VA_ENC_PACKED_HEADER_NONE; |
| 729 |
} |
| 730 |
|
| 731 |
(*attribList)[attrib.type] = attrib.value; |
| 732 |
if(IsJpegProfile(profile)) |
| 733 |
{ |
| 734 |
return status; |
| 735 |
} |
| 736 |
|
| 737 |
attrib.type = VAConfigAttribRateControl; |
| 738 |
attrib.value = VA_RC_CQP; |
| 739 |
if (entrypoint != VAEntrypointEncSliceLP || |
| 740 |
(entrypoint == VAEntrypointEncSliceLP && MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels))) |
| 741 |
{ |
| 742 |
attrib.value |= VA_RC_CBR | VA_RC_VBR | VA_RC_MB; |
| 743 |
|
| 744 |
if (IsHevcProfile(profile)) |
| 745 |
{ |
| 746 |
if (entrypoint != VAEntrypointEncSliceLP) |
| 747 |
attrib.value |= VA_RC_ICQ | VA_RC_QVBR; |
| 748 |
|
| 749 |
attrib.value |= VA_RC_VCM; |
| 750 |
} |
| 751 |
} |
| 752 |
if (IsAvcProfile(profile) && (entrypoint != VAEntrypointEncSliceLP)) |
| 753 |
{ |
| 754 |
attrib.value |= VA_RC_ICQ | VA_RC_VCM | VA_RC_QVBR | VA_RC_AVBR; |
| 755 |
} |
| 756 |
if (IsAvcProfile(profile) && |
| 757 |
((entrypoint == VAEntrypointEncSliceLP) && MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels))) |
| 758 |
{ |
| 759 |
attrib.value |= VA_RC_QVBR; |
| 760 |
} |
| 761 |
if(entrypoint == VAEntrypointFEI) |
| 762 |
{ |
| 763 |
attrib.value = VA_RC_CQP; |
| 764 |
} |
| 765 |
else if(entrypoint == VAEntrypointStats) |
| 766 |
{ |
| 767 |
attrib.value = VA_RC_NONE; |
| 768 |
} |
| 769 |
(*attribList)[attrib.type] = attrib.value; |
| 770 |
|
| 771 |
attrib.type = VAConfigAttribEncInterlaced; |
| 772 |
attrib.value = VA_ENC_INTERLACED_NONE; |
| 773 |
#ifndef ANDROID |
| 774 |
if(IsAvcProfile(profile) && (entrypoint != VAEntrypointEncSliceLP)) |
| 775 |
{ |
| 776 |
attrib.value = VA_ENC_INTERLACED_FIELD; |
| 777 |
} |
| 778 |
if(IsMpeg2Profile(profile)) |
| 779 |
{ |
| 780 |
attrib.value = VA_ENC_INTERLACED_FRAME; |
| 781 |
} |
| 782 |
#endif |
| 783 |
(*attribList)[attrib.type] = attrib.value; |
| 784 |
|
| 785 |
attrib.type = VAConfigAttribEncMaxRefFrames; |
| 786 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 787 |
{ |
| 788 |
//VDEnc Low delay P |
| 789 |
attrib.value = DDI_CODEC_VDENC_MAX_L0_REF_FRAMES | (DDI_CODEC_VDENC_MAX_L1_REF_FRAMES << DDI_CODEC_LEFT_SHIFT_FOR_REFLIST1); |
| 790 |
if(IsHevcProfile(profile)) |
| 791 |
{ |
| 792 |
//VDEnc Low Delay B, for B frame, it should be 3, 1 instead of this value, but libva could distinguish it with different frame type now |
| 793 |
attrib.value = DDI_CODEC_VDENC_MAX_L0_REF_FRAMES_LDB | (DDI_CODEC_VDENC_MAX_L1_REF_FRAMES_LDB << DDI_CODEC_LEFT_SHIFT_FOR_REFLIST1); |
| 794 |
} |
| 795 |
} |
| 796 |
else |
| 797 |
{ |
| 798 |
// default value: 1 frame for each reference list |
| 799 |
attrib.value = 1 | (1 << 16); |
| 800 |
if(IsAvcProfile(profile)) |
| 801 |
{ |
| 802 |
attrib.value = CODECHAL_ENCODE_NUM_MAX_VME_L0_REF | (CODECHAL_ENCODE_NUM_MAX_VME_L1_REF << 16); |
| 803 |
} |
| 804 |
if(IsVp8Profile(profile)) |
| 805 |
{ |
| 806 |
attrib.value = ENCODE_VP8_NUM_MAX_L0_REF ; |
| 807 |
} |
| 808 |
if(IsVp9Profile(profile)) |
| 809 |
{ |
| 810 |
attrib.value = ENCODE_VP9_NUM_MAX_L0_REF; |
| 811 |
} |
| 812 |
if (IsHevcProfile(profile)) |
| 813 |
{ |
| 814 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 815 |
VAConfigAttribEncMaxRefFrames, &attrib.value); |
| 816 |
} |
| 817 |
} |
| 818 |
(*attribList)[attrib.type] = attrib.value; |
| 819 |
|
| 820 |
attrib.type = VAConfigAttribEncMaxSlices; |
| 821 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 822 |
{ |
| 823 |
if (IsAvcProfile(profile)) |
| 824 |
{ |
| 825 |
attrib.value = ENCODE_AVC_MAX_SLICES_SUPPORTED; |
| 826 |
} |
| 827 |
else if (IsHevcProfile(profile)) |
| 828 |
{ |
| 829 |
attrib.value = ENCODE_HEVC_VDENC_NUM_MAX_SLICES; |
| 830 |
} |
| 831 |
} |
| 832 |
else |
| 833 |
{ |
| 834 |
attrib.value = 0; |
| 835 |
if (IsAvcProfile(profile)) |
| 836 |
{ |
| 837 |
attrib.value = ENCODE_AVC_MAX_SLICES_SUPPORTED; |
| 838 |
} |
| 839 |
else if (IsHevcProfile(profile)) |
| 840 |
{ |
| 841 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 842 |
VAConfigAttribEncMaxSlices, &attrib.value); |
| 843 |
} |
| 844 |
} |
| 845 |
(*attribList)[attrib.type] = attrib.value; |
| 846 |
|
| 847 |
attrib.type = VAConfigAttribEncSliceStructure; |
| 848 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 849 |
{ |
| 850 |
attrib.value = VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS | VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS |
| 851 |
| VA_ENC_SLICE_STRUCTURE_MAX_SLICE_SIZE; |
| 852 |
} |
| 853 |
else |
| 854 |
{ |
| 855 |
attrib.value = VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS; |
| 856 |
} |
| 857 |
(*attribList)[attrib.type] = attrib.value; |
| 858 |
|
| 859 |
attrib.type = VAConfigAttribEncQuantization; |
| 860 |
if(IsAvcProfile(profile)) |
| 861 |
{ |
| 862 |
attrib.value = VA_ENC_QUANTIZATION_TRELLIS_SUPPORTED; |
| 863 |
} |
| 864 |
else |
| 865 |
{ |
| 866 |
attrib.value = VA_ENC_QUANTIZATION_NONE; |
| 867 |
} |
| 868 |
(*attribList)[attrib.type] = attrib.value; |
| 869 |
|
| 870 |
attrib.type = VAConfigAttribEncIntraRefresh; |
| 871 |
attrib.value = VA_ENC_INTRA_REFRESH_NONE; |
| 872 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 873 |
VAConfigAttribEncIntraRefresh, &attrib.value); |
| 874 |
(*attribList)[attrib.type] = attrib.value; |
| 875 |
|
| 876 |
attrib.type = VAConfigAttribEncSkipFrame; |
| 877 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 878 |
{ |
| 879 |
if (IsAvcProfile(profile)) |
| 880 |
{ |
| 881 |
attrib.value = 1; |
| 882 |
} |
| 883 |
else |
| 884 |
{ |
| 885 |
attrib.value = 0; |
| 886 |
} |
| 887 |
} |
| 888 |
else |
| 889 |
{ |
| 890 |
attrib.value = 1; |
| 891 |
} |
| 892 |
(*attribList)[attrib.type] = attrib.value; |
| 893 |
|
| 894 |
attrib.type = VAConfigAttribEncryption; |
| 895 |
attrib.value = VA_ATTRIB_NOT_SUPPORTED; |
| 896 |
if (m_isEntryptSupported) |
| 897 |
{ |
| 898 |
attrib.value = 0; |
| 899 |
uint32_t encryptTypes[DDI_CP_ENCRYPT_TYPES_NUM] = {0}; |
| 900 |
int32_t numTypes = m_CapsCp->GetEncryptionTypes(profile, |
| 901 |
encryptTypes, DDI_CP_ENCRYPT_TYPES_NUM); |
| 902 |
if (numTypes > 0) |
| 903 |
{ |
| 904 |
for (int32_t j = 0; j < numTypes; j++) |
| 905 |
{ |
| 906 |
attrib.value |= encryptTypes[j]; |
| 907 |
} |
| 908 |
} |
| 909 |
} |
| 910 |
(*attribList)[attrib.type] = attrib.value; |
| 911 |
|
| 912 |
attrib.type = VAConfigAttribEncROI; |
| 913 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 914 |
{ |
| 915 |
VAConfigAttribValEncROI roi_attrib = {0}; |
| 916 |
if (IsAvcProfile(profile)) |
| 917 |
{ |
| 918 |
roi_attrib.bits.num_roi_regions = ENCODE_VDENC_AVC_MAX_ROI_NUMBER_G9; |
| 919 |
} |
| 920 |
else if (IsHevcProfile(profile)) |
| 921 |
{ |
| 922 |
roi_attrib.bits.num_roi_regions = CODECHAL_ENCODE_HEVC_MAX_NUM_ROI; |
| 923 |
} |
| 924 |
|
| 925 |
roi_attrib.bits.roi_rc_priority_support = 0; |
| 926 |
roi_attrib.bits.roi_rc_qp_delta_support = 1; |
| 927 |
|
| 928 |
attrib.value = roi_attrib.value; |
| 929 |
} |
| 930 |
else |
| 931 |
{ |
| 932 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 933 |
VAConfigAttribEncROI, &attrib.value); |
| 934 |
} |
| 935 |
(*attribList)[attrib.type] = attrib.value; |
| 936 |
|
| 937 |
attrib.type = VAConfigAttribProcessingRate; |
| 938 |
attrib.value = VA_PROCESSING_RATE_ENCODE; |
| 939 |
(*attribList)[attrib.type] = attrib.value; |
| 940 |
|
| 941 |
attrib.type = (VAConfigAttribType)VAConfigAttribEncDirtyRect; |
| 942 |
attrib.value = 4; |
| 943 |
(*attribList)[attrib.type] = attrib.value; |
| 944 |
|
| 945 |
attrib.type = VAConfigAttribEncParallelRateControl; |
| 946 |
attrib.value = 1; |
| 947 |
(*attribList)[attrib.type] = attrib.value; |
| 948 |
|
| 949 |
if ((entrypoint == VAEntrypointFEI) && (IsAvcProfile(profile) || IsHevcProfile(profile))) |
| 950 |
{ |
| 951 |
attrib.type = (VAConfigAttribType)VAConfigAttribFEIFunctionType; |
| 952 |
attrib.value = IsAvcProfile(profile) ? |
| 953 |
(VA_FEI_FUNCTION_ENC | VA_FEI_FUNCTION_PAK | VA_FEI_FUNCTION_ENC_PAK) : |
| 954 |
VA_FEI_FUNCTION_ENC_PAK; |
| 955 |
(*attribList)[attrib.type] = attrib.value; |
| 956 |
} |
| 957 |
|
| 958 |
attrib.type = (VAConfigAttribType)VAConfigAttribFEIMVPredictors; |
| 959 |
attrib.value = 0; |
| 960 |
if(IsAvcProfile(profile) || IsHevcProfile(profile)) |
| 961 |
{ |
| 962 |
attrib.value = DDI_CODEC_FEI_MAX_NUM_MVPREDICTOR; |
| 963 |
} |
| 964 |
(*attribList)[attrib.type] = attrib.value; |
| 965 |
|
| 966 |
if(profile == VAProfileNone) |
| 967 |
{ |
| 968 |
attrib.type = (VAConfigAttribType)VAConfigAttribStats; |
| 969 |
VAConfigAttribValStats attribValStats; |
| 970 |
memset(&attribValStats, 0, sizeof(attribValStats)); |
| 971 |
attribValStats.bits.max_num_past_references = DDI_CODEC_STATS_MAX_NUM_PAST_REFS; |
| 972 |
attribValStats.bits.max_num_future_references = DDI_CODEC_STATS_MAX_NUM_FUTURE_REFS; |
| 973 |
attribValStats.bits.num_outputs = DDI_CODEC_STATS_MAX_NUM_OUTPUTS; |
| 974 |
attribValStats.bits.interlaced = DDI_CODEC_STATS_INTERLACED_SUPPORT; |
| 975 |
attrib.value = attribValStats.value; |
| 976 |
(*attribList)[attrib.type] = attrib.value; |
| 977 |
} |
| 978 |
|
| 979 |
attrib.type = (VAConfigAttribType)VAConfigAttribCustomRoundingControl; |
| 980 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 981 |
(VAConfigAttribType)VAConfigAttribCustomRoundingControl, &attrib.value); |
| 982 |
(*attribList)[attrib.type] = attrib.value; |
| 983 |
|
| 984 |
if(IsAvcProfile(profile)) |
| 985 |
{ |
| 986 |
// Use VAConfigAttribQPBlockSize to report MBQP support: |
| 987 |
// >0 means supported, 0 unsupported. Previous versions of driver |
| 988 |
// return VA_ATTRIB_NOT_SUPPORTED for that attribute. |
| 989 |
attrib.type = VAConfigAttribQPBlockSize; |
| 990 |
if(entrypoint == VAEntrypointEncSliceLP) |
| 991 |
{ |
| 992 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 993 |
VAConfigAttribQPBlockSize, &attrib.value); |
| 994 |
if(attrib.value == VA_ATTRIB_NOT_SUPPORTED) |
| 995 |
{ |
| 996 |
attrib.value = 0; |
| 997 |
} |
| 998 |
} else |
| 999 |
{ |
| 1000 |
// MBQP always supported for VME |
| 1001 |
attrib.value = CODECHAL_MACROBLOCK_WIDTH; |
| 1002 |
} |
| 1003 |
(*attribList)[attrib.type] = attrib.value; |
| 1004 |
} |
| 1005 |
|
| 1006 |
if (IsAvcProfile(profile)) |
| 1007 |
{ |
| 1008 |
attrib.type = (VAConfigAttribType)VAConfigAttribMaxFrameSize; |
| 1009 |
VAConfigAttribValMaxFrameSize attribValMaxFrameSize; |
| 1010 |
memset(&attribValMaxFrameSize, 0, sizeof(attribValMaxFrameSize)); |
| 1011 |
attribValMaxFrameSize.bits.max_frame_size = 1; |
| 1012 |
attribValMaxFrameSize.bits.multiple_pass = 1; |
| 1013 |
attribValMaxFrameSize.bits.reserved = 0; |
| 1014 |
attrib.value = attribValMaxFrameSize.value; |
| 1015 |
(*attribList)[attrib.type] = attrib.value; |
| 1016 |
} |
| 1017 |
|
| 1018 |
if (IsHevcProfile(profile)) |
| 1019 |
{ |
| 1020 |
attrib.type = (VAConfigAttribType) VAConfigAttribPredictionDirection; |
| 1021 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 1022 |
VAConfigAttribPredictionDirection, &attrib.value); |
| 1023 |
(*attribList)[attrib.type] = attrib.value; |
| 1024 |
} |
| 1025 |
return status; |
| 1026 |
} |
| 1027 |
|
| 1028 |
VAStatus MediaLibvaCaps::CreateDecAttributes( |
| 1029 |
VAProfile profile, |
| 1030 |
VAEntrypoint entrypoint, |
| 1031 |
AttribMap **attributeList) |
| 1032 |
{ |
| 1033 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1034 |
|
| 1035 |
VAStatus status = CreateAttributeList(attributeList); |
| 1036 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1037 |
|
| 1038 |
auto attribList = *attributeList; |
| 1039 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1040 |
|
| 1041 |
VAConfigAttrib attrib; |
| 1042 |
attrib.type = VAConfigAttribRTFormat; |
| 1043 |
if ( profile == VAProfileJPEGBaseline ) |
| 1044 |
{ |
| 1045 |
// at present, latest libva have not support RGB24. |
| 1046 |
attrib.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV400 | VA_RT_FORMAT_YUV411 | VA_RT_FORMAT_RGB16 | VA_RT_FORMAT_RGB32; |
| 1047 |
} |
| 1048 |
else if(profile == VAProfileHEVCMain10) |
| 1049 |
{ |
| 1050 |
attrib.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10; |
| 1051 |
} |
| 1052 |
else if(profile == VAProfileHEVCMain422_10) |
| 1053 |
{ |
| 1054 |
attrib.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV400 | VA_RT_FORMAT_YUV420_10 | VA_RT_FORMAT_YUV422_10; |
| 1055 |
} |
| 1056 |
else |
| 1057 |
{ |
| 1058 |
attrib.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_RGB32; |
| 1059 |
} |
| 1060 |
(*attribList)[attrib.type] = attrib.value; |
| 1061 |
|
| 1062 |
attrib.type = VAConfigAttribDecSliceMode; |
| 1063 |
if (IsAvcProfile(profile)) |
| 1064 |
{ |
| 1065 |
attrib.value = VA_DEC_SLICE_MODE_NORMAL | VA_DEC_SLICE_MODE_BASE; |
| 1066 |
} |
| 1067 |
else if (IsHevcProfile(profile)) |
| 1068 |
{ |
| 1069 |
bool hevcmainProfileSupported = false; |
| 1070 |
attrib.value = 0; |
| 1071 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMainDecoding) |
| 1072 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain10Decoding) |
| 1073 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit420Decoding) |
| 1074 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD42210bitDecoding) |
| 1075 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit422Decoding) |
| 1076 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD4448bitDecoding) |
| 1077 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD44410bitDecoding) |
| 1078 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit444Decoding)) |
| 1079 |
{ |
| 1080 |
attrib.value |= VA_DEC_SLICE_MODE_NORMAL; |
| 1081 |
hevcmainProfileSupported = true; |
| 1082 |
} |
| 1083 |
if ((MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrHEVCVLDMainShortDecoding) || |
| 1084 |
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrHEVCVLDMain10ShortDecoding)) |
| 1085 |
&& MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)) |
| 1086 |
{ |
| 1087 |
attrib.value |= VA_DEC_SLICE_MODE_BASE; |
| 1088 |
hevcmainProfileSupported = true; |
| 1089 |
} |
| 1090 |
if (!hevcmainProfileSupported) |
| 1091 |
{ |
| 1092 |
attrib.value = VA_ATTRIB_NOT_SUPPORTED; |
| 1093 |
} |
| 1094 |
} |
| 1095 |
else if (profile == VAProfileVP9Profile0 |
| 1096 |
|| profile == VAProfileVP9Profile2 |
| 1097 |
|| profile == VAProfileVP9Profile1 |
| 1098 |
|| profile == VAProfileVP9Profile3) |
| 1099 |
{ |
| 1100 |
bool vp9ProfileSupported = false; |
| 1101 |
attrib.value = 0; |
| 1102 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile0Decoding8bit420) |
| 1103 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile1Decoding8bit444)) |
| 1104 |
{ |
| 1105 |
attrib.value |= VA_DEC_SLICE_MODE_NORMAL | VA_DEC_SLICE_MODE_BASE; |
| 1106 |
vp9ProfileSupported = true; |
| 1107 |
} |
| 1108 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrVP9VLD10bProfile2Decoding) |
| 1109 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding10bit444)) |
| 1110 |
{ |
| 1111 |
attrib.value |= VA_DEC_SLICE_MODE_NORMAL; |
| 1112 |
vp9ProfileSupported = true; |
| 1113 |
} |
| 1114 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile2Decoding10bit420)) |
| 1115 |
{ |
| 1116 |
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV420_10; |
| 1117 |
attrib.value |= VA_DEC_SLICE_MODE_NORMAL; |
| 1118 |
vp9ProfileSupported = true; |
| 1119 |
} |
| 1120 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile2Decoding12bit420) |
| 1121 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding12bit444)) |
| 1122 |
{ |
| 1123 |
attrib.value |= VA_DEC_SLICE_MODE_NORMAL; |
| 1124 |
vp9ProfileSupported = true; |
| 1125 |
} |
| 1126 |
if (!vp9ProfileSupported) |
| 1127 |
{ |
| 1128 |
attrib.value = VA_ATTRIB_NOT_SUPPORTED; |
| 1129 |
} |
| 1130 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile1Decoding8bit444)) |
| 1131 |
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV444; |
| 1132 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrVP9VLD10bProfile2Decoding)) |
| 1133 |
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV420_10; |
| 1134 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding10bit444)) |
| 1135 |
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV444_10; |
| 1136 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile2Decoding12bit420)) |
| 1137 |
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV420_12; |
| 1138 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding12bit444)) |
| 1139 |
(*attribList) [VAConfigAttribRTFormat] |= VA_RT_FORMAT_YUV444_12; |
| 1140 |
} |
| 1141 |
else |
| 1142 |
{ |
| 1143 |
attrib.value = VA_DEC_SLICE_MODE_NORMAL; |
| 1144 |
} |
| 1145 |
(*attribList)[attrib.type] = attrib.value; |
| 1146 |
|
| 1147 |
attrib.type = VAConfigAttribDecProcessing; |
| 1148 |
attrib.value = VA_DEC_PROCESSING_NONE; |
| 1149 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 1150 |
VAConfigAttribDecProcessing, &attrib.value); |
| 1151 |
(*attribList)[attrib.type] = attrib.value; |
| 1152 |
|
| 1153 |
attrib.type = VAConfigAttribMaxPictureWidth; |
| 1154 |
attrib.value = CODEC_MAX_PIC_WIDTH; |
| 1155 |
if(profile == VAProfileJPEGBaseline) |
| 1156 |
{ |
| 1157 |
attrib.value = ENCODE_JPEG_MAX_PIC_WIDTH; |
| 1158 |
} |
| 1159 |
if(IsVc1Profile(profile) || IsMpeg2Profile(profile)) |
| 1160 |
{ |
| 1161 |
attrib.value = CODEC_2K_MAX_PIC_WIDTH; |
| 1162 |
} |
| 1163 |
if(IsVp8Profile(profile)) |
| 1164 |
{ |
| 1165 |
attrib.value = CODEC_4K_MAX_PIC_WIDTH; |
| 1166 |
} |
| 1167 |
if(IsAvcProfile(profile)) |
| 1168 |
{ |
| 1169 |
attrib.value = CODEC_4K_MAX_PIC_WIDTH; |
| 1170 |
} |
| 1171 |
if(IsHevcProfile(profile) || IsVp9Profile(profile)) |
| 1172 |
{ |
| 1173 |
attrib.value = CODEC_8K_MAX_PIC_WIDTH; |
| 1174 |
} |
| 1175 |
(*attribList)[attrib.type] = attrib.value; |
| 1176 |
|
| 1177 |
attrib.type = VAConfigAttribMaxPictureHeight; |
| 1178 |
attrib.value = CODEC_MAX_PIC_HEIGHT; |
| 1179 |
if(profile == VAProfileJPEGBaseline) |
| 1180 |
{ |
| 1181 |
attrib.value = ENCODE_JPEG_MAX_PIC_HEIGHT; |
| 1182 |
} |
| 1183 |
if(IsVc1Profile(profile) || IsMpeg2Profile(profile)) |
| 1184 |
{ |
| 1185 |
attrib.value = CODEC_2K_MAX_PIC_HEIGHT; |
| 1186 |
} |
| 1187 |
if(IsVp8Profile(profile)) |
| 1188 |
{ |
| 1189 |
attrib.value = CODEC_4K_MAX_PIC_HEIGHT; |
| 1190 |
} |
| 1191 |
if(IsAvcProfile(profile)) |
| 1192 |
{ |
| 1193 |
attrib.value = CODEC_4K_MAX_PIC_HEIGHT; |
| 1194 |
} |
| 1195 |
if(IsHevcProfile(profile) || IsVp9Profile(profile)) |
| 1196 |
{ |
| 1197 |
attrib.value = CODEC_8K_MAX_PIC_HEIGHT; |
| 1198 |
} |
| 1199 |
(*attribList)[attrib.type] = attrib.value; |
| 1200 |
|
| 1201 |
attrib.type = VAConfigAttribEncryption; |
| 1202 |
attrib.value = VA_ATTRIB_NOT_SUPPORTED; |
| 1203 |
if (m_isEntryptSupported) |
| 1204 |
{ |
| 1205 |
attrib.value = 0; |
| 1206 |
uint32_t encryptTypes[DDI_CP_ENCRYPT_TYPES_NUM] = {0}; |
| 1207 |
int32_t numTypes = m_CapsCp->GetEncryptionTypes(profile, |
| 1208 |
encryptTypes, DDI_CP_ENCRYPT_TYPES_NUM); |
| 1209 |
if (numTypes > 0) |
| 1210 |
{ |
| 1211 |
for (int32_t j = 0; j < numTypes; j++) |
| 1212 |
{ |
| 1213 |
attrib.value |= encryptTypes[j]; |
| 1214 |
} |
| 1215 |
} |
| 1216 |
} |
| 1217 |
(*attribList)[attrib.type] = attrib.value; |
| 1218 |
|
| 1219 |
if(profile == VAProfileJPEGBaseline) |
| 1220 |
{ |
| 1221 |
attrib.type = VAConfigAttribDecJPEG; |
| 1222 |
attrib.value = ((1 << VA_ROTATION_NONE) | (1 << VA_ROTATION_90) | (1 << VA_ROTATION_180) | (1 << VA_ROTATION_270)); |
| 1223 |
(*attribList)[attrib.type] = attrib.value; |
| 1224 |
} |
| 1225 |
|
| 1226 |
if(profile == VAProfileNone) |
| 1227 |
{ |
| 1228 |
attrib.type = (VAConfigAttribType)VAConfigAttribStats; |
| 1229 |
VAConfigAttribValStats attribValStats; |
| 1230 |
memset(&attribValStats, 0, sizeof(attribValStats)); |
| 1231 |
attribValStats.bits.max_num_past_references = DDI_CODEC_STATS_MAX_NUM_PAST_REFS; |
| 1232 |
attribValStats.bits.max_num_future_references = DDI_CODEC_STATS_MAX_NUM_FUTURE_REFS; |
| 1233 |
attribValStats.bits.num_outputs = DDI_CODEC_STATS_MAX_NUM_OUTPUTS; |
| 1234 |
attribValStats.bits.interlaced = DDI_CODEC_STATS_INTERLACED_SUPPORT; |
| 1235 |
attrib.value = attribValStats.value; |
| 1236 |
(*attribList)[attrib.type] = attrib.value; |
| 1237 |
} |
| 1238 |
|
| 1239 |
attrib.type = VAConfigAttribProcessingRate; |
| 1240 |
attrib.value = VA_PROCESSING_RATE_DECODE; |
| 1241 |
(*attribList)[attrib.type] = attrib.value; |
| 1242 |
|
| 1243 |
attrib.type = (VAConfigAttribType)VAConfigAttribCustomRoundingControl; |
| 1244 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 1245 |
(VAConfigAttribType)VAConfigAttribCustomRoundingControl, &attrib.value); |
| 1246 |
(*attribList)[attrib.type] = attrib.value; |
| 1247 |
|
| 1248 |
return status; |
| 1249 |
} |
| 1250 |
|
| 1251 |
VAStatus MediaLibvaCaps::CreateVpAttributes( |
| 1252 |
VAProfile profile, |
| 1253 |
VAEntrypoint entrypoint, |
| 1254 |
AttribMap **attributeList) |
| 1255 |
{ |
| 1256 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1257 |
|
| 1258 |
VAStatus status = CreateAttributeList(attributeList); |
| 1259 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1260 |
|
| 1261 |
auto attribList = *attributeList; |
| 1262 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1263 |
|
| 1264 |
VAConfigAttrib attrib; |
| 1265 |
attrib.type = VAConfigAttribRTFormat; |
| 1266 |
attrib.value = VA_RT_FORMAT_YUV420 | |
| 1267 |
VA_RT_FORMAT_YUV422 | |
| 1268 |
VA_RT_FORMAT_YUV444 | |
| 1269 |
VA_RT_FORMAT_YUV400 | |
| 1270 |
VA_RT_FORMAT_YUV411 | |
| 1271 |
VA_RT_FORMAT_RGB16 | |
| 1272 |
VA_RT_FORMAT_RGB32; |
| 1273 |
|
| 1274 |
if ((m_mediaCtx->platform.eRenderCoreFamily == IGFX_GEN9_CORE) || |
| 1275 |
(m_mediaCtx->platform.eRenderCoreFamily == IGFX_GEN12_CORE)) |
| 1276 |
{ |
| 1277 |
attrib.value |= VA_RT_FORMAT_RGBP; |
| 1278 |
} |
| 1279 |
|
| 1280 |
(*attribList)[attrib.type] = attrib.value; |
| 1281 |
return status; |
| 1282 |
} |
| 1283 |
|
| 1284 |
VAStatus MediaLibvaCaps::LoadAvcDecProfileEntrypoints() |
| 1285 |
{ |
| 1286 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1287 |
|
| 1288 |
#ifdef _AVC_DECODE_SUPPORTED |
| 1289 |
AttribMap *attributeList = nullptr; |
| 1290 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrAVCVLDLongDecoding) |
| 1291 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrAVCVLDShortDecoding)) |
| 1292 |
{ |
| 1293 |
status = CreateDecAttributes(VAProfileH264Main, VAEntrypointVLD, &attributeList); |
| 1294 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1295 |
|
| 1296 |
VAProfile profile[3] = { |
| 1297 |
VAProfileH264Main, |
| 1298 |
VAProfileH264High, |
| 1299 |
VAProfileH264ConstrainedBaseline}; |
| 1300 |
|
| 1301 |
uint32_t configStartIdx, configNum; |
| 1302 |
for (int32_t i = 0; i < 3; i++) |
| 1303 |
{ |
| 1304 |
configStartIdx = m_decConfigs.size(); |
| 1305 |
for (int32_t j = 0; j < 2; j++) |
| 1306 |
{ |
| 1307 |
for (int32_t k = 0; k < 2; k++) |
| 1308 |
{ |
| 1309 |
AddDecConfig(m_decSliceMode[j], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]); |
| 1310 |
if (m_isEntryptSupported) |
| 1311 |
{ |
| 1312 |
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM]; |
| 1313 |
|
| 1314 |
int32_t numTypes = m_CapsCp->GetEncryptionTypes(profile[i], |
| 1315 |
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM); |
| 1316 |
|
| 1317 |
if (numTypes > 0) |
| 1318 |
{ |
| 1319 |
for (int32_t l = 0; l < numTypes; l++) |
| 1320 |
{ |
| 1321 |
AddDecConfig(m_decSliceMode[j], encrytTypes[l], |
| 1322 |
m_decProcessMode[k]); |
| 1323 |
} |
| 1324 |
} |
| 1325 |
} |
| 1326 |
} |
| 1327 |
} |
| 1328 |
|
| 1329 |
configNum = m_decConfigs.size() - configStartIdx; |
| 1330 |
AddProfileEntry(profile[i], VAEntrypointVLD, attributeList, configStartIdx, configNum); |
| 1331 |
} |
| 1332 |
} |
| 1333 |
#endif |
| 1334 |
return status; |
| 1335 |
} |
| 1336 |
|
| 1337 |
VAStatus MediaLibvaCaps::LoadAvcEncProfileEntrypoints() |
| 1338 |
{ |
| 1339 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1340 |
|
| 1341 |
#if defined (_AVC_ENCODE_VME_SUPPORTED) || defined (_AVC_ENCODE_VDENC_SUPPORTED) |
| 1342 |
AttribMap *attributeList = nullptr; |
| 1343 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeAVC)) |
| 1344 |
{ |
| 1345 |
status = CreateEncAttributes(VAProfileH264Main, VAEntrypointEncSlice, &attributeList); |
| 1346 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1347 |
|
| 1348 |
VAProfile profile[3] = { |
| 1349 |
VAProfileH264Main, |
| 1350 |
VAProfileH264High, |
| 1351 |
VAProfileH264ConstrainedBaseline}; |
| 1352 |
|
| 1353 |
VAEntrypoint entrypoint[2] = {VAEntrypointEncSlice, VAEntrypointFEI}; |
| 1354 |
|
| 1355 |
uint32_t feiFunctions[3] = { |
| 1356 |
VA_FEI_FUNCTION_ENC, |
| 1357 |
VA_FEI_FUNCTION_PAK, |
| 1358 |
VA_FEI_FUNCTION_ENC_PAK}; |
| 1359 |
|
| 1360 |
uint32_t configStartIdx; |
| 1361 |
|
| 1362 |
for (int32_t e = 0; e < 2; e++) |
| 1363 |
{ |
| 1364 |
status = CreateEncAttributes(VAProfileH264ConstrainedBaseline, entrypoint[e], &attributeList); |
| 1365 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1366 |
|
| 1367 |
for (int32_t i = 0; i < 3; i++) |
| 1368 |
{ |
| 1369 |
configStartIdx = m_encConfigs.size(); |
| 1370 |
bool isFei = !!(entrypoint[e] == VAEntrypointFEI); |
| 1371 |
int32_t maxRcMode = (entrypoint[e] == VAEntrypointEncSlice ? 9 : 1); |
| 1372 |
for (int32_t j = 0; j < maxRcMode; j++) |
| 1373 |
{ |
| 1374 |
if (isFei) |
| 1375 |
{ |
| 1376 |
for (int32_t k = 0; k < 3; k++) |
| 1377 |
{ |
| 1378 |
AddEncConfig(m_encRcMode[j], feiFunctions[k]); |
| 1379 |
} |
| 1380 |
} |
| 1381 |
else |
| 1382 |
AddEncConfig(m_encRcMode[j]); |
| 1383 |
} |
| 1384 |
AddProfileEntry(profile[i], entrypoint[e], attributeList, |
| 1385 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 1386 |
} |
| 1387 |
} |
| 1388 |
} |
| 1389 |
#endif |
| 1390 |
return status; |
| 1391 |
} |
| 1392 |
|
| 1393 |
VAStatus MediaLibvaCaps::LoadAvcEncLpProfileEntrypoints() |
| 1394 |
{ |
| 1395 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1396 |
|
| 1397 |
#if defined (_AVC_ENCODE_VME_SUPPORTED) || defined (_AVC_ENCODE_VDENC_SUPPORTED) |
| 1398 |
AttribMap *attributeList = nullptr; |
| 1399 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeAVCVdenc)) |
| 1400 |
{ |
| 1401 |
status = CreateEncAttributes(VAProfileH264Main, VAEntrypointEncSliceLP, &attributeList); |
| 1402 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1403 |
|
| 1404 |
VAProfile profile[3] = { |
| 1405 |
VAProfileH264Main, |
| 1406 |
VAProfileH264High, |
| 1407 |
VAProfileH264ConstrainedBaseline}; |
| 1408 |
|
| 1409 |
for (int32_t i = 0; i < 3; i++) |
| 1410 |
{ |
| 1411 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 1412 |
AddEncConfig(VA_RC_CQP); |
| 1413 |
|
| 1414 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)) |
| 1415 |
{ |
| 1416 |
/* m_encRcMode[0] is VA_RC_CQP and it is already added */ |
| 1417 |
for (int32_t j = 1; j < 5; j++) |
| 1418 |
{ |
| 1419 |
AddEncConfig(m_encRcMode[j]); |
| 1420 |
} |
| 1421 |
AddEncConfig(VA_RC_QVBR); |
| 1422 |
#if VA_CHECK_VERSION(1, 10, 0) |
| 1423 |
AddEncConfig(VA_RC_TCBRC); |
| 1424 |
#endif |
| 1425 |
} |
| 1426 |
AddProfileEntry(profile[i], VAEntrypointEncSliceLP, attributeList, |
| 1427 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 1428 |
} |
| 1429 |
} |
| 1430 |
#endif |
| 1431 |
|
| 1432 |
return status; |
| 1433 |
} |
| 1434 |
|
| 1435 |
VAStatus MediaLibvaCaps::LoadMpeg2DecProfileEntrypoints() |
| 1436 |
{ |
| 1437 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1438 |
|
| 1439 |
#ifdef _MPEG2_DECODE_SUPPORTED |
| 1440 |
AttribMap *attributeList = nullptr; |
| 1441 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrMPEG2VLDDecoding)) |
| 1442 |
{ |
| 1443 |
status = CreateDecAttributes(VAProfileMPEG2Simple, VAEntrypointVLD, &attributeList); |
| 1444 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1445 |
|
| 1446 |
VAProfile profile[2] = {VAProfileMPEG2Simple, VAProfileMPEG2Main}; |
| 1447 |
|
| 1448 |
for (int32_t i = 0; i < 2; i++) |
| 1449 |
{ |
| 1450 |
uint32_t configStartIdx = m_decConfigs.size(); |
| 1451 |
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, VA_ENCRYPTION_TYPE_NONE, VA_DEC_PROCESSING_NONE); |
| 1452 |
AddProfileEntry(profile[i], VAEntrypointVLD, attributeList, configStartIdx, 1); |
| 1453 |
} |
| 1454 |
} |
| 1455 |
#endif |
| 1456 |
|
| 1457 |
return status; |
| 1458 |
} |
| 1459 |
|
| 1460 |
VAStatus MediaLibvaCaps::LoadMpeg2EncProfileEntrypoints() |
| 1461 |
{ |
| 1462 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1463 |
|
| 1464 |
#ifdef _MPEG2_ENCODE_VME_SUPPORTED |
| 1465 |
AttribMap *attributeList = nullptr; |
| 1466 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeMPEG2)) |
| 1467 |
{ |
| 1468 |
status = CreateEncAttributes(VAProfileMPEG2Simple, VAEntrypointEncSlice, &attributeList); |
| 1469 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1470 |
|
| 1471 |
VAProfile profile[2] = {VAProfileMPEG2Simple, VAProfileMPEG2Main}; |
| 1472 |
for (int32_t i = 0; i < 2; i++) |
| 1473 |
{ |
| 1474 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 1475 |
for (int32_t j = 0; j < 3; j++) |
| 1476 |
{ |
| 1477 |
AddEncConfig(m_encRcMode[j]); |
| 1478 |
} |
| 1479 |
AddProfileEntry(profile[i], VAEntrypointEncSlice, attributeList, |
| 1480 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 1481 |
} |
| 1482 |
} |
| 1483 |
#endif |
| 1484 |
return status; |
| 1485 |
} |
| 1486 |
|
| 1487 |
VAStatus MediaLibvaCaps::LoadJpegDecProfileEntrypoints() |
| 1488 |
{ |
| 1489 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1490 |
|
| 1491 |
#ifdef _JPEG_DECODE_SUPPORTED |
| 1492 |
AttribMap *attributeList = nullptr; |
| 1493 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelJPEGDecoding)) |
| 1494 |
{ |
| 1495 |
status = CreateDecAttributes(VAProfileJPEGBaseline, VAEntrypointVLD, &attributeList); |
| 1496 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1497 |
|
| 1498 |
uint32_t configStartIdx = m_decConfigs.size(); |
| 1499 |
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, VA_ENCRYPTION_TYPE_NONE, VA_DEC_PROCESSING_NONE); |
| 1500 |
AddProfileEntry(VAProfileJPEGBaseline, VAEntrypointVLD, attributeList, configStartIdx, 1); |
| 1501 |
} |
| 1502 |
#endif |
| 1503 |
|
| 1504 |
return status; |
| 1505 |
} |
| 1506 |
|
| 1507 |
VAStatus MediaLibvaCaps::LoadJpegEncProfileEntrypoints() |
| 1508 |
{ |
| 1509 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1510 |
|
| 1511 |
#ifdef _JPEG_ENCODE_SUPPORTED |
| 1512 |
AttribMap *attributeList = nullptr; |
| 1513 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeJPEG)) |
| 1514 |
{ |
| 1515 |
status = CreateEncAttributes(VAProfileJPEGBaseline, VAEntrypointEncPicture, &attributeList); |
| 1516 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1517 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 1518 |
AddEncConfig(VA_RC_NONE); |
| 1519 |
AddProfileEntry(VAProfileJPEGBaseline, VAEntrypointEncPicture, attributeList, |
| 1520 |
configStartIdx, 1); |
| 1521 |
} |
| 1522 |
#endif |
| 1523 |
return status; |
| 1524 |
} |
| 1525 |
|
| 1526 |
VAStatus MediaLibvaCaps::LoadVc1DecProfileEntrypoints() |
| 1527 |
{ |
| 1528 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1529 |
|
| 1530 |
#ifdef _VC1_DECODE_SUPPORTED |
| 1531 |
AttribMap *attributeList = nullptr; |
| 1532 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrVC1VLDDecoding)) |
| 1533 |
{ |
| 1534 |
status = CreateDecAttributes(VAProfileVC1Main, VAEntrypointVLD, &attributeList); |
| 1535 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1536 |
VAProfile profile[3] = {VAProfileVC1Advanced, VAProfileVC1Main, VAProfileVC1Simple}; |
| 1537 |
|
| 1538 |
for (int32_t i = 0; i < 3; i++) |
| 1539 |
{ |
| 1540 |
uint32_t configStartIdx = m_decConfigs.size(); |
| 1541 |
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, VA_ENCRYPTION_TYPE_NONE, VA_DEC_PROCESSING_NONE); |
| 1542 |
AddProfileEntry(profile[i], VAEntrypointVLD, attributeList, configStartIdx, 1); |
| 1543 |
} |
| 1544 |
} |
| 1545 |
#endif |
| 1546 |
|
| 1547 |
return status; |
| 1548 |
} |
| 1549 |
|
| 1550 |
VAStatus MediaLibvaCaps::LoadVp8DecProfileEntrypoints() |
| 1551 |
{ |
| 1552 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1553 |
|
| 1554 |
#ifdef _VP8_DECODE_SUPPORTED |
| 1555 |
AttribMap *attributeList; |
| 1556 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP8VLDDecoding)) |
| 1557 |
{ |
| 1558 |
status = CreateDecAttributes(VAProfileVP8Version0_3, VAEntrypointVLD, &attributeList); |
| 1559 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1560 |
|
| 1561 |
uint32_t configStartIdx = m_decConfigs.size(); |
| 1562 |
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, VA_ENCRYPTION_TYPE_NONE, VA_DEC_PROCESSING_NONE); |
| 1563 |
AddProfileEntry(VAProfileVP8Version0_3, VAEntrypointVLD, attributeList, configStartIdx, 1); |
| 1564 |
} |
| 1565 |
#endif |
| 1566 |
|
| 1567 |
return status; |
| 1568 |
} |
| 1569 |
|
| 1570 |
VAStatus MediaLibvaCaps::LoadVp8EncProfileEntrypoints() |
| 1571 |
{ |
| 1572 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1573 |
|
| 1574 |
#ifdef _VP8_ENCODE_SUPPORTED |
| 1575 |
AttribMap *attributeList; |
| 1576 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeVP8)) |
| 1577 |
{ |
| 1578 |
status = CreateEncAttributes(VAProfileVP8Version0_3, VAEntrypointEncSlice, &attributeList); |
| 1579 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1580 |
|
| 1581 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 1582 |
for (int32_t j = 0; j < 3; j++) |
| 1583 |
{ |
| 1584 |
AddEncConfig(m_encRcMode[j]); |
| 1585 |
} |
| 1586 |
AddProfileEntry(VAProfileVP8Version0_3, VAEntrypointEncSlice, attributeList, |
| 1587 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 1588 |
} |
| 1589 |
#endif |
| 1590 |
return status; |
| 1591 |
} |
| 1592 |
|
| 1593 |
VAStatus MediaLibvaCaps::LoadAdvancedDecProfileEntrypoints() |
| 1594 |
{ |
| 1595 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1596 |
|
| 1597 |
return status; |
| 1598 |
} |
| 1599 |
|
| 1600 |
VAStatus MediaLibvaCaps::LoadVp9DecProfileEntrypoints() |
| 1601 |
{ |
| 1602 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1603 |
|
| 1604 |
#ifdef _VP9_DECODE_SUPPORTED |
| 1605 |
AttribMap *attributeList; |
| 1606 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile0Decoding8bit420)) |
| 1607 |
{ |
| 1608 |
status = CreateDecAttributes(VAProfileVP9Profile0, VAEntrypointVLD, &attributeList); |
| 1609 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1610 |
|
| 1611 |
uint32_t configStartIdx = m_decConfigs.size(); |
| 1612 |
for (int32_t i = 0; i < 2; i++) |
| 1613 |
{ |
| 1614 |
for (int32_t k = 0; k < 2; k++) |
| 1615 |
{ |
| 1616 |
AddDecConfig(m_decSliceMode[i], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]); |
| 1617 |
if (m_isEntryptSupported) |
| 1618 |
{ |
| 1619 |
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM]; |
| 1620 |
|
| 1621 |
int32_t numTypes = m_CapsCp->GetEncryptionTypes(VAProfileVP9Profile0, |
| 1622 |
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM); |
| 1623 |
|
| 1624 |
if (numTypes > 0) |
| 1625 |
{ |
| 1626 |
for (int32_t l = 0; l < numTypes; l++) |
| 1627 |
{ |
| 1628 |
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, encrytTypes[l], |
| 1629 |
m_decProcessMode[k]); |
| 1630 |
} |
| 1631 |
} |
| 1632 |
} |
| 1633 |
} |
| 1634 |
} |
| 1635 |
|
| 1636 |
AddProfileEntry(VAProfileVP9Profile0, VAEntrypointVLD, attributeList, |
| 1637 |
configStartIdx, m_decConfigs.size() - configStartIdx); |
| 1638 |
} |
| 1639 |
|
| 1640 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrVP9VLD10bProfile2Decoding) |
| 1641 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile2Decoding12bit420)) |
| 1642 |
{ |
| 1643 |
status = CreateDecAttributes(VAProfileVP9Profile2, VAEntrypointVLD, &attributeList); |
| 1644 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1645 |
|
| 1646 |
uint32_t configStartIdx = m_decConfigs.size(); |
| 1647 |
for (int32_t i = 0; i < 2; i++) |
| 1648 |
{ |
| 1649 |
for (int32_t k = 0; k < 2; k++) |
| 1650 |
{ |
| 1651 |
AddDecConfig(m_decSliceMode[i], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]); |
| 1652 |
if (m_isEntryptSupported) |
| 1653 |
{ |
| 1654 |
|
| 1655 |
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM]; |
| 1656 |
|
| 1657 |
int32_t numTypes = m_CapsCp->GetEncryptionTypes(VAProfileVP9Profile2, |
| 1658 |
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM); |
| 1659 |
|
| 1660 |
if (numTypes > 0) |
| 1661 |
{ |
| 1662 |
for (int32_t l = 0; l < numTypes; l++) |
| 1663 |
{ |
| 1664 |
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, encrytTypes[l], |
| 1665 |
m_decProcessMode[k]); |
| 1666 |
} |
| 1667 |
} |
| 1668 |
} |
| 1669 |
} |
| 1670 |
} |
| 1671 |
AddProfileEntry(VAProfileVP9Profile2, VAEntrypointVLD, attributeList, |
| 1672 |
configStartIdx, m_decConfigs.size() - configStartIdx); |
| 1673 |
} |
| 1674 |
|
| 1675 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile1Decoding8bit444)) |
| 1676 |
{ |
| 1677 |
status = CreateDecAttributes(VAProfileVP9Profile1, VAEntrypointVLD, &attributeList); |
| 1678 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1679 |
|
| 1680 |
uint32_t configStartIdx = m_decConfigs.size(); |
| 1681 |
for (int32_t i = 0; i < 2; i++) |
| 1682 |
{ |
| 1683 |
for (int32_t k = 0; k < 2; k++) |
| 1684 |
{ |
| 1685 |
AddDecConfig(m_decSliceMode[i], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]); |
| 1686 |
if (m_isEntryptSupported) |
| 1687 |
{ |
| 1688 |
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM]; |
| 1689 |
|
| 1690 |
int32_t numTypes = m_CapsCp->GetEncryptionTypes(VAProfileVP9Profile1, |
| 1691 |
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM); |
| 1692 |
|
| 1693 |
if (numTypes > 0) |
| 1694 |
{ |
| 1695 |
for (int32_t l = 0; l < numTypes; l++) |
| 1696 |
{ |
| 1697 |
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, encrytTypes[l], |
| 1698 |
m_decProcessMode[k]); |
| 1699 |
} |
| 1700 |
} |
| 1701 |
} |
| 1702 |
} |
| 1703 |
} |
| 1704 |
AddProfileEntry(VAProfileVP9Profile1, VAEntrypointVLD, attributeList, |
| 1705 |
configStartIdx, m_decConfigs.size() - configStartIdx); |
| 1706 |
} |
| 1707 |
|
| 1708 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding10bit444) |
| 1709 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelVP9VLDProfile3Decoding12bit444)) |
| 1710 |
{ |
| 1711 |
status = CreateDecAttributes(VAProfileVP9Profile3, VAEntrypointVLD, &attributeList); |
| 1712 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1713 |
|
| 1714 |
uint32_t configStartIdx = m_decConfigs.size(); |
| 1715 |
for (int32_t i = 0; i < 2; i++) |
| 1716 |
{ |
| 1717 |
for (int32_t k = 0; k < 2; k++) |
| 1718 |
{ |
| 1719 |
AddDecConfig(m_decSliceMode[i], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]); |
| 1720 |
if (m_isEntryptSupported) |
| 1721 |
{ |
| 1722 |
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM]; |
| 1723 |
|
| 1724 |
int32_t numTypes = m_CapsCp->GetEncryptionTypes(VAProfileVP9Profile3, |
| 1725 |
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM); |
| 1726 |
|
| 1727 |
if (numTypes > 0) |
| 1728 |
{ |
| 1729 |
for (int32_t l = 0; l < numTypes; l++) |
| 1730 |
{ |
| 1731 |
AddDecConfig(VA_DEC_SLICE_MODE_NORMAL, encrytTypes[l], |
| 1732 |
m_decProcessMode[k]); |
| 1733 |
} |
| 1734 |
} |
| 1735 |
} |
| 1736 |
} |
| 1737 |
} |
| 1738 |
AddProfileEntry(VAProfileVP9Profile3, VAEntrypointVLD, attributeList, |
| 1739 |
configStartIdx, m_decConfigs.size() - configStartIdx); |
| 1740 |
} |
| 1741 |
#endif |
| 1742 |
return status; |
| 1743 |
} |
| 1744 |
|
| 1745 |
VAStatus MediaLibvaCaps::LoadVp9EncProfileEntrypoints() |
| 1746 |
{ |
| 1747 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1748 |
|
| 1749 |
return status; |
| 1750 |
} |
| 1751 |
|
| 1752 |
VAStatus MediaLibvaCaps::LoadHevcDecProfileEntrypoints() |
| 1753 |
{ |
| 1754 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1755 |
|
| 1756 |
#ifdef _HEVC_DECODE_SUPPORTED |
| 1757 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMainDecoding) |
| 1758 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrHEVCVLDMainShortDecoding)) |
| 1759 |
{ |
| 1760 |
LoadDecProfileEntrypoints(VAProfileHEVCMain); |
| 1761 |
} |
| 1762 |
|
| 1763 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain10Decoding) |
| 1764 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrHEVCVLDMain10ShortDecoding)) |
| 1765 |
{ |
| 1766 |
LoadDecProfileEntrypoints(VAProfileHEVCMain10); |
| 1767 |
} |
| 1768 |
|
| 1769 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit420Decoding)) |
| 1770 |
{ |
| 1771 |
LoadDecProfileEntrypoints(VAProfileHEVCMain12); |
| 1772 |
} |
| 1773 |
|
| 1774 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD42210bitDecoding)) |
| 1775 |
{ |
| 1776 |
LoadDecProfileEntrypoints(VAProfileHEVCMain422_10); |
| 1777 |
} |
| 1778 |
|
| 1779 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit422Decoding)) |
| 1780 |
{ |
| 1781 |
LoadDecProfileEntrypoints(VAProfileHEVCMain422_12); |
| 1782 |
} |
| 1783 |
|
| 1784 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD4448bitDecoding)) |
| 1785 |
{ |
| 1786 |
LoadDecProfileEntrypoints(VAProfileHEVCMain444); |
| 1787 |
} |
| 1788 |
|
| 1789 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLD44410bitDecoding)) |
| 1790 |
{ |
| 1791 |
LoadDecProfileEntrypoints(VAProfileHEVCMain444_10); |
| 1792 |
} |
| 1793 |
|
| 1794 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrIntelHEVCVLDMain12bit444Decoding)) |
| 1795 |
{ |
| 1796 |
LoadDecProfileEntrypoints(VAProfileHEVCMain444_12); |
| 1797 |
} |
| 1798 |
|
| 1799 |
#endif |
| 1800 |
return status; |
| 1801 |
} |
| 1802 |
|
| 1803 |
VAStatus MediaLibvaCaps::LoadDecProfileEntrypoints(VAProfile profile) |
| 1804 |
{ |
| 1805 |
AttribMap *attributeList = nullptr; |
| 1806 |
VAStatus status = CreateDecAttributes(profile, VAEntrypointVLD, &attributeList); |
| 1807 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1808 |
|
| 1809 |
uint32_t configStartIdx = m_decConfigs.size(); |
| 1810 |
for (int32_t j = 0; j < 2; j++) |
| 1811 |
{ |
| 1812 |
for (int32_t k = 0; k < 2; k++) |
| 1813 |
{ |
| 1814 |
AddDecConfig(m_decSliceMode[j], VA_ENCRYPTION_TYPE_NONE, m_decProcessMode[k]); |
| 1815 |
if (m_isEntryptSupported) |
| 1816 |
{ |
| 1817 |
uint32_t encrytTypes[DDI_CP_ENCRYPT_TYPES_NUM]; |
| 1818 |
|
| 1819 |
int32_t numTypes = m_CapsCp->GetEncryptionTypes(profile, |
| 1820 |
encrytTypes, DDI_CP_ENCRYPT_TYPES_NUM); |
| 1821 |
|
| 1822 |
if (numTypes > 0) |
| 1823 |
{ |
| 1824 |
for (int32_t l = 0; l < numTypes; l++) |
| 1825 |
{ |
| 1826 |
AddDecConfig(m_decSliceMode[j], encrytTypes[l], |
| 1827 |
m_decProcessMode[k]); |
| 1828 |
} |
| 1829 |
} |
| 1830 |
} |
| 1831 |
} |
| 1832 |
} |
| 1833 |
AddProfileEntry(profile, VAEntrypointVLD, attributeList, |
| 1834 |
configStartIdx, m_decConfigs.size() - configStartIdx); |
| 1835 |
return status; |
| 1836 |
} |
| 1837 |
|
| 1838 |
VAStatus MediaLibvaCaps::LoadHevcEncProfileEntrypoints() |
| 1839 |
{ |
| 1840 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1841 |
const uint8_t rcModeSize = (sizeof(m_encRcMode))/(sizeof(m_encRcMode[0])); |
| 1842 |
|
| 1843 |
#if defined (_HEVC_ENCODE_VME_SUPPORTED) || defined (_HEVC_ENCODE_VDENC_SUPPORTED) |
| 1844 |
AttribMap *attributeList = nullptr; |
| 1845 |
|
| 1846 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC)) |
| 1847 |
{ |
| 1848 |
status = CreateEncAttributes(VAProfileHEVCMain, VAEntrypointEncSlice, &attributeList); |
| 1849 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1850 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1851 |
|
| 1852 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 1853 |
|
| 1854 |
for (int32_t j = 0; j < rcModeSize; j++) |
| 1855 |
{ |
| 1856 |
AddEncConfig(m_encRcMode[j]); |
| 1857 |
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); |
| 1858 |
} |
| 1859 |
|
| 1860 |
AddProfileEntry(VAProfileHEVCMain, VAEntrypointEncSlice, attributeList, |
| 1861 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 1862 |
|
| 1863 |
status = CreateEncAttributes(VAProfileHEVCMain, VAEntrypointFEI, &attributeList); |
| 1864 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1865 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1866 |
|
| 1867 |
configStartIdx = m_encConfigs.size(); |
| 1868 |
AddEncConfig(VA_RC_CQP, VA_FEI_FUNCTION_ENC_PAK); |
| 1869 |
|
| 1870 |
AddProfileEntry(VAProfileHEVCMain, VAEntrypointFEI, attributeList, |
| 1871 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 1872 |
} |
| 1873 |
|
| 1874 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC10bit)) |
| 1875 |
{ |
| 1876 |
status = CreateEncAttributes(VAProfileHEVCMain10, VAEntrypointEncSlice, &attributeList); |
| 1877 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1878 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1879 |
|
| 1880 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 1881 |
|
| 1882 |
for (int32_t j = 0; j < rcModeSize; j++) |
| 1883 |
{ |
| 1884 |
AddEncConfig(m_encRcMode[j]); |
| 1885 |
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); |
| 1886 |
} |
| 1887 |
|
| 1888 |
AddProfileEntry(VAProfileHEVCMain10, VAEntrypointEncSlice, attributeList, |
| 1889 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 1890 |
} |
| 1891 |
|
| 1892 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC12bit)) |
| 1893 |
{ |
| 1894 |
status = CreateEncAttributes(VAProfileHEVCMain12, VAEntrypointEncSlice, &attributeList); |
| 1895 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1896 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1897 |
|
| 1898 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 1899 |
|
| 1900 |
for (int32_t j = 0; j < rcModeSize; j++) |
| 1901 |
{ |
| 1902 |
AddEncConfig(m_encRcMode[j]); |
| 1903 |
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); |
| 1904 |
} |
| 1905 |
|
| 1906 |
AddProfileEntry(VAProfileHEVCMain12, VAEntrypointEncSlice, attributeList, |
| 1907 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 1908 |
} |
| 1909 |
|
| 1910 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC10bit422)) |
| 1911 |
{ |
| 1912 |
status = CreateEncAttributes(VAProfileHEVCMain422_10, VAEntrypointEncSlice, &attributeList); |
| 1913 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1914 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1915 |
|
| 1916 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 1917 |
|
| 1918 |
for (int32_t j = 0; j < rcModeSize; j++) |
| 1919 |
{ |
| 1920 |
AddEncConfig(m_encRcMode[j]); |
| 1921 |
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); |
| 1922 |
} |
| 1923 |
|
| 1924 |
AddProfileEntry(VAProfileHEVCMain422_10, VAEntrypointEncSlice, attributeList, |
| 1925 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 1926 |
} |
| 1927 |
|
| 1928 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC12bit422)) |
| 1929 |
{ |
| 1930 |
status = CreateEncAttributes(VAProfileHEVCMain422_12, VAEntrypointEncSlice, &attributeList); |
| 1931 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1932 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1933 |
|
| 1934 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 1935 |
|
| 1936 |
for (int32_t j = 0; j < rcModeSize; j++) |
| 1937 |
{ |
| 1938 |
AddEncConfig(m_encRcMode[j]); |
| 1939 |
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); |
| 1940 |
} |
| 1941 |
|
| 1942 |
AddProfileEntry(VAProfileHEVCMain422_12, VAEntrypointEncSlice, attributeList, |
| 1943 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 1944 |
} |
| 1945 |
|
| 1946 |
#endif |
| 1947 |
return status; |
| 1948 |
} |
| 1949 |
|
| 1950 |
VAStatus MediaLibvaCaps::LoadNoneProfileEntrypoints() |
| 1951 |
{ |
| 1952 |
VAStatus status = VA_STATUS_SUCCESS; |
| 1953 |
|
| 1954 |
AttribMap *attributeList = nullptr; |
| 1955 |
|
| 1956 |
status = CreateVpAttributes(VAProfileNone, VAEntrypointVideoProc, &attributeList); |
| 1957 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1958 |
|
| 1959 |
uint32_t configStartIdx = m_vpConfigs.size(); |
| 1960 |
AddVpConfig(0); |
| 1961 |
AddProfileEntry(VAProfileNone, VAEntrypointVideoProc, attributeList, configStartIdx, 1); |
| 1962 |
|
| 1963 |
configStartIdx = m_encConfigs.size(); |
| 1964 |
AddEncConfig(VA_RC_NONE); |
| 1965 |
AddProfileEntry(VAProfileNone, VAEntrypointStats, attributeList, |
| 1966 |
configStartIdx, 1); |
| 1967 |
return status; |
| 1968 |
} |
| 1969 |
|
| 1970 |
VAStatus MediaLibvaCaps::GetConfigAttributes(VAProfile profile, |
| 1971 |
VAEntrypoint entrypoint, |
| 1972 |
VAConfigAttrib *attribList, |
| 1973 |
int32_t numAttribs) |
| 1974 |
{ |
| 1975 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1976 |
int32_t i = GetProfileTableIdx(profile, entrypoint); |
| 1977 |
|
| 1978 |
switch(i) |
| 1979 |
{ |
| 1980 |
case -2: |
| 1981 |
return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; |
| 1982 |
case -1: |
| 1983 |
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; |
| 1984 |
default: |
| 1985 |
break; |
| 1986 |
} |
| 1987 |
|
| 1988 |
DDI_CHK_NULL(m_profileEntryTbl[i].m_attributes, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1989 |
for (int32_t j = 0; j < numAttribs; j++) |
| 1990 |
{ |
| 1991 |
if (m_profileEntryTbl[i].m_attributes->find(attribList[j].type) != |
| 1992 |
m_profileEntryTbl[i].m_attributes->end()) |
| 1993 |
{ |
| 1994 |
attribList[j].value = (*m_profileEntryTbl[i].m_attributes)[attribList[j].type]; |
| 1995 |
} |
| 1996 |
else |
| 1997 |
{ |
| 1998 |
if (GetGeneralConfigAttrib(&attribList[j]) != VA_STATUS_SUCCESS) |
| 1999 |
{ |
| 2000 |
//For unknown attribute, set to VA_ATTRIB_NOT_SUPPORTED |
| 2001 |
attribList[j].value = VA_ATTRIB_NOT_SUPPORTED; |
| 2002 |
} |
| 2003 |
} |
| 2004 |
} |
| 2005 |
|
| 2006 |
return VA_STATUS_SUCCESS; |
| 2007 |
} |
| 2008 |
|
| 2009 |
VAStatus MediaLibvaCaps::CreateDecConfig( |
| 2010 |
int32_t profileTableIdx, |
| 2011 |
VAConfigAttrib *attribList, |
| 2012 |
int32_t numAttribs, |
| 2013 |
VAConfigID *configId) |
| 2014 |
{ |
| 2015 |
DDI_CHK_NULL(configId, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2016 |
|
| 2017 |
if (numAttribs) |
| 2018 |
{ |
| 2019 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2020 |
} |
| 2021 |
|
| 2022 |
VAConfigAttrib decAttributes[3]; |
| 2023 |
|
| 2024 |
decAttributes[0].type = VAConfigAttribDecSliceMode; |
| 2025 |
decAttributes[0].value = VA_DEC_SLICE_MODE_NORMAL; |
| 2026 |
decAttributes[1].type = VAConfigAttribEncryption; |
| 2027 |
decAttributes[1].value = VA_ENCRYPTION_TYPE_NONE; |
| 2028 |
decAttributes[2].type = VAConfigAttribDecProcessing; |
| 2029 |
decAttributes[2].value = VA_DEC_PROCESSING_NONE; |
| 2030 |
|
| 2031 |
int32_t i,j; |
| 2032 |
for (j = 0; j < numAttribs; j++) |
| 2033 |
{ |
| 2034 |
for (i = 0; i < 3; i++) |
| 2035 |
{ |
| 2036 |
if (attribList[j].type == decAttributes[i].type) |
| 2037 |
{ |
| 2038 |
decAttributes[i].value = attribList[j].value; |
| 2039 |
break; |
| 2040 |
} |
| 2041 |
} |
| 2042 |
} |
| 2043 |
|
| 2044 |
int32_t startIdx = m_profileEntryTbl[profileTableIdx].m_configStartIdx; |
| 2045 |
int32_t configNum = m_profileEntryTbl[profileTableIdx].m_configNum; |
| 2046 |
for (i = startIdx; i < (startIdx + configNum); i++) |
| 2047 |
{ |
| 2048 |
if (decAttributes[0].value == m_decConfigs[i].m_sliceMode |
| 2049 |
&& decAttributes[1].value == m_decConfigs[i].m_encryptType |
| 2050 |
&& decAttributes[2].value == m_decConfigs[i].m_processType) |
| 2051 |
{ |
| 2052 |
break; |
| 2053 |
} |
| 2054 |
} |
| 2055 |
|
| 2056 |
if (i < (startIdx + configNum)) |
| 2057 |
{ |
| 2058 |
*configId = DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE + i; |
| 2059 |
return VA_STATUS_SUCCESS; |
| 2060 |
|
| 2061 |
} |
| 2062 |
else |
| 2063 |
{ |
| 2064 |
*configId = 0xFFFFFFFF; |
| 2065 |
return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED; |
| 2066 |
} |
| 2067 |
} |
| 2068 |
|
| 2069 |
VAStatus MediaLibvaCaps::CreateEncConfig( |
| 2070 |
int32_t profileTableIdx, |
| 2071 |
VAEntrypoint entrypoint, |
| 2072 |
VAConfigAttrib *attribList, |
| 2073 |
int32_t numAttribs, |
| 2074 |
VAConfigID *configId) |
| 2075 |
{ |
| 2076 |
DDI_CHK_NULL(configId, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2077 |
|
| 2078 |
if (numAttribs) |
| 2079 |
{ |
| 2080 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2081 |
} |
| 2082 |
|
| 2083 |
uint32_t rcMode = VA_RC_CQP; |
| 2084 |
if((entrypoint == VAEntrypointStats) || (entrypoint == VAEntrypointEncPicture)) |
| 2085 |
{ |
| 2086 |
rcMode = VA_RC_NONE; |
| 2087 |
} |
| 2088 |
|
| 2089 |
bool rc_mb_flag = false; |
| 2090 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 2091 |
{ |
| 2092 |
switch(m_profileEntryTbl[profileTableIdx].m_profile) |
| 2093 |
{ |
| 2094 |
case VAProfileHEVCMain: |
| 2095 |
case VAProfileHEVCMain10: |
| 2096 |
case VAProfileHEVCMain444: |
| 2097 |
case VAProfileHEVCMain444_10: |
| 2098 |
rc_mb_flag = true; |
| 2099 |
break; |
| 2100 |
default: |
| 2101 |
rc_mb_flag = false; |
| 2102 |
break; |
| 2103 |
} |
| 2104 |
m_vdencActive = true; |
| 2105 |
} |
| 2106 |
|
| 2107 |
uint32_t feiFunction = 0; |
| 2108 |
|
| 2109 |
int32_t j; |
| 2110 |
for (j = 0; j < numAttribs; j++) |
| 2111 |
{ |
| 2112 |
if (VAConfigAttribRateControl == attribList[j].type) |
| 2113 |
{ |
| 2114 |
//do not set VA_RC_MB without other BRC mode |
| 2115 |
//if it happend, just set it to default RC mode |
| 2116 |
if(attribList[j].value != VA_RC_MB) |
| 2117 |
{ |
| 2118 |
if ((attribList[j].value == VA_RC_CBR || |
| 2119 |
attribList[j].value == VA_RC_VBR) && rc_mb_flag) |
| 2120 |
rcMode = attribList[j].value | VA_RC_MB; |
| 2121 |
else |
| 2122 |
rcMode = attribList[j].value; |
| 2123 |
} |
| 2124 |
} |
| 2125 |
if(VAConfigAttribFEIFunctionType == attribList[j].type) |
| 2126 |
{ |
| 2127 |
feiFunction = attribList[j].value; |
| 2128 |
} |
| 2129 |
if(VAConfigAttribRTFormat == attribList[j].type) |
| 2130 |
{ |
| 2131 |
VAConfigAttrib attribRT; |
| 2132 |
CheckEncRTFormat(m_profileEntryTbl[profileTableIdx].m_profile, entrypoint, &attribRT); |
| 2133 |
if((attribList[j].value | attribRT.value) == 0) |
| 2134 |
{ |
| 2135 |
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT; |
| 2136 |
} |
| 2137 |
} |
| 2138 |
} |
| 2139 |
|
| 2140 |
// If VAEntrypointFEI but FEI type (ENC/PAK/ENCPAK) wasn't provided via VAConfigAttribFEIFunctionType |
| 2141 |
// then use ENC_PAK as default |
| 2142 |
if (VAEntrypointFEI == entrypoint && 0 == feiFunction) |
| 2143 |
feiFunction = VA_FEI_FUNCTION_ENC_PAK; |
| 2144 |
|
| 2145 |
int32_t startIdx = m_profileEntryTbl[profileTableIdx].m_configStartIdx; |
| 2146 |
int32_t configNum = m_profileEntryTbl[profileTableIdx].m_configNum; |
| 2147 |
for (j = startIdx; j < (startIdx + configNum); j++) |
| 2148 |
{ |
| 2149 |
if (m_encConfigs[j].m_rcMode == rcMode && |
| 2150 |
m_encConfigs[j].m_FeiFunction == feiFunction) |
| 2151 |
{ |
| 2152 |
break; |
| 2153 |
} |
| 2154 |
} |
| 2155 |
|
| 2156 |
if (j < (configNum + startIdx)) |
| 2157 |
{ |
| 2158 |
*configId = j + DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE; |
| 2159 |
return VA_STATUS_SUCCESS; |
| 2160 |
} |
| 2161 |
else |
| 2162 |
{ |
| 2163 |
*configId = 0xFFFFFFFF; |
| 2164 |
return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED; |
| 2165 |
} |
| 2166 |
} |
| 2167 |
|
| 2168 |
VAStatus MediaLibvaCaps::CreateVpConfig( |
| 2169 |
int32_t profileTableIdx, |
| 2170 |
VAConfigAttrib *attribList, |
| 2171 |
int32_t numAttribs, |
| 2172 |
VAConfigID *configId) |
| 2173 |
{ |
| 2174 |
// attribList and numAttribs are for future usage. |
| 2175 |
DDI_UNUSED(attribList); |
| 2176 |
DDI_UNUSED(numAttribs); |
| 2177 |
|
| 2178 |
DDI_CHK_NULL(configId, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2179 |
|
| 2180 |
*configId = m_profileEntryTbl[profileTableIdx].m_configStartIdx |
| 2181 |
+ DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE; |
| 2182 |
|
| 2183 |
return VA_STATUS_SUCCESS; |
| 2184 |
} |
| 2185 |
|
| 2186 |
VAStatus MediaLibvaCaps::CheckDecodeResolution( |
| 2187 |
int32_t codecMode, |
| 2188 |
VAProfile profile, |
| 2189 |
uint32_t width, |
| 2190 |
uint32_t height) |
| 2191 |
{ |
| 2192 |
|
| 2193 |
uint32_t maxWidth = 0; |
| 2194 |
uint32_t maxHeight = 0; |
| 2195 |
switch (codecMode) |
| 2196 |
{ |
| 2197 |
case CODECHAL_DECODE_MODE_MPEG2VLD: |
| 2198 |
maxWidth = m_decMpeg2MaxWidth; |
| 2199 |
maxHeight = m_decMpeg2MaxHeight; |
| 2200 |
break; |
| 2201 |
case CODECHAL_DECODE_MODE_VC1VLD: |
| 2202 |
maxWidth = m_decVc1MaxWidth; |
| 2203 |
maxHeight = m_decVc1MaxHeight; |
| 2204 |
break; |
| 2205 |
case CODECHAL_DECODE_MODE_JPEG: |
| 2206 |
maxWidth = m_decJpegMaxWidth; |
| 2207 |
maxHeight = m_decJpegMaxHeight; |
| 2208 |
break; |
| 2209 |
case CODECHAL_DECODE_MODE_HEVCVLD: |
| 2210 |
maxWidth = m_decHevcMaxWidth; |
| 2211 |
maxHeight = m_decHevcMaxHeight; |
| 2212 |
break; |
| 2213 |
case CODECHAL_DECODE_MODE_VP9VLD: |
| 2214 |
maxWidth = m_decVp9MaxWidth; |
| 2215 |
maxHeight = m_decVp9MaxHeight; |
| 2216 |
break; |
| 2217 |
default: |
| 2218 |
maxWidth = m_decDefaultMaxWidth; |
| 2219 |
maxHeight = m_decDefaultMaxHeight; |
| 2220 |
break; |
| 2221 |
} |
| 2222 |
|
| 2223 |
uint32_t alignedHeight = 0; |
| 2224 |
if (profile == VAProfileVC1Advanced) |
| 2225 |
{ |
| 2226 |
alignedHeight = MOS_ALIGN_CEIL(height,32); |
| 2227 |
} |
| 2228 |
else |
| 2229 |
{ |
| 2230 |
alignedHeight = height; |
| 2231 |
} |
| 2232 |
|
| 2233 |
if (width > maxWidth || alignedHeight > maxHeight) |
| 2234 |
{ |
| 2235 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 2236 |
} |
| 2237 |
else |
| 2238 |
{ |
| 2239 |
return VA_STATUS_SUCCESS; |
| 2240 |
} |
| 2241 |
} |
| 2242 |
|
| 2243 |
VAStatus MediaLibvaCaps::CheckEncodeResolution( |
| 2244 |
VAProfile profile, |
| 2245 |
uint32_t width, |
| 2246 |
uint32_t height) |
| 2247 |
{ |
| 2248 |
switch (profile) |
| 2249 |
{ |
| 2250 |
case VAProfileJPEGBaseline: |
| 2251 |
if (width > m_encJpegMaxWidth |
| 2252 |
|| width < m_encJpegMinWidth |
| 2253 |
|| height > m_encJpegMaxHeight |
| 2254 |
|| height < m_encJpegMinHeight) |
| 2255 |
{ |
| 2256 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 2257 |
} |
| 2258 |
break; |
| 2259 |
case VAProfileMPEG2Simple: |
| 2260 |
case VAProfileMPEG2Main: |
| 2261 |
if( width > CODEC_MAX_PIC_WIDTH |
| 2262 |
|| width < m_encMinWidth |
| 2263 |
|| height > CODEC_MAX_PIC_HEIGHT |
| 2264 |
|| height < m_encMinHeight) |
| 2265 |
{ |
| 2266 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 2267 |
} |
| 2268 |
break; |
| 2269 |
default: |
| 2270 |
if (width > m_encMax4kWidth |
| 2271 |
|| width < m_encMinWidth |
| 2272 |
|| height > m_encMax4kHeight |
| 2273 |
|| height < m_encMinHeight) |
| 2274 |
{ |
| 2275 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 2276 |
} |
| 2277 |
break; |
| 2278 |
} |
| 2279 |
return VA_STATUS_SUCCESS; |
| 2280 |
} |
| 2281 |
|
| 2282 |
VAStatus MediaLibvaCaps::CheckProfile(VAProfile profile) |
| 2283 |
{ |
| 2284 |
return VA_STATUS_SUCCESS; |
| 2285 |
} |
| 2286 |
|
| 2287 |
VAStatus MediaLibvaCaps::CreateConfig( |
| 2288 |
VAProfile profile, |
| 2289 |
VAEntrypoint entrypoint, |
| 2290 |
VAConfigAttrib *attribList, |
| 2291 |
int32_t numAttribs, |
| 2292 |
VAConfigID *configId) |
| 2293 |
{ |
| 2294 |
|
| 2295 |
DDI_CHK_NULL(configId, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2296 |
|
| 2297 |
DDI_CHK_RET(CheckProfile(profile),"Failed to check config!"); |
| 2298 |
|
| 2299 |
int32_t i = GetProfileTableIdx(profile, entrypoint); |
| 2300 |
|
| 2301 |
if (i < 0) |
| 2302 |
{ |
| 2303 |
if(i == -2) |
| 2304 |
{ |
| 2305 |
return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; |
| 2306 |
} |
| 2307 |
else |
| 2308 |
{ |
| 2309 |
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; |
| 2310 |
} |
| 2311 |
} |
| 2312 |
|
| 2313 |
VAStatus ret = CheckAttribList(profile, entrypoint, attribList, numAttribs); |
| 2314 |
if(ret != VA_STATUS_SUCCESS) |
| 2315 |
{ |
| 2316 |
return ret; |
| 2317 |
} |
| 2318 |
|
| 2319 |
if (CheckEntrypointCodecType(entrypoint, videoDecode)) |
| 2320 |
{ |
| 2321 |
return CreateDecConfig(i, attribList, numAttribs, configId); |
| 2322 |
} |
| 2323 |
else if(CheckEntrypointCodecType(entrypoint, videoProcess)) |
| 2324 |
{ |
| 2325 |
return CreateVpConfig(i, attribList, numAttribs, configId); |
| 2326 |
} |
| 2327 |
else if(CheckEntrypointCodecType(entrypoint, videoEncode)) |
| 2328 |
{ |
| 2329 |
return CreateEncConfig(i,entrypoint,attribList, numAttribs, configId); |
| 2330 |
} |
| 2331 |
else if(CheckEntrypointCodecType(entrypoint, videoProtect)) |
| 2332 |
{ |
| 2333 |
return m_CapsCp->CreateCpConfig(i, entrypoint, attribList, numAttribs, configId); |
| 2334 |
} |
| 2335 |
else |
| 2336 |
{ |
| 2337 |
DDI_ASSERTMESSAGE("DDI: Unsupported EntryPoint"); |
| 2338 |
return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; |
| 2339 |
} |
| 2340 |
} |
| 2341 |
|
| 2342 |
VAStatus MediaLibvaCaps::QueryConfigProfiles( |
| 2343 |
VAProfile *profileList, |
| 2344 |
int32_t *numProfiles) |
| 2345 |
{ |
| 2346 |
DDI_CHK_NULL(profileList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2347 |
DDI_CHK_NULL(numProfiles, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2348 |
std::set<int32_t> profiles; |
| 2349 |
int32_t i; |
| 2350 |
for (i = 0; i < m_profileEntryCount; i++) |
| 2351 |
{ |
| 2352 |
profiles.insert((int32_t)m_profileEntryTbl[i].m_profile); |
| 2353 |
} |
| 2354 |
|
| 2355 |
std::set<int32_t>::iterator it; |
| 2356 |
for (it = profiles.begin(), i = 0; it != profiles.end(); ++it, i++) |
| 2357 |
{ |
| 2358 |
profileList[i] = (VAProfile)*it; |
| 2359 |
} |
| 2360 |
|
| 2361 |
*numProfiles = i; |
| 2362 |
|
| 2363 |
DDI_CHK_CONDITION((i > DDI_CODEC_GEN_MAX_PROFILES), |
| 2364 |
"Execeed maximum number of profiles!", VA_STATUS_ERROR_MAX_NUM_EXCEEDED); |
| 2365 |
return VA_STATUS_SUCCESS; |
| 2366 |
} |
| 2367 |
|
| 2368 |
VAStatus MediaLibvaCaps::QueryConfigEntrypoints( |
| 2369 |
VAProfile profile, |
| 2370 |
VAEntrypoint *entrypointList, |
| 2371 |
int32_t *numEntrypoints) |
| 2372 |
{ |
| 2373 |
DDI_CHK_NULL(entrypointList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2374 |
DDI_CHK_NULL(numEntrypoints, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2375 |
int32_t j = 0; |
| 2376 |
for (int32_t i = 0; i < m_profileEntryCount; i++) |
| 2377 |
{ |
| 2378 |
if (m_profileEntryTbl[i].m_profile == profile) |
| 2379 |
{ |
| 2380 |
entrypointList[j] = m_profileEntryTbl[i].m_entrypoint; |
| 2381 |
j++; |
| 2382 |
} |
| 2383 |
} |
| 2384 |
*numEntrypoints = j; |
| 2385 |
DDI_CHK_CONDITION((j == 0), "cant find the profile!", VA_STATUS_ERROR_UNSUPPORTED_PROFILE); |
| 2386 |
/* If the assert fails then GEN_MAX_ENTRYPOINTS needs to be bigger */ |
| 2387 |
DDI_CHK_CONDITION((j > DDI_CODEC_GEN_MAX_ENTRYPOINTS), |
| 2388 |
"Execeed maximum number of profiles!", VA_STATUS_ERROR_MAX_NUM_EXCEEDED); |
| 2389 |
|
| 2390 |
return VA_STATUS_SUCCESS; |
| 2391 |
} |
| 2392 |
|
| 2393 |
VAStatus MediaLibvaCaps::QueryConfigAttributes( |
| 2394 |
VAConfigID configId, |
| 2395 |
VAProfile *profile, |
| 2396 |
VAEntrypoint *entrypoint, |
| 2397 |
VAConfigAttrib *attribList, |
| 2398 |
int32_t *numAttribs) |
| 2399 |
{ |
| 2400 |
DDI_CHK_NULL(profile, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2401 |
DDI_CHK_NULL(entrypoint, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2402 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2403 |
DDI_CHK_NULL(numAttribs, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2404 |
int32_t profileTableIdx = -1; |
| 2405 |
VAStatus status = GetProfileEntrypointFromConfigId(configId, profile, entrypoint, &profileTableIdx); |
| 2406 |
DDI_CHK_RET(status, "Invalide config_id!"); |
| 2407 |
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount) |
| 2408 |
{ |
| 2409 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 2410 |
} |
| 2411 |
auto allAttribsList = m_profileEntryTbl[profileTableIdx].m_attributes; |
| 2412 |
|
| 2413 |
DDI_CHK_NULL(allAttribsList, "Null pointer", VA_STATUS_ERROR_INVALID_CONFIG); |
| 2414 |
|
| 2415 |
uint32_t j = 0; |
| 2416 |
for (auto it = allAttribsList->begin(); it != allAttribsList->end(); ++it) |
| 2417 |
{ |
| 2418 |
if (it->second != VA_ATTRIB_NOT_SUPPORTED) |
| 2419 |
{ |
| 2420 |
attribList[j].type = it->first; |
| 2421 |
attribList[j].value = it->second; |
| 2422 |
j++; |
| 2423 |
} |
| 2424 |
} |
| 2425 |
|
| 2426 |
*numAttribs = j; |
| 2427 |
// tracing profile/entry/config, compiler will optimize if trace is disabled |
| 2428 |
uint32_t data[] = {*profile, *entrypoint, j}; |
| 2429 |
MOS_TraceEventExt(EVENT_VA_CONFIG, EVENT_TYPE_INFO, data, sizeof(data), attribList, j*sizeof(VAConfigAttrib)); |
| 2430 |
|
| 2431 |
return VA_STATUS_SUCCESS; |
| 2432 |
} |
| 2433 |
|
| 2434 |
VAStatus MediaLibvaCaps::GetEncConfigAttr( |
| 2435 |
VAConfigID configId, |
| 2436 |
VAProfile *profile, |
| 2437 |
VAEntrypoint *entrypoint, |
| 2438 |
uint32_t *rcMode, |
| 2439 |
uint32_t *feiFunction) |
| 2440 |
{ |
| 2441 |
DDI_CHK_NULL(profile, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2442 |
DDI_CHK_NULL(entrypoint, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2443 |
DDI_CHK_NULL(rcMode, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2444 |
int32_t profileTableIdx = -1; |
| 2445 |
int32_t configOffset = configId - DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE; |
| 2446 |
VAStatus status = GetProfileEntrypointFromConfigId(configId, profile, entrypoint, &profileTableIdx); |
| 2447 |
DDI_CHK_RET(status, "Invalide config_id!"); |
| 2448 |
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount) |
| 2449 |
{ |
| 2450 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 2451 |
} |
| 2452 |
|
| 2453 |
int32_t configStart = m_profileEntryTbl[profileTableIdx].m_configStartIdx; |
| 2454 |
int32_t configEnd = m_profileEntryTbl[ profileTableIdx].m_configStartIdx |
| 2455 |
+ m_profileEntryTbl[profileTableIdx].m_configNum; |
| 2456 |
|
| 2457 |
if (configOffset < configStart || configOffset > configEnd) |
| 2458 |
{ |
| 2459 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 2460 |
} |
| 2461 |
*rcMode = m_encConfigs[configOffset].m_rcMode; |
| 2462 |
*feiFunction = m_encConfigs[configOffset].m_FeiFunction; |
| 2463 |
return VA_STATUS_SUCCESS; |
| 2464 |
} |
| 2465 |
|
| 2466 |
VAStatus MediaLibvaCaps::GetDecConfigAttr( |
| 2467 |
VAConfigID configId, |
| 2468 |
VAProfile *profile, |
| 2469 |
VAEntrypoint *entrypoint, |
| 2470 |
uint32_t *sliceMode, |
| 2471 |
uint32_t *encryptType, |
| 2472 |
uint32_t *processMode) |
| 2473 |
{ |
| 2474 |
DDI_CHK_NULL(profile, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2475 |
DDI_CHK_NULL(entrypoint, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2476 |
DDI_CHK_NULL(sliceMode, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2477 |
DDI_CHK_NULL(encryptType, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2478 |
DDI_CHK_NULL(processMode, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2479 |
|
| 2480 |
int32_t profileTableIdx = -1; |
| 2481 |
int32_t configOffset = configId - DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE; |
| 2482 |
VAStatus status = GetProfileEntrypointFromConfigId(configId, profile, entrypoint, &profileTableIdx); |
| 2483 |
DDI_CHK_RET(status, "Invalide config_id!"); |
| 2484 |
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount) |
| 2485 |
{ |
| 2486 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 2487 |
} |
| 2488 |
|
| 2489 |
int32_t configStart = m_profileEntryTbl[profileTableIdx].m_configStartIdx; |
| 2490 |
int32_t configEnd = m_profileEntryTbl[ profileTableIdx].m_configStartIdx |
| 2491 |
+ m_profileEntryTbl[profileTableIdx].m_configNum; |
| 2492 |
|
| 2493 |
if (configOffset < configStart || configOffset > configEnd) |
| 2494 |
{ |
| 2495 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 2496 |
} |
| 2497 |
|
| 2498 |
if (sliceMode) |
| 2499 |
{ |
| 2500 |
*sliceMode = m_decConfigs[configOffset].m_sliceMode; |
| 2501 |
} |
| 2502 |
|
| 2503 |
if (encryptType) |
| 2504 |
{ |
| 2505 |
*encryptType = m_decConfigs[configOffset].m_encryptType; |
| 2506 |
} |
| 2507 |
|
| 2508 |
if (processMode) |
| 2509 |
{ |
| 2510 |
*processMode = m_decConfigs[configOffset].m_processType; |
| 2511 |
} |
| 2512 |
return VA_STATUS_SUCCESS; |
| 2513 |
} |
| 2514 |
|
| 2515 |
VAStatus MediaLibvaCaps::GetVpConfigAttr( |
| 2516 |
VAConfigID configId, |
| 2517 |
VAProfile *profile, |
| 2518 |
VAEntrypoint *entrypoint) |
| 2519 |
{ |
| 2520 |
DDI_CHK_NULL(profile, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2521 |
DDI_CHK_NULL(entrypoint, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2522 |
int32_t profileTableIdx = -1; |
| 2523 |
int32_t configOffset = configId - DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE; |
| 2524 |
VAStatus status = GetProfileEntrypointFromConfigId(configId, profile, entrypoint, &profileTableIdx); |
| 2525 |
DDI_CHK_RET(status, "Invalide config_id!"); |
| 2526 |
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount) |
| 2527 |
{ |
| 2528 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 2529 |
} |
| 2530 |
|
| 2531 |
int32_t configStart = m_profileEntryTbl[profileTableIdx].m_configStartIdx; |
| 2532 |
int32_t configEnd = m_profileEntryTbl[ profileTableIdx].m_configStartIdx |
| 2533 |
+ m_profileEntryTbl[profileTableIdx].m_configNum; |
| 2534 |
|
| 2535 |
if (configOffset < configStart || configOffset > configEnd) |
| 2536 |
{ |
| 2537 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 2538 |
} |
| 2539 |
|
| 2540 |
return VA_STATUS_SUCCESS; |
| 2541 |
} |
| 2542 |
|
| 2543 |
VAStatus MediaLibvaCaps::QueryProcessingRate( |
| 2544 |
VAConfigID configId, |
| 2545 |
VAProcessingRateParameter *procBuf, |
| 2546 |
uint32_t *processingRate) |
| 2547 |
{ |
| 2548 |
DDI_CHK_NULL(procBuf, "Null procBuf", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2549 |
DDI_CHK_NULL(processingRate, "Null processingRate", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2550 |
|
| 2551 |
int32_t profileTableIdx = -1; |
| 2552 |
VAEntrypoint entrypoint; |
| 2553 |
VAProfile profile; |
| 2554 |
VAStatus status = GetProfileEntrypointFromConfigId(configId, &profile, &entrypoint, &profileTableIdx); |
| 2555 |
DDI_CHK_RET(status, "Invalide config_id!"); |
| 2556 |
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount) |
| 2557 |
{ |
| 2558 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 2559 |
} |
| 2560 |
|
| 2561 |
PLATFORM platform; |
| 2562 |
MEDIA_FEATURE_TABLE skuTable; |
| 2563 |
MEDIA_WA_TABLE waTable; |
| 2564 |
memset(&platform, 0, sizeof(platform)); |
| 2565 |
|
| 2566 |
if (MOS_STATUS_SUCCESS != HWInfo_GetGfxInfo(m_mediaCtx->fd, m_mediaCtx->pDrmBufMgr, &platform, &skuTable, &waTable, m_mediaCtx->pGtSystemInfo, m_mediaCtx->m_userSettingPtr)) |
| 2567 |
{ |
| 2568 |
DDI_ASSERTMESSAGE("Fatal error - Cannot get Sku/Wa Tables/GtSystemInfo and Platform information"); |
| 2569 |
return VA_STATUS_ERROR_OPERATION_FAILED; |
| 2570 |
} |
| 2571 |
|
| 2572 |
const int32_t tuIdxTable[] = {7, 6, 5, 4, 3, 2, 1, 0}; |
| 2573 |
VAProcessingRateParameterEnc *processingRateBuffEnc = nullptr; |
| 2574 |
VAProcessingRateParameterDec *processingRateBuffDec = nullptr; |
| 2575 |
uint32_t tuIdx = tuIdxTable[TARGETUSAGE_BEST_SPEED]; |
| 2576 |
VAStatus res = VA_STATUS_SUCCESS; |
| 2577 |
CODECHAL_MODE encodeMode = CODECHAL_UNSUPPORTED_MODE; |
| 2578 |
|
| 2579 |
if ((entrypoint == VAEntrypointEncSlice) || |
| 2580 |
(entrypoint == VAEntrypointEncSliceLP)) |
| 2581 |
{ |
| 2582 |
// Get VAProcessingBufferEnc |
| 2583 |
processingRateBuffEnc = &procBuf->proc_buf_enc; |
| 2584 |
|
| 2585 |
if (processingRateBuffEnc && |
| 2586 |
processingRateBuffEnc->quality_level < sizeof(tuIdxTable) / sizeof(tuIdxTable[0])) |
| 2587 |
{ |
| 2588 |
// If app passes the rate input data from DDI and also its TU is valid, then use it |
| 2589 |
tuIdx = tuIdxTable[processingRateBuffEnc->quality_level]; |
| 2590 |
} |
| 2591 |
|
| 2592 |
if (IsAvcProfile(profile)) |
| 2593 |
{ |
| 2594 |
encodeMode = CODECHAL_ENCODE_MODE_AVC; |
| 2595 |
} |
| 2596 |
else if(IsMpeg2Profile(profile)) |
| 2597 |
{ |
| 2598 |
encodeMode = CODECHAL_ENCODE_MODE_MPEG2; |
| 2599 |
} |
| 2600 |
else if (IsVp8Profile(profile)) |
| 2601 |
{ |
| 2602 |
encodeMode = CODECHAL_ENCODE_MODE_VP8; |
| 2603 |
} |
| 2604 |
else if (IsJpegProfile(profile)) |
| 2605 |
{ |
| 2606 |
encodeMode = CODECHAL_ENCODE_MODE_JPEG; |
| 2607 |
} |
| 2608 |
else if(IsHevcProfile(profile)) |
| 2609 |
{ |
| 2610 |
encodeMode = CODECHAL_ENCODE_MODE_HEVC; |
| 2611 |
} |
| 2612 |
else if (IsVp9Profile(profile)) |
| 2613 |
{ |
| 2614 |
encodeMode = CODECHAL_ENCODE_MODE_VP9; |
| 2615 |
} |
| 2616 |
|
| 2617 |
res = GetMbProcessingRateEnc( |
| 2618 |
&skuTable, |
| 2619 |
tuIdx, |
| 2620 |
encodeMode, |
| 2621 |
(entrypoint == VAEntrypointEncSliceLP), |
| 2622 |
processingRate); |
| 2623 |
} |
| 2624 |
else if (entrypoint == VAEntrypointVLD) |
| 2625 |
{ |
| 2626 |
// Get VAProcessingBufferEnc |
| 2627 |
processingRateBuffDec = & procBuf->proc_buf_dec; |
| 2628 |
|
| 2629 |
res = GetMbProcessingRateDec( |
| 2630 |
&skuTable, |
| 2631 |
processingRate); |
| 2632 |
} |
| 2633 |
else // VA_PROCESSING_RATE_NONE or else |
| 2634 |
{ |
| 2635 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 2636 |
} |
| 2637 |
|
| 2638 |
return res; |
| 2639 |
} |
| 2640 |
|
| 2641 |
VAStatus MediaLibvaCaps::QuerySurfaceAttributes( |
| 2642 |
VAConfigID configId, |
| 2643 |
VASurfaceAttrib *attribList, |
| 2644 |
uint32_t *numAttribs) |
| 2645 |
{ |
| 2646 |
DDI_CHK_NULL(numAttribs, "Null num_attribs", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 2647 |
|
| 2648 |
if (attribList == nullptr) |
| 2649 |
{ |
| 2650 |
*numAttribs = DDI_CODEC_GEN_MAX_SURFACE_ATTRIBUTES; |
| 2651 |
return VA_STATUS_SUCCESS; |
| 2652 |
} |
| 2653 |
|
| 2654 |
int32_t profileTableIdx = -1; |
| 2655 |
VAEntrypoint entrypoint; |
| 2656 |
VAProfile profile; |
| 2657 |
VAStatus status = GetProfileEntrypointFromConfigId(configId, &profile, &entrypoint, &profileTableIdx); |
| 2658 |
DDI_CHK_RET(status, "Invalid config_id!"); |
| 2659 |
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount) |
| 2660 |
{ |
| 2661 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 2662 |
} |
| 2663 |
|
| 2664 |
VASurfaceAttrib *attribs = (VASurfaceAttrib *)MOS_AllocAndZeroMemory(DDI_CODEC_GEN_MAX_SURFACE_ATTRIBUTES * sizeof(*attribs)); |
| 2665 |
if (attribs == nullptr) |
| 2666 |
{ |
| 2667 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 2668 |
} |
| 2669 |
|
| 2670 |
uint32_t i = 0; |
| 2671 |
|
| 2672 |
if (entrypoint == VAEntrypointVideoProc) /* vpp */ |
| 2673 |
{ |
| 2674 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2675 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2676 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2677 |
attribs[i].value.value.i = VA_FOURCC('N', 'V', '1', '2'); |
| 2678 |
i++; |
| 2679 |
|
| 2680 |
attribs[i].type = VASurfaceAttribMaxWidth; |
| 2681 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2682 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2683 |
attribs[i].value.value.i = VP_MAX_PIC_WIDTH; |
| 2684 |
i++; |
| 2685 |
|
| 2686 |
attribs[i].type = VASurfaceAttribMaxHeight; |
| 2687 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2688 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2689 |
attribs[i].value.value.i = VP_MAX_PIC_HEIGHT; |
| 2690 |
i++; |
| 2691 |
|
| 2692 |
attribs[i].type = VASurfaceAttribMinWidth; |
| 2693 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2694 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2695 |
attribs[i].value.value.i = VP_MIN_PIC_WIDTH; |
| 2696 |
i++; |
| 2697 |
|
| 2698 |
attribs[i].type = VASurfaceAttribMinHeight; |
| 2699 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2700 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2701 |
attribs[i].value.value.i = VP_MIN_PIC_HEIGHT; |
| 2702 |
i++; |
| 2703 |
|
| 2704 |
for (uint32_t j = 0; j < m_numVpSurfaceAttr && m_vpSurfaceAttr[j]; j++) |
| 2705 |
{ |
| 2706 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2707 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2708 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2709 |
attribs[i].value.value.i = m_vpSurfaceAttr[j]; |
| 2710 |
i++; |
| 2711 |
} |
| 2712 |
|
| 2713 |
attribs[i].type = VASurfaceAttribMemoryType; |
| 2714 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2715 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2716 |
attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | |
| 2717 |
VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR | |
| 2718 |
VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM | |
| 2719 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME | |
| 2720 |
#if VA_CHECK_VERSION(1, 21, 0) |
| 2721 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_3 | |
| 2722 |
#endif |
| 2723 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2; |
| 2724 |
i++; |
| 2725 |
|
| 2726 |
attribs[i].type = VASurfaceAttribExternalBufferDescriptor; |
| 2727 |
attribs[i].value.type = VAGenericValueTypePointer; |
| 2728 |
attribs[i].flags = VA_SURFACE_ATTRIB_SETTABLE; |
| 2729 |
attribs[i].value.value.p = nullptr; /* ignore */ |
| 2730 |
i++; |
| 2731 |
} |
| 2732 |
else if (entrypoint == VAEntrypointVLD) /* vld */ |
| 2733 |
{ |
| 2734 |
if (profile == VAProfileHEVCMain10 || profile == VAProfileVP9Profile2) |
| 2735 |
{ |
| 2736 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2737 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2738 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2739 |
attribs[i].value.value.i = VA_FOURCC_P010; |
| 2740 |
i++; |
| 2741 |
|
| 2742 |
if(profile == VAProfileVP9Profile2) |
| 2743 |
{ |
| 2744 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2745 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2746 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2747 |
attribs[i].value.value.i = VA_FOURCC_P012; |
| 2748 |
i++; |
| 2749 |
|
| 2750 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2751 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2752 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2753 |
attribs[i].value.value.i = VA_FOURCC_P016; |
| 2754 |
i++; |
| 2755 |
} |
| 2756 |
} |
| 2757 |
else if(profile == VAProfileHEVCMain12) |
| 2758 |
{ |
| 2759 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2760 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2761 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2762 |
attribs[i].value.value.i = VA_FOURCC_P012; |
| 2763 |
i++; |
| 2764 |
|
| 2765 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2766 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2767 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2768 |
attribs[i].value.value.i = VA_FOURCC_P016; |
| 2769 |
i++; |
| 2770 |
} |
| 2771 |
else if(profile == VAProfileHEVCMain422_10) |
| 2772 |
{ |
| 2773 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2774 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2775 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2776 |
attribs[i].value.value.i = VA_FOURCC_YUY2; |
| 2777 |
i++; |
| 2778 |
|
| 2779 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2780 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2781 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2782 |
attribs[i].value.value.i = VA_FOURCC_Y210; |
| 2783 |
i++; |
| 2784 |
} |
| 2785 |
else if(profile == VAProfileHEVCMain422_12) |
| 2786 |
{ |
| 2787 |
//hevc rext: Y216 12/16bit 422 |
| 2788 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 2789 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2790 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2791 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2792 |
attribs[i].value.value.i = VA_FOURCC_Y212; |
| 2793 |
i++; |
| 2794 |
#endif |
| 2795 |
|
| 2796 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2797 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2798 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2799 |
attribs[i].value.value.i = VA_FOURCC_Y216; |
| 2800 |
i++; |
| 2801 |
|
| 2802 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2803 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2804 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2805 |
attribs[i].value.value.i = VA_FOURCC_P012; |
| 2806 |
i++; |
| 2807 |
} |
| 2808 |
else if(profile == VAProfileHEVCMain444 || profile == VAProfileVP9Profile1) |
| 2809 |
{ |
| 2810 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2811 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2812 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2813 |
attribs[i].value.value.i = VA_FOURCC_AYUV; |
| 2814 |
i++; |
| 2815 |
|
| 2816 |
#if VA_CHECK_VERSION(1, 13, 0) |
| 2817 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2818 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2819 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2820 |
attribs[i].value.value.i = VA_FOURCC_XYUV; |
| 2821 |
i++; |
| 2822 |
#endif |
| 2823 |
} |
| 2824 |
else if(profile == VAProfileHEVCMain444_10 || profile == VAProfileVP9Profile3) |
| 2825 |
{ |
| 2826 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2827 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2828 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2829 |
attribs[i].value.value.i = VA_FOURCC_Y410; |
| 2830 |
i++; |
| 2831 |
|
| 2832 |
if(profile == VAProfileVP9Profile3) |
| 2833 |
{ |
| 2834 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 2835 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2836 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2837 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2838 |
attribs[i].value.value.i = VA_FOURCC_Y412; |
| 2839 |
i++; |
| 2840 |
#endif |
| 2841 |
|
| 2842 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2843 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2844 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2845 |
attribs[i].value.value.i = VA_FOURCC_Y416; |
| 2846 |
i++; |
| 2847 |
} |
| 2848 |
} |
| 2849 |
else if(profile == VAProfileHEVCMain444_12) |
| 2850 |
{ |
| 2851 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 2852 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2853 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2854 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2855 |
attribs[i].value.value.i = VA_FOURCC_Y412; |
| 2856 |
i++; |
| 2857 |
|
| 2858 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2859 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2860 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2861 |
attribs[i].value.value.i = VA_FOURCC_Y212; |
| 2862 |
i++; |
| 2863 |
#endif |
| 2864 |
|
| 2865 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2866 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2867 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2868 |
attribs[i].value.value.i = VA_FOURCC_Y416; |
| 2869 |
i++; |
| 2870 |
|
| 2871 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2872 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2873 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2874 |
attribs[i].value.value.i = VA_FOURCC_P012; |
| 2875 |
i++; |
| 2876 |
} |
| 2877 |
else if (profile == VAProfileJPEGBaseline) |
| 2878 |
{ |
| 2879 |
for (uint32_t j = 0; j < m_numJpegSurfaceAttr; j++) |
| 2880 |
{ |
| 2881 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2882 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2883 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2884 |
attribs[i].value.value.i = m_jpegSurfaceAttr[j]; |
| 2885 |
i++; |
| 2886 |
} |
| 2887 |
} |
| 2888 |
else |
| 2889 |
{ |
| 2890 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2891 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2892 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2893 |
attribs[i].value.value.i = VA_FOURCC('N', 'V', '1', '2'); |
| 2894 |
i++; |
| 2895 |
} |
| 2896 |
|
| 2897 |
auto maxWidth = m_decDefaultMaxWidth; |
| 2898 |
auto maxHeight = m_decDefaultMaxHeight; |
| 2899 |
if(IsMpeg2Profile(profile)) |
| 2900 |
{ |
| 2901 |
maxWidth = m_decMpeg2MaxWidth; |
| 2902 |
maxHeight = m_decMpeg2MaxHeight; |
| 2903 |
} |
| 2904 |
else if(IsHevcProfile(profile)) |
| 2905 |
{ |
| 2906 |
maxWidth = m_decHevcMaxWidth; |
| 2907 |
maxHeight = m_decHevcMaxHeight; |
| 2908 |
} |
| 2909 |
else if(IsVc1Profile(profile)) |
| 2910 |
{ |
| 2911 |
maxWidth = m_decVc1MaxWidth; |
| 2912 |
maxHeight = m_decVc1MaxHeight; |
| 2913 |
} |
| 2914 |
else if(IsJpegProfile(profile)) |
| 2915 |
{ |
| 2916 |
maxWidth = m_decJpegMaxWidth; |
| 2917 |
maxHeight = m_decJpegMaxHeight; |
| 2918 |
} |
| 2919 |
else if(IsVp9Profile(profile)) |
| 2920 |
{ |
| 2921 |
maxWidth = m_decVp9MaxWidth; |
| 2922 |
maxHeight = m_decVp9MaxHeight; |
| 2923 |
} |
| 2924 |
|
| 2925 |
attribs[i].type = VASurfaceAttribMaxWidth; |
| 2926 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2927 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 2928 |
attribs[i].value.value.i = maxWidth; |
| 2929 |
i++; |
| 2930 |
|
| 2931 |
attribs[i].type = VASurfaceAttribMaxHeight; |
| 2932 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2933 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 2934 |
attribs[i].value.value.i = maxHeight; |
| 2935 |
i++; |
| 2936 |
|
| 2937 |
attribs[i].type = VASurfaceAttribMemoryType; |
| 2938 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2939 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2940 |
attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | |
| 2941 |
VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR | |
| 2942 |
VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM | |
| 2943 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME | |
| 2944 |
#if VA_CHECK_VERSION(1, 21, 0) |
| 2945 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_3 | |
| 2946 |
#endif |
| 2947 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2; |
| 2948 |
i++; |
| 2949 |
} |
| 2950 |
else if(entrypoint == VAEntrypointEncSlice || entrypoint == VAEntrypointEncSliceLP || entrypoint == VAEntrypointEncPicture || entrypoint == VAEntrypointFEI) |
| 2951 |
{ |
| 2952 |
if (profile == VAProfileHEVCMain10 || profile == VAProfileVP9Profile2) |
| 2953 |
{ |
| 2954 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2955 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2956 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2957 |
attribs[i].value.value.i = VA_FOURCC('P', '0', '1', '0'); |
| 2958 |
i++; |
| 2959 |
} |
| 2960 |
else if(profile == VAProfileHEVCMain12) |
| 2961 |
{ |
| 2962 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2963 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2964 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2965 |
attribs[i].value.value.i = VA_FOURCC_P012; |
| 2966 |
i++; |
| 2967 |
|
| 2968 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2969 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2970 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2971 |
attribs[i].value.value.i = VA_FOURCC_P016; |
| 2972 |
i++; |
| 2973 |
} |
| 2974 |
else if(profile == VAProfileHEVCMain422_10) |
| 2975 |
{ |
| 2976 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2977 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2978 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2979 |
attribs[i].value.value.i = VA_FOURCC_YUY2; |
| 2980 |
i++; |
| 2981 |
|
| 2982 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2983 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2984 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2985 |
attribs[i].value.value.i = VA_FOURCC_Y210; |
| 2986 |
i++; |
| 2987 |
} |
| 2988 |
else if(profile == VAProfileHEVCMain422_12) |
| 2989 |
{ |
| 2990 |
//hevc rext: Y216 12/16bit 422 |
| 2991 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 2992 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 2993 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 2994 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 2995 |
attribs[i].value.value.i = VA_FOURCC_Y212; |
| 2996 |
i++; |
| 2997 |
#endif |
| 2998 |
|
| 2999 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 3000 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 3001 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 3002 |
attribs[i].value.value.i = VA_FOURCC_Y216; |
| 3003 |
i++; |
| 3004 |
} |
| 3005 |
else if (profile == VAProfileJPEGBaseline) |
| 3006 |
{ |
| 3007 |
for (uint32_t j = 0; j < m_numJpegEncSurfaceAttr; j++) |
| 3008 |
{ |
| 3009 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 3010 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 3011 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 3012 |
attribs[i].value.value.i = m_jpegEncSurfaceAttr[j]; |
| 3013 |
i++; |
| 3014 |
} |
| 3015 |
} |
| 3016 |
else |
| 3017 |
{ |
| 3018 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 3019 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 3020 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 3021 |
attribs[i].value.value.i = VA_FOURCC('N', 'V', '1', '2'); |
| 3022 |
i++; |
| 3023 |
} |
| 3024 |
attribs[i].type = VASurfaceAttribMaxWidth; |
| 3025 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 3026 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 3027 |
attribs[i].value.value.i = CODEC_MAX_PIC_WIDTH; |
| 3028 |
|
| 3029 |
if(profile == VAProfileJPEGBaseline) |
| 3030 |
{ |
| 3031 |
attribs[i].value.value.i = ENCODE_JPEG_MAX_PIC_WIDTH; |
| 3032 |
} |
| 3033 |
if(IsAvcProfile(profile)||IsHevcProfile(profile)||IsVp8Profile(profile)) |
| 3034 |
{ |
| 3035 |
attribs[i].value.value.i = CODEC_4K_MAX_PIC_WIDTH; |
| 3036 |
} |
| 3037 |
i++; |
| 3038 |
|
| 3039 |
attribs[i].type = VASurfaceAttribMaxHeight; |
| 3040 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 3041 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 3042 |
attribs[i].value.value.i = CODEC_MAX_PIC_HEIGHT; |
| 3043 |
if(profile == VAProfileJPEGBaseline) |
| 3044 |
{ |
| 3045 |
attribs[i].value.value.i = ENCODE_JPEG_MAX_PIC_HEIGHT; |
| 3046 |
} |
| 3047 |
if(IsAvcProfile(profile)||IsHevcProfile(profile)||IsVp8Profile(profile)) |
| 3048 |
{ |
| 3049 |
attribs[i].value.value.i = CODEC_4K_MAX_PIC_HEIGHT; |
| 3050 |
} |
| 3051 |
i++; |
| 3052 |
|
| 3053 |
attribs[i].type = VASurfaceAttribMinWidth; |
| 3054 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 3055 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 3056 |
attribs[i].value.value.i = m_encMinWidth; |
| 3057 |
if(profile == VAProfileJPEGBaseline) |
| 3058 |
{ |
| 3059 |
attribs[i].value.value.i = m_encJpegMinWidth; |
| 3060 |
} |
| 3061 |
i++; |
| 3062 |
|
| 3063 |
attribs[i].type = VASurfaceAttribMinHeight; |
| 3064 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 3065 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 3066 |
attribs[i].value.value.i = m_encMinHeight; |
| 3067 |
if(profile == VAProfileJPEGBaseline) |
| 3068 |
{ |
| 3069 |
attribs[i].value.value.i = m_encJpegMinHeight; |
| 3070 |
} |
| 3071 |
i++; |
| 3072 |
|
| 3073 |
attribs[i].type = VASurfaceAttribMemoryType; |
| 3074 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 3075 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 3076 |
attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | |
| 3077 |
VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR | |
| 3078 |
VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM | |
| 3079 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME | |
| 3080 |
#if VA_CHECK_VERSION(1, 21, 0) |
| 3081 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_3 | |
| 3082 |
#endif |
| 3083 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2; |
| 3084 |
i++; |
| 3085 |
} |
| 3086 |
else |
| 3087 |
{ |
| 3088 |
MOS_FreeMemory(attribs); |
| 3089 |
return VA_STATUS_ERROR_UNIMPLEMENTED; |
| 3090 |
} |
| 3091 |
|
| 3092 |
if (i > *numAttribs) |
| 3093 |
{ |
| 3094 |
*numAttribs = i; |
| 3095 |
MOS_FreeMemory(attribs); |
| 3096 |
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; |
| 3097 |
} |
| 3098 |
|
| 3099 |
*numAttribs = i; |
| 3100 |
MOS_SecureMemcpy(attribList, i * sizeof(*attribs), attribs, i * sizeof(*attribs)); |
| 3101 |
|
| 3102 |
MOS_FreeMemory(attribs); |
| 3103 |
return status; |
| 3104 |
} |
| 3105 |
|
| 3106 |
VAStatus MediaLibvaCaps::QueryDisplayAttributes( |
| 3107 |
VADisplayAttribute *attribList, |
| 3108 |
int32_t *numAttribs) |
| 3109 |
{ |
| 3110 |
DDI_CHK_NULL(attribList, "Null attribList", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3111 |
DDI_CHK_NULL(numAttribs, "Null num_attribs", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3112 |
VADisplayAttribute * attrib = attribList; |
| 3113 |
*numAttribs = 0; |
| 3114 |
|
| 3115 |
attrib->type = VADisplayAttribCopy; |
| 3116 |
(*numAttribs) ++; |
| 3117 |
#if VA_CHECK_VERSION(1, 15, 0) |
| 3118 |
attrib ++; |
| 3119 |
|
| 3120 |
attrib->type = VADisplayPCIID; |
| 3121 |
(*numAttribs) ++; |
| 3122 |
#endif |
| 3123 |
|
| 3124 |
return GetDisplayAttributes(attribList, *numAttribs); |
| 3125 |
} |
| 3126 |
|
| 3127 |
VAStatus MediaLibvaCaps::GetDisplayAttributes( |
| 3128 |
VADisplayAttribute *attribList, |
| 3129 |
int32_t numAttribs) |
| 3130 |
{ |
| 3131 |
DDI_CHK_NULL(attribList, "Null attribList", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3132 |
for(auto i = 0; i < numAttribs; i ++) |
| 3133 |
{ |
| 3134 |
switch(attribList->type) |
| 3135 |
{ |
| 3136 |
case VADisplayAttribCopy: |
| 3137 |
attribList->min_value = attribList->value = attribList->max_value = 0; |
| 3138 |
attribList->flags = VA_DISPLAY_ATTRIB_GETTABLE; |
| 3139 |
break; |
| 3140 |
#if VA_CHECK_VERSION(1, 15, 0) |
| 3141 |
case VADisplayPCIID: |
| 3142 |
attribList->min_value = attribList->value = attribList->max_value = (m_mediaCtx->iDeviceId & 0xffff) | 0x80860000; |
| 3143 |
attribList->flags = VA_DISPLAY_ATTRIB_GETTABLE; |
| 3144 |
break; |
| 3145 |
#endif |
| 3146 |
default: |
| 3147 |
attribList->min_value = VA_ATTRIB_NOT_SUPPORTED; |
| 3148 |
attribList->max_value = VA_ATTRIB_NOT_SUPPORTED; |
| 3149 |
attribList->value = VA_ATTRIB_NOT_SUPPORTED; |
| 3150 |
attribList->flags = VA_DISPLAY_ATTRIB_NOT_SUPPORTED; |
| 3151 |
break; |
| 3152 |
} |
| 3153 |
attribList ++; |
| 3154 |
} |
| 3155 |
return VA_STATUS_SUCCESS; |
| 3156 |
} |
| 3157 |
|
| 3158 |
bool MediaLibvaCaps::IsVc1Profile(VAProfile profile) |
| 3159 |
{ |
| 3160 |
return ( |
| 3161 |
(profile == VAProfileVC1Advanced) || |
| 3162 |
(profile == VAProfileVC1Main) || |
| 3163 |
(profile == VAProfileVC1Simple) |
| 3164 |
); |
| 3165 |
} |
| 3166 |
|
| 3167 |
bool MediaLibvaCaps::IsAvcProfile(VAProfile profile) |
| 3168 |
{ |
| 3169 |
return ( |
| 3170 |
(profile == VAProfileH264ConstrainedBaseline) || |
| 3171 |
(profile == VAProfileH264Main) || |
| 3172 |
(profile == VAProfileH264High) |
| 3173 |
); |
| 3174 |
} |
| 3175 |
|
| 3176 |
bool MediaLibvaCaps::IsMpeg2Profile(VAProfile profile) |
| 3177 |
{ |
| 3178 |
return ( |
| 3179 |
(profile == VAProfileMPEG2Simple) || |
| 3180 |
(profile == VAProfileMPEG2Main) |
| 3181 |
); |
| 3182 |
} |
| 3183 |
|
| 3184 |
bool MediaLibvaCaps::IsVp8Profile(VAProfile profile) |
| 3185 |
{ |
| 3186 |
return (profile == VAProfileVP8Version0_3); |
| 3187 |
} |
| 3188 |
|
| 3189 |
bool MediaLibvaCaps::IsVp9Profile(VAProfile profile) |
| 3190 |
{ |
| 3191 |
return ( |
| 3192 |
(profile == VAProfileVP9Profile0) || |
| 3193 |
(profile == VAProfileVP9Profile2) || |
| 3194 |
(profile == VAProfileVP9Profile1) || |
| 3195 |
(profile == VAProfileVP9Profile3) |
| 3196 |
); |
| 3197 |
} |
| 3198 |
|
| 3199 |
bool MediaLibvaCaps::IsHevcProfile(VAProfile profile) |
| 3200 |
{ |
| 3201 |
return ( |
| 3202 |
(profile == VAProfileHEVCMain) || |
| 3203 |
(profile == VAProfileHEVCMain10) || |
| 3204 |
(profile == VAProfileHEVCMain12) || |
| 3205 |
(profile == VAProfileHEVCMain422_10) || |
| 3206 |
(profile == VAProfileHEVCMain422_12) || |
| 3207 |
(profile == VAProfileHEVCMain444) || |
| 3208 |
(profile == VAProfileHEVCMain444_10) || |
| 3209 |
(profile == VAProfileHEVCMain444_12) |
| 3210 |
); |
| 3211 |
} |
| 3212 |
|
| 3213 |
bool MediaLibvaCaps::IsJpegProfile(VAProfile profile) |
| 3214 |
{ |
| 3215 |
return (profile == VAProfileJPEGBaseline); |
| 3216 |
} |
| 3217 |
|
| 3218 |
bool MediaLibvaCaps::IsEncFei(VAEntrypoint entrypoint, uint32_t feiFunction) |
| 3219 |
{ |
| 3220 |
if ((feiFunction & VA_FEI_FUNCTION_ENC_PAK) || |
| 3221 |
(feiFunction == VA_FEI_FUNCTION_ENC) || |
| 3222 |
(feiFunction == VA_FEI_FUNCTION_PAK) || |
| 3223 |
(feiFunction == (VA_FEI_FUNCTION_ENC | VA_FEI_FUNCTION_PAK)) || |
| 3224 |
(entrypoint == VAEntrypointStats)) |
| 3225 |
{ |
| 3226 |
return true; |
| 3227 |
} |
| 3228 |
return false; |
| 3229 |
} |
| 3230 |
|
| 3231 |
CODECHAL_FUNCTION MediaLibvaCaps::GetEncodeCodecFunction(VAProfile profile, VAEntrypoint entrypoint, uint32_t feiFunction) |
| 3232 |
{ |
| 3233 |
CODECHAL_FUNCTION codecFunction; |
| 3234 |
if (profile == VAProfileJPEGBaseline) |
| 3235 |
{ |
| 3236 |
codecFunction = CODECHAL_FUNCTION_PAK; |
| 3237 |
} |
| 3238 |
else if (entrypoint == VAEntrypointEncSliceLP) |
| 3239 |
{ |
| 3240 |
codecFunction = CODECHAL_FUNCTION_ENC_VDENC_PAK; |
| 3241 |
} |
| 3242 |
else |
| 3243 |
{ |
| 3244 |
codecFunction = CODECHAL_FUNCTION_ENC_PAK; |
| 3245 |
/* |
| 3246 |
// FeiFunction bit 0: FEI_ENC_INTEL |
| 3247 |
// 1: FEI_PAK_INTEL |
| 3248 |
// 2: FEI_ENC_PAK_INTEL |
| 3249 |
// |
| 3250 |
// +---+---+---+ |
| 3251 |
// | 2 | 1 | 0 | FeiFunction [2:0] |
| 3252 |
// +---+---+---+ |
| 3253 |
// |
| 3254 |
// b000 means ENC_PAK |
| 3255 |
*/ |
| 3256 |
if (feiFunction & VA_FEI_FUNCTION_ENC_PAK) |
| 3257 |
{ |
| 3258 |
codecFunction = CODECHAL_FUNCTION_FEI_ENC_PAK; |
| 3259 |
} |
| 3260 |
else if (feiFunction == VA_FEI_FUNCTION_ENC) |
| 3261 |
{ |
| 3262 |
codecFunction = CODECHAL_FUNCTION_FEI_ENC; |
| 3263 |
} |
| 3264 |
else if (feiFunction == VA_FEI_FUNCTION_PAK) |
| 3265 |
{ |
| 3266 |
codecFunction = CODECHAL_FUNCTION_FEI_PAK; |
| 3267 |
} |
| 3268 |
else if (feiFunction == (VA_FEI_FUNCTION_ENC | VA_FEI_FUNCTION_PAK)) |
| 3269 |
{ |
| 3270 |
// codecFunction in context keeps FEI_ENC_PAK if input is ENC|PAK |
| 3271 |
codecFunction = CODECHAL_FUNCTION_FEI_ENC_PAK; |
| 3272 |
} |
| 3273 |
else if (entrypoint == VAEntrypointStats) |
| 3274 |
{ |
| 3275 |
codecFunction = CODECHAL_FUNCTION_FEI_PRE_ENC; |
| 3276 |
} |
| 3277 |
} |
| 3278 |
return codecFunction; |
| 3279 |
} |
| 3280 |
|
| 3281 |
CODECHAL_MODE MediaLibvaCaps::GetEncodeCodecMode(VAProfile profile, VAEntrypoint entrypoint) |
| 3282 |
{ |
| 3283 |
if (entrypoint == VAEntrypointStats) |
| 3284 |
{ |
| 3285 |
return CODECHAL_ENCODE_MODE_AVC; |
| 3286 |
} |
| 3287 |
|
| 3288 |
switch (profile) |
| 3289 |
{ |
| 3290 |
case VAProfileH264High: |
| 3291 |
case VAProfileH264Main: |
| 3292 |
case VAProfileH264ConstrainedBaseline: |
| 3293 |
return CODECHAL_ENCODE_MODE_AVC; |
| 3294 |
case VAProfileMPEG2Main: |
| 3295 |
case VAProfileMPEG2Simple: |
| 3296 |
return CODECHAL_ENCODE_MODE_MPEG2; |
| 3297 |
case VAProfileJPEGBaseline: |
| 3298 |
return CODECHAL_ENCODE_MODE_JPEG; |
| 3299 |
case VAProfileVP8Version0_3: |
| 3300 |
return CODECHAL_ENCODE_MODE_VP8; |
| 3301 |
case VAProfileVP9Profile0: |
| 3302 |
return CODECHAL_ENCODE_MODE_VP9; |
| 3303 |
case VAProfileHEVCMain: |
| 3304 |
case VAProfileHEVCMain10: |
| 3305 |
case VAProfileHEVCMain12: |
| 3306 |
case VAProfileHEVCMain422_10: |
| 3307 |
case VAProfileHEVCMain422_12: |
| 3308 |
return CODECHAL_ENCODE_MODE_HEVC; |
| 3309 |
default: |
| 3310 |
DDI_ASSERTMESSAGE("Invalid Encode Mode"); |
| 3311 |
return CODECHAL_UNSUPPORTED_MODE; |
| 3312 |
} |
| 3313 |
} |
| 3314 |
|
| 3315 |
CODECHAL_MODE MediaLibvaCaps::GetDecodeCodecMode(VAProfile profile) |
| 3316 |
{ |
| 3317 |
switch (profile) |
| 3318 |
{ |
| 3319 |
case VAProfileH264High: |
| 3320 |
case VAProfileH264Main: |
| 3321 |
case VAProfileH264ConstrainedBaseline: |
| 3322 |
return CODECHAL_DECODE_MODE_AVCVLD; |
| 3323 |
case VAProfileMPEG2Main: |
| 3324 |
case VAProfileMPEG2Simple: |
| 3325 |
return CODECHAL_DECODE_MODE_MPEG2VLD; |
| 3326 |
case VAProfileJPEGBaseline: |
| 3327 |
return CODECHAL_DECODE_MODE_JPEG; |
| 3328 |
case VAProfileVP8Version0_3: |
| 3329 |
return CODECHAL_DECODE_MODE_VP8VLD; |
| 3330 |
case VAProfileVP9Profile0: |
| 3331 |
case VAProfileVP9Profile1: |
| 3332 |
case VAProfileVP9Profile2: |
| 3333 |
case VAProfileVP9Profile3: |
| 3334 |
return CODECHAL_DECODE_MODE_VP9VLD; |
| 3335 |
case VAProfileHEVCMain: |
| 3336 |
case VAProfileHEVCMain10: |
| 3337 |
case VAProfileHEVCMain12: |
| 3338 |
case VAProfileHEVCMain422_10: |
| 3339 |
case VAProfileHEVCMain422_12: |
| 3340 |
case VAProfileHEVCMain444: |
| 3341 |
case VAProfileHEVCMain444_10: |
| 3342 |
case VAProfileHEVCMain444_12: |
| 3343 |
return CODECHAL_DECODE_MODE_HEVCVLD; |
| 3344 |
case VAProfileVC1Simple: |
| 3345 |
case VAProfileVC1Main: |
| 3346 |
case VAProfileVC1Advanced: |
| 3347 |
return CODECHAL_DECODE_MODE_VC1VLD; |
| 3348 |
default: |
| 3349 |
DDI_ASSERTMESSAGE("Invalid Encode Mode"); |
| 3350 |
return CODECHAL_UNSUPPORTED_MODE; |
| 3351 |
} |
| 3352 |
} |
| 3353 |
|
| 3354 |
std::string MediaLibvaCaps::GetDecodeCodecKey(VAProfile profile) |
| 3355 |
{ |
| 3356 |
switch (profile) |
| 3357 |
{ |
| 3358 |
case VAProfileH264High: |
| 3359 |
case VAProfileH264Main: |
| 3360 |
case VAProfileH264ConstrainedBaseline: |
| 3361 |
return DECODE_ID_AVC; |
| 3362 |
case VAProfileMPEG2Main: |
| 3363 |
case VAProfileMPEG2Simple: |
| 3364 |
return DECODE_ID_MPEG2; |
| 3365 |
case VAProfileJPEGBaseline: |
| 3366 |
return DECODE_ID_JPEG; |
| 3367 |
case VAProfileVP8Version0_3: |
| 3368 |
return DECODE_ID_VP8; |
| 3369 |
case VAProfileVP9Profile0: |
| 3370 |
case VAProfileVP9Profile1: |
| 3371 |
case VAProfileVP9Profile2: |
| 3372 |
case VAProfileVP9Profile3: |
| 3373 |
return DECODE_ID_VP9; |
| 3374 |
case VAProfileHEVCMain: |
| 3375 |
case VAProfileHEVCMain10: |
| 3376 |
return DECODE_ID_HEVC; |
| 3377 |
case VAProfileVC1Simple: |
| 3378 |
case VAProfileVC1Main: |
| 3379 |
case VAProfileVC1Advanced: |
| 3380 |
return DECODE_ID_VC1; |
| 3381 |
default: |
| 3382 |
DDI_ASSERTMESSAGE("Invalid Encode Mode"); |
| 3383 |
return DECODE_ID_NONE; |
| 3384 |
} |
| 3385 |
} |
| 3386 |
|
| 3387 |
std::string MediaLibvaCaps::GetEncodeCodecKey(VAProfile profile, VAEntrypoint entrypoint, uint32_t feiFunction) |
| 3388 |
{ |
| 3389 |
switch (profile) |
| 3390 |
{ |
| 3391 |
case VAProfileH264High: |
| 3392 |
case VAProfileH264Main: |
| 3393 |
case VAProfileH264ConstrainedBaseline: |
| 3394 |
if (IsEncFei(entrypoint, feiFunction)) |
| 3395 |
{ |
| 3396 |
return ENCODE_ID_AVCFEI; |
| 3397 |
} |
| 3398 |
else |
| 3399 |
{ |
| 3400 |
return ENCODE_ID_AVC; |
| 3401 |
} |
| 3402 |
case VAProfileMPEG2Main: |
| 3403 |
case VAProfileMPEG2Simple: |
| 3404 |
return ENCODE_ID_MPEG2; |
| 3405 |
case VAProfileJPEGBaseline: |
| 3406 |
return ENCODE_ID_JPEG; |
| 3407 |
case VAProfileVP8Version0_3: |
| 3408 |
return ENCODE_ID_VP8; |
| 3409 |
case VAProfileVP9Profile0: |
| 3410 |
return ENCODE_ID_VP9; |
| 3411 |
case VAProfileHEVCMain: |
| 3412 |
case VAProfileHEVCMain10: |
| 3413 |
case VAProfileHEVCMain12: |
| 3414 |
case VAProfileHEVCMain422_10: |
| 3415 |
case VAProfileHEVCMain422_12: |
| 3416 |
if (IsEncFei(entrypoint, feiFunction)) |
| 3417 |
{ |
| 3418 |
return ENCODE_ID_HEVCFEI; |
| 3419 |
} |
| 3420 |
else |
| 3421 |
{ |
| 3422 |
return ENCODE_ID_HEVC; |
| 3423 |
} |
| 3424 |
case VAProfileNone: |
| 3425 |
if (IsEncFei(entrypoint, feiFunction)) |
| 3426 |
{ |
| 3427 |
return ENCODE_ID_AVCFEI; |
| 3428 |
} |
| 3429 |
else |
| 3430 |
{ |
| 3431 |
return ENCODE_ID_NONE; |
| 3432 |
} |
| 3433 |
default: |
| 3434 |
return ENCODE_ID_NONE; |
| 3435 |
} |
| 3436 |
} |
| 3437 |
|
| 3438 |
bool MediaLibvaCaps::IsDecConfigId(VAConfigID configId) |
| 3439 |
{ |
| 3440 |
// configId >= DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE always be true |
| 3441 |
return configId < (DDI_CODEC_GEN_CONFIG_ATTRIBUTES_DEC_BASE + m_decConfigs.size()); |
| 3442 |
} |
| 3443 |
|
| 3444 |
bool MediaLibvaCaps::IsEncConfigId(VAConfigID configId) |
| 3445 |
{ |
| 3446 |
return ((configId >= DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE) && |
| 3447 |
(configId < (DDI_CODEC_GEN_CONFIG_ATTRIBUTES_ENC_BASE + m_encConfigs.size()))); |
| 3448 |
} |
| 3449 |
|
| 3450 |
bool MediaLibvaCaps::IsVpConfigId(VAConfigID configId) |
| 3451 |
{ |
| 3452 |
return ((configId >= DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE) && |
| 3453 |
(configId < (DDI_VP_GEN_CONFIG_ATTRIBUTES_BASE + m_vpConfigs.size()))); |
| 3454 |
} |
| 3455 |
|
| 3456 |
|
| 3457 |
MediaLibvaCapsCpInterface* MediaLibvaCaps::GetCpCaps() |
| 3458 |
{ |
| 3459 |
return m_CapsCp; |
| 3460 |
} |
| 3461 |
|
| 3462 |
bool MediaLibvaCaps::IsMfeSupportedEntrypoint(VAEntrypoint entrypoint) |
| 3463 |
{ |
| 3464 |
if (entrypoint != VAEntrypointEncSlice && //MFE only support Encode slice |
| 3465 |
entrypoint != VAEntrypointFEI ) //and FEI yet |
| 3466 |
{ |
| 3467 |
return false; |
| 3468 |
} |
| 3469 |
|
| 3470 |
return true; |
| 3471 |
} |
| 3472 |
|
| 3473 |
bool MediaLibvaCaps::IsMfeSupportedProfile(VAProfile profile) |
| 3474 |
{ |
| 3475 |
if (profile != VAProfileH264Main && // MFE only support AVC now |
| 3476 |
profile != VAProfileH264High && |
| 3477 |
profile != VAProfileH264ConstrainedBaseline) |
| 3478 |
{ |
| 3479 |
return false; |
| 3480 |
} |
| 3481 |
|
| 3482 |
return true; |
| 3483 |
} |
| 3484 |
|
| 3485 |
VAStatus MediaLibvaCaps::DestroyConfig(VAConfigID configId) |
| 3486 |
{ |
| 3487 |
if ( IsDecConfigId(configId) || IsEncConfigId(configId) || IsVpConfigId(configId) || |
| 3488 |
(m_CapsCp && m_CapsCp->IsCpConfigId(configId)) ) |
| 3489 |
{ |
| 3490 |
return VA_STATUS_SUCCESS; |
| 3491 |
} |
| 3492 |
|
| 3493 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 3494 |
} |
| 3495 |
|
| 3496 |
GMM_RESOURCE_FORMAT MediaLibvaCaps::ConvertMediaFmtToGmmFmt( |
| 3497 |
DDI_MEDIA_FORMAT format) |
| 3498 |
{ |
| 3499 |
switch (format) |
| 3500 |
{ |
| 3501 |
case Media_Format_X8R8G8B8 : return GMM_FORMAT_B8G8R8X8_UNORM_TYPE; |
| 3502 |
case Media_Format_A8R8G8B8 : return GMM_FORMAT_B8G8R8A8_UNORM_TYPE; |
| 3503 |
case Media_Format_X8B8G8R8 : return GMM_FORMAT_R8G8B8X8_UNORM_TYPE; |
| 3504 |
case Media_Format_A8B8G8R8 : return GMM_FORMAT_R8G8B8A8_UNORM_TYPE; |
| 3505 |
case Media_Format_R8G8B8A8 : return GMM_FORMAT_R8G8B8A8_UNORM_TYPE; |
| 3506 |
case Media_Format_R5G6B5 : return GMM_FORMAT_B5G6R5_UNORM_TYPE; |
| 3507 |
case Media_Format_R8G8B8 : return GMM_FORMAT_R8G8B8_UNORM; |
| 3508 |
case Media_Format_RGBP : return GMM_FORMAT_RGBP; |
| 3509 |
case Media_Format_BGRP : return GMM_FORMAT_BGRP; |
| 3510 |
case Media_Format_NV12 : return GMM_FORMAT_NV12_TYPE; |
| 3511 |
case Media_Format_NV21 : return GMM_FORMAT_NV21_TYPE; |
| 3512 |
case Media_Format_AYUV : return GMM_FORMAT_AYUV_TYPE; |
| 3513 |
case Media_Format_YUY2 : return GMM_FORMAT_YUY2; |
| 3514 |
case Media_Format_UYVY : return GMM_FORMAT_UYVY; |
| 3515 |
case Media_Format_YV12 : return GMM_FORMAT_YV12_TYPE; |
| 3516 |
case Media_Format_IYUV : return GMM_FORMAT_IYUV_TYPE; |
| 3517 |
case Media_Format_I420 : return GMM_FORMAT_I420_TYPE; |
| 3518 |
case Media_Format_444P : return GMM_FORMAT_MFX_JPEG_YUV444_TYPE; |
| 3519 |
case Media_Format_422H : return GMM_FORMAT_MFX_JPEG_YUV422H_TYPE; |
| 3520 |
case Media_Format_411P : return GMM_FORMAT_MFX_JPEG_YUV411_TYPE; |
| 3521 |
case Media_Format_422V : return GMM_FORMAT_MFX_JPEG_YUV422V_TYPE; |
| 3522 |
case Media_Format_IMC3 : return GMM_FORMAT_IMC3_TYPE; |
| 3523 |
case Media_Format_400P : return GMM_FORMAT_GENERIC_8BIT; |
| 3524 |
case Media_Format_Buffer : return GMM_FORMAT_RENDER_8BIT; |
| 3525 |
case Media_Format_P010 : return GMM_FORMAT_P010_TYPE; |
| 3526 |
case Media_Format_P012 : return GMM_FORMAT_P016_TYPE; |
| 3527 |
case Media_Format_P016 : return GMM_FORMAT_P016_TYPE; |
| 3528 |
case Media_Format_Y210 : return GMM_FORMAT_Y210_TYPE; |
| 3529 |
case Media_Format_Y216 : return GMM_FORMAT_Y216_TYPE; |
| 3530 |
case Media_Format_Y410 : return GMM_FORMAT_Y410_TYPE; |
| 3531 |
case Media_Format_Y416 : return GMM_FORMAT_Y416_TYPE; |
| 3532 |
case Media_Format_R10G10B10A2: return GMM_FORMAT_R10G10B10A2_UNORM_TYPE; |
| 3533 |
case Media_Format_B10G10R10A2: return GMM_FORMAT_B10G10R10A2_UNORM_TYPE; |
| 3534 |
case Media_Format_R10G10B10X2: return GMM_FORMAT_R10G10B10A2_UNORM_TYPE; |
| 3535 |
case Media_Format_B10G10R10X2: return GMM_FORMAT_B10G10R10A2_UNORM_TYPE; |
| 3536 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 3537 |
case Media_Format_Y212 : return GMM_FORMAT_Y212_TYPE; |
| 3538 |
case Media_Format_Y412 : return GMM_FORMAT_Y412_TYPE; |
| 3539 |
#endif |
| 3540 |
#if VA_CHECK_VERSION(1, 13, 0) |
| 3541 |
case Media_Format_XYUV : return GMM_FORMAT_AYUV_TYPE; |
| 3542 |
#endif |
| 3543 |
default : return GMM_FORMAT_INVALID; |
| 3544 |
} |
| 3545 |
} |
| 3546 |
|
| 3547 |
GMM_RESOURCE_FORMAT MediaLibvaCaps::ConvertFourccToGmmFmt(uint32_t fourcc) |
| 3548 |
{ |
| 3549 |
switch (fourcc) |
| 3550 |
{ |
| 3551 |
case VA_FOURCC_BGRA : return GMM_FORMAT_B8G8R8A8_UNORM_TYPE; |
| 3552 |
case VA_FOURCC_ARGB : return GMM_FORMAT_B8G8R8A8_UNORM_TYPE; |
| 3553 |
case VA_FOURCC_RGBA : return GMM_FORMAT_R8G8B8A8_UNORM_TYPE; |
| 3554 |
case VA_FOURCC_ABGR : return GMM_FORMAT_R8G8B8A8_UNORM_TYPE; |
| 3555 |
case VA_FOURCC_BGRX : return GMM_FORMAT_B8G8R8X8_UNORM_TYPE; |
| 3556 |
case VA_FOURCC_XRGB : return GMM_FORMAT_B8G8R8X8_UNORM_TYPE; |
| 3557 |
case VA_FOURCC_RGBX : return GMM_FORMAT_R8G8B8X8_UNORM_TYPE; |
| 3558 |
case VA_FOURCC_XBGR : return GMM_FORMAT_R8G8B8X8_UNORM_TYPE; |
| 3559 |
case VA_FOURCC_R8G8B8 : return GMM_FORMAT_R8G8B8_UNORM; |
| 3560 |
case VA_FOURCC_RGBP : return GMM_FORMAT_RGBP; |
| 3561 |
case VA_FOURCC_BGRP : return GMM_FORMAT_BGRP; |
| 3562 |
case VA_FOURCC_RGB565 : return GMM_FORMAT_B5G6R5_UNORM_TYPE; |
| 3563 |
case VA_FOURCC_AYUV : return GMM_FORMAT_AYUV_TYPE; |
| 3564 |
#if VA_CHECK_VERSION(1, 13, 0) |
| 3565 |
case VA_FOURCC_XYUV : return GMM_FORMAT_AYUV_TYPE; |
| 3566 |
#endif |
| 3567 |
case VA_FOURCC_NV12 : return GMM_FORMAT_NV12_TYPE; |
| 3568 |
case VA_FOURCC_NV21 : return GMM_FORMAT_NV21_TYPE; |
| 3569 |
case VA_FOURCC_YUY2 : return GMM_FORMAT_YUY2; |
| 3570 |
case VA_FOURCC_UYVY : return GMM_FORMAT_UYVY; |
| 3571 |
case VA_FOURCC_YV12 : return GMM_FORMAT_YV12_TYPE; |
| 3572 |
case VA_FOURCC_I420 : return GMM_FORMAT_I420_TYPE; |
| 3573 |
case VA_FOURCC_IYUV : return GMM_FORMAT_IYUV_TYPE; |
| 3574 |
case VA_FOURCC_411P : return GMM_FORMAT_MFX_JPEG_YUV411_TYPE; |
| 3575 |
case VA_FOURCC_422H : return GMM_FORMAT_MFX_JPEG_YUV422H_TYPE; |
| 3576 |
case VA_FOURCC_422V : return GMM_FORMAT_MFX_JPEG_YUV422V_TYPE; |
| 3577 |
case VA_FOURCC_444P : return GMM_FORMAT_MFX_JPEG_YUV444_TYPE; |
| 3578 |
case VA_FOURCC_IMC3 : return GMM_FORMAT_IMC3_TYPE; |
| 3579 |
case VA_FOURCC_P208 : return GMM_FORMAT_P208_TYPE; |
| 3580 |
case VA_FOURCC_P010 : return GMM_FORMAT_P010_TYPE; |
| 3581 |
case VA_FOURCC_P012 : return GMM_FORMAT_P016_TYPE; |
| 3582 |
case VA_FOURCC_P016 : return GMM_FORMAT_P016_TYPE; |
| 3583 |
case VA_FOURCC_Y210 : return GMM_FORMAT_Y210_TYPE; |
| 3584 |
case VA_FOURCC_Y410 : return GMM_FORMAT_Y410_TYPE; |
| 3585 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 3586 |
case VA_FOURCC_Y212 : return GMM_FORMAT_Y212_TYPE; |
| 3587 |
#endif |
| 3588 |
case VA_FOURCC_Y216 : return GMM_FORMAT_Y216_TYPE; |
| 3589 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 3590 |
case VA_FOURCC_Y412 : return GMM_FORMAT_Y412_TYPE; |
| 3591 |
#endif |
| 3592 |
case VA_FOURCC_Y416 : return GMM_FORMAT_Y416_TYPE; |
| 3593 |
case VA_FOURCC_Y800 : return GMM_FORMAT_GENERIC_8BIT; |
| 3594 |
case VA_FOURCC_A2R10G10B10 : return GMM_FORMAT_R10G10B10A2_UNORM_TYPE; |
| 3595 |
case VA_FOURCC_A2B10G10R10 : return GMM_FORMAT_B10G10R10A2_UNORM_TYPE; |
| 3596 |
case VA_FOURCC_X2R10G10B10 : return GMM_FORMAT_R10G10B10A2_UNORM_TYPE; |
| 3597 |
case VA_FOURCC_X2B10G10R10 : return GMM_FORMAT_B10G10R10A2_UNORM_TYPE; |
| 3598 |
default : return GMM_FORMAT_INVALID; |
| 3599 |
} |
| 3600 |
} |
| 3601 |
|
| 3602 |
bool MediaLibvaCaps::IsMfeSupportedOnPlatform(const PLATFORM &platform) |
| 3603 |
{ |
| 3604 |
return (GFX_IS_PRODUCT(platform, IGFX_SKYLAKE)); |
| 3605 |
} |
| 3606 |
|
| 3607 |
VAStatus MediaLibvaCaps::GetMbProcessingRateDec( |
| 3608 |
MEDIA_FEATURE_TABLE *skuTable, |
| 3609 |
uint32_t *mbProcessingRatePerSec) |
| 3610 |
{ |
| 3611 |
uint32_t idx = 0; |
| 3612 |
|
| 3613 |
DDI_CHK_NULL(skuTable, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3614 |
DDI_CHK_NULL(mbProcessingRatePerSec, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3615 |
|
| 3616 |
const uint32_t mb_rate[2] = |
| 3617 |
{ |
| 3618 |
// non-ULX, ULX/Atom |
| 3619 |
4800000, 3600000 |
| 3620 |
}; |
| 3621 |
|
| 3622 |
if (MEDIA_IS_SKU(skuTable, FtrLCIA) || //Atom |
| 3623 |
MEDIA_IS_SKU(skuTable, FtrULX)) // ULX |
| 3624 |
{ |
| 3625 |
idx = 1; |
| 3626 |
} |
| 3627 |
else |
| 3628 |
{ |
| 3629 |
// Default is non-ULX |
| 3630 |
idx = 0; |
| 3631 |
} |
| 3632 |
|
| 3633 |
*mbProcessingRatePerSec = mb_rate[idx]; |
| 3634 |
return VA_STATUS_SUCCESS; |
| 3635 |
} |
| 3636 |
|
| 3637 |
VAStatus MediaLibvaCaps::GetMbProcessingRateEnc( |
| 3638 |
MEDIA_FEATURE_TABLE *skuTable, |
| 3639 |
uint32_t tuIdx, |
| 3640 |
uint32_t codecMode, |
| 3641 |
bool vdencActive, |
| 3642 |
uint32_t *mbProcessingRatePerSec) |
| 3643 |
{ |
| 3644 |
DDI_CHK_NULL(skuTable, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3645 |
DDI_CHK_NULL(mbProcessingRatePerSec, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 3646 |
|
| 3647 |
uint32_t gtIdx = 0; |
| 3648 |
|
| 3649 |
// Calculate the GT index based on GT type |
| 3650 |
if (MEDIA_IS_SKU(skuTable, FtrGT1)) |
| 3651 |
{ |
| 3652 |
gtIdx = 4; |
| 3653 |
} |
| 3654 |
else if (MEDIA_IS_SKU(skuTable, FtrGT1_5)) |
| 3655 |
{ |
| 3656 |
gtIdx = 3; |
| 3657 |
} |
| 3658 |
else if (MEDIA_IS_SKU(skuTable, FtrGT2)) |
| 3659 |
{ |
| 3660 |
gtIdx = 2; |
| 3661 |
} |
| 3662 |
else if (MEDIA_IS_SKU(skuTable, FtrGT3)) |
| 3663 |
{ |
| 3664 |
gtIdx = 1; |
| 3665 |
} |
| 3666 |
else if (MEDIA_IS_SKU(skuTable, FtrGT4)) |
| 3667 |
{ |
| 3668 |
gtIdx = 0; |
| 3669 |
} |
| 3670 |
else |
| 3671 |
{ |
| 3672 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 3673 |
} |
| 3674 |
|
| 3675 |
if (MEDIA_IS_SKU(skuTable, FtrULX)) |
| 3676 |
{ |
| 3677 |
static const uint32_t mbRate[7][5] = |
| 3678 |
{ |
| 3679 |
// GT4 | GT3 | GT2 | GT1.5 | GT1 |
| 3680 |
{ 0, 0, 1029393, 1029393, 676280 }, |
| 3681 |
{ 0, 0, 975027, 975027, 661800 }, |
| 3682 |
{ 0, 0, 776921, 776921, 640000 }, |
| 3683 |
{ 0, 0, 776921, 776921, 640000 }, |
| 3684 |
{ 0, 0, 776921, 776921, 640000 }, |
| 3685 |
{ 0, 0, 416051, 416051, 317980 }, |
| 3686 |
{ 0, 0, 214438, 214438, 180655 } |
| 3687 |
}; |
| 3688 |
|
| 3689 |
if (gtIdx == 0 || gtIdx == 1) |
| 3690 |
{ |
| 3691 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 3692 |
} |
| 3693 |
*mbProcessingRatePerSec = mbRate[tuIdx][gtIdx]; |
| 3694 |
} |
| 3695 |
else if (MEDIA_IS_SKU(skuTable, FtrULT)) |
| 3696 |
{ |
| 3697 |
static const uint32_t defaultult_mb_rate[7][5] = |
| 3698 |
{ |
| 3699 |
// GT4 | GT3 | GT2 | GT1.5 | GT1 |
| 3700 |
{ 1544090, 1544090, 1544090, 1029393, 676280 }, |
| 3701 |
{ 1462540, 1462540, 1462540, 975027, 661800 }, |
| 3702 |
{ 1165381, 1165381, 1165381, 776921, 640000 }, |
| 3703 |
{ 1165381, 1165381, 1165381, 776921, 640000 }, |
| 3704 |
{ 1165381, 1165381, 1165381, 776921, 640000 }, |
| 3705 |
{ 624076, 624076, 624076, 416051, 317980 }, |
| 3706 |
{ 321657, 321657, 321657, 214438, 180655 } |
| 3707 |
}; |
| 3708 |
|
| 3709 |
*mbProcessingRatePerSec = defaultult_mb_rate[tuIdx][gtIdx]; |
| 3710 |
} |
| 3711 |
else |
| 3712 |
{ |
| 3713 |
// regular |
| 3714 |
const uint32_t default_mb_rate[7][5] = |
| 3715 |
{ |
| 3716 |
// GT4 | GT3 | GT2 | GT1.5 | GT1 |
| 3717 |
{ 1544090, 1544090, 1544090, 1029393, 676280 }, |
| 3718 |
{ 1462540, 1462540, 1462540, 975027, 661800 }, |
| 3719 |
{ 1165381, 1165381, 1165381, 776921, 640000 }, |
| 3720 |
{ 1165381, 1165381, 1165381, 776921, 640000 }, |
| 3721 |
{ 1165381, 1165381, 1165381, 776921, 640000 }, |
| 3722 |
{ 624076, 624076, 624076, 416051, 317980 }, |
| 3723 |
{ 321657, 321657, 321657, 214438, 180655 } |
| 3724 |
}; |
| 3725 |
|
| 3726 |
*mbProcessingRatePerSec = default_mb_rate[tuIdx][gtIdx]; |
| 3727 |
} |
| 3728 |
return VA_STATUS_SUCCESS; |
| 3729 |
} |
| 3730 |
|
| 3731 |
MediaLibvaCaps * MediaLibvaCaps::CreateMediaLibvaCaps(DDI_MEDIA_CONTEXT *mediaCtx) |
| 3732 |
{ |
| 3733 |
if (mediaCtx != nullptr) |
| 3734 |
{ |
| 3735 |
|
| 3736 |
MediaLibvaCaps * Caps = CapsFactory::CreateCaps( |
| 3737 |
(uint32_t)mediaCtx->platform.eProductFamily + MEDIA_EXT_FLAG, mediaCtx); |
| 3738 |
|
| 3739 |
if(Caps == nullptr) |
| 3740 |
{ |
| 3741 |
Caps = CapsFactory::CreateCaps((uint32_t)mediaCtx->platform.eProductFamily, mediaCtx); |
| 3742 |
} |
| 3743 |
|
| 3744 |
return Caps; |
| 3745 |
|
| 3746 |
} |
| 3747 |
else |
| 3748 |
{ |
| 3749 |
return nullptr; |
| 3750 |
} |
| 3751 |
} |
| 3752 |
|
| 3753 |
VAStatus MediaLibvaCaps::GetSurfaceModifier(DDI_MEDIA_SURFACE* mediaSurface, uint64_t &modifier) |
| 3754 |
{ |
| 3755 |
DDI_CHK_NULL(mediaSurface, "nullptr mediaSurface", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3756 |
DDI_CHK_NULL(mediaSurface->bo, "nullptr mediaSurface->bo", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3757 |
DDI_CHK_NULL(mediaSurface->pGmmResourceInfo, "nullptr mediaSurface->pGmmResourceInfo", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3758 |
GMM_TILE_TYPE gmmTileType = mediaSurface->pGmmResourceInfo->GetTileType(); |
| 3759 |
GMM_RESOURCE_FLAG GmmFlags = {0}; |
| 3760 |
GmmFlags = mediaSurface->pGmmResourceInfo->GetResFlags(); |
| 3761 |
|
| 3762 |
bool bMmcEnabled = false; |
| 3763 |
if ((GmmFlags.Gpu.MMC || |
| 3764 |
GmmFlags.Gpu.CCS) && |
| 3765 |
(GmmFlags.Info.MediaCompressed || |
| 3766 |
GmmFlags.Info.RenderCompressed)) |
| 3767 |
{ |
| 3768 |
bMmcEnabled = true; |
| 3769 |
} |
| 3770 |
else |
| 3771 |
{ |
| 3772 |
bMmcEnabled = false; |
| 3773 |
} |
| 3774 |
|
| 3775 |
switch(gmmTileType) |
| 3776 |
{ |
| 3777 |
case GMM_TILED_Y: |
| 3778 |
if (m_mediaCtx->m_auxTableMgr && bMmcEnabled) |
| 3779 |
{ |
| 3780 |
modifier = GmmFlags.Info.MediaCompressed ? I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS : |
| 3781 |
(GmmFlags.Info.RenderCompressed ? I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS : I915_FORMAT_MOD_Y_TILED); |
| 3782 |
} |
| 3783 |
else |
| 3784 |
{ |
| 3785 |
modifier = I915_FORMAT_MOD_Y_TILED; |
| 3786 |
} |
| 3787 |
break; |
| 3788 |
case GMM_TILED_X: |
| 3789 |
modifier = I915_FORMAT_MOD_X_TILED; |
| 3790 |
break; |
| 3791 |
case GMM_NOT_TILED: |
| 3792 |
modifier = DRM_FORMAT_MOD_LINEAR; |
| 3793 |
break; |
| 3794 |
default: |
| 3795 |
//handle other possible tile format |
| 3796 |
if(TILING_Y == mediaSurface->TileType) |
| 3797 |
{ |
| 3798 |
modifier = GmmFlags.Info.MediaCompressed ? I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS : |
| 3799 |
(GmmFlags.Info.RenderCompressed ? I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS : I915_FORMAT_MOD_Y_TILED); |
| 3800 |
} |
| 3801 |
else |
| 3802 |
{ |
| 3803 |
modifier = DRM_FORMAT_MOD_LINEAR; |
| 3804 |
} |
| 3805 |
break; |
| 3806 |
|
| 3807 |
} |
| 3808 |
return VA_STATUS_SUCCESS; |
| 3809 |
} |
| 3810 |
|
| 3811 |
VAStatus MediaLibvaCaps::SetExternalSurfaceTileFormat(DDI_MEDIA_SURFACE* mediaSurface, |
| 3812 |
uint32_t &tileformat, bool &bMemCompEnable, bool &bMemCompRC) |
| 3813 |
{ |
| 3814 |
DDI_CHK_NULL(mediaSurface, "nullptr mediaSurface", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3815 |
DDI_CHK_NULL(mediaSurface->pSurfDesc, "nullptr mediaSurface->pSurfDesc", VA_STATUS_ERROR_INVALID_SURFACE); |
| 3816 |
|
| 3817 |
switch (mediaSurface->pSurfDesc->modifier) |
| 3818 |
{ |
| 3819 |
case DRM_FORMAT_MOD_LINEAR: |
| 3820 |
tileformat = TILING_NONE; |
| 3821 |
bMemCompEnable = false; |
| 3822 |
break; |
| 3823 |
case I915_FORMAT_MOD_X_TILED: |
| 3824 |
tileformat = TILING_X; |
| 3825 |
bMemCompEnable = false; |
| 3826 |
break; |
| 3827 |
case I915_FORMAT_MOD_Y_TILED: |
| 3828 |
case I915_FORMAT_MOD_Yf_TILED: |
| 3829 |
tileformat = TILING_Y; |
| 3830 |
bMemCompEnable = false; |
| 3831 |
break; |
| 3832 |
case I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS: |
| 3833 |
tileformat = TILING_Y; |
| 3834 |
bMemCompEnable = true; |
| 3835 |
bMemCompRC = true; |
| 3836 |
break; |
| 3837 |
case I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS: |
| 3838 |
tileformat = TILING_Y; |
| 3839 |
bMemCompEnable = true; |
| 3840 |
bMemCompRC = false; |
| 3841 |
break; |
| 3842 |
default: |
| 3843 |
return VA_STATUS_ERROR_INVALID_SURFACE; |
| 3844 |
} |
| 3845 |
|
| 3846 |
return VA_STATUS_SUCCESS; |
| 3847 |
} |