| 1 |
/* |
| 2 |
* Copyright (c) 2020-2022, 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 |
//! |
| 24 |
//! \file media_libva_caps_dg2.cpp |
| 25 |
//! \brief This file implements the C++ class/interface for dg2 media capbilities. |
| 26 |
//! |
| 27 |
|
| 28 |
#include "media_libva.h" |
| 29 |
#include "media_libva_util.h" |
| 30 |
#include "media_ddi_encode_const.h" |
| 31 |
#include "codec_def_encode_hevc_g12.h" |
| 32 |
#include "codec_def_encode_av1.h" |
| 33 |
#include "media_libva_caps_dg2.h" |
| 34 |
#include "media_libva_caps_factory.h" |
| 35 |
#include "media_libva_caps_cp_interface.h" |
| 36 |
|
| 37 |
extern template class MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>; |
| 38 |
|
| 39 |
VAStatus MediaLibvaCapsDG2::LoadAv1EncProfileEntrypoints() |
| 40 |
{ |
| 41 |
VAStatus status = VA_STATUS_SUCCESS; |
| 42 |
#ifdef _AV1_ENCODE_VDENC_SUPPORTED |
| 43 |
AttribMap *attributeList = nullptr; |
| 44 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeAV1Vdenc)|| |
| 45 |
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeAV1Vdenc10bit420)) |
| 46 |
{ |
| 47 |
status = CreateEncAttributes(VAProfileAV1Profile0, VAEntrypointEncSliceLP, &attributeList); |
| 48 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 49 |
(*attributeList)[VAConfigAttribEncDynamicScaling] = 0; |
| 50 |
(*attributeList)[VAConfigAttribEncTileSupport] = 1; |
| 51 |
(*attributeList)[VAConfigAttribEncDirtyRect] = 0; |
| 52 |
(*attributeList)[VAConfigAttribEncMaxRefFrames] = CODEC_AV1_NUM_REFL0P_FRAMES | CODEC_AV1_NUM_REFL1B_FRAMES<<16; |
| 53 |
|
| 54 |
VAConfigAttrib attrib; |
| 55 |
attrib.type = (VAConfigAttribType) VAConfigAttribEncAV1; |
| 56 |
VAConfigAttribValEncAV1 attribValAV1Tools; |
| 57 |
memset(&attribValAV1Tools, 0, sizeof(attribValAV1Tools)); |
| 58 |
|
| 59 |
attrib.value = attribValAV1Tools.value; |
| 60 |
(*attributeList)[attrib.type] = attrib.value; |
| 61 |
|
| 62 |
attrib.type = (VAConfigAttribType) VAConfigAttribEncAV1Ext1; |
| 63 |
VAConfigAttribValEncAV1Ext1 attribValAV1ToolsExt1; |
| 64 |
memset(&attribValAV1ToolsExt1, 0, sizeof(attribValAV1ToolsExt1)); |
| 65 |
attribValAV1ToolsExt1.bits.interpolation_filter = 31; |
| 66 |
attribValAV1ToolsExt1.bits.min_segid_block_size_accepted = 32; |
| 67 |
attribValAV1ToolsExt1.bits.segment_feature_support = 1; |
| 68 |
|
| 69 |
attrib.value = attribValAV1ToolsExt1.value; |
| 70 |
(*attributeList)[attrib.type] = attrib.value; |
| 71 |
|
| 72 |
attrib.type = (VAConfigAttribType) VAConfigAttribEncAV1Ext2; |
| 73 |
VAConfigAttribValEncAV1Ext2 attribValAV1ToolsExt2; |
| 74 |
memset(&attribValAV1ToolsExt2, 0, sizeof(attribValAV1ToolsExt2)); |
| 75 |
attribValAV1ToolsExt2.bits.tile_size_bytes_minus1 = 3; |
| 76 |
attribValAV1ToolsExt2.bits.obu_size_bytes_minus1 = 3; |
| 77 |
attribValAV1ToolsExt2.bits.max_tile_num_minus1 = 511; |
| 78 |
attribValAV1ToolsExt2.bits.tx_mode_support = 4; |
| 79 |
|
| 80 |
attrib.value = attribValAV1ToolsExt2.value; |
| 81 |
(*attributeList)[attrib.type] = attrib.value; |
| 82 |
} |
| 83 |
|
| 84 |
if(MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeAV1Vdenc)|| |
| 85 |
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeAV1Vdenc10bit420)) |
| 86 |
{ |
| 87 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 88 |
AddEncConfig(VA_RC_CQP); |
| 89 |
AddEncConfig(VA_RC_CBR); |
| 90 |
AddEncConfig(VA_RC_VBR); |
| 91 |
AddEncConfig(VA_RC_ICQ); |
| 92 |
AddEncConfig(VA_RC_TCBRC); |
| 93 |
AddProfileEntry(VAProfileAV1Profile0, VAEntrypointEncSliceLP, attributeList, |
| 94 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 95 |
} |
| 96 |
#endif |
| 97 |
return status; |
| 98 |
} |
| 99 |
|
| 100 |
VAStatus MediaLibvaCapsDG2::LoadAvcEncLpProfileEntrypoints() |
| 101 |
{ |
| 102 |
VAStatus status = VA_STATUS_SUCCESS; |
| 103 |
|
| 104 |
#if defined(_AVC_ENCODE_VDENC_SUPPORTED) |
| 105 |
AttribMap *attributeList = nullptr; |
| 106 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeAVCVdenc)) |
| 107 |
{ |
| 108 |
status = CreateEncAttributes(VAProfileH264Main, VAEntrypointEncSliceLP, &attributeList); |
| 109 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 110 |
|
| 111 |
VAProfile profile[3] = { |
| 112 |
VAProfileH264Main, |
| 113 |
VAProfileH264High, |
| 114 |
VAProfileH264ConstrainedBaseline}; |
| 115 |
|
| 116 |
uint32_t encRcMode[] = |
| 117 |
{ |
| 118 |
VA_RC_CQP, VA_RC_CBR, VA_RC_VBR, |
| 119 |
VA_RC_CBR | VA_RC_MB, VA_RC_VBR | VA_RC_MB, |
| 120 |
VA_RC_ICQ, VA_RC_QVBR |
| 121 |
#if VA_CHECK_VERSION(1, 10, 0) |
| 122 |
, VA_RC_TCBRC |
| 123 |
#endif |
| 124 |
}; |
| 125 |
|
| 126 |
int32_t numModes = MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels) ? sizeof(encRcMode)/sizeof(encRcMode[0]) : 1; |
| 127 |
|
| 128 |
for (int32_t profileIdx = 0; profileIdx < sizeof(profile) / sizeof(profile[0]); profileIdx++) |
| 129 |
{ |
| 130 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 131 |
for (int32_t modeIdx = 0; modeIdx < numModes; modeIdx++) |
| 132 |
{ |
| 133 |
AddEncConfig(encRcMode[modeIdx]); |
| 134 |
} |
| 135 |
AddProfileEntry(profile[profileIdx], VAEntrypointEncSliceLP, attributeList, |
| 136 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 137 |
} |
| 138 |
} |
| 139 |
#endif |
| 140 |
|
| 141 |
return status; |
| 142 |
} |
| 143 |
|
| 144 |
VAStatus MediaLibvaCapsDG2::LoadProfileEntrypoints() |
| 145 |
{ |
| 146 |
VAStatus status = VA_STATUS_SUCCESS; |
| 147 |
status = MediaLibvaCapsG12::LoadProfileEntrypoints(); |
| 148 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 149 |
|
| 150 |
status = LoadAv1EncProfileEntrypoints(); |
| 151 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 152 |
|
| 153 |
return status; |
| 154 |
} |
| 155 |
|
| 156 |
std::string MediaLibvaCapsDG2::GetEncodeCodecKey(VAProfile profile, VAEntrypoint entrypoint, uint32_t feiFunction) |
| 157 |
{ |
| 158 |
switch (profile) |
| 159 |
{ |
| 160 |
case VAProfileH264High: |
| 161 |
case VAProfileH264Main: |
| 162 |
case VAProfileH264ConstrainedBaseline: |
| 163 |
if (IsEncFei(entrypoint, feiFunction)) |
| 164 |
return ENCODE_ID_AVCFEI; |
| 165 |
else |
| 166 |
return ENCODE_ID_AVC; |
| 167 |
case VAProfileMPEG2Main: |
| 168 |
case VAProfileMPEG2Simple: |
| 169 |
return ENCODE_ID_MPEG2; |
| 170 |
case VAProfileJPEGBaseline: |
| 171 |
return ENCODE_ID_JPEG; |
| 172 |
case VAProfileVP8Version0_3: |
| 173 |
return ENCODE_ID_VP8; |
| 174 |
case VAProfileVP9Profile0: |
| 175 |
case VAProfileVP9Profile1: |
| 176 |
case VAProfileVP9Profile2: |
| 177 |
case VAProfileVP9Profile3: |
| 178 |
return ENCODE_ID_VP9; |
| 179 |
case VAProfileHEVCMain: |
| 180 |
case VAProfileHEVCMain10: |
| 181 |
case VAProfileHEVCMain12: |
| 182 |
case VAProfileHEVCMain422_10: |
| 183 |
case VAProfileHEVCMain444: |
| 184 |
case VAProfileHEVCMain444_10: |
| 185 |
case VAProfileHEVCSccMain: |
| 186 |
case VAProfileHEVCSccMain10: |
| 187 |
case VAProfileHEVCSccMain444: |
| 188 |
case VAProfileHEVCSccMain444_10: |
| 189 |
return ENCODE_ID_HEVC; |
| 190 |
case VAProfileAV1Profile0: |
| 191 |
case VAProfileAV1Profile1: |
| 192 |
return ENCODE_ID_AV1; |
| 193 |
case VAProfileNone: |
| 194 |
if (IsEncFei(entrypoint, feiFunction)) |
| 195 |
return ENCODE_ID_AVCFEI; |
| 196 |
else |
| 197 |
return ENCODE_ID_NONE; |
| 198 |
default: |
| 199 |
return ENCODE_ID_NONE; |
| 200 |
} |
| 201 |
} |
| 202 |
|
| 203 |
CODECHAL_MODE MediaLibvaCapsDG2::GetEncodeCodecMode(VAProfile profile, VAEntrypoint entrypoint) |
| 204 |
{ |
| 205 |
if (entrypoint == VAEntrypointStats) |
| 206 |
{ |
| 207 |
return CODECHAL_ENCODE_MODE_AVC; |
| 208 |
} |
| 209 |
|
| 210 |
switch (profile) |
| 211 |
{ |
| 212 |
case VAProfileH264High: |
| 213 |
case VAProfileH264Main: |
| 214 |
case VAProfileH264ConstrainedBaseline: |
| 215 |
return CODECHAL_ENCODE_MODE_AVC; |
| 216 |
case VAProfileMPEG2Main: |
| 217 |
case VAProfileMPEG2Simple: |
| 218 |
return CODECHAL_ENCODE_MODE_MPEG2; |
| 219 |
case VAProfileJPEGBaseline: |
| 220 |
return CODECHAL_ENCODE_MODE_JPEG; |
| 221 |
case VAProfileVP8Version0_3: |
| 222 |
return CODECHAL_ENCODE_MODE_VP8; |
| 223 |
case VAProfileVP9Profile0: |
| 224 |
case VAProfileVP9Profile1: |
| 225 |
case VAProfileVP9Profile2: |
| 226 |
case VAProfileVP9Profile3: |
| 227 |
return CODECHAL_ENCODE_MODE_VP9; |
| 228 |
case VAProfileHEVCMain: |
| 229 |
case VAProfileHEVCMain10: |
| 230 |
case VAProfileHEVCMain12: |
| 231 |
case VAProfileHEVCMain422_10: |
| 232 |
case VAProfileHEVCMain444: |
| 233 |
case VAProfileHEVCMain444_10: |
| 234 |
case VAProfileHEVCSccMain: |
| 235 |
case VAProfileHEVCSccMain10: |
| 236 |
case VAProfileHEVCSccMain444: |
| 237 |
case VAProfileHEVCSccMain444_10: |
| 238 |
return CODECHAL_ENCODE_MODE_HEVC; |
| 239 |
case VAProfileAV1Profile0: |
| 240 |
case VAProfileAV1Profile1: |
| 241 |
return CODECHAL_ENCODE_MODE_AV1; |
| 242 |
default: |
| 243 |
DDI_ASSERTMESSAGE("Invalid Encode Mode"); |
| 244 |
return CODECHAL_UNSUPPORTED_MODE; |
| 245 |
} |
| 246 |
} |
| 247 |
|
| 248 |
VAStatus MediaLibvaCapsDG2::CheckEncodeResolution( |
| 249 |
VAProfile profile, |
| 250 |
uint32_t width, |
| 251 |
uint32_t height) |
| 252 |
{ |
| 253 |
switch (profile) |
| 254 |
{ |
| 255 |
case VAProfileJPEGBaseline: |
| 256 |
if (width > m_encJpegMaxWidth |
| 257 |
|| width < m_encJpegMinWidth |
| 258 |
|| height > m_encJpegMaxHeight |
| 259 |
|| height < m_encJpegMinHeight) |
| 260 |
{ |
| 261 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 262 |
} |
| 263 |
break; |
| 264 |
case VAProfileMPEG2Simple: |
| 265 |
case VAProfileMPEG2Main: |
| 266 |
if( width > CODEC_MAX_PIC_WIDTH |
| 267 |
|| width < m_encMinWidth |
| 268 |
|| height > CODEC_MAX_PIC_HEIGHT |
| 269 |
|| height < m_encMinHeight) |
| 270 |
{ |
| 271 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 272 |
} |
| 273 |
break; |
| 274 |
case VAProfileHEVCMain: |
| 275 |
case VAProfileHEVCMain10: |
| 276 |
case VAProfileHEVCMain12: |
| 277 |
case VAProfileHEVCMain422_10: |
| 278 |
case VAProfileHEVCMain444: |
| 279 |
case VAProfileHEVCMain444_10: |
| 280 |
case VAProfileHEVCSccMain: |
| 281 |
case VAProfileHEVCSccMain10: |
| 282 |
case VAProfileHEVCSccMain444: |
| 283 |
case VAProfileHEVCSccMain444_10: |
| 284 |
if (width > m_maxHevcEncWidth |
| 285 |
|| width < (m_vdencActive ? m_hevcVDEncMinWidth : m_encMinWidth) |
| 286 |
|| height > m_maxHevcEncHeight |
| 287 |
|| height < (m_vdencActive ? m_hevcVDEncMinHeight : m_encMinHeight)) |
| 288 |
{ |
| 289 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 290 |
} |
| 291 |
break; |
| 292 |
case VAProfileVP9Profile0: |
| 293 |
case VAProfileVP9Profile1: |
| 294 |
case VAProfileVP9Profile2: |
| 295 |
case VAProfileVP9Profile3: |
| 296 |
if ((width > m_maxVp9EncWidth) || |
| 297 |
(width < m_minVp9EncWidth) || |
| 298 |
(height > m_maxVp9EncHeight) || |
| 299 |
(height < m_minVp9EncHeight) ) |
| 300 |
{ |
| 301 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 302 |
} |
| 303 |
break; |
| 304 |
case VAProfileAV1Profile0: |
| 305 |
case VAProfileAV1Profile1: |
| 306 |
if ((width > CODEC_8K_MAX_PIC_WIDTH) || |
| 307 |
(width < m_encMinWidth) || |
| 308 |
(height > CODEC_8K_MAX_PIC_HEIGHT) || |
| 309 |
(height < m_encMinHeight)) |
| 310 |
{ |
| 311 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 312 |
} |
| 313 |
break; |
| 314 |
default: |
| 315 |
if (width > m_encMax4kWidth |
| 316 |
|| width < m_encMinWidth |
| 317 |
|| height > m_encMax4kHeight |
| 318 |
|| height < m_encMinHeight) |
| 319 |
{ |
| 320 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 321 |
} |
| 322 |
break; |
| 323 |
} |
| 324 |
return VA_STATUS_SUCCESS; |
| 325 |
} |
| 326 |
|
| 327 |
VAStatus MediaLibvaCapsDG2::CheckEncRTFormat( |
| 328 |
VAProfile profile, |
| 329 |
VAEntrypoint entrypoint, |
| 330 |
VAConfigAttrib* attrib) |
| 331 |
{ |
| 332 |
DDI_CHK_NULL(attrib, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 333 |
attrib->type = VAConfigAttribRTFormat; |
| 334 |
if (profile == VAProfileJPEGBaseline) |
| 335 |
{ |
| 336 |
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; |
| 337 |
} |
| 338 |
else if(profile == VAProfileHEVCMain10 || profile == VAProfileHEVCSccMain10) |
| 339 |
{ |
| 340 |
attrib->value = VA_RT_FORMAT_YUV420_10; |
| 341 |
} |
| 342 |
else if(profile == VAProfileHEVCMain12) |
| 343 |
{ |
| 344 |
attrib->value = VA_RT_FORMAT_YUV420_12; |
| 345 |
} |
| 346 |
else if(profile == VAProfileHEVCMain422_10) |
| 347 |
{ |
| 348 |
attrib->value = VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV422_10; |
| 349 |
} |
| 350 |
else if(profile == VAProfileHEVCMain444 || profile == VAProfileHEVCSccMain444) |
| 351 |
{ |
| 352 |
attrib->value = VA_RT_FORMAT_YUV444; |
| 353 |
} |
| 354 |
else if(profile == VAProfileHEVCMain444_10 || profile == VAProfileHEVCSccMain444_10) |
| 355 |
{ |
| 356 |
attrib->value = VA_RT_FORMAT_YUV444_10; |
| 357 |
} |
| 358 |
else |
| 359 |
{ |
| 360 |
attrib->value = VA_RT_FORMAT_YUV420; |
| 361 |
} |
| 362 |
|
| 363 |
EncodeFormat format = Others; |
| 364 |
EncodeType type = entrypoint == VAEntrypointEncSliceLP ? Vdenc : DualPipe; |
| 365 |
struct EncodeFormatTable* encodeFormatTable = m_encodeFormatTable; |
| 366 |
|
| 367 |
if(IsAvcProfile(profile)) |
| 368 |
{ |
| 369 |
format = AVC; |
| 370 |
} |
| 371 |
else if(IsHevcProfile(profile)) |
| 372 |
{ |
| 373 |
format = HEVC; |
| 374 |
} |
| 375 |
else if(IsVp9Profile(profile)) |
| 376 |
{ |
| 377 |
format = VP9; |
| 378 |
} |
| 379 |
else if(IsAV1Profile(profile)) |
| 380 |
{ |
| 381 |
format = AV1; |
| 382 |
} |
| 383 |
|
| 384 |
for(uint32_t i = 0; i < m_encodeFormatCount && encodeFormatTable != nullptr; encodeFormatTable++, i++) |
| 385 |
{ |
| 386 |
if(encodeFormatTable->encodeFormat == format |
| 387 |
&& encodeFormatTable->encodeType == type) |
| 388 |
{ |
| 389 |
attrib->value = encodeFormatTable->colorFormat; |
| 390 |
break; |
| 391 |
} |
| 392 |
} |
| 393 |
return VA_STATUS_SUCCESS; |
| 394 |
} |
| 395 |
|
| 396 |
VAStatus MediaLibvaCapsDG2::GetPlatformSpecificAttrib(VAProfile profile, |
| 397 |
VAEntrypoint entrypoint, |
| 398 |
VAConfigAttribType type, |
| 399 |
uint32_t *value) |
| 400 |
{ |
| 401 |
DDI_CHK_NULL(value, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 402 |
VAStatus status = VA_STATUS_SUCCESS; |
| 403 |
*value = VA_ATTRIB_NOT_SUPPORTED; |
| 404 |
switch ((int)type) |
| 405 |
{ |
| 406 |
case VAConfigAttribDecProcessing: |
| 407 |
{ |
| 408 |
#ifdef _DECODE_PROCESSING_SUPPORTED |
| 409 |
if ((IsAvcProfile(profile) || IsHevcProfile(profile) || IsJpegProfile(profile) || IsVp9Profile(profile)) |
| 410 |
&& !(MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrDisableVDBox2SFC))) |
| 411 |
{ |
| 412 |
*value = VA_DEC_PROCESSING; |
| 413 |
} |
| 414 |
else |
| 415 |
#endif |
| 416 |
{ |
| 417 |
*value = VA_DEC_PROCESSING_NONE; |
| 418 |
} |
| 419 |
break; |
| 420 |
} |
| 421 |
case VAConfigAttribEncIntraRefresh: |
| 422 |
{ |
| 423 |
if(IsAvcProfile(profile) || (entrypoint == VAEntrypointEncSliceLP && IsHevcProfile(profile))) |
| 424 |
{ |
| 425 |
*value = VA_ENC_INTRA_REFRESH_ROLLING_COLUMN | VA_ENC_INTRA_REFRESH_ROLLING_ROW; |
| 426 |
} |
| 427 |
else |
| 428 |
{ |
| 429 |
*value = VA_ENC_INTRA_REFRESH_NONE; |
| 430 |
} |
| 431 |
break; |
| 432 |
} |
| 433 |
case VAConfigAttribEncROI: |
| 434 |
{ |
| 435 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 436 |
{ |
| 437 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 438 |
} |
| 439 |
else if (IsAvcProfile(profile)) |
| 440 |
{ |
| 441 |
VAConfigAttribValEncROI roi_attrib = {0}; |
| 442 |
roi_attrib.bits.num_roi_regions = ENCODE_DP_AVC_MAX_ROI_NUM_BRC; |
| 443 |
roi_attrib.bits.roi_rc_priority_support = 1; |
| 444 |
roi_attrib.bits.roi_rc_qp_delta_support = 1; |
| 445 |
*value = roi_attrib.value; |
| 446 |
} |
| 447 |
else if (IsHevcProfile(profile)) |
| 448 |
{ |
| 449 |
VAConfigAttribValEncROI roi_attrib = {0}; |
| 450 |
roi_attrib.bits.num_roi_regions = CODECHAL_ENCODE_HEVC_MAX_NUM_ROI; |
| 451 |
roi_attrib.bits.roi_rc_priority_support = 0; |
| 452 |
roi_attrib.bits.roi_rc_qp_delta_support = 1; |
| 453 |
*value = roi_attrib.value; |
| 454 |
} |
| 455 |
break; |
| 456 |
} |
| 457 |
case VAConfigAttribCustomRoundingControl: |
| 458 |
{ |
| 459 |
*value = 1; |
| 460 |
break; |
| 461 |
} |
| 462 |
case VAConfigAttribEncMaxSlices: |
| 463 |
{ |
| 464 |
if (entrypoint == VAEntrypointEncSlice && IsHevcProfile(profile)) |
| 465 |
{ |
| 466 |
*value = CODECHAL_HEVC_MAX_NUM_SLICES_LVL_6; |
| 467 |
} |
| 468 |
else |
| 469 |
{ |
| 470 |
*value =0; |
| 471 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 472 |
} |
| 473 |
break; |
| 474 |
} |
| 475 |
case VAConfigAttribMaxPictureWidth: |
| 476 |
{ |
| 477 |
if(profile == VAProfileJPEGBaseline) |
| 478 |
{ |
| 479 |
*value = ENCODE_JPEG_MAX_PIC_WIDTH; |
| 480 |
} |
| 481 |
else if(IsHevcProfile(profile)) |
| 482 |
{ |
| 483 |
*value = CODEC_16K_MAX_PIC_WIDTH; |
| 484 |
} |
| 485 |
else if(IsVp9Profile(profile)) |
| 486 |
{ |
| 487 |
*value = CODEC_8K_MAX_PIC_WIDTH; |
| 488 |
} |
| 489 |
else if(IsAvcProfile(profile)) |
| 490 |
{ |
| 491 |
*value = CODEC_4K_MAX_PIC_WIDTH; |
| 492 |
} |
| 493 |
else if(IsAV1Profile(profile)) |
| 494 |
{ |
| 495 |
*value = CODEC_8K_MAX_PIC_WIDTH; |
| 496 |
} |
| 497 |
else |
| 498 |
{ |
| 499 |
*value = CODEC_MAX_PIC_WIDTH; |
| 500 |
} |
| 501 |
break; |
| 502 |
} |
| 503 |
case VAConfigAttribMaxPictureHeight: |
| 504 |
{ |
| 505 |
if(profile == VAProfileJPEGBaseline) |
| 506 |
{ |
| 507 |
*value = ENCODE_JPEG_MAX_PIC_HEIGHT; |
| 508 |
} |
| 509 |
else if(IsHevcProfile(profile)) |
| 510 |
{ |
| 511 |
*value = CODEC_12K_MAX_PIC_HEIGHT; |
| 512 |
} |
| 513 |
else if(IsVp9Profile(profile)) |
| 514 |
{ |
| 515 |
*value = CODEC_8K_MAX_PIC_HEIGHT; |
| 516 |
} |
| 517 |
else if(IsAvcProfile(profile)) |
| 518 |
{ |
| 519 |
*value = CODEC_4K_MAX_PIC_HEIGHT; |
| 520 |
} |
| 521 |
else if(IsAV1Profile(profile)) |
| 522 |
{ |
| 523 |
*value = CODEC_8K_MAX_PIC_HEIGHT; |
| 524 |
} |
| 525 |
else |
| 526 |
{ |
| 527 |
*value = CODEC_MAX_PIC_HEIGHT; |
| 528 |
} |
| 529 |
break; |
| 530 |
} |
| 531 |
case VAConfigAttribQPBlockSize: |
| 532 |
{ |
| 533 |
if(IsAvcProfile(profile)) |
| 534 |
{ |
| 535 |
*value = CODECHAL_MACROBLOCK_WIDTH; |
| 536 |
} |
| 537 |
else |
| 538 |
{ |
| 539 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 540 |
} |
| 541 |
break; |
| 542 |
} |
| 543 |
case VAConfigAttribPredictionDirection: |
| 544 |
{ |
| 545 |
if (!IsHevcSccProfile(profile)) |
| 546 |
{ |
| 547 |
*value = VA_PREDICTION_DIRECTION_PREVIOUS | VA_PREDICTION_DIRECTION_FUTURE | VA_PREDICTION_DIRECTION_BI_NOT_EMPTY; |
| 548 |
} |
| 549 |
else |
| 550 |
{ |
| 551 |
// Here we set |
| 552 |
// VAConfigAttribPredictionDirection: VA_PREDICTION_DIRECTION_PREVIOUS | VA_PREDICTION_DIRECTION_BI_NOT_EMPTY together with |
| 553 |
// VAConfigAttribEncMaxRefFrames: L0 != 0, L1 !=0 |
| 554 |
// to indicate SCC only supports I/low delay B |
| 555 |
*value = VA_PREDICTION_DIRECTION_PREVIOUS | VA_PREDICTION_DIRECTION_BI_NOT_EMPTY; |
| 556 |
} |
| 557 |
break; |
| 558 |
} |
| 559 |
#if VA_CHECK_VERSION(1, 12, 0) |
| 560 |
case VAConfigAttribEncHEVCFeatures: |
| 561 |
{ |
| 562 |
if (entrypoint == VAEntrypointEncSliceLP && IsHevcProfile(profile)) |
| 563 |
{ |
| 564 |
VAConfigAttribValEncHEVCFeatures hevcFeatures = {0}; |
| 565 |
hevcFeatures.bits.separate_colour_planes = VA_FEATURE_NOT_SUPPORTED; |
| 566 |
hevcFeatures.bits.scaling_lists = VA_FEATURE_SUPPORTED; |
| 567 |
hevcFeatures.bits.amp = VA_FEATURE_REQUIRED; |
| 568 |
hevcFeatures.bits.sao = VA_FEATURE_SUPPORTED; |
| 569 |
hevcFeatures.bits.pcm = VA_FEATURE_NOT_SUPPORTED; |
| 570 |
hevcFeatures.bits.temporal_mvp = VA_FEATURE_SUPPORTED; |
| 571 |
hevcFeatures.bits.strong_intra_smoothing = VA_FEATURE_NOT_SUPPORTED; |
| 572 |
hevcFeatures.bits.dependent_slices = VA_FEATURE_NOT_SUPPORTED; |
| 573 |
hevcFeatures.bits.sign_data_hiding = VA_FEATURE_NOT_SUPPORTED; |
| 574 |
hevcFeatures.bits.constrained_intra_pred = VA_FEATURE_NOT_SUPPORTED; |
| 575 |
hevcFeatures.bits.transform_skip = VA_FEATURE_SUPPORTED; |
| 576 |
hevcFeatures.bits.cu_qp_delta = VA_FEATURE_REQUIRED; |
| 577 |
hevcFeatures.bits.weighted_prediction = VA_FEATURE_SUPPORTED; |
| 578 |
hevcFeatures.bits.transquant_bypass = VA_FEATURE_NOT_SUPPORTED; |
| 579 |
hevcFeatures.bits.deblocking_filter_disable = VA_FEATURE_NOT_SUPPORTED; |
| 580 |
*value = hevcFeatures.value; |
| 581 |
} |
| 582 |
break; |
| 583 |
} |
| 584 |
case VAConfigAttribEncHEVCBlockSizes: |
| 585 |
{ |
| 586 |
if (entrypoint == VAEntrypointEncSliceLP && IsHevcProfile(profile)) |
| 587 |
{ |
| 588 |
VAConfigAttribValEncHEVCBlockSizes hevcBlockSize = {0}; |
| 589 |
hevcBlockSize.bits.log2_max_coding_tree_block_size_minus3 = 3; |
| 590 |
hevcBlockSize.bits.log2_min_coding_tree_block_size_minus3 = 3; |
| 591 |
hevcBlockSize.bits.log2_min_luma_coding_block_size_minus3 = 0; |
| 592 |
hevcBlockSize.bits.log2_max_luma_transform_block_size_minus2 = 3; |
| 593 |
hevcBlockSize.bits.log2_min_luma_transform_block_size_minus2 = 0; |
| 594 |
hevcBlockSize.bits.max_max_transform_hierarchy_depth_inter = 2; |
| 595 |
hevcBlockSize.bits.min_max_transform_hierarchy_depth_inter = 0; |
| 596 |
hevcBlockSize.bits.max_max_transform_hierarchy_depth_intra = 2; |
| 597 |
hevcBlockSize.bits.min_max_transform_hierarchy_depth_intra = 0; |
| 598 |
hevcBlockSize.bits.log2_max_pcm_coding_block_size_minus3 = 0; |
| 599 |
hevcBlockSize.bits.log2_min_pcm_coding_block_size_minus3 = 0; |
| 600 |
*value = hevcBlockSize.value; |
| 601 |
} |
| 602 |
break; |
| 603 |
} |
| 604 |
#endif |
| 605 |
default: |
| 606 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 607 |
break; |
| 608 |
} |
| 609 |
return status; |
| 610 |
} |
| 611 |
|
| 612 |
VAStatus MediaLibvaCapsDG2::CreateEncAttributes( |
| 613 |
VAProfile profile, |
| 614 |
VAEntrypoint entrypoint, |
| 615 |
AttribMap **attributeList) |
| 616 |
{ |
| 617 |
if(IsVp8Profile(profile)) |
| 618 |
{ |
| 619 |
return VA_STATUS_ERROR_UNSUPPORTED_PROFILE; |
| 620 |
} |
| 621 |
|
| 622 |
DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 623 |
|
| 624 |
VAStatus status = CreateAttributeList(attributeList); |
| 625 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 626 |
|
| 627 |
auto attribList = *attributeList; |
| 628 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 629 |
|
| 630 |
VAConfigAttrib attrib; |
| 631 |
attrib.type = VAConfigAttribRTFormat; |
| 632 |
status = CheckEncRTFormat(profile, entrypoint, &attrib); |
| 633 |
DDI_CHK_RET(status, "Failed to Check Encode RT Format!"); |
| 634 |
(*attribList)[attrib.type] = attrib.value; |
| 635 |
|
| 636 |
attrib.type = VAConfigAttribMaxPictureWidth; |
| 637 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 638 |
VAConfigAttribMaxPictureWidth, &attrib.value); |
| 639 |
(*attribList)[attrib.type] = attrib.value; |
| 640 |
|
| 641 |
attrib.type = VAConfigAttribMaxPictureHeight; |
| 642 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 643 |
VAConfigAttribMaxPictureHeight, &attrib.value); |
| 644 |
(*attribList)[attrib.type] = attrib.value; |
| 645 |
|
| 646 |
if (profile == VAProfileJPEGBaseline) |
| 647 |
{ |
| 648 |
attrib.type = VAConfigAttribEncJPEG; |
| 649 |
attrib.value = |
| 650 |
((JPEG_MAX_QUANT_TABLE << 14) | // max_num_quantization_tables : 3 |
| 651 |
(JPEG_MAX_NUM_HUFF_TABLE_INDEX << 11) | // max_num_huffman_tables : 3 |
| 652 |
(1 << 7) | // max_num_scans : 4 |
| 653 |
(jpegNumComponent << 4)); // max_num_components : 3 |
| 654 |
// arithmatic_coding_mode = 0 |
| 655 |
// progressive_dct_mode = 0 |
| 656 |
// non_interleaved_mode = 0 |
| 657 |
// differential_mode = 0 |
| 658 |
(*attribList)[attrib.type] = attrib.value; |
| 659 |
} |
| 660 |
|
| 661 |
attrib.type = VAConfigAttribEncQualityRange; |
| 662 |
if (profile == VAProfileJPEGBaseline) |
| 663 |
{ |
| 664 |
// JPEG has no target usage. |
| 665 |
attrib.value = 1; |
| 666 |
} |
| 667 |
else |
| 668 |
{ |
| 669 |
attrib.value = NUM_TARGET_USAGE_MODES - 1;// Indicates TUs from 1 upto the value reported are supported |
| 670 |
} |
| 671 |
(*attribList)[attrib.type] = attrib.value; |
| 672 |
|
| 673 |
attrib.type = VAConfigAttribEncPackedHeaders; |
| 674 |
attrib.value = VA_ATTRIB_NOT_SUPPORTED; |
| 675 |
if ((IsAvcProfile(profile))||(IsHevcProfile(profile))||(IsAV1Profile(profile))) |
| 676 |
{ |
| 677 |
attrib.value = VA_ENC_PACKED_HEADER_PICTURE | |
| 678 |
VA_ENC_PACKED_HEADER_SEQUENCE | |
| 679 |
VA_ENC_PACKED_HEADER_SLICE | |
| 680 |
VA_ENC_PACKED_HEADER_RAW_DATA | |
| 681 |
VA_ENC_PACKED_HEADER_MISC; |
| 682 |
} |
| 683 |
else if (IsMpeg2Profile(profile)) |
| 684 |
{ |
| 685 |
attrib.value = VA_ENC_PACKED_HEADER_RAW_DATA; |
| 686 |
} |
| 687 |
else if(IsJpegProfile(profile)) |
| 688 |
{ |
| 689 |
attrib.value = VA_ENC_PACKED_HEADER_RAW_DATA; |
| 690 |
} |
| 691 |
else if(IsVp9Profile(profile)) |
| 692 |
{ |
| 693 |
attrib.value = VA_ENC_PACKED_HEADER_RAW_DATA; |
| 694 |
} |
| 695 |
|
| 696 |
(*attribList)[attrib.type] = attrib.value; |
| 697 |
if(IsJpegProfile(profile)) |
| 698 |
{ |
| 699 |
return status; |
| 700 |
} |
| 701 |
|
| 702 |
attrib.type = VAConfigAttribRateControl; |
| 703 |
attrib.value = VA_RC_CQP; |
| 704 |
if (entrypoint == VAEntrypointEncSliceLP && |
| 705 |
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels) && |
| 706 |
!IsHevcSccProfile(profile)) // Currently, SCC doesn't support BRC |
| 707 |
{ |
| 708 |
attrib.value |= VA_RC_CBR | VA_RC_VBR | VA_RC_MB; |
| 709 |
if (IsHevcProfile(profile)) |
| 710 |
{ |
| 711 |
attrib.value |= VA_RC_ICQ | VA_RC_VCM | VA_RC_QVBR; |
| 712 |
#if VA_CHECK_VERSION(1, 10, 0) |
| 713 |
attrib.value |= VA_RC_TCBRC; |
| 714 |
#endif |
| 715 |
} |
| 716 |
if (IsVp9Profile(profile)) |
| 717 |
{ |
| 718 |
attrib.value |= VA_RC_ICQ; |
| 719 |
} |
| 720 |
} |
| 721 |
if (IsAV1Profile(profile)) |
| 722 |
{ |
| 723 |
attrib.value = VA_RC_CQP | VA_RC_CBR | VA_RC_VBR | VA_RC_ICQ; |
| 724 |
#if VA_CHECK_VERSION(1, 10, 0) |
| 725 |
attrib.value |= VA_RC_TCBRC; |
| 726 |
#endif |
| 727 |
} |
| 728 |
if (IsAvcProfile(profile) && |
| 729 |
((entrypoint == VAEntrypointEncSliceLP) && MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels))) |
| 730 |
{ |
| 731 |
attrib.value |= VA_RC_ICQ | VA_RC_QVBR; |
| 732 |
#if VA_CHECK_VERSION(1, 10, 0) |
| 733 |
attrib.value |= VA_RC_TCBRC; |
| 734 |
#endif |
| 735 |
} |
| 736 |
if(entrypoint == VAEntrypointFEI) |
| 737 |
{ |
| 738 |
attrib.value = VA_RC_CQP; |
| 739 |
} |
| 740 |
else if(entrypoint == VAEntrypointStats) |
| 741 |
{ |
| 742 |
attrib.value = VA_RC_NONE; |
| 743 |
} |
| 744 |
(*attribList)[attrib.type] = attrib.value; |
| 745 |
|
| 746 |
attrib.type = VAConfigAttribEncInterlaced; |
| 747 |
attrib.value = VA_ENC_INTERLACED_NONE; |
| 748 |
#ifndef ANDROID |
| 749 |
if(IsAvcProfile(profile) && (entrypoint != VAEntrypointEncSliceLP)) |
| 750 |
{ |
| 751 |
attrib.value = VA_ENC_INTERLACED_FIELD; |
| 752 |
} |
| 753 |
if(IsMpeg2Profile(profile)) |
| 754 |
{ |
| 755 |
attrib.value = VA_ENC_INTERLACED_FRAME; |
| 756 |
} |
| 757 |
#endif |
| 758 |
(*attribList)[attrib.type] = attrib.value; |
| 759 |
|
| 760 |
attrib.type = VAConfigAttribEncMaxRefFrames; |
| 761 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 762 |
{ |
| 763 |
attrib.value = DDI_CODEC_VDENC_MAX_L0_REF_FRAMES | (DDI_CODEC_VDENC_MAX_L1_REF_FRAMES << DDI_CODEC_LEFT_SHIFT_FOR_REFLIST1); |
| 764 |
if (IsAvcProfile(profile)) |
| 765 |
{ |
| 766 |
attrib.value = DDI_CODEC_VDENC_MAX_L0_REF_FRAMES | (DDI_CODEC_VDENC_MAX_L1_REF_FRAMES_RAB_AVC << DDI_CODEC_LEFT_SHIFT_FOR_REFLIST1); |
| 767 |
} |
| 768 |
if (IsHevcProfile(profile)) |
| 769 |
{ |
| 770 |
attrib.value = DDI_CODEC_VDENC_MAX_L0_REF_FRAMES_LDB | (DDI_CODEC_VDENC_MAX_L1_REF_FRAMES_LDB << DDI_CODEC_LEFT_SHIFT_FOR_REFLIST1); |
| 771 |
} |
| 772 |
} |
| 773 |
else |
| 774 |
{ |
| 775 |
// default value: 1 frame for each reference list |
| 776 |
attrib.value = 1 | (1 << 16); |
| 777 |
if(IsAvcProfile(profile)) |
| 778 |
{ |
| 779 |
attrib.value = CODECHAL_ENCODE_NUM_MAX_VME_L0_REF | (CODECHAL_ENCODE_NUM_MAX_VME_L1_REF << 16); |
| 780 |
} |
| 781 |
if(IsVp8Profile(profile)) |
| 782 |
{ |
| 783 |
attrib.value = ENCODE_VP8_NUM_MAX_L0_REF ; |
| 784 |
} |
| 785 |
if (IsHevcProfile(profile)) |
| 786 |
{ |
| 787 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 788 |
VAConfigAttribEncMaxRefFrames, &attrib.value); |
| 789 |
} |
| 790 |
} |
| 791 |
(*attribList)[attrib.type] = attrib.value; |
| 792 |
|
| 793 |
attrib.type = VAConfigAttribEncMaxSlices; |
| 794 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 795 |
{ |
| 796 |
if (IsAvcProfile(profile)) |
| 797 |
{ |
| 798 |
attrib.value = ENCODE_AVC_MAX_SLICES_SUPPORTED; |
| 799 |
} |
| 800 |
else if (IsHevcProfile(profile)) |
| 801 |
{ |
| 802 |
attrib.value = ENCODE_HEVC_VDENC_NUM_MAX_SLICES; |
| 803 |
} |
| 804 |
} |
| 805 |
else |
| 806 |
{ |
| 807 |
attrib.value = 0; |
| 808 |
if (IsAvcProfile(profile)) |
| 809 |
{ |
| 810 |
attrib.value = ENCODE_AVC_MAX_SLICES_SUPPORTED; |
| 811 |
} |
| 812 |
else if (IsHevcProfile(profile)) |
| 813 |
{ |
| 814 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 815 |
VAConfigAttribEncMaxSlices, &attrib.value); |
| 816 |
} |
| 817 |
} |
| 818 |
(*attribList)[attrib.type] = attrib.value; |
| 819 |
|
| 820 |
attrib.type = VAConfigAttribEncSliceStructure; |
| 821 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 822 |
{ |
| 823 |
if (IsHevcProfile(profile)) |
| 824 |
{ |
| 825 |
attrib.value = VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS | VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS | |
| 826 |
VA_ENC_SLICE_STRUCTURE_MAX_SLICE_SIZE | VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS | VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS; |
| 827 |
} |
| 828 |
else |
| 829 |
{ |
| 830 |
attrib.value = VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS | VA_ENC_SLICE_STRUCTURE_MAX_SLICE_SIZE | |
| 831 |
VA_ENC_SLICE_STRUCTURE_EQUAL_MULTI_ROWS; |
| 832 |
} |
| 833 |
} |
| 834 |
else |
| 835 |
{ |
| 836 |
attrib.value = VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS; |
| 837 |
} |
| 838 |
(*attribList)[attrib.type] = attrib.value; |
| 839 |
|
| 840 |
attrib.type = VAConfigAttribEncQuantization; |
| 841 |
if(IsAvcProfile(profile)) |
| 842 |
{ |
| 843 |
attrib.value = VA_ENC_QUANTIZATION_TRELLIS_SUPPORTED; |
| 844 |
} |
| 845 |
else |
| 846 |
{ |
| 847 |
attrib.value = VA_ENC_QUANTIZATION_NONE; |
| 848 |
} |
| 849 |
(*attribList)[attrib.type] = attrib.value; |
| 850 |
|
| 851 |
attrib.type = VAConfigAttribEncIntraRefresh; |
| 852 |
attrib.value = VA_ENC_INTRA_REFRESH_NONE; |
| 853 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 854 |
VAConfigAttribEncIntraRefresh, &attrib.value); |
| 855 |
(*attribList)[attrib.type] = attrib.value; |
| 856 |
|
| 857 |
attrib.type = VAConfigAttribEncSkipFrame; |
| 858 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 859 |
{ |
| 860 |
if (IsAvcProfile(profile)) |
| 861 |
{ |
| 862 |
attrib.value = 1; |
| 863 |
} |
| 864 |
else |
| 865 |
{ |
| 866 |
attrib.value = 0; |
| 867 |
} |
| 868 |
} |
| 869 |
else |
| 870 |
{ |
| 871 |
attrib.value = 1; |
| 872 |
} |
| 873 |
(*attribList)[attrib.type] = attrib.value; |
| 874 |
|
| 875 |
attrib.type = VAConfigAttribEncryption; |
| 876 |
attrib.value = VA_ATTRIB_NOT_SUPPORTED; |
| 877 |
if (m_isEntryptSupported) |
| 878 |
{ |
| 879 |
attrib.value = 0; |
| 880 |
uint32_t encryptTypes[DDI_CP_ENCRYPT_TYPES_NUM] = {0}; |
| 881 |
int32_t numTypes = m_CapsCp->GetEncryptionTypes(profile, |
| 882 |
encryptTypes, DDI_CP_ENCRYPT_TYPES_NUM); |
| 883 |
if (numTypes > 0) |
| 884 |
{ |
| 885 |
for (int32_t j = 0; j < numTypes; j++) |
| 886 |
{ |
| 887 |
attrib.value |= encryptTypes[j]; |
| 888 |
} |
| 889 |
} |
| 890 |
} |
| 891 |
(*attribList)[attrib.type] = attrib.value; |
| 892 |
|
| 893 |
attrib.type = VAConfigAttribEncROI; |
| 894 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 895 |
{ |
| 896 |
VAConfigAttribValEncROI roi_attrib = {0}; |
| 897 |
if (IsAvcProfile(profile)) |
| 898 |
{ |
| 899 |
roi_attrib.bits.num_roi_regions = ENCODE_VDENC_AVC_MAX_ROI_NUMBER_ADV; |
| 900 |
} |
| 901 |
else if (IsHevcProfile(profile)) |
| 902 |
{ |
| 903 |
roi_attrib.bits.num_roi_regions = CODECHAL_ENCODE_HEVC_MAX_NUM_ROI; |
| 904 |
} |
| 905 |
|
| 906 |
roi_attrib.bits.roi_rc_priority_support = 0; |
| 907 |
roi_attrib.bits.roi_rc_qp_delta_support = 1; |
| 908 |
|
| 909 |
attrib.value = roi_attrib.value; |
| 910 |
} |
| 911 |
else |
| 912 |
{ |
| 913 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 914 |
VAConfigAttribEncROI, &attrib.value); |
| 915 |
} |
| 916 |
(*attribList)[attrib.type] = attrib.value; |
| 917 |
|
| 918 |
attrib.type = VAConfigAttribProcessingRate; |
| 919 |
attrib.value = VA_PROCESSING_RATE_ENCODE; |
| 920 |
(*attribList)[attrib.type] = attrib.value; |
| 921 |
|
| 922 |
attrib.type = (VAConfigAttribType)VAConfigAttribEncDirtyRect; |
| 923 |
if((entrypoint == VAEntrypointEncSliceLP) && IsHevcProfile(profile)) |
| 924 |
{ |
| 925 |
attrib.value = CODECHAL_ENCODE_HEVC_MAX_NUM_DIRTYRECT; |
| 926 |
} |
| 927 |
else |
| 928 |
{ |
| 929 |
attrib.value = 4; |
| 930 |
} |
| 931 |
|
| 932 |
(*attribList)[attrib.type] = attrib.value; |
| 933 |
|
| 934 |
attrib.type = VAConfigAttribEncParallelRateControl; |
| 935 |
if(entrypoint == VAEntrypointEncSliceLP) |
| 936 |
{ |
| 937 |
attrib.value = 0; |
| 938 |
} |
| 939 |
else |
| 940 |
{ |
| 941 |
attrib.value = 1; |
| 942 |
} |
| 943 |
(*attribList)[attrib.type] = attrib.value; |
| 944 |
|
| 945 |
attrib.type = (VAConfigAttribType)VAConfigAttribFEIMVPredictors; |
| 946 |
attrib.value = 0; |
| 947 |
if(IsAvcProfile(profile) || IsHevcProfile(profile)) |
| 948 |
{ |
| 949 |
attrib.value = DDI_CODEC_FEI_MAX_NUM_MVPREDICTOR; |
| 950 |
} |
| 951 |
(*attribList)[attrib.type] = attrib.value; |
| 952 |
|
| 953 |
if(profile == VAProfileNone) |
| 954 |
{ |
| 955 |
attrib.type = (VAConfigAttribType)VAConfigAttribStats; |
| 956 |
VAConfigAttribValStats attribValStats; |
| 957 |
memset(&attribValStats, 0, sizeof(attribValStats)); |
| 958 |
attribValStats.bits.max_num_past_references = DDI_CODEC_STATS_MAX_NUM_PAST_REFS; |
| 959 |
attribValStats.bits.max_num_future_references = DDI_CODEC_STATS_MAX_NUM_FUTURE_REFS; |
| 960 |
attribValStats.bits.num_outputs = DDI_CODEC_STATS_MAX_NUM_OUTPUTS; |
| 961 |
attribValStats.bits.interlaced = DDI_CODEC_STATS_INTERLACED_SUPPORT; |
| 962 |
attrib.value = attribValStats.value; |
| 963 |
(*attribList)[attrib.type] = attrib.value; |
| 964 |
} |
| 965 |
|
| 966 |
attrib.type = (VAConfigAttribType)VAConfigAttribCustomRoundingControl; |
| 967 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 968 |
(VAConfigAttribType)VAConfigAttribCustomRoundingControl, &attrib.value); |
| 969 |
(*attribList)[attrib.type] = attrib.value; |
| 970 |
|
| 971 |
if (IsAvcProfile(profile) || IsHevcProfile(profile) || IsAV1Profile(profile)) |
| 972 |
{ |
| 973 |
attrib.type = (VAConfigAttribType)VAConfigAttribMaxFrameSize; |
| 974 |
VAConfigAttribValMaxFrameSize attribValMaxFrameSize; |
| 975 |
memset(&attribValMaxFrameSize, 0, sizeof(attribValMaxFrameSize)); |
| 976 |
attribValMaxFrameSize.bits.max_frame_size = 1; |
| 977 |
attribValMaxFrameSize.bits.multiple_pass = 1; |
| 978 |
attribValMaxFrameSize.bits.reserved = 0; |
| 979 |
attrib.value = attribValMaxFrameSize.value; |
| 980 |
(*attribList)[attrib.type] = attrib.value; |
| 981 |
} |
| 982 |
|
| 983 |
if (IsHevcProfile(profile)) |
| 984 |
{ |
| 985 |
attrib.type = (VAConfigAttribType) VAConfigAttribPredictionDirection; |
| 986 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 987 |
(VAConfigAttribType)VAConfigAttribPredictionDirection, &attrib.value); |
| 988 |
(*attribList)[attrib.type] = attrib.value; |
| 989 |
#if VA_CHECK_VERSION(1, 12, 0) |
| 990 |
attrib.type = (VAConfigAttribType)VAConfigAttribEncHEVCFeatures; |
| 991 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 992 |
(VAConfigAttribType)VAConfigAttribEncHEVCFeatures, &attrib.value); |
| 993 |
(*attribList)[attrib.type] = attrib.value; |
| 994 |
attrib.type = (VAConfigAttribType)VAConfigAttribEncHEVCBlockSizes; |
| 995 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 996 |
(VAConfigAttribType)VAConfigAttribEncHEVCBlockSizes, &attrib.value); |
| 997 |
(*attribList)[attrib.type] = attrib.value; |
| 998 |
#endif |
| 999 |
} |
| 1000 |
|
| 1001 |
return status; |
| 1002 |
} |
| 1003 |
|
| 1004 |
VAStatus MediaLibvaCapsDG2::AddEncSurfaceAttributes( |
| 1005 |
VAProfile profile, |
| 1006 |
VAEntrypoint entrypoint, |
| 1007 |
VASurfaceAttrib *attribList, |
| 1008 |
uint32_t &numAttribs) |
| 1009 |
{ |
| 1010 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1011 |
|
| 1012 |
if (profile == VAProfileAV1Profile0) |
| 1013 |
{ |
| 1014 |
attribList[numAttribs].type = VASurfaceAttribPixelFormat; |
| 1015 |
attribList[numAttribs].value.type = VAGenericValueTypeInteger; |
| 1016 |
attribList[numAttribs].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1017 |
attribList[numAttribs].value.value.i = VA_FOURCC_NV12; |
| 1018 |
numAttribs++; |
| 1019 |
|
| 1020 |
attribList[numAttribs].type = VASurfaceAttribPixelFormat; |
| 1021 |
attribList[numAttribs].value.type = VAGenericValueTypeInteger; |
| 1022 |
attribList[numAttribs].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1023 |
attribList[numAttribs].value.value.i = VA_FOURCC_P010; |
| 1024 |
numAttribs++; |
| 1025 |
|
| 1026 |
attribList[numAttribs].type = VASurfaceAttribMaxWidth; |
| 1027 |
attribList[numAttribs].value.type = VAGenericValueTypeInteger; |
| 1028 |
attribList[numAttribs].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 1029 |
attribList[numAttribs].value.value.i = CODEC_8K_MAX_PIC_WIDTH; |
| 1030 |
numAttribs++; |
| 1031 |
|
| 1032 |
attribList[numAttribs].type = VASurfaceAttribMaxHeight; |
| 1033 |
attribList[numAttribs].value.type = VAGenericValueTypeInteger; |
| 1034 |
attribList[numAttribs].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 1035 |
attribList[numAttribs].value.value.i = CODEC_8K_MAX_PIC_HEIGHT; |
| 1036 |
numAttribs++; |
| 1037 |
|
| 1038 |
attribList[numAttribs].type = VASurfaceAttribMinWidth; |
| 1039 |
attribList[numAttribs].value.type = VAGenericValueTypeInteger; |
| 1040 |
attribList[numAttribs].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 1041 |
attribList[numAttribs].value.value.i = m_encMinWidth; |
| 1042 |
numAttribs++; |
| 1043 |
|
| 1044 |
attribList[numAttribs].type = VASurfaceAttribMinHeight; |
| 1045 |
attribList[numAttribs].value.type = VAGenericValueTypeInteger; |
| 1046 |
attribList[numAttribs].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 1047 |
attribList[numAttribs].value.value.i = m_encMinHeight; |
| 1048 |
numAttribs++; |
| 1049 |
|
| 1050 |
attribList[numAttribs].type = VASurfaceAttribMemoryType; |
| 1051 |
attribList[numAttribs].value.type = VAGenericValueTypeInteger; |
| 1052 |
attribList[numAttribs].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1053 |
attribList[numAttribs].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | |
| 1054 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2; |
| 1055 |
numAttribs++; |
| 1056 |
} |
| 1057 |
else |
| 1058 |
{ |
| 1059 |
return MediaLibvaCapsG12::AddEncSurfaceAttributes(profile, entrypoint, attribList, numAttribs); |
| 1060 |
} |
| 1061 |
|
| 1062 |
return VA_STATUS_SUCCESS; |
| 1063 |
} |
| 1064 |
|
| 1065 |
VAStatus MediaLibvaCapsDG2::GetDisplayAttributes( |
| 1066 |
VADisplayAttribute *attribList, |
| 1067 |
int32_t numAttribs) |
| 1068 |
{ |
| 1069 |
DDI_CHK_NULL(attribList, "Null attribList", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1070 |
for(auto i = 0; i < numAttribs; i ++) |
| 1071 |
{ |
| 1072 |
switch(attribList->type) |
| 1073 |
{ |
| 1074 |
#if VA_CHECK_VERSION(1, 15, 0) |
| 1075 |
case VADisplayPCIID: |
| 1076 |
attribList->min_value = attribList->value = attribList->max_value = (m_mediaCtx->iDeviceId & 0xffff) | 0x80860000; |
| 1077 |
attribList->flags = VA_DISPLAY_ATTRIB_GETTABLE; |
| 1078 |
break; |
| 1079 |
#endif |
| 1080 |
case VADisplayAttribCopy: |
| 1081 |
attribList->min_value = attribList->value = attribList->max_value = |
| 1082 |
(1 << VA_EXEC_MODE_POWER_SAVING) | (1 << VA_EXEC_MODE_PERFORMANCE) | (1 << VA_EXEC_MODE_DEFAULT); |
| 1083 |
// 100: perfromance model: Render copy |
| 1084 |
// 10: POWER_SAVING: BLT |
| 1085 |
// 1: default model: 1: vebox |
| 1086 |
// 0: don't support media copy. |
| 1087 |
attribList->flags = VA_DISPLAY_ATTRIB_GETTABLE; |
| 1088 |
break; |
| 1089 |
default: |
| 1090 |
attribList->min_value = VA_ATTRIB_NOT_SUPPORTED; |
| 1091 |
attribList->max_value = VA_ATTRIB_NOT_SUPPORTED; |
| 1092 |
attribList->value = VA_ATTRIB_NOT_SUPPORTED; |
| 1093 |
attribList->flags = VA_DISPLAY_ATTRIB_NOT_SUPPORTED; |
| 1094 |
break; |
| 1095 |
} |
| 1096 |
attribList ++; |
| 1097 |
} |
| 1098 |
return VA_STATUS_SUCCESS; |
| 1099 |
} |
| 1100 |
|
| 1101 |
static bool dg2Registered = MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>:: |
| 1102 |
RegisterCaps<MediaLibvaCapsDG2>((uint32_t)IGFX_DG2); |