| 1 |
/* |
| 2 |
* Copyright (c) 2017, 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_g8.cpp |
| 24 |
//! \brief This file implements the C++ class/interface for gen8 media capbilities. |
| 25 |
//! |
| 26 |
|
| 27 |
#include "codec_def_encode_avc.h" |
| 28 |
#include "media_libva_util.h" |
| 29 |
#include "media_libva.h" |
| 30 |
#include "media_libva_caps_g8.h" |
| 31 |
#include "media_libva_caps_factory.h" |
| 32 |
|
| 33 |
const VAImageFormat m_supportedImageformatsG8[] = |
| 34 |
{ |
| 35 |
// "VA_LSB_FIRST" is to identify how following bit masks mapped to address instead of char order in VA_FOURCC_RGBA naming. |
| 36 |
{VA_FOURCC_BGRA, VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, /* [31:0] A:R:G:B 8:8:8:8 little endian */ |
| 37 |
{VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000}, /* [31:0] A:B:G:R 8:8:8:8 little endian */ |
| 38 |
{VA_FOURCC_BGRX, VA_LSB_FIRST, 32, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0}, /* [31:0] X:R:G:B 8:8:8:8 little endian */ |
| 39 |
{VA_FOURCC_RGBX, VA_LSB_FIRST, 32, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0}, /* [31:0] X:B:G:R 8:8:8:8 little endian */ |
| 40 |
{VA_FOURCC_RGB565, VA_LSB_FIRST, 16, 16, 0xf800, 0x07e0, 0x001f, 0}, |
| 41 |
{VA_FOURCC_NV12, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 42 |
{VA_FOURCC_NV21, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 43 |
{VA_FOURCC_YUY2, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 44 |
{VA_FOURCC_UYVY, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 45 |
{VA_FOURCC_YV12, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 46 |
{VA_FOURCC_I420, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 47 |
{VA_FOURCC_422H, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 48 |
{VA_FOURCC_422V, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 49 |
{VA_FOURCC_444P, VA_LSB_FIRST, 24, 0,0,0,0,0}, |
| 50 |
{VA_FOURCC_IMC3, VA_LSB_FIRST, 16, 0,0,0,0,0} |
| 51 |
}; |
| 52 |
|
| 53 |
VAStatus MediaLibvaCapsG8::QueryImageFormats(VAImageFormat *formatList, int32_t *numFormats) |
| 54 |
{ |
| 55 |
DDI_CHK_NULL(formatList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 56 |
DDI_CHK_NULL(numFormats, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 57 |
int32_t num = 0; |
| 58 |
uint32_t maxNum = GetImageFormatsMaxNum(); |
| 59 |
|
| 60 |
memset(formatList, 0, sizeof(m_supportedImageformatsG8)); |
| 61 |
for (uint32_t idx = 0; idx < maxNum; idx++) |
| 62 |
{ |
| 63 |
formatList[num].fourcc = m_supportedImageformatsG8[idx].fourcc; |
| 64 |
formatList[num].byte_order = m_supportedImageformatsG8[idx].byte_order; |
| 65 |
formatList[num].bits_per_pixel = m_supportedImageformatsG8[idx].bits_per_pixel; |
| 66 |
formatList[num].depth = m_supportedImageformatsG8[idx].depth; |
| 67 |
formatList[num].red_mask = m_supportedImageformatsG8[idx].red_mask; |
| 68 |
formatList[num].green_mask = m_supportedImageformatsG8[idx].green_mask; |
| 69 |
formatList[num].blue_mask = m_supportedImageformatsG8[idx].blue_mask; |
| 70 |
formatList[num].alpha_mask = m_supportedImageformatsG8[idx].alpha_mask; |
| 71 |
num++; |
| 72 |
} |
| 73 |
*numFormats = num; |
| 74 |
|
| 75 |
return VA_STATUS_SUCCESS; |
| 76 |
} |
| 77 |
|
| 78 |
uint32_t MediaLibvaCapsG8::GetImageFormatsMaxNum() |
| 79 |
{ |
| 80 |
return sizeof(m_supportedImageformatsG8)/sizeof(m_supportedImageformatsG8[0]); |
| 81 |
} |
| 82 |
|
| 83 |
bool MediaLibvaCapsG8::IsImageSupported(uint32_t fourcc) |
| 84 |
{ |
| 85 |
uint32_t maxNum = GetImageFormatsMaxNum(); |
| 86 |
for (int32_t idx = 0; idx < maxNum; idx++) |
| 87 |
{ |
| 88 |
if (m_supportedImageformatsG8[idx].fourcc == fourcc) |
| 89 |
{ |
| 90 |
return true; |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
return false; |
| 95 |
} |
| 96 |
|
| 97 |
VAStatus MediaLibvaCapsG8::PopulateColorMaskInfo(VAImageFormat *vaImgFmt) |
| 98 |
{ |
| 99 |
uint32_t maxNum = GetImageFormatsMaxNum(); |
| 100 |
|
| 101 |
DDI_CHK_NULL(vaImgFmt, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 102 |
|
| 103 |
for (int32_t idx = 0; idx < maxNum; idx++) |
| 104 |
{ |
| 105 |
if (m_supportedImageformatsG8[idx].fourcc == vaImgFmt->fourcc) |
| 106 |
{ |
| 107 |
vaImgFmt->red_mask = m_supportedImageformatsG8[idx].red_mask; |
| 108 |
vaImgFmt->green_mask = m_supportedImageformatsG8[idx].green_mask; |
| 109 |
vaImgFmt->blue_mask = m_supportedImageformatsG8[idx].blue_mask; |
| 110 |
vaImgFmt->alpha_mask = m_supportedImageformatsG8[idx].alpha_mask; |
| 111 |
|
| 112 |
return VA_STATUS_SUCCESS; |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; |
| 117 |
} |
| 118 |
|
| 119 |
VAStatus MediaLibvaCapsG8::GetPlatformSpecificAttrib( |
| 120 |
VAProfile profile, |
| 121 |
VAEntrypoint entrypoint, |
| 122 |
VAConfigAttribType type, |
| 123 |
uint32_t *value) |
| 124 |
{ |
| 125 |
DDI_CHK_NULL(value, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 126 |
VAStatus status = VA_STATUS_SUCCESS; |
| 127 |
*value = VA_ATTRIB_NOT_SUPPORTED; |
| 128 |
switch ((int32_t)type) |
| 129 |
{ |
| 130 |
case VAConfigAttribEncMaxRefFrames: |
| 131 |
{ |
| 132 |
if (entrypoint == VAEntrypointEncSliceLP || !IsHevcProfile(profile)) |
| 133 |
{ |
| 134 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 135 |
} |
| 136 |
else |
| 137 |
{ |
| 138 |
*value = 1 | (1 << 16); |
| 139 |
} |
| 140 |
break; |
| 141 |
} |
| 142 |
case VAConfigAttribDecProcessing: |
| 143 |
{ |
| 144 |
*value = VA_DEC_PROCESSING_NONE; |
| 145 |
break; |
| 146 |
} |
| 147 |
case VAConfigAttribEncIntraRefresh: |
| 148 |
{ |
| 149 |
if(IsAvcProfile(profile)) |
| 150 |
{ |
| 151 |
*value = VA_ENC_INTRA_REFRESH_ROLLING_COLUMN | |
| 152 |
VA_ENC_INTRA_REFRESH_ROLLING_ROW; |
| 153 |
} |
| 154 |
else |
| 155 |
{ |
| 156 |
*value = VA_ENC_INTRA_REFRESH_NONE; |
| 157 |
} |
| 158 |
break; |
| 159 |
} |
| 160 |
case VAConfigAttribEncROI: |
| 161 |
{ |
| 162 |
VAConfigAttribValEncROI roi_attr = { .value = 0 }; |
| 163 |
|
| 164 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 165 |
{ |
| 166 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 167 |
} |
| 168 |
else if (IsAvcProfile(profile)) |
| 169 |
{ |
| 170 |
roi_attr.bits.num_roi_regions = ENCODE_DP_AVC_MAX_ROI_NUMBER; |
| 171 |
} |
| 172 |
|
| 173 |
*value = roi_attr.value; |
| 174 |
break; |
| 175 |
} |
| 176 |
case VAConfigAttribCustomRoundingControl: |
| 177 |
{ |
| 178 |
if (IsAvcProfile(profile)) |
| 179 |
{ |
| 180 |
*value = 1; |
| 181 |
} |
| 182 |
else |
| 183 |
{ |
| 184 |
*value = 0; |
| 185 |
} |
| 186 |
break; |
| 187 |
} |
| 188 |
case VAConfigAttribEncMaxSlices: |
| 189 |
{ |
| 190 |
*value = ENCODE_AVC_MAX_SLICES_SUPPORTED; |
| 191 |
break; |
| 192 |
} |
| 193 |
case VAConfigAttribMaxPictureWidth: |
| 194 |
{ |
| 195 |
if(profile == VAProfileJPEGBaseline) |
| 196 |
{ |
| 197 |
*value = ENCODE_JPEG_MAX_PIC_WIDTH; |
| 198 |
} |
| 199 |
else if(IsAvcProfile(profile)) |
| 200 |
{ |
| 201 |
*value = CODEC_4K_MAX_PIC_WIDTH; |
| 202 |
} |
| 203 |
else |
| 204 |
{ |
| 205 |
*value = CODEC_MAX_PIC_WIDTH; |
| 206 |
} |
| 207 |
break; |
| 208 |
} |
| 209 |
case VAConfigAttribMaxPictureHeight: |
| 210 |
{ |
| 211 |
if(profile == VAProfileJPEGBaseline) |
| 212 |
{ |
| 213 |
*value = ENCODE_JPEG_MAX_PIC_HEIGHT; |
| 214 |
} |
| 215 |
else if(IsAvcProfile(profile)) |
| 216 |
{ |
| 217 |
*value = CODEC_4K_MAX_PIC_HEIGHT; |
| 218 |
} |
| 219 |
else |
| 220 |
{ |
| 221 |
*value = CODEC_MAX_PIC_HEIGHT; |
| 222 |
} |
| 223 |
break; |
| 224 |
} |
| 225 |
default: |
| 226 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 227 |
break; |
| 228 |
} |
| 229 |
return status; |
| 230 |
} |
| 231 |
|
| 232 |
VAStatus MediaLibvaCapsG8::LoadProfileEntrypoints() |
| 233 |
{ |
| 234 |
VAStatus status = VA_STATUS_SUCCESS; |
| 235 |
status = LoadAvcDecProfileEntrypoints(); |
| 236 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 237 |
status = LoadAvcEncProfileEntrypoints(); |
| 238 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 239 |
status = LoadMpeg2DecProfileEntrypoints(); |
| 240 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 241 |
status = LoadMpeg2EncProfileEntrypoints(); |
| 242 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 243 |
status = LoadVc1DecProfileEntrypoints(); |
| 244 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 245 |
status = LoadJpegDecProfileEntrypoints(); |
| 246 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 247 |
status = LoadJpegEncProfileEntrypoints(); |
| 248 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 249 |
status = LoadVp8DecProfileEntrypoints(); |
| 250 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 251 |
status = LoadVp8EncProfileEntrypoints(); |
| 252 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 253 |
status = LoadVp9DecProfileEntrypoints(); |
| 254 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 255 |
status = LoadVp9EncProfileEntrypoints(); |
| 256 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 257 |
#if !defined(_FULL_OPEN_SOURCE) && defined(ENABLE_KERNELS) |
| 258 |
status = LoadNoneProfileEntrypoints(); |
| 259 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 260 |
#endif |
| 261 |
return status; |
| 262 |
} |
| 263 |
|
| 264 |
VAStatus MediaLibvaCapsG8::QueryAVCROIMaxNum(uint32_t rcMode, bool isVdenc, uint32_t *maxNum, bool *isRoiInDeltaQP) |
| 265 |
{ |
| 266 |
DDI_CHK_NULL(maxNum, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 267 |
DDI_CHK_NULL(isRoiInDeltaQP, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 268 |
DDI_CHK_CONDITION(isVdenc == true, "VDEnc is not supported in Gen8", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 269 |
|
| 270 |
*maxNum = ENCODE_DP_AVC_MAX_ROI_NUMBER; |
| 271 |
*isRoiInDeltaQP = false; |
| 272 |
return VA_STATUS_SUCCESS; |
| 273 |
} |
| 274 |
|
| 275 |
VAStatus MediaLibvaCapsG8::GetMbProcessingRateEnc( |
| 276 |
MEDIA_FEATURE_TABLE *skuTable, |
| 277 |
uint32_t tuIdx, |
| 278 |
uint32_t codecMode, |
| 279 |
bool vdencActive, |
| 280 |
uint32_t *mbProcessingRatePerSec) |
| 281 |
{ |
| 282 |
DDI_CHK_NULL(skuTable, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 283 |
DDI_CHK_NULL(mbProcessingRatePerSec, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 284 |
|
| 285 |
uint32_t gtIdx = 0; |
| 286 |
|
| 287 |
if (MEDIA_IS_SKU(skuTable, FtrGT1)) |
| 288 |
{ |
| 289 |
gtIdx = 3; |
| 290 |
} |
| 291 |
else if (MEDIA_IS_SKU(skuTable, FtrGT1_5)) |
| 292 |
{ |
| 293 |
gtIdx = 2; |
| 294 |
} |
| 295 |
else if (MEDIA_IS_SKU(skuTable, FtrGT2)) |
| 296 |
{ |
| 297 |
gtIdx = 1; |
| 298 |
} |
| 299 |
else if (MEDIA_IS_SKU(skuTable, FtrGT3)) |
| 300 |
{ |
| 301 |
gtIdx = 0; |
| 302 |
} |
| 303 |
else |
| 304 |
{ |
| 305 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 306 |
} |
| 307 |
|
| 308 |
if (MEDIA_IS_SKU(skuTable, FtrULX)) |
| 309 |
{ |
| 310 |
const uint32_t mbRate[7][4] = |
| 311 |
{ |
| 312 |
// GT3 | GT2 | GT1.5 | GT1 |
| 313 |
{ 0, 750000, 750000, 676280 }, |
| 314 |
{ 0, 750000, 750000, 661800 }, |
| 315 |
{ 0, 750000, 750000, 640000 }, |
| 316 |
{ 0, 750000, 750000, 640000 }, |
| 317 |
{ 0, 750000, 750000, 640000 }, |
| 318 |
{ 0, 416051, 416051, 317980 }, |
| 319 |
{ 0, 214438, 214438, 180655 } |
| 320 |
}; |
| 321 |
|
| 322 |
if (gtIdx == 0) |
| 323 |
{ |
| 324 |
return VA_STATUS_ERROR_INVALID_PARAMETER; |
| 325 |
} |
| 326 |
*mbProcessingRatePerSec = mbRate[tuIdx][gtIdx]; |
| 327 |
} |
| 328 |
else if (MEDIA_IS_SKU(skuTable, FtrULT)) |
| 329 |
{ |
| 330 |
const uint32_t mbRate[7][4] = |
| 331 |
{ |
| 332 |
// GT3 | GT2 | GT1.5 | GT1 |
| 333 |
{ 1544090, 1544090, 1029393, 676280 }, |
| 334 |
{ 1462540, 1462540, 975027, 661800 }, |
| 335 |
{ 1165381, 1165381, 776921, 640000 }, |
| 336 |
{ 1165381, 1165381, 776921, 640000 }, |
| 337 |
{ 1165381, 1165381, 776921, 640000 }, |
| 338 |
{ 624076, 624076, 416051, 317980 }, |
| 339 |
{ 321657, 321657, 214438, 180655 } |
| 340 |
}; |
| 341 |
|
| 342 |
*mbProcessingRatePerSec = mbRate[tuIdx][gtIdx]; |
| 343 |
} |
| 344 |
else |
| 345 |
{ |
| 346 |
const uint32_t mbRate[7][4] = |
| 347 |
{ |
| 348 |
// GT3 | GT2 | GT1.5 | GT1 |
| 349 |
{ 1544090, 1544090, 1029393, 676280 }, |
| 350 |
{ 1462540, 1462540, 975027, 661800 }, |
| 351 |
{ 1165381, 1165381, 776921, 640000 }, |
| 352 |
{ 1165381, 1165381, 776921, 640000 }, |
| 353 |
{ 1165381, 1165381, 776921, 640000 }, |
| 354 |
{ 624076, 624076, 416051, 317980 }, |
| 355 |
{ 321657, 321657, 214438, 180655 } |
| 356 |
}; |
| 357 |
|
| 358 |
*mbProcessingRatePerSec = mbRate[tuIdx][gtIdx]; |
| 359 |
} |
| 360 |
|
| 361 |
return VA_STATUS_SUCCESS; |
| 362 |
} |
| 363 |
|
| 364 |
extern template class MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>; |
| 365 |
|
| 366 |
static bool bdwRegistered = MediaLibvaCapsFactory<MediaLibvaCaps, DDI_MEDIA_CONTEXT>:: |
| 367 |
RegisterCaps<MediaLibvaCapsG8>((uint32_t)IGFX_BROADWELL); |