| 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_g11.cpp |
| 24 |
//! \brief This file implements the C++ class/interface for gen11 media capbilities. |
| 25 |
//! |
| 26 |
|
| 27 |
#include "codec_def_encode_hevc_g11.h" |
| 28 |
#include "media_libva_util.h" |
| 29 |
#include "media_libva.h" |
| 30 |
#include "media_libva_caps_cp_interface.h" |
| 31 |
#include "media_libva_caps_g11.h" |
| 32 |
#include "media_libva_caps_factory.h" |
| 33 |
#include "media_ddi_decode_const.h" |
| 34 |
#include "media_ddi_encode_const.h" |
| 35 |
#include "media_ddi_decode_const_g11.h" |
| 36 |
#include "media_libva_vp.h" |
| 37 |
|
| 38 |
const VAImageFormat m_supportedImageformatsG11[] = |
| 39 |
{ |
| 40 |
// "VA_LSB_FIRST" is to identify how following bit masks mapped to address instead of char order in VA_FOURCC_RGBA naming. |
| 41 |
{VA_FOURCC_BGRA, VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, /* [31:0] A:R:G:B 8:8:8:8 little endian */ |
| 42 |
{VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000}, /* [31:0] A:B:G:R 8:8:8:8 little endian */ |
| 43 |
{VA_FOURCC_BGRX, VA_LSB_FIRST, 32, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0}, /* [31:0] X:R:G:B 8:8:8:8 little endian */ |
| 44 |
{VA_FOURCC_RGBX, VA_LSB_FIRST, 32, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0}, /* [31:0] X:B:G:R 8:8:8:8 little endian */ |
| 45 |
{VA_FOURCC_A2R10G10B10, VA_LSB_FIRST, 32, 30, 0x3ff00000, 0x000ffc00, 0x000003ff, 0x30000000}, /* [31:0] A:R:G:B 2:10:10:10 little endian */ |
| 46 |
{VA_FOURCC_A2B10G10R10, VA_LSB_FIRST, 32, 30, 0x000003ff, 0x000ffc00, 0x3ff00000, 0x30000000}, /* [31:0] A:B:G:R 2:10:10:10 little endian */ |
| 47 |
{VA_FOURCC_X2R10G10B10, VA_LSB_FIRST, 32, 30, 0x3ff00000, 0x000ffc00, 0x000003ff, 0}, /* [31:0] X:R:G:B 2:10:10:10 little endian */ |
| 48 |
{VA_FOURCC_X2B10G10R10, VA_LSB_FIRST, 32, 30, 0x000003ff, 0x000ffc00, 0x3ff00000, 0}, /* [31:0] X:B:G:R 2:10:10:10 little endian */ |
| 49 |
{VA_FOURCC_RGB565, VA_LSB_FIRST, 16, 16, 0xf800, 0x07e0, 0x001f, 0}, /* [15:0] R:G:B 5:6:5 little endian */ |
| 50 |
{VA_FOURCC_AYUV, VA_LSB_FIRST, 32, 0,0,0,0,0}, |
| 51 |
#if VA_CHECK_VERSION(1, 13, 0) |
| 52 |
{VA_FOURCC_XYUV, VA_LSB_FIRST, 32, 0,0,0,0,0}, |
| 53 |
#endif |
| 54 |
{VA_FOURCC_Y800, VA_LSB_FIRST, 8, 0,0,0,0,0}, |
| 55 |
{VA_FOURCC_NV12, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 56 |
{VA_FOURCC_NV21, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 57 |
{VA_FOURCC_YUY2, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 58 |
{VA_FOURCC_UYVY, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 59 |
{VA_FOURCC_YV12, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 60 |
{VA_FOURCC_I420, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 61 |
{VA_FOURCC_411P, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 62 |
{VA_FOURCC_422H, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 63 |
{VA_FOURCC_422V, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 64 |
{VA_FOURCC_444P, VA_LSB_FIRST, 24, 0,0,0,0,0}, |
| 65 |
{VA_FOURCC_IMC3, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 66 |
{VA_FOURCC_P010, VA_LSB_FIRST, 24, 0,0,0,0,0}, |
| 67 |
{VA_FOURCC_Y210, VA_LSB_FIRST, 32, 0,0,0,0,0}, |
| 68 |
{VA_FOURCC_Y410, VA_LSB_FIRST, 32, 0,0,0,0,0} |
| 69 |
}; |
| 70 |
|
| 71 |
const VAConfigAttribValEncRateControlExt MediaLibvaCapsG11::m_encVp9RateControlExt = |
| 72 |
{ |
| 73 |
{CODECHAL_ENCODE_VP9_MAX_NUM_TEMPORAL_LAYERS - 1, 1, 0} |
| 74 |
}; |
| 75 |
|
| 76 |
VAStatus MediaLibvaCapsG11::QueryImageFormats(VAImageFormat *formatList, int32_t *numFormats) |
| 77 |
{ |
| 78 |
DDI_CHK_NULL(formatList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 79 |
DDI_CHK_NULL(numFormats, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 80 |
int32_t num = 0; |
| 81 |
uint32_t maxNum = GetImageFormatsMaxNum(); |
| 82 |
|
| 83 |
memset(formatList, 0, sizeof(m_supportedImageformatsG11)); |
| 84 |
for (uint32_t idx = 0; idx < maxNum; idx++) |
| 85 |
{ |
| 86 |
formatList[num].fourcc = m_supportedImageformatsG11[idx].fourcc; |
| 87 |
formatList[num].byte_order = m_supportedImageformatsG11[idx].byte_order; |
| 88 |
formatList[num].bits_per_pixel = m_supportedImageformatsG11[idx].bits_per_pixel; |
| 89 |
formatList[num].depth = m_supportedImageformatsG11[idx].depth; |
| 90 |
formatList[num].red_mask = m_supportedImageformatsG11[idx].red_mask; |
| 91 |
formatList[num].green_mask = m_supportedImageformatsG11[idx].green_mask; |
| 92 |
formatList[num].blue_mask = m_supportedImageformatsG11[idx].blue_mask; |
| 93 |
formatList[num].alpha_mask = m_supportedImageformatsG11[idx].alpha_mask; |
| 94 |
num++; |
| 95 |
} |
| 96 |
*numFormats = num; |
| 97 |
|
| 98 |
return VA_STATUS_SUCCESS; |
| 99 |
} |
| 100 |
|
| 101 |
uint32_t MediaLibvaCapsG11::GetImageFormatsMaxNum() |
| 102 |
{ |
| 103 |
return sizeof(m_supportedImageformatsG11)/sizeof(m_supportedImageformatsG11[0]); |
| 104 |
} |
| 105 |
|
| 106 |
bool MediaLibvaCapsG11::IsImageSupported(uint32_t fourcc) |
| 107 |
{ |
| 108 |
uint32_t maxNum = GetImageFormatsMaxNum(); |
| 109 |
for (int32_t idx = 0; idx < maxNum; idx++) |
| 110 |
{ |
| 111 |
if (m_supportedImageformatsG11[idx].fourcc == fourcc) |
| 112 |
{ |
| 113 |
return true; |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
return false; |
| 118 |
} |
| 119 |
|
| 120 |
VAStatus MediaLibvaCapsG11::PopulateColorMaskInfo(VAImageFormat *vaImgFmt) |
| 121 |
{ |
| 122 |
uint32_t maxNum = GetImageFormatsMaxNum(); |
| 123 |
|
| 124 |
DDI_CHK_NULL(vaImgFmt, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 125 |
|
| 126 |
for (int32_t idx = 0; idx < maxNum; idx++) |
| 127 |
{ |
| 128 |
if (m_supportedImageformatsG11[idx].fourcc == vaImgFmt->fourcc) |
| 129 |
{ |
| 130 |
vaImgFmt->red_mask = m_supportedImageformatsG11[idx].red_mask; |
| 131 |
vaImgFmt->green_mask = m_supportedImageformatsG11[idx].green_mask; |
| 132 |
vaImgFmt->blue_mask = m_supportedImageformatsG11[idx].blue_mask; |
| 133 |
vaImgFmt->alpha_mask = m_supportedImageformatsG11[idx].alpha_mask; |
| 134 |
|
| 135 |
return VA_STATUS_SUCCESS; |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; |
| 140 |
} |
| 141 |
|
| 142 |
CODECHAL_MODE MediaLibvaCapsG11::GetEncodeCodecMode(VAProfile profile, VAEntrypoint entrypoint) |
| 143 |
{ |
| 144 |
if (entrypoint == VAEntrypointStats) |
| 145 |
{ |
| 146 |
return CODECHAL_ENCODE_MODE_AVC; |
| 147 |
} |
| 148 |
|
| 149 |
switch (profile) |
| 150 |
{ |
| 151 |
case VAProfileH264High: |
| 152 |
case VAProfileH264Main: |
| 153 |
case VAProfileH264ConstrainedBaseline: |
| 154 |
return CODECHAL_ENCODE_MODE_AVC; |
| 155 |
case VAProfileMPEG2Main: |
| 156 |
case VAProfileMPEG2Simple: |
| 157 |
return CODECHAL_ENCODE_MODE_MPEG2; |
| 158 |
case VAProfileJPEGBaseline: |
| 159 |
return CODECHAL_ENCODE_MODE_JPEG; |
| 160 |
case VAProfileVP8Version0_3: |
| 161 |
return CODECHAL_ENCODE_MODE_VP8; |
| 162 |
case VAProfileVP9Profile0: |
| 163 |
case VAProfileVP9Profile1: |
| 164 |
case VAProfileVP9Profile2: |
| 165 |
case VAProfileVP9Profile3: |
| 166 |
return CODECHAL_ENCODE_MODE_VP9; |
| 167 |
case VAProfileHEVCMain: |
| 168 |
case VAProfileHEVCMain10: |
| 169 |
case VAProfileHEVCMain422_10: |
| 170 |
case VAProfileHEVCMain444: |
| 171 |
case VAProfileHEVCMain444_10: |
| 172 |
return CODECHAL_ENCODE_MODE_HEVC; |
| 173 |
default: |
| 174 |
DDI_ASSERTMESSAGE("Invalid Encode Mode"); |
| 175 |
return CODECHAL_UNSUPPORTED_MODE; |
| 176 |
} |
| 177 |
} |
| 178 |
|
| 179 |
std::string MediaLibvaCapsG11::GetDecodeCodecKey(VAProfile profile) |
| 180 |
{ |
| 181 |
switch (profile) |
| 182 |
{ |
| 183 |
case VAProfileH264High: |
| 184 |
case VAProfileH264Main: |
| 185 |
case VAProfileH264ConstrainedBaseline: |
| 186 |
return DECODE_ID_AVC; |
| 187 |
case VAProfileMPEG2Main: |
| 188 |
case VAProfileMPEG2Simple: |
| 189 |
return DECODE_ID_MPEG2; |
| 190 |
case VAProfileJPEGBaseline: |
| 191 |
return DECODE_ID_JPEG; |
| 192 |
case VAProfileVP8Version0_3: |
| 193 |
return DECODE_ID_VP8; |
| 194 |
case VAProfileVP9Profile0: |
| 195 |
case VAProfileVP9Profile1: |
| 196 |
case VAProfileVP9Profile2: |
| 197 |
case VAProfileVP9Profile3: |
| 198 |
return DECODE_ID_VP9; |
| 199 |
case VAProfileHEVCMain: |
| 200 |
case VAProfileHEVCMain10: |
| 201 |
case VAProfileHEVCMain12: |
| 202 |
case VAProfileHEVCMain422_10: |
| 203 |
case VAProfileHEVCMain422_12: |
| 204 |
case VAProfileHEVCMain444: |
| 205 |
case VAProfileHEVCMain444_10: |
| 206 |
case VAProfileHEVCMain444_12: |
| 207 |
return DECODE_ID_HEVC_G11; |
| 208 |
case VAProfileVC1Simple: |
| 209 |
case VAProfileVC1Main: |
| 210 |
case VAProfileVC1Advanced: |
| 211 |
return DECODE_ID_VC1; |
| 212 |
default: |
| 213 |
DDI_ASSERTMESSAGE("Invalid Encode Mode"); |
| 214 |
return DECODE_ID_NONE; |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
std::string MediaLibvaCapsG11::GetEncodeCodecKey(VAProfile profile, VAEntrypoint entrypoint, uint32_t feiFunction) |
| 219 |
{ |
| 220 |
switch (profile) |
| 221 |
{ |
| 222 |
case VAProfileH264High: |
| 223 |
case VAProfileH264Main: |
| 224 |
case VAProfileH264ConstrainedBaseline: |
| 225 |
if (IsEncFei(entrypoint, feiFunction)) |
| 226 |
{ |
| 227 |
return ENCODE_ID_AVCFEI; |
| 228 |
} |
| 229 |
else |
| 230 |
{ |
| 231 |
return ENCODE_ID_AVC; |
| 232 |
} |
| 233 |
case VAProfileMPEG2Main: |
| 234 |
case VAProfileMPEG2Simple: |
| 235 |
return ENCODE_ID_MPEG2; |
| 236 |
case VAProfileJPEGBaseline: |
| 237 |
return ENCODE_ID_JPEG; |
| 238 |
case VAProfileVP8Version0_3: |
| 239 |
return ENCODE_ID_VP8; |
| 240 |
case VAProfileVP9Profile0: |
| 241 |
case VAProfileVP9Profile1: |
| 242 |
case VAProfileVP9Profile2: |
| 243 |
case VAProfileVP9Profile3: |
| 244 |
return ENCODE_ID_VP9; |
| 245 |
case VAProfileHEVCMain: |
| 246 |
case VAProfileHEVCMain10: |
| 247 |
case VAProfileHEVCMain422_10: |
| 248 |
case VAProfileHEVCMain444: |
| 249 |
case VAProfileHEVCMain444_10: |
| 250 |
if (IsEncFei(entrypoint, feiFunction)) |
| 251 |
{ |
| 252 |
return ENCODE_ID_HEVCFEI; |
| 253 |
} |
| 254 |
else |
| 255 |
{ |
| 256 |
return ENCODE_ID_HEVC; |
| 257 |
} |
| 258 |
case VAProfileNone: |
| 259 |
if (IsEncFei(entrypoint, feiFunction)) |
| 260 |
{ |
| 261 |
return ENCODE_ID_AVCFEI; |
| 262 |
} |
| 263 |
else |
| 264 |
{ |
| 265 |
return ENCODE_ID_NONE; |
| 266 |
} |
| 267 |
default: |
| 268 |
return ENCODE_ID_NONE; |
| 269 |
} |
| 270 |
} |
| 271 |
|
| 272 |
VAStatus MediaLibvaCapsG11::GetPlatformSpecificAttrib(VAProfile profile, |
| 273 |
VAEntrypoint entrypoint, |
| 274 |
VAConfigAttribType type, |
| 275 |
uint32_t *value) |
| 276 |
{ |
| 277 |
DDI_CHK_NULL(value, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 278 |
VAStatus status = VA_STATUS_SUCCESS; |
| 279 |
*value = VA_ATTRIB_NOT_SUPPORTED; |
| 280 |
switch ((int)type) |
| 281 |
{ |
| 282 |
case VAConfigAttribEncMaxRefFrames: |
| 283 |
{ |
| 284 |
// just VAConfigAttribEncMaxRefFrames of HEVC VME is different with platforms |
| 285 |
if (entrypoint == VAEntrypointEncSlice && IsHevcProfile(profile)) |
| 286 |
{ |
| 287 |
*value = ENCODE_DP_HEVC_NUM_MAX_VME_L0_REF_G11 | (ENCODE_DP_HEVC_NUM_MAX_VME_L1_REF_G11 << 16);; |
| 288 |
} |
| 289 |
else |
| 290 |
{ |
| 291 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 292 |
} |
| 293 |
break; |
| 294 |
} |
| 295 |
case VAConfigAttribDecProcessing: |
| 296 |
{ |
| 297 |
#ifdef _DECODE_PROCESSING_SUPPORTED |
| 298 |
if ((IsAvcProfile(profile) || IsHevcProfile(profile)) && !(MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrDisableVDBox2SFC))) |
| 299 |
{ |
| 300 |
*value = VA_DEC_PROCESSING; |
| 301 |
} |
| 302 |
else |
| 303 |
#endif |
| 304 |
{ |
| 305 |
*value = VA_DEC_PROCESSING_NONE; |
| 306 |
} |
| 307 |
break; |
| 308 |
} |
| 309 |
case VAConfigAttribEncIntraRefresh: |
| 310 |
{ |
| 311 |
if(IsAvcProfile(profile) || (entrypoint == VAEntrypointEncSliceLP && IsHevcProfile(profile))) |
| 312 |
{ |
| 313 |
*value = VA_ENC_INTRA_REFRESH_ROLLING_COLUMN | VA_ENC_INTRA_REFRESH_ROLLING_ROW; |
| 314 |
} |
| 315 |
else |
| 316 |
{ |
| 317 |
*value = VA_ENC_INTRA_REFRESH_NONE; |
| 318 |
} |
| 319 |
break; |
| 320 |
} |
| 321 |
case VAConfigAttribEncROI: |
| 322 |
{ |
| 323 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 324 |
{ |
| 325 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 326 |
} |
| 327 |
else if (IsAvcProfile(profile)) |
| 328 |
{ |
| 329 |
VAConfigAttribValEncROI roi_attrib = {0}; |
| 330 |
roi_attrib.bits.num_roi_regions = ENCODE_DP_AVC_MAX_ROI_NUM_BRC; |
| 331 |
roi_attrib.bits.roi_rc_priority_support = 1; |
| 332 |
roi_attrib.bits.roi_rc_qp_delta_support = 1; |
| 333 |
*value = roi_attrib.value; |
| 334 |
} |
| 335 |
else if (IsHevcProfile(profile)) |
| 336 |
{ |
| 337 |
VAConfigAttribValEncROI roi_attrib = {0}; |
| 338 |
roi_attrib.bits.num_roi_regions = CODECHAL_ENCODE_HEVC_MAX_NUM_ROI; |
| 339 |
roi_attrib.bits.roi_rc_priority_support = 0; |
| 340 |
roi_attrib.bits.roi_rc_qp_delta_support = 1; |
| 341 |
*value = roi_attrib.value; |
| 342 |
} |
| 343 |
break; |
| 344 |
} |
| 345 |
case VAConfigAttribCustomRoundingControl: |
| 346 |
{ |
| 347 |
*value = 1; |
| 348 |
break; |
| 349 |
} |
| 350 |
case VAConfigAttribEncMaxSlices: |
| 351 |
{ |
| 352 |
if (entrypoint == VAEntrypointEncSlice && IsHevcProfile(profile)) |
| 353 |
{ |
| 354 |
*value = CODECHAL_HEVC_MAX_NUM_SLICES_LVL_6; |
| 355 |
} |
| 356 |
else |
| 357 |
{ |
| 358 |
*value =0; |
| 359 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 360 |
} |
| 361 |
break; |
| 362 |
} |
| 363 |
case VAConfigAttribMaxPictureWidth: |
| 364 |
{ |
| 365 |
if(profile == VAProfileJPEGBaseline) |
| 366 |
{ |
| 367 |
*value = ENCODE_JPEG_MAX_PIC_WIDTH; |
| 368 |
} |
| 369 |
else if(IsHevcProfile(profile)) |
| 370 |
{ |
| 371 |
*value = CODEC_8K_MAX_PIC_WIDTH; |
| 372 |
} |
| 373 |
else if(IsAvcProfile(profile) || IsVp8Profile(profile)) |
| 374 |
{ |
| 375 |
*value = CODEC_4K_MAX_PIC_WIDTH; |
| 376 |
} |
| 377 |
else |
| 378 |
{ |
| 379 |
*value = CODEC_MAX_PIC_WIDTH; |
| 380 |
} |
| 381 |
break; |
| 382 |
} |
| 383 |
case VAConfigAttribMaxPictureHeight: |
| 384 |
{ |
| 385 |
if(profile == VAProfileJPEGBaseline) |
| 386 |
{ |
| 387 |
*value = ENCODE_JPEG_MAX_PIC_HEIGHT; |
| 388 |
} |
| 389 |
else if(IsHevcProfile(profile)) |
| 390 |
{ |
| 391 |
*value = CODEC_8K_MAX_PIC_HEIGHT; |
| 392 |
} |
| 393 |
else if(IsAvcProfile(profile) || IsVp8Profile(profile)) |
| 394 |
{ |
| 395 |
*value = CODEC_4K_MAX_PIC_HEIGHT; |
| 396 |
} |
| 397 |
else |
| 398 |
{ |
| 399 |
*value = CODEC_MAX_PIC_HEIGHT; |
| 400 |
} |
| 401 |
break; |
| 402 |
} |
| 403 |
case VAConfigAttribPredictionDirection: |
| 404 |
{ |
| 405 |
if(IsHevcProfile(profile) && (entrypoint == VAEntrypointEncSliceLP)) |
| 406 |
{ |
| 407 |
*value = VA_PREDICTION_DIRECTION_PREVIOUS | VA_PREDICTION_DIRECTION_BI_NOT_EMPTY; |
| 408 |
} |
| 409 |
break; |
| 410 |
} |
| 411 |
#if VA_CHECK_VERSION(1, 12, 0) |
| 412 |
case VAConfigAttribEncHEVCFeatures: |
| 413 |
{ |
| 414 |
if ((entrypoint == VAEntrypointEncSlice || entrypoint == VAEntrypointEncSliceLP) && IsHevcProfile(profile)) |
| 415 |
{ |
| 416 |
VAConfigAttribValEncHEVCFeatures hevcFeatures = {0}; |
| 417 |
hevcFeatures.bits.separate_colour_planes = VA_FEATURE_NOT_SUPPORTED; |
| 418 |
hevcFeatures.bits.scaling_lists = VA_FEATURE_SUPPORTED; |
| 419 |
hevcFeatures.bits.amp = VA_FEATURE_REQUIRED; |
| 420 |
hevcFeatures.bits.sao = VA_FEATURE_SUPPORTED; |
| 421 |
hevcFeatures.bits.pcm = VA_FEATURE_NOT_SUPPORTED; |
| 422 |
hevcFeatures.bits.temporal_mvp = VA_FEATURE_SUPPORTED; |
| 423 |
hevcFeatures.bits.strong_intra_smoothing = VA_FEATURE_NOT_SUPPORTED; |
| 424 |
hevcFeatures.bits.dependent_slices = VA_FEATURE_NOT_SUPPORTED; |
| 425 |
hevcFeatures.bits.sign_data_hiding = VA_FEATURE_NOT_SUPPORTED; |
| 426 |
hevcFeatures.bits.constrained_intra_pred = VA_FEATURE_NOT_SUPPORTED; |
| 427 |
hevcFeatures.bits.transform_skip = VA_FEATURE_SUPPORTED; |
| 428 |
hevcFeatures.bits.cu_qp_delta = VA_FEATURE_REQUIRED; |
| 429 |
hevcFeatures.bits.weighted_prediction = VA_FEATURE_SUPPORTED; |
| 430 |
hevcFeatures.bits.transquant_bypass = VA_FEATURE_NOT_SUPPORTED; |
| 431 |
hevcFeatures.bits.deblocking_filter_disable = VA_FEATURE_NOT_SUPPORTED; |
| 432 |
*value = hevcFeatures.value; |
| 433 |
} |
| 434 |
break; |
| 435 |
} |
| 436 |
case VAConfigAttribEncHEVCBlockSizes: |
| 437 |
{ |
| 438 |
if (entrypoint == VAEntrypointEncSlice && IsHevcProfile(profile)) |
| 439 |
{ |
| 440 |
VAConfigAttribValEncHEVCBlockSizes hevcBlockSize = {0}; |
| 441 |
hevcBlockSize.bits.log2_max_coding_tree_block_size_minus3 = 2; |
| 442 |
hevcBlockSize.bits.log2_min_coding_tree_block_size_minus3 = 1; |
| 443 |
hevcBlockSize.bits.log2_min_luma_coding_block_size_minus3 = 0; |
| 444 |
hevcBlockSize.bits.log2_max_luma_transform_block_size_minus2 = 3; |
| 445 |
hevcBlockSize.bits.log2_min_luma_transform_block_size_minus2 = 0; |
| 446 |
hevcBlockSize.bits.max_max_transform_hierarchy_depth_inter = 2; |
| 447 |
hevcBlockSize.bits.min_max_transform_hierarchy_depth_inter = 0; |
| 448 |
hevcBlockSize.bits.max_max_transform_hierarchy_depth_intra = 2; |
| 449 |
hevcBlockSize.bits.min_max_transform_hierarchy_depth_intra = 0; |
| 450 |
hevcBlockSize.bits.log2_max_pcm_coding_block_size_minus3 = 0; |
| 451 |
hevcBlockSize.bits.log2_min_pcm_coding_block_size_minus3 = 0; |
| 452 |
*value = hevcBlockSize.value; |
| 453 |
} |
| 454 |
if (entrypoint == VAEntrypointEncSliceLP && IsHevcProfile(profile)) |
| 455 |
{ |
| 456 |
VAConfigAttribValEncHEVCBlockSizes hevcBlockSize = {0}; |
| 457 |
hevcBlockSize.bits.log2_max_coding_tree_block_size_minus3 = 3; |
| 458 |
hevcBlockSize.bits.log2_min_coding_tree_block_size_minus3 = 3; |
| 459 |
hevcBlockSize.bits.log2_min_luma_coding_block_size_minus3 = 0; |
| 460 |
hevcBlockSize.bits.log2_max_luma_transform_block_size_minus2 = 3; |
| 461 |
hevcBlockSize.bits.log2_min_luma_transform_block_size_minus2 = 0; |
| 462 |
hevcBlockSize.bits.max_max_transform_hierarchy_depth_inter = 2; |
| 463 |
hevcBlockSize.bits.min_max_transform_hierarchy_depth_inter = 0; |
| 464 |
hevcBlockSize.bits.max_max_transform_hierarchy_depth_intra = 2; |
| 465 |
hevcBlockSize.bits.min_max_transform_hierarchy_depth_intra = 0; |
| 466 |
hevcBlockSize.bits.log2_max_pcm_coding_block_size_minus3 = 0; |
| 467 |
hevcBlockSize.bits.log2_min_pcm_coding_block_size_minus3 = 0; |
| 468 |
*value = hevcBlockSize.value; |
| 469 |
} |
| 470 |
break; |
| 471 |
} |
| 472 |
#endif |
| 473 |
default: |
| 474 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 475 |
break; |
| 476 |
} |
| 477 |
return status; |
| 478 |
} |
| 479 |
|
| 480 |
VAStatus MediaLibvaCapsG11::LoadHevcEncProfileEntrypoints() |
| 481 |
{ |
| 482 |
VAStatus status = VA_STATUS_SUCCESS; |
| 483 |
|
| 484 |
#ifdef _HEVC_ENCODE_VME_SUPPORTED |
| 485 |
|
| 486 |
status = MediaLibvaCaps::LoadHevcEncProfileEntrypoints(); |
| 487 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 488 |
|
| 489 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC)) |
| 490 |
{ |
| 491 |
SetAttribute(VAProfileHEVCMain, VAEntrypointEncSlice, VAConfigAttribEncTileSupport, 1); |
| 492 |
} |
| 493 |
|
| 494 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC10bit)) |
| 495 |
{ |
| 496 |
SetAttribute(VAProfileHEVCMain10, VAEntrypointEncSlice, VAConfigAttribEncTileSupport, 1); |
| 497 |
} |
| 498 |
|
| 499 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC12bit)) |
| 500 |
{ |
| 501 |
SetAttribute(VAProfileHEVCMain12, VAEntrypointEncSlice, VAConfigAttribEncTileSupport, 1); |
| 502 |
} |
| 503 |
|
| 504 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC10bit422)) |
| 505 |
{ |
| 506 |
SetAttribute(VAProfileHEVCMain422_10, VAEntrypointEncSlice, VAConfigAttribEncTileSupport, 1); |
| 507 |
} |
| 508 |
|
| 509 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC12bit422)) |
| 510 |
{ |
| 511 |
SetAttribute(VAProfileHEVCMain422_12, VAEntrypointEncSlice, VAConfigAttribEncTileSupport, 1); |
| 512 |
} |
| 513 |
#endif |
| 514 |
return status; |
| 515 |
} |
| 516 |
|
| 517 |
VAStatus MediaLibvaCapsG11::LoadHevcEncLpProfileEntrypoints() |
| 518 |
{ |
| 519 |
VAStatus status = VA_STATUS_SUCCESS; |
| 520 |
|
| 521 |
#ifdef _HEVC_ENCODE_VDENC_SUPPORTED |
| 522 |
AttribMap *attributeList = nullptr; |
| 523 |
|
| 524 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain) |
| 525 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain10) |
| 526 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain444) |
| 527 |
|| MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain10bit444)) |
| 528 |
{ |
| 529 |
status = CreateEncAttributes(VAProfileHEVCMain, VAEntrypointEncSliceLP, &attributeList); |
| 530 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 531 |
(*attributeList)[VAConfigAttribEncTileSupport] = 1; |
| 532 |
(*attributeList)[VAConfigAttribEncMaxRefFrames] = DDI_CODEC_VDENC_MAX_L0_REF_FRAMES_LDB | (DDI_CODEC_VDENC_MAX_L1_REF_FRAMES_LDB << DDI_CODEC_LEFT_SHIFT_FOR_REFLIST1); |
| 533 |
(*attributeList)[VAConfigAttribEncDirtyRect] = CODECHAL_ENCODE_HEVC_MAX_NUM_DIRTYRECT; |
| 534 |
(*attributeList)[VAConfigAttribEncParallelRateControl] = 0; |
| 535 |
} |
| 536 |
|
| 537 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain)) |
| 538 |
{ |
| 539 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 540 |
AddEncConfig(VA_RC_CQP); |
| 541 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)) |
| 542 |
{ |
| 543 |
for (int32_t j = 3; j < 7; j++) |
| 544 |
{ |
| 545 |
AddEncConfig(m_encRcMode[j]); |
| 546 |
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); |
| 547 |
} |
| 548 |
} |
| 549 |
AddProfileEntry(VAProfileHEVCMain, VAEntrypointEncSliceLP, attributeList, |
| 550 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 551 |
} |
| 552 |
|
| 553 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain10)) |
| 554 |
{ |
| 555 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 556 |
AddEncConfig(VA_RC_CQP); |
| 557 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)) |
| 558 |
{ |
| 559 |
for (int32_t j = 3; j < 7; j++) |
| 560 |
{ |
| 561 |
AddEncConfig(m_encRcMode[j]); |
| 562 |
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); |
| 563 |
} |
| 564 |
} |
| 565 |
AddProfileEntry(VAProfileHEVCMain10, VAEntrypointEncSliceLP, attributeList, |
| 566 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 567 |
} |
| 568 |
|
| 569 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain444)) |
| 570 |
{ |
| 571 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 572 |
AddEncConfig(VA_RC_CQP); |
| 573 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)) |
| 574 |
{ |
| 575 |
for (int32_t j = 3; j < 7; j++) |
| 576 |
{ |
| 577 |
AddEncConfig(m_encRcMode[j]); |
| 578 |
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); |
| 579 |
} |
| 580 |
} |
| 581 |
AddProfileEntry(VAProfileHEVCMain444, VAEntrypointEncSliceLP, attributeList, |
| 582 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 583 |
} |
| 584 |
|
| 585 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVCVdencMain10bit444)) |
| 586 |
{ |
| 587 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 588 |
AddEncConfig(VA_RC_CQP); |
| 589 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)) |
| 590 |
{ |
| 591 |
for (int32_t j = 3; j < 7; j++) |
| 592 |
{ |
| 593 |
AddEncConfig(m_encRcMode[j]); |
| 594 |
AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); |
| 595 |
} |
| 596 |
} |
| 597 |
AddProfileEntry(VAProfileHEVCMain444_10, VAEntrypointEncSliceLP, attributeList, |
| 598 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 599 |
} |
| 600 |
#endif |
| 601 |
return status; |
| 602 |
} |
| 603 |
|
| 604 |
VAStatus MediaLibvaCapsG11::LoadVp9EncProfileEntrypoints() |
| 605 |
{ |
| 606 |
VAStatus status = VA_STATUS_SUCCESS; |
| 607 |
|
| 608 |
#ifdef _VP9_ENCODE_VDENC_SUPPORTED |
| 609 |
AttribMap *attributeList = nullptr; |
| 610 |
|
| 611 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels) && |
| 612 |
(MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeVP9Vdenc) || |
| 613 |
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeVP9Vdenc8bit444) || |
| 614 |
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeVP9Vdenc10bit420) || |
| 615 |
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeVP9Vdenc10bit444))) |
| 616 |
{ |
| 617 |
status = CreateEncAttributes(VAProfileVP9Profile0, VAEntrypointEncSliceLP, &attributeList); |
| 618 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 619 |
(*attributeList)[VAConfigAttribMaxPictureWidth] = m_maxVp9EncWidth; |
| 620 |
(*attributeList)[VAConfigAttribMaxPictureHeight] = m_maxVp9EncHeight; |
| 621 |
(*attributeList)[VAConfigAttribEncDynamicScaling] = 1; |
| 622 |
(*attributeList)[VAConfigAttribEncTileSupport] = 1; |
| 623 |
(*attributeList)[VAConfigAttribEncRateControlExt] = m_encVp9RateControlExt.value; |
| 624 |
} |
| 625 |
|
| 626 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeVP9Vdenc) && |
| 627 |
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)) |
| 628 |
{ |
| 629 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 630 |
AddEncConfig(VA_RC_CQP); |
| 631 |
AddEncConfig(VA_RC_CBR); |
| 632 |
AddEncConfig(VA_RC_VBR); |
| 633 |
AddProfileEntry(VAProfileVP9Profile0, VAEntrypointEncSliceLP, attributeList, |
| 634 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 635 |
} |
| 636 |
|
| 637 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeVP9Vdenc8bit444) && |
| 638 |
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)) |
| 639 |
{ |
| 640 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 641 |
AddEncConfig(VA_RC_CQP); |
| 642 |
AddEncConfig(VA_RC_CBR); |
| 643 |
AddEncConfig(VA_RC_VBR); |
| 644 |
AddProfileEntry(VAProfileVP9Profile1, VAEntrypointEncSliceLP, attributeList, |
| 645 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 646 |
} |
| 647 |
|
| 648 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeVP9Vdenc10bit420) && |
| 649 |
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)) |
| 650 |
{ |
| 651 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 652 |
AddEncConfig(VA_RC_CQP); |
| 653 |
AddEncConfig(VA_RC_CBR); |
| 654 |
AddEncConfig(VA_RC_VBR); |
| 655 |
AddProfileEntry(VAProfileVP9Profile2, VAEntrypointEncSliceLP, attributeList, |
| 656 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 657 |
} |
| 658 |
|
| 659 |
if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeVP9Vdenc10bit444) && |
| 660 |
MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEnableMediaKernels)) |
| 661 |
{ |
| 662 |
uint32_t configStartIdx = m_encConfigs.size(); |
| 663 |
AddEncConfig(VA_RC_CQP); |
| 664 |
AddEncConfig(VA_RC_CBR); |
| 665 |
AddEncConfig(VA_RC_VBR); |
| 666 |
AddProfileEntry(VAProfileVP9Profile3, VAEntrypointEncSliceLP, attributeList, |
| 667 |
configStartIdx, m_encConfigs.size() - configStartIdx); |
| 668 |
} |
| 669 |
#endif |
| 670 |
return status; |
| 671 |
} |
| 672 |
|
| 673 |
VAStatus MediaLibvaCapsG11::LoadProfileEntrypoints() |
| 674 |
{ |
| 675 |
VAStatus status = VA_STATUS_SUCCESS; |
| 676 |
status = LoadAvcDecProfileEntrypoints(); |
| 677 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 678 |
status = LoadAvcEncProfileEntrypoints(); |
| 679 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 680 |
status = LoadAvcEncLpProfileEntrypoints(); |
| 681 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 682 |
status = LoadMpeg2DecProfileEntrypoints(); |
| 683 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 684 |
status = LoadMpeg2EncProfileEntrypoints(); |
| 685 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 686 |
status = LoadVc1DecProfileEntrypoints(); |
| 687 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 688 |
status = LoadJpegDecProfileEntrypoints(); |
| 689 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 690 |
status = LoadJpegEncProfileEntrypoints(); |
| 691 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 692 |
status = LoadHevcDecProfileEntrypoints(); |
| 693 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 694 |
status = LoadHevcEncProfileEntrypoints(); |
| 695 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 696 |
status = LoadHevcEncLpProfileEntrypoints(); |
| 697 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 698 |
status = LoadVp8DecProfileEntrypoints(); |
| 699 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 700 |
status = LoadVp8EncProfileEntrypoints(); |
| 701 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 702 |
status = LoadVp9DecProfileEntrypoints(); |
| 703 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 704 |
status = LoadVp9EncProfileEntrypoints(); |
| 705 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 706 |
#ifdef ENABLE_KERNELS |
| 707 |
status = LoadNoneProfileEntrypoints(); |
| 708 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 709 |
#endif |
| 710 |
status = m_CapsCp->LoadCpProfileEntrypoints(); |
| 711 |
DDI_CHK_RET(status, "Failed to initialize CP Caps!"); |
| 712 |
return status; |
| 713 |
} |
| 714 |
|
| 715 |
VAStatus MediaLibvaCapsG11::CheckEncodeResolution( |
| 716 |
VAProfile profile, |
| 717 |
uint32_t width, |
| 718 |
uint32_t height) |
| 719 |
{ |
| 720 |
switch (profile) |
| 721 |
{ |
| 722 |
case VAProfileJPEGBaseline: |
| 723 |
if (width > m_encJpegMaxWidth |
| 724 |
|| width < m_encJpegMinWidth |
| 725 |
|| height > m_encJpegMaxHeight |
| 726 |
|| height < m_encJpegMinHeight) |
| 727 |
{ |
| 728 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 729 |
} |
| 730 |
break; |
| 731 |
case VAProfileMPEG2Simple: |
| 732 |
case VAProfileMPEG2Main: |
| 733 |
if( width > CODEC_MAX_PIC_WIDTH |
| 734 |
|| width < m_encMinWidth |
| 735 |
|| height > CODEC_MAX_PIC_HEIGHT |
| 736 |
|| height < m_encMinHeight) |
| 737 |
{ |
| 738 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 739 |
} |
| 740 |
break; |
| 741 |
case VAProfileHEVCMain: |
| 742 |
case VAProfileHEVCMain10: |
| 743 |
case VAProfileHEVCMain422_10: |
| 744 |
case VAProfileHEVCMain444: |
| 745 |
case VAProfileHEVCMain444_10: |
| 746 |
if (width > m_maxHevcEncWidth |
| 747 |
|| width < (m_vdencActive ? m_hevcVDEncMinWidth : m_encMinWidth) |
| 748 |
|| height > m_maxHevcEncHeight |
| 749 |
|| height < (m_vdencActive ? m_hevcVDEncMinHeight : m_encMinHeight)) |
| 750 |
{ |
| 751 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 752 |
} |
| 753 |
break; |
| 754 |
case VAProfileVP9Profile0: |
| 755 |
case VAProfileVP9Profile1: |
| 756 |
case VAProfileVP9Profile2: |
| 757 |
case VAProfileVP9Profile3: |
| 758 |
if ((width > m_maxVp9EncWidth) || |
| 759 |
(width < m_minVp9EncWidth) || |
| 760 |
(height > m_maxVp9EncHeight) || |
| 761 |
(height < m_minVp9EncHeight) ) |
| 762 |
{ |
| 763 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 764 |
} |
| 765 |
break; |
| 766 |
default: |
| 767 |
if (width > m_encMax4kWidth |
| 768 |
|| width < m_encMinWidth |
| 769 |
|| height > m_encMax4kHeight |
| 770 |
|| height < m_encMinHeight) |
| 771 |
{ |
| 772 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 773 |
} |
| 774 |
break; |
| 775 |
} |
| 776 |
return VA_STATUS_SUCCESS; |
| 777 |
} |
| 778 |
VAStatus MediaLibvaCapsG11::CheckDecodeResolution( |
| 779 |
int32_t codecMode, |
| 780 |
VAProfile profile, |
| 781 |
uint32_t width, |
| 782 |
uint32_t height) |
| 783 |
{ |
| 784 |
|
| 785 |
uint32_t maxWidth, maxHeight; |
| 786 |
switch (codecMode) |
| 787 |
{ |
| 788 |
case CODECHAL_DECODE_MODE_MPEG2VLD: |
| 789 |
maxWidth = m_decMpeg2MaxWidth; |
| 790 |
maxHeight = m_decMpeg2MaxHeight; |
| 791 |
break; |
| 792 |
case CODECHAL_DECODE_MODE_VC1VLD: |
| 793 |
maxWidth = m_decVc1MaxWidth; |
| 794 |
maxHeight = m_decVc1MaxHeight; |
| 795 |
break; |
| 796 |
case CODECHAL_DECODE_MODE_JPEG: |
| 797 |
maxWidth = m_decJpegMaxWidth; |
| 798 |
maxHeight = m_decJpegMaxHeight; |
| 799 |
break; |
| 800 |
case CODECHAL_DECODE_MODE_HEVCVLD: |
| 801 |
maxWidth = m_decHevcMaxWidth; |
| 802 |
maxHeight = m_decHevcMaxHeight; |
| 803 |
break; |
| 804 |
case CODECHAL_DECODE_MODE_VP9VLD: |
| 805 |
maxWidth = m_decVp9MaxWidth; |
| 806 |
maxHeight = m_decVp9MaxHeight; |
| 807 |
break; |
| 808 |
default: |
| 809 |
maxWidth = m_decDefaultMaxWidth; |
| 810 |
maxHeight = m_decDefaultMaxHeight; |
| 811 |
break; |
| 812 |
} |
| 813 |
|
| 814 |
uint32_t alignedHeight; |
| 815 |
if (profile == VAProfileVC1Advanced) |
| 816 |
{ |
| 817 |
alignedHeight = MOS_ALIGN_CEIL(height,32); |
| 818 |
} |
| 819 |
else |
| 820 |
{ |
| 821 |
alignedHeight = height; |
| 822 |
} |
| 823 |
|
| 824 |
if (width > maxWidth || alignedHeight > maxHeight) |
| 825 |
{ |
| 826 |
return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; |
| 827 |
} |
| 828 |
else |
| 829 |
{ |
| 830 |
return VA_STATUS_SUCCESS; |
| 831 |
} |
| 832 |
} |
| 833 |
|
| 834 |
VAStatus MediaLibvaCapsG11::QueryAVCROIMaxNum(uint32_t rcMode, bool isVdenc, uint32_t *maxNum, bool *isRoiInDeltaQP) |
| 835 |
{ |
| 836 |
DDI_CHK_NULL(maxNum, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 837 |
DDI_CHK_NULL(isRoiInDeltaQP, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 838 |
|
| 839 |
if(isVdenc) |
| 840 |
{ |
| 841 |
*maxNum = ENCODE_VDENC_AVC_MAX_ROI_NUMBER; |
| 842 |
} |
| 843 |
else |
| 844 |
{ |
| 845 |
switch (rcMode) |
| 846 |
{ |
| 847 |
case VA_RC_CQP: |
| 848 |
*maxNum = ENCODE_DP_AVC_MAX_ROI_NUMBER; |
| 849 |
break; |
| 850 |
default: |
| 851 |
*maxNum = ENCODE_DP_AVC_MAX_ROI_NUM_BRC; |
| 852 |
break; |
| 853 |
} |
| 854 |
} |
| 855 |
|
| 856 |
*isRoiInDeltaQP = true; |
| 857 |
|
| 858 |
return VA_STATUS_SUCCESS; |
| 859 |
} |
| 860 |
|
| 861 |
GMM_RESOURCE_FORMAT MediaLibvaCapsG11::ConvertMediaFmtToGmmFmt( |
| 862 |
DDI_MEDIA_FORMAT format) |
| 863 |
{ |
| 864 |
switch (format) |
| 865 |
{ |
| 866 |
case Media_Format_X8R8G8B8 : return GMM_FORMAT_B8G8R8X8_UNORM_TYPE; |
| 867 |
case Media_Format_A8R8G8B8 : return GMM_FORMAT_B8G8R8A8_UNORM_TYPE; |
| 868 |
case Media_Format_X8B8G8R8 : return GMM_FORMAT_R8G8B8X8_UNORM_TYPE; |
| 869 |
case Media_Format_A8B8G8R8 : return GMM_FORMAT_R8G8B8A8_UNORM_TYPE; |
| 870 |
case Media_Format_R8G8B8A8 : return GMM_FORMAT_R8G8B8A8_UNORM_TYPE; |
| 871 |
case Media_Format_R5G6B5 : return GMM_FORMAT_B5G6R5_UNORM_TYPE; |
| 872 |
case Media_Format_R8G8B8 : return GMM_FORMAT_R8G8B8_UNORM; |
| 873 |
case Media_Format_RGBP : return GMM_FORMAT_RGBP; |
| 874 |
case Media_Format_BGRP : return GMM_FORMAT_BGRP; |
| 875 |
case Media_Format_NV12 : return GMM_FORMAT_NV12_TYPE; |
| 876 |
case Media_Format_NV21 : return GMM_FORMAT_NV21_TYPE; |
| 877 |
case Media_Format_YUY2 : return GMM_FORMAT_YUY2; |
| 878 |
case Media_Format_UYVY : return GMM_FORMAT_UYVY; |
| 879 |
case Media_Format_YV12 : return GMM_FORMAT_YV12_TYPE; |
| 880 |
case Media_Format_IYUV : return GMM_FORMAT_IYUV_TYPE; |
| 881 |
case Media_Format_I420 : return GMM_FORMAT_I420_TYPE; |
| 882 |
case Media_Format_444P : return GMM_FORMAT_MFX_JPEG_YUV444_TYPE; |
| 883 |
case Media_Format_422H : return GMM_FORMAT_MFX_JPEG_YUV422H_TYPE; |
| 884 |
case Media_Format_411P : return GMM_FORMAT_MFX_JPEG_YUV411_TYPE; |
| 885 |
case Media_Format_422V : return GMM_FORMAT_MFX_JPEG_YUV422V_TYPE; |
| 886 |
case Media_Format_IMC3 : return GMM_FORMAT_IMC3_TYPE; |
| 887 |
case Media_Format_400P : return GMM_FORMAT_GENERIC_8BIT; |
| 888 |
case Media_Format_Buffer : return GMM_FORMAT_RENDER_8BIT; |
| 889 |
case Media_Format_P010 : return GMM_FORMAT_P010_TYPE; |
| 890 |
case Media_Format_P012 : return GMM_FORMAT_P016_TYPE; |
| 891 |
case Media_Format_P016 : return GMM_FORMAT_P016_TYPE; |
| 892 |
case Media_Format_R10G10B10A2: return GMM_FORMAT_R10G10B10A2_UNORM_TYPE; |
| 893 |
case Media_Format_B10G10R10A2: return GMM_FORMAT_B10G10R10A2_UNORM_TYPE; |
| 894 |
case Media_Format_R10G10B10X2: return GMM_FORMAT_R10G10B10A2_UNORM_TYPE; |
| 895 |
case Media_Format_B10G10R10X2: return GMM_FORMAT_B10G10R10A2_UNORM_TYPE; |
| 896 |
case Media_Format_Y210 : return GMM_FORMAT_Y210_TYPE; |
| 897 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 898 |
case Media_Format_Y212 : return GMM_FORMAT_Y216_TYPE; |
| 899 |
#endif |
| 900 |
case Media_Format_Y216 : return GMM_FORMAT_Y216_TYPE; |
| 901 |
case Media_Format_AYUV : return GMM_FORMAT_AYUV_TYPE; |
| 902 |
#if VA_CHECK_VERSION(1, 13, 0) |
| 903 |
case Media_Format_XYUV : return GMM_FORMAT_AYUV_TYPE; |
| 904 |
#endif |
| 905 |
case Media_Format_Y410 : return GMM_FORMAT_Y410_TYPE; |
| 906 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 907 |
case Media_Format_Y412 : return GMM_FORMAT_Y416_TYPE; |
| 908 |
#endif |
| 909 |
case Media_Format_Y416 : return GMM_FORMAT_Y416_TYPE; |
| 910 |
default : return GMM_FORMAT_INVALID; |
| 911 |
} |
| 912 |
} |
| 913 |
|
| 914 |
VAStatus MediaLibvaCapsG11::QuerySurfaceAttributes( |
| 915 |
VAConfigID configId, |
| 916 |
VASurfaceAttrib *attribList, |
| 917 |
uint32_t *numAttribs) |
| 918 |
{ |
| 919 |
DDI_CHK_NULL(numAttribs, "Null num_attribs", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 920 |
|
| 921 |
if (attribList == nullptr) |
| 922 |
{ |
| 923 |
*numAttribs = DDI_CODEC_GEN_MAX_SURFACE_ATTRIBUTES; |
| 924 |
return VA_STATUS_SUCCESS; |
| 925 |
} |
| 926 |
|
| 927 |
int32_t profileTableIdx = -1; |
| 928 |
VAEntrypoint entrypoint; |
| 929 |
VAProfile profile; |
| 930 |
VAStatus status = GetProfileEntrypointFromConfigId(configId, &profile, &entrypoint, &profileTableIdx); |
| 931 |
DDI_CHK_RET(status, "Invalid config_id!"); |
| 932 |
if (profileTableIdx < 0 || profileTableIdx >= m_profileEntryCount) |
| 933 |
{ |
| 934 |
return VA_STATUS_ERROR_INVALID_CONFIG; |
| 935 |
} |
| 936 |
|
| 937 |
VASurfaceAttrib *attribs = (VASurfaceAttrib *)MOS_AllocAndZeroMemory(DDI_CODEC_GEN_MAX_SURFACE_ATTRIBUTES * sizeof(*attribs)); |
| 938 |
if (attribs == nullptr) |
| 939 |
{ |
| 940 |
return VA_STATUS_ERROR_ALLOCATION_FAILED; |
| 941 |
} |
| 942 |
|
| 943 |
int32_t i = 0; |
| 944 |
|
| 945 |
if (entrypoint == VAEntrypointVideoProc) /* vpp */ |
| 946 |
{ |
| 947 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 948 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 949 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 950 |
attribs[i].value.value.i = VA_FOURCC('N', 'V', '1', '2'); |
| 951 |
i++; |
| 952 |
|
| 953 |
attribs[i].type = VASurfaceAttribMaxWidth; |
| 954 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 955 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 956 |
attribs[i].value.value.i = VP_MAX_PIC_WIDTH; |
| 957 |
i++; |
| 958 |
|
| 959 |
attribs[i].type = VASurfaceAttribMaxHeight; |
| 960 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 961 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 962 |
attribs[i].value.value.i = VP_MAX_PIC_HEIGHT; |
| 963 |
i++; |
| 964 |
|
| 965 |
attribs[i].type = VASurfaceAttribMinWidth; |
| 966 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 967 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 968 |
attribs[i].value.value.i = VP_MIN_PIC_WIDTH; |
| 969 |
i++; |
| 970 |
|
| 971 |
attribs[i].type = VASurfaceAttribMinHeight; |
| 972 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 973 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 974 |
attribs[i].value.value.i = VP_MIN_PIC_HEIGHT; |
| 975 |
i++; |
| 976 |
|
| 977 |
for (int32_t j = 0; j < m_numVpSurfaceAttr && m_vpSurfaceAttr[j]; j++) |
| 978 |
{ |
| 979 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 980 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 981 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 982 |
attribs[i].value.value.i = m_vpSurfaceAttr[j]; |
| 983 |
i++; |
| 984 |
} |
| 985 |
|
| 986 |
attribs[i].type = VASurfaceAttribMemoryType; |
| 987 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 988 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 989 |
attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | |
| 990 |
VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR | |
| 991 |
VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM | |
| 992 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME | |
| 993 |
#if VA_CHECK_VERSION(1, 21, 0) |
| 994 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_3 | |
| 995 |
#endif |
| 996 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2; |
| 997 |
i++; |
| 998 |
|
| 999 |
attribs[i].type = VASurfaceAttribExternalBufferDescriptor; |
| 1000 |
attribs[i].value.type = VAGenericValueTypePointer; |
| 1001 |
attribs[i].flags = VA_SURFACE_ATTRIB_SETTABLE; |
| 1002 |
attribs[i].value.value.p = nullptr; /* ignore */ |
| 1003 |
i++; |
| 1004 |
} |
| 1005 |
else if (entrypoint == VAEntrypointVLD) /* vld */ |
| 1006 |
{ |
| 1007 |
if (profile == VAProfileHEVCMain10 || profile == VAProfileVP9Profile2) |
| 1008 |
{ |
| 1009 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1010 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1011 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1012 |
attribs[i].value.value.i = VA_FOURCC_P010; |
| 1013 |
i++; |
| 1014 |
|
| 1015 |
if(profile == VAProfileVP9Profile2) |
| 1016 |
{ |
| 1017 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1018 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1019 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1020 |
attribs[i].value.value.i = VA_FOURCC_P012; |
| 1021 |
i++; |
| 1022 |
|
| 1023 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1024 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1025 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1026 |
attribs[i].value.value.i = VA_FOURCC_P016; |
| 1027 |
i++; |
| 1028 |
} |
| 1029 |
} |
| 1030 |
else if(profile == VAProfileHEVCMain12) |
| 1031 |
{ |
| 1032 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1033 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1034 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1035 |
attribs[i].value.value.i = VA_FOURCC_P012; |
| 1036 |
i++; |
| 1037 |
|
| 1038 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1039 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1040 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1041 |
attribs[i].value.value.i = VA_FOURCC_P016; |
| 1042 |
i++; |
| 1043 |
} |
| 1044 |
else if(profile == VAProfileHEVCMain422_10) |
| 1045 |
{ |
| 1046 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1047 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1048 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1049 |
attribs[i].value.value.i = VA_FOURCC_YUY2; |
| 1050 |
i++; |
| 1051 |
|
| 1052 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1053 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1054 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1055 |
attribs[i].value.value.i = VA_FOURCC_Y210; |
| 1056 |
i++; |
| 1057 |
} |
| 1058 |
else if(profile == VAProfileHEVCMain422_12) |
| 1059 |
{ |
| 1060 |
//hevc rext: Y216 12/16bit 422 |
| 1061 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 1062 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1063 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1064 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1065 |
attribs[i].value.value.i = VA_FOURCC_Y212; |
| 1066 |
i++; |
| 1067 |
#endif |
| 1068 |
|
| 1069 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1070 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1071 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1072 |
attribs[i].value.value.i = VA_FOURCC_Y216; |
| 1073 |
i++; |
| 1074 |
|
| 1075 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1076 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1077 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1078 |
attribs[i].value.value.i = VA_FOURCC_P012; |
| 1079 |
i++; |
| 1080 |
} |
| 1081 |
else if(profile == VAProfileHEVCMain444 || profile == VAProfileVP9Profile1) |
| 1082 |
{ |
| 1083 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1084 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1085 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1086 |
attribs[i].value.value.i = VA_FOURCC_AYUV; |
| 1087 |
i++; |
| 1088 |
|
| 1089 |
#if VA_CHECK_VERSION(1, 13, 0) |
| 1090 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1091 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1092 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1093 |
attribs[i].value.value.i = VA_FOURCC_XYUV; |
| 1094 |
i++; |
| 1095 |
#endif |
| 1096 |
} |
| 1097 |
else if(profile == VAProfileHEVCMain444_10 || profile == VAProfileVP9Profile3) |
| 1098 |
{ |
| 1099 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1100 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1101 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1102 |
attribs[i].value.value.i = VA_FOURCC_Y410; |
| 1103 |
i++; |
| 1104 |
|
| 1105 |
if(profile == VAProfileVP9Profile3) |
| 1106 |
{ |
| 1107 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 1108 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1109 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1110 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1111 |
attribs[i].value.value.i = VA_FOURCC_Y412; |
| 1112 |
i++; |
| 1113 |
#endif |
| 1114 |
|
| 1115 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1116 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1117 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1118 |
attribs[i].value.value.i = VA_FOURCC_Y416; |
| 1119 |
i++; |
| 1120 |
} |
| 1121 |
} |
| 1122 |
else if(profile == VAProfileHEVCMain444_12) |
| 1123 |
{ |
| 1124 |
#if VA_CHECK_VERSION(1, 9, 0) |
| 1125 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1126 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1127 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1128 |
attribs[i].value.value.i = VA_FOURCC_Y412; |
| 1129 |
i++; |
| 1130 |
|
| 1131 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1132 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1133 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1134 |
attribs[i].value.value.i = VA_FOURCC_Y212; |
| 1135 |
i++; |
| 1136 |
#endif |
| 1137 |
|
| 1138 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1139 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1140 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1141 |
attribs[i].value.value.i = VA_FOURCC_Y416; |
| 1142 |
i++; |
| 1143 |
|
| 1144 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1145 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1146 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1147 |
attribs[i].value.value.i = VA_FOURCC_P012; |
| 1148 |
i++; |
| 1149 |
} |
| 1150 |
else if (profile == VAProfileJPEGBaseline) |
| 1151 |
{ |
| 1152 |
for (int32_t j = 0; j < m_numJpegSurfaceAttr; j++) |
| 1153 |
{ |
| 1154 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1155 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1156 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1157 |
attribs[i].value.value.i = m_jpegSurfaceAttr[j]; |
| 1158 |
i++; |
| 1159 |
} |
| 1160 |
} |
| 1161 |
else |
| 1162 |
{ |
| 1163 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1164 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1165 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1166 |
attribs[i].value.value.i = VA_FOURCC('N', 'V', '1', '2'); |
| 1167 |
i++; |
| 1168 |
} |
| 1169 |
|
| 1170 |
auto maxWidth = m_decDefaultMaxWidth; |
| 1171 |
auto maxHeight = m_decDefaultMaxHeight; |
| 1172 |
if(IsMpeg2Profile(profile)) |
| 1173 |
{ |
| 1174 |
maxWidth = m_decMpeg2MaxWidth; |
| 1175 |
maxHeight = m_decMpeg2MaxHeight; |
| 1176 |
} |
| 1177 |
else if(IsHevcProfile(profile)) |
| 1178 |
{ |
| 1179 |
maxWidth = m_decHevcMaxWidth; |
| 1180 |
maxHeight = m_decHevcMaxHeight; |
| 1181 |
} |
| 1182 |
else if(IsVc1Profile(profile)) |
| 1183 |
{ |
| 1184 |
maxWidth = m_decVc1MaxWidth; |
| 1185 |
maxHeight = m_decVc1MaxHeight; |
| 1186 |
} |
| 1187 |
else if(IsJpegProfile(profile)) |
| 1188 |
{ |
| 1189 |
maxWidth = m_decJpegMaxWidth; |
| 1190 |
maxHeight = m_decJpegMaxHeight; |
| 1191 |
} |
| 1192 |
else if(IsVp9Profile(profile)) |
| 1193 |
{ |
| 1194 |
maxWidth = m_decVp9MaxWidth; |
| 1195 |
maxHeight = m_decVp9MaxHeight; |
| 1196 |
} |
| 1197 |
|
| 1198 |
attribs[i].type = VASurfaceAttribMaxWidth; |
| 1199 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1200 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 1201 |
attribs[i].value.value.i = maxWidth; |
| 1202 |
i++; |
| 1203 |
|
| 1204 |
attribs[i].type = VASurfaceAttribMaxHeight; |
| 1205 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1206 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 1207 |
attribs[i].value.value.i = maxHeight; |
| 1208 |
i++; |
| 1209 |
|
| 1210 |
attribs[i].type = VASurfaceAttribMemoryType; |
| 1211 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1212 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1213 |
attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | |
| 1214 |
VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR | |
| 1215 |
VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM | |
| 1216 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME | |
| 1217 |
#if VA_CHECK_VERSION(1, 21, 0) |
| 1218 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_3 | |
| 1219 |
#endif |
| 1220 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2; |
| 1221 |
i++; |
| 1222 |
} |
| 1223 |
else if(entrypoint == VAEntrypointEncSlice || entrypoint == VAEntrypointEncSliceLP || entrypoint == VAEntrypointEncPicture || entrypoint == VAEntrypointFEI) |
| 1224 |
{ |
| 1225 |
if (profile == VAProfileHEVCMain10 || profile == VAProfileVP9Profile2) |
| 1226 |
{ |
| 1227 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1228 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1229 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1230 |
attribs[i].value.value.i = VA_FOURCC('P', '0', '1', '0'); |
| 1231 |
i++; |
| 1232 |
} |
| 1233 |
else if(profile == VAProfileHEVCMain444) |
| 1234 |
{ |
| 1235 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1236 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1237 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1238 |
attribs[i].value.value.i = VA_FOURCC_AYUV; |
| 1239 |
i++; |
| 1240 |
|
| 1241 |
#if VA_CHECK_VERSION(1, 13, 0) |
| 1242 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1243 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1244 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1245 |
attribs[i].value.value.i = VA_FOURCC_XYUV; |
| 1246 |
i++; |
| 1247 |
#endif |
| 1248 |
} |
| 1249 |
else if(profile == VAProfileHEVCMain444_10) |
| 1250 |
{ |
| 1251 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1252 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1253 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1254 |
attribs[i].value.value.i = VA_FOURCC_Y410; |
| 1255 |
i++; |
| 1256 |
} |
| 1257 |
else if(profile == VAProfileHEVCMain422_10) |
| 1258 |
{ |
| 1259 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1260 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1261 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1262 |
attribs[i].value.value.i = VA_FOURCC_YUY2; |
| 1263 |
i++; |
| 1264 |
|
| 1265 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1266 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1267 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1268 |
attribs[i].value.value.i = VA_FOURCC_Y210; |
| 1269 |
i++; |
| 1270 |
} |
| 1271 |
else if (profile == VAProfileVP9Profile1) |
| 1272 |
{ |
| 1273 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1274 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1275 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1276 |
attribs[i].value.value.i = VA_FOURCC('A', 'Y', 'U', 'V'); |
| 1277 |
i++; |
| 1278 |
} |
| 1279 |
else if (profile == VAProfileVP9Profile3) |
| 1280 |
{ |
| 1281 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1282 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1283 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1284 |
attribs[i].value.value.i = VA_FOURCC('Y', '4', '1', '6'); |
| 1285 |
i++; |
| 1286 |
|
| 1287 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1288 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1289 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1290 |
attribs[i].value.value.i = VA_FOURCC('A', 'R', 'G', 'B'); |
| 1291 |
i++; |
| 1292 |
|
| 1293 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1294 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1295 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1296 |
attribs[i].value.value.i = VA_FOURCC('A', 'B', 'G', 'R'); |
| 1297 |
i++; |
| 1298 |
} |
| 1299 |
else if (profile == VAProfileJPEGBaseline) |
| 1300 |
{ |
| 1301 |
for (int32_t j = 0; j < m_numJpegEncSurfaceAttr; j++) |
| 1302 |
{ |
| 1303 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1304 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1305 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1306 |
attribs[i].value.value.i = m_jpegEncSurfaceAttr[j]; |
| 1307 |
i++; |
| 1308 |
} |
| 1309 |
} |
| 1310 |
else |
| 1311 |
{ |
| 1312 |
attribs[i].type = VASurfaceAttribPixelFormat; |
| 1313 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1314 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1315 |
attribs[i].value.value.i = VA_FOURCC('N', 'V', '1', '2'); |
| 1316 |
i++; |
| 1317 |
} |
| 1318 |
attribs[i].type = VASurfaceAttribMaxWidth; |
| 1319 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1320 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 1321 |
attribs[i].value.value.i = CODEC_MAX_PIC_WIDTH; |
| 1322 |
|
| 1323 |
if(profile == VAProfileJPEGBaseline) |
| 1324 |
{ |
| 1325 |
attribs[i].value.value.i = ENCODE_JPEG_MAX_PIC_WIDTH; |
| 1326 |
} |
| 1327 |
else if(IsHevcProfile(profile)) |
| 1328 |
{ |
| 1329 |
attribs[i].value.value.i = CODEC_8K_MAX_PIC_WIDTH; |
| 1330 |
} |
| 1331 |
else if(IsAvcProfile(profile) || IsVp8Profile(profile)) |
| 1332 |
{ |
| 1333 |
attribs[i].value.value.i = CODEC_4K_MAX_PIC_WIDTH; |
| 1334 |
} |
| 1335 |
else if (IsVp9Profile(profile)) |
| 1336 |
{ |
| 1337 |
attribs[i].value.value.i = m_maxVp9EncWidth; |
| 1338 |
} |
| 1339 |
i++; |
| 1340 |
|
| 1341 |
attribs[i].type = VASurfaceAttribMaxHeight; |
| 1342 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1343 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 1344 |
attribs[i].value.value.i = CODEC_MAX_PIC_HEIGHT; |
| 1345 |
if(profile == VAProfileJPEGBaseline) |
| 1346 |
{ |
| 1347 |
attribs[i].value.value.i = ENCODE_JPEG_MAX_PIC_HEIGHT; |
| 1348 |
} |
| 1349 |
else if(IsHevcProfile(profile)) |
| 1350 |
{ |
| 1351 |
attribs[i].value.value.i = CODEC_8K_MAX_PIC_HEIGHT; |
| 1352 |
} |
| 1353 |
else if(IsAvcProfile(profile) || IsVp8Profile(profile)) |
| 1354 |
{ |
| 1355 |
attribs[i].value.value.i = CODEC_4K_MAX_PIC_HEIGHT; |
| 1356 |
} |
| 1357 |
else if (IsVp9Profile(profile)) |
| 1358 |
{ |
| 1359 |
attribs[i].value.value.i = m_maxVp9EncHeight; |
| 1360 |
} |
| 1361 |
i++; |
| 1362 |
|
| 1363 |
attribs[i].type = VASurfaceAttribMinWidth; |
| 1364 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1365 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 1366 |
attribs[i].value.value.i = m_encMinWidth; |
| 1367 |
if(IsHevcProfile(profile)) |
| 1368 |
{ |
| 1369 |
attribs[i].value.value.i = m_vdencActive ? m_hevcVDEncMinWidth : m_encMinWidth; |
| 1370 |
} |
| 1371 |
else if (IsVp9Profile(profile)) |
| 1372 |
{ |
| 1373 |
attribs[i].value.value.i = m_vdencActive ? m_minVp9EncWidth : m_encMinWidth; |
| 1374 |
} |
| 1375 |
else if (profile == VAProfileJPEGBaseline) |
| 1376 |
{ |
| 1377 |
attribs[i].value.value.i = m_encJpegMinWidth; |
| 1378 |
} |
| 1379 |
i++; |
| 1380 |
|
| 1381 |
attribs[i].type = VASurfaceAttribMinHeight; |
| 1382 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1383 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE; |
| 1384 |
attribs[i].value.value.i = m_encMinHeight; |
| 1385 |
if(IsHevcProfile(profile)) |
| 1386 |
{ |
| 1387 |
attribs[i].value.value.i = m_vdencActive ? m_hevcVDEncMinHeight : m_encMinHeight; |
| 1388 |
} |
| 1389 |
else if (IsVp9Profile(profile)) |
| 1390 |
{ |
| 1391 |
attribs[i].value.value.i = m_vdencActive ? m_minVp9EncHeight : m_encMinHeight; |
| 1392 |
} |
| 1393 |
else if (profile == VAProfileJPEGBaseline) |
| 1394 |
{ |
| 1395 |
attribs[i].value.value.i = m_encJpegMinHeight; |
| 1396 |
} |
| 1397 |
i++; |
| 1398 |
|
| 1399 |
attribs[i].type = VASurfaceAttribMemoryType; |
| 1400 |
attribs[i].value.type = VAGenericValueTypeInteger; |
| 1401 |
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; |
| 1402 |
attribs[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA | |
| 1403 |
VA_SURFACE_ATTRIB_MEM_TYPE_USER_PTR | |
| 1404 |
VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM | |
| 1405 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME | |
| 1406 |
#if VA_CHECK_VERSION(1, 21, 0) |
| 1407 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_3 | |
| 1408 |
#endif |
| 1409 |
VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2; |
| 1410 |
i++; |
| 1411 |
} |
| 1412 |
else |
| 1413 |
{ |
| 1414 |
MOS_FreeMemory(attribs); |
| 1415 |
return VA_STATUS_ERROR_UNIMPLEMENTED; |
| 1416 |
} |
| 1417 |
|
| 1418 |
if (i > *numAttribs) |
| 1419 |
{ |
| 1420 |
*numAttribs = i; |
| 1421 |
MOS_FreeMemory(attribs); |
| 1422 |
return VA_STATUS_ERROR_MAX_NUM_EXCEEDED; |
| 1423 |
} |
| 1424 |
|
| 1425 |
*numAttribs = i; |
| 1426 |
MOS_SecureMemcpy(attribList, i * sizeof(*attribs), attribs, i * sizeof(*attribs)); |
| 1427 |
|
| 1428 |
MOS_FreeMemory(attribs); |
| 1429 |
return status; |
| 1430 |
} |
| 1431 |
|
| 1432 |
VAStatus MediaLibvaCapsG11::CreateEncAttributes( |
| 1433 |
VAProfile profile, |
| 1434 |
VAEntrypoint entrypoint, |
| 1435 |
AttribMap **attributeList) |
| 1436 |
{ |
| 1437 |
VAStatus status = MediaLibvaCaps::CreateEncAttributes(profile, entrypoint, attributeList); |
| 1438 |
DDI_CHK_RET(status, "Failed to create base encode attributes"); |
| 1439 |
|
| 1440 |
auto attribList = *attributeList; |
| 1441 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1442 |
|
| 1443 |
#if VA_CHECK_VERSION(1, 12, 0) |
| 1444 |
if (IsHevcProfile(profile)) { |
| 1445 |
VAConfigAttrib attrib; |
| 1446 |
|
| 1447 |
attrib.type = VAConfigAttribEncHEVCFeatures; |
| 1448 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 1449 |
attrib.type, &attrib.value); |
| 1450 |
(*attribList)[attrib.type] = attrib.value; |
| 1451 |
|
| 1452 |
attrib.type = VAConfigAttribEncHEVCBlockSizes; |
| 1453 |
GetPlatformSpecificAttrib(profile, entrypoint, |
| 1454 |
attrib.type, &attrib.value); |
| 1455 |
(*attribList)[attrib.type] = attrib.value; |
| 1456 |
} |
| 1457 |
#endif |
| 1458 |
|
| 1459 |
return status; |
| 1460 |
} |
| 1461 |
|
| 1462 |
VAStatus MediaLibvaCapsG11::CreateDecAttributes( |
| 1463 |
VAProfile profile, |
| 1464 |
VAEntrypoint entrypoint, |
| 1465 |
AttribMap **attributeList) |
| 1466 |
{ |
| 1467 |
VAStatus status = MediaLibvaCaps::CreateDecAttributes(profile, entrypoint, attributeList); |
| 1468 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 1469 |
|
| 1470 |
auto attribList = *attributeList; |
| 1471 |
DDI_CHK_NULL(attribList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 1472 |
|
| 1473 |
VAConfigAttrib attrib; |
| 1474 |
attrib.type = VAConfigAttribRTFormat; |
| 1475 |
if(profile == VAProfileHEVCMain444) |
| 1476 |
{ |
| 1477 |
attrib.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV400 | VA_RT_FORMAT_YUV444; |
| 1478 |
(*attribList)[attrib.type] = attrib.value; |
| 1479 |
} |
| 1480 |
else if(profile == VAProfileHEVCMain444_10) |
| 1481 |
{ |
| 1482 |
attrib.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV400 | VA_RT_FORMAT_YUV444; |
| 1483 |
attrib.value |= VA_RT_FORMAT_YUV420_10 | VA_RT_FORMAT_YUV422_10 | VA_RT_FORMAT_YUV444_10; |
| 1484 |
(*attribList)[attrib.type] = attrib.value; |
| 1485 |
} else if(profile == VAProfileNone) |
| 1486 |
{ |
| 1487 |
attrib.value = VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_RGB32 | VA_RT_FORMAT_YUV444; |
| 1488 |
(*attribList)[attrib.type] = attrib.value; |
| 1489 |
} |
| 1490 |
|
| 1491 |
return status; |
| 1492 |
} |
| 1493 |
|
| 1494 |
extern template class MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>; |
| 1495 |
|
| 1496 |
static bool iclRegistered = MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>:: |
| 1497 |
RegisterCaps<MediaLibvaCapsG11>((uint32_t)IGFX_ICELAKE); |
| 1498 |
static bool icllpRegistered = MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>:: |
| 1499 |
RegisterCaps<MediaLibvaCapsG11>((uint32_t)IGFX_ICELAKE_LP); |
| 1500 |
static bool ehlRegistered = MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>:: |
| 1501 |
RegisterCaps<MediaLibvaCapsG11>((uint32_t)IGFX_ELKHARTLAKE); |