| 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_g9.cpp |
| 24 |
//! \brief This file implements the C++ class/interface for gen9 media capbilities. |
| 25 |
//! |
| 26 |
|
| 27 |
#include "codec_def_encode_hevc.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_g9.h" |
| 32 |
#include "media_libva_caps_factory.h" |
| 33 |
|
| 34 |
const VAImageFormat m_supportedImageformatsG9[] = |
| 35 |
{ |
| 36 |
// "VA_LSB_FIRST" is to identify how following bit masks mapped to address instead of char order in VA_FOURCC_RGBA naming. |
| 37 |
{VA_FOURCC_BGRA, VA_LSB_FIRST, 32, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, /* [31:0] A:R:G:B 8:8:8:8 little endian */ |
| 38 |
{VA_FOURCC_RGBA, VA_LSB_FIRST, 32, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000}, /* [31:0] A:B:G:R 8:8:8:8 little endian */ |
| 39 |
{VA_FOURCC_BGRX, VA_LSB_FIRST, 32, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0}, /* [31:0] X:R:G:B 8:8:8:8 little endian */ |
| 40 |
{VA_FOURCC_RGBX, VA_LSB_FIRST, 32, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0}, /* [31:0] X:B:G:R 8:8:8:8 little endian */ |
| 41 |
{VA_FOURCC_A2R10G10B10, VA_LSB_FIRST, 32, 30, 0x3ff00000, 0x000ffc00, 0x000003ff, 0x30000000}, /* [31:0] A:R:G:B 2:10:10:10 little endian */ |
| 42 |
{VA_FOURCC_A2B10G10R10, VA_LSB_FIRST, 32, 30, 0x000003ff, 0x000ffc00, 0x3ff00000, 0x30000000}, /* [31:0] A:B:G:R 2:10:10:10 little endian */ |
| 43 |
{VA_FOURCC_X2R10G10B10, VA_LSB_FIRST, 32, 30, 0x3ff00000, 0x000ffc00, 0x000003ff, 0}, /* [31:0] X:R:G:B 2:10:10:10 little endian */ |
| 44 |
{VA_FOURCC_X2B10G10R10, VA_LSB_FIRST, 32, 30, 0x000003ff, 0x000ffc00, 0x3ff00000, 0}, /* [31:0] X:B:G:R 2:10:10:10 little endian */ |
| 45 |
{VA_FOURCC_RGB565, VA_LSB_FIRST, 16, 16, 0xf800, 0x07e0, 0x001f, 0}, /* [15:0] R:G:B 5:6:5 little endian */ |
| 46 |
{VA_FOURCC_RGBP, VA_LSB_FIRST, 24, 24,0,0,0,0}, |
| 47 |
{VA_FOURCC_BGRP, VA_LSB_FIRST, 24, 24,0,0,0,0}, |
| 48 |
{VA_FOURCC_AYUV, VA_LSB_FIRST, 32, 0,0,0,0,0}, |
| 49 |
{VA_FOURCC_Y800, VA_LSB_FIRST, 8, 0,0,0,0,0}, |
| 50 |
{VA_FOURCC_NV12, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 51 |
{VA_FOURCC_NV21, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 52 |
{VA_FOURCC_YUY2, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 53 |
{VA_FOURCC_UYVY, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 54 |
{VA_FOURCC_YV12, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 55 |
{VA_FOURCC_I420, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 56 |
{VA_FOURCC_411P, VA_LSB_FIRST, 12, 0,0,0,0,0}, |
| 57 |
{VA_FOURCC_422H, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 58 |
{VA_FOURCC_422V, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 59 |
{VA_FOURCC_444P, VA_LSB_FIRST, 24, 0,0,0,0,0}, |
| 60 |
{VA_FOURCC_IMC3, VA_LSB_FIRST, 16, 0,0,0,0,0}, |
| 61 |
{VA_FOURCC_P010, VA_LSB_FIRST, 24, 0,0,0,0,0} |
| 62 |
}; |
| 63 |
|
| 64 |
VAStatus MediaLibvaCapsG9::QueryImageFormats(VAImageFormat *formatList, int32_t *numFormats) |
| 65 |
{ |
| 66 |
DDI_CHK_NULL(formatList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 67 |
DDI_CHK_NULL(numFormats, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 68 |
int32_t num = 0; |
| 69 |
uint32_t maxNum = GetImageFormatsMaxNum(); |
| 70 |
|
| 71 |
memset(formatList, 0, sizeof(m_supportedImageformatsG9)); |
| 72 |
for (uint32_t idx = 0; idx < maxNum; idx++) |
| 73 |
{ |
| 74 |
formatList[num].fourcc = m_supportedImageformatsG9[idx].fourcc; |
| 75 |
formatList[num].byte_order = m_supportedImageformatsG9[idx].byte_order; |
| 76 |
formatList[num].bits_per_pixel = m_supportedImageformatsG9[idx].bits_per_pixel; |
| 77 |
formatList[num].depth = m_supportedImageformatsG9[idx].depth; |
| 78 |
formatList[num].red_mask = m_supportedImageformatsG9[idx].red_mask; |
| 79 |
formatList[num].green_mask = m_supportedImageformatsG9[idx].green_mask; |
| 80 |
formatList[num].blue_mask = m_supportedImageformatsG9[idx].blue_mask; |
| 81 |
formatList[num].alpha_mask = m_supportedImageformatsG9[idx].alpha_mask; |
| 82 |
num++; |
| 83 |
} |
| 84 |
*numFormats = num; |
| 85 |
|
| 86 |
return VA_STATUS_SUCCESS; |
| 87 |
} |
| 88 |
|
| 89 |
uint32_t MediaLibvaCapsG9::GetImageFormatsMaxNum() |
| 90 |
{ |
| 91 |
return sizeof(m_supportedImageformatsG9)/sizeof(m_supportedImageformatsG9[0]); |
| 92 |
} |
| 93 |
|
| 94 |
bool MediaLibvaCapsG9::IsImageSupported(uint32_t fourcc) |
| 95 |
{ |
| 96 |
uint32_t maxNum = GetImageFormatsMaxNum(); |
| 97 |
for (int32_t idx = 0; idx < maxNum; idx++) |
| 98 |
{ |
| 99 |
if (m_supportedImageformatsG9[idx].fourcc == fourcc) |
| 100 |
{ |
| 101 |
return true; |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
return false; |
| 106 |
} |
| 107 |
|
| 108 |
VAStatus MediaLibvaCapsG9::PopulateColorMaskInfo(VAImageFormat *vaImgFmt) |
| 109 |
{ |
| 110 |
uint32_t maxNum = GetImageFormatsMaxNum(); |
| 111 |
|
| 112 |
DDI_CHK_NULL(vaImgFmt, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 113 |
|
| 114 |
for (int32_t idx = 0; idx < maxNum; idx++) |
| 115 |
{ |
| 116 |
if (m_supportedImageformatsG9[idx].fourcc == vaImgFmt->fourcc) |
| 117 |
{ |
| 118 |
vaImgFmt->red_mask = m_supportedImageformatsG9[idx].red_mask; |
| 119 |
vaImgFmt->green_mask = m_supportedImageformatsG9[idx].green_mask; |
| 120 |
vaImgFmt->blue_mask = m_supportedImageformatsG9[idx].blue_mask; |
| 121 |
vaImgFmt->alpha_mask = m_supportedImageformatsG9[idx].alpha_mask; |
| 122 |
|
| 123 |
return VA_STATUS_SUCCESS; |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT; |
| 128 |
} |
| 129 |
|
| 130 |
VAStatus MediaLibvaCapsG9::GetPlatformSpecificAttrib(VAProfile profile, |
| 131 |
VAEntrypoint entrypoint, |
| 132 |
VAConfigAttribType type, |
| 133 |
uint32_t *value) |
| 134 |
{ |
| 135 |
DDI_CHK_NULL(value, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 136 |
VAStatus status = VA_STATUS_SUCCESS; |
| 137 |
*value = VA_ATTRIB_NOT_SUPPORTED; |
| 138 |
switch ((int)type) |
| 139 |
{ |
| 140 |
case VAConfigAttribEncMaxRefFrames: |
| 141 |
{ |
| 142 |
if (entrypoint == VAEntrypointEncSliceLP || !IsHevcProfile(profile)) |
| 143 |
{ |
| 144 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 145 |
} |
| 146 |
else |
| 147 |
{ |
| 148 |
*value = ENCODE_DP_HEVC_NUM_MAX_VME_L0_REF_G9 | (ENCODE_DP_HEVC_NUM_MAX_VME_L1_REF_G9 << 16);; |
| 149 |
} |
| 150 |
break; |
| 151 |
} |
| 152 |
case VAConfigAttribDecProcessing: |
| 153 |
{ |
| 154 |
if (IsAvcProfile(profile) || IsHevcProfile(profile)) |
| 155 |
{ |
| 156 |
*value = VA_DEC_PROCESSING; |
| 157 |
} |
| 158 |
else |
| 159 |
{ |
| 160 |
*value = VA_DEC_PROCESSING_NONE; |
| 161 |
} |
| 162 |
break; |
| 163 |
} |
| 164 |
case VAConfigAttribEncIntraRefresh: |
| 165 |
{ |
| 166 |
if(IsAvcProfile(profile)) |
| 167 |
{ |
| 168 |
*value = VA_ENC_INTRA_REFRESH_ROLLING_COLUMN | |
| 169 |
VA_ENC_INTRA_REFRESH_ROLLING_ROW; |
| 170 |
} |
| 171 |
else if(entrypoint == VAEntrypointEncSlice && IsHevcProfile(profile)) |
| 172 |
{ |
| 173 |
*value = VA_ENC_INTRA_REFRESH_ROLLING_COLUMN; |
| 174 |
} |
| 175 |
else |
| 176 |
{ |
| 177 |
*value = VA_ENC_INTRA_REFRESH_NONE; |
| 178 |
} |
| 179 |
break; |
| 180 |
} |
| 181 |
case VAConfigAttribEncROI: |
| 182 |
{ |
| 183 |
VAConfigAttribValEncROI roi_attr = { .value = 0 }; |
| 184 |
|
| 185 |
if (entrypoint == VAEntrypointEncSliceLP) |
| 186 |
{ |
| 187 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 188 |
} |
| 189 |
else if (IsAvcProfile(profile)) |
| 190 |
{ |
| 191 |
// the capacity is differnt for CQP and BRC mode, set it as larger one here |
| 192 |
roi_attr.bits.num_roi_regions = ENCODE_DP_AVC_MAX_ROI_NUM_BRC; |
| 193 |
roi_attr.bits.roi_rc_priority_support = 0; |
| 194 |
roi_attr.bits.roi_rc_qp_delta_support = 1; |
| 195 |
} |
| 196 |
else if (IsHevcProfile(profile)) |
| 197 |
{ |
| 198 |
roi_attr.bits.num_roi_regions = ENCODE_DP_HEVC_MAX_NUM_ROI; |
| 199 |
roi_attr.bits.roi_rc_priority_support = 0; |
| 200 |
roi_attr.bits.roi_rc_qp_delta_support = 1; |
| 201 |
} |
| 202 |
|
| 203 |
*value = roi_attr.value; |
| 204 |
break; |
| 205 |
} |
| 206 |
case VAConfigAttribCustomRoundingControl: |
| 207 |
{ |
| 208 |
if (IsAvcProfile(profile)) |
| 209 |
{ |
| 210 |
*value = 1; |
| 211 |
} |
| 212 |
else |
| 213 |
{ |
| 214 |
*value = 0; |
| 215 |
} |
| 216 |
break; |
| 217 |
} |
| 218 |
case VAConfigAttribEncMaxSlices: |
| 219 |
{ |
| 220 |
if (entrypoint == VAEntrypointEncSlice && IsHevcProfile(profile)) |
| 221 |
{ |
| 222 |
*value = CODECHAL_HEVC_MAX_NUM_SLICES_LVL_5; |
| 223 |
} |
| 224 |
else |
| 225 |
{ |
| 226 |
*value =0; |
| 227 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 228 |
} |
| 229 |
break; |
| 230 |
} |
| 231 |
case VAConfigAttribMaxPictureWidth: |
| 232 |
{ |
| 233 |
if(profile == VAProfileJPEGBaseline) |
| 234 |
{ |
| 235 |
*value = ENCODE_JPEG_MAX_PIC_WIDTH; |
| 236 |
} |
| 237 |
else if(IsHevcProfile(profile) || IsAvcProfile(profile) || IsVp8Profile(profile)) |
| 238 |
{ |
| 239 |
*value = CODEC_4K_MAX_PIC_WIDTH; |
| 240 |
} |
| 241 |
else |
| 242 |
{ |
| 243 |
*value = CODEC_MAX_PIC_WIDTH; |
| 244 |
} |
| 245 |
break; |
| 246 |
} |
| 247 |
case VAConfigAttribMaxPictureHeight: |
| 248 |
{ |
| 249 |
if(profile == VAProfileJPEGBaseline) |
| 250 |
{ |
| 251 |
*value = ENCODE_JPEG_MAX_PIC_HEIGHT; |
| 252 |
} |
| 253 |
else if(IsHevcProfile(profile) || IsAvcProfile(profile) || IsVp8Profile(profile)) |
| 254 |
{ |
| 255 |
*value = CODEC_4K_MAX_PIC_HEIGHT; |
| 256 |
} |
| 257 |
else |
| 258 |
{ |
| 259 |
*value = CODEC_MAX_PIC_HEIGHT; |
| 260 |
} |
| 261 |
break; |
| 262 |
} |
| 263 |
default: |
| 264 |
status = VA_STATUS_ERROR_INVALID_PARAMETER; |
| 265 |
break; |
| 266 |
} |
| 267 |
return status; |
| 268 |
} |
| 269 |
|
| 270 |
VAStatus MediaLibvaCapsG9::LoadProfileEntrypoints() |
| 271 |
{ |
| 272 |
VAStatus status = VA_STATUS_SUCCESS; |
| 273 |
status = LoadAvcDecProfileEntrypoints(); |
| 274 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 275 |
status = LoadAvcEncProfileEntrypoints(); |
| 276 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 277 |
status = LoadAvcEncLpProfileEntrypoints(); |
| 278 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 279 |
status = LoadMpeg2DecProfileEntrypoints(); |
| 280 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 281 |
status = LoadMpeg2EncProfileEntrypoints(); |
| 282 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 283 |
status = LoadVc1DecProfileEntrypoints(); |
| 284 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 285 |
status = LoadJpegDecProfileEntrypoints(); |
| 286 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 287 |
status = LoadJpegEncProfileEntrypoints(); |
| 288 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 289 |
status = LoadHevcDecProfileEntrypoints(); |
| 290 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 291 |
status = LoadHevcEncProfileEntrypoints(); |
| 292 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 293 |
status = LoadVp8DecProfileEntrypoints(); |
| 294 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 295 |
status = LoadVp8EncProfileEntrypoints(); |
| 296 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 297 |
status = LoadVp9DecProfileEntrypoints(); |
| 298 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 299 |
status = LoadVp9EncProfileEntrypoints(); |
| 300 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 301 |
#if !defined(_FULL_OPEN_SOURCE) && defined(ENABLE_KERNELS) |
| 302 |
status = LoadNoneProfileEntrypoints(); |
| 303 |
DDI_CHK_RET(status, "Failed to initialize Caps!"); |
| 304 |
#endif |
| 305 |
status = m_CapsCp->LoadCpProfileEntrypoints(); |
| 306 |
DDI_CHK_RET(status, "Failed to initialize CP Caps!"); |
| 307 |
return status; |
| 308 |
} |
| 309 |
|
| 310 |
VAStatus MediaLibvaCapsG9::QueryAVCROIMaxNum(uint32_t rcMode, bool isVdenc, uint32_t *maxNum, bool *isRoiInDeltaQP) |
| 311 |
{ |
| 312 |
DDI_CHK_NULL(maxNum, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 313 |
DDI_CHK_NULL(isRoiInDeltaQP, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); |
| 314 |
|
| 315 |
if(isVdenc) |
| 316 |
{ |
| 317 |
*maxNum = ENCODE_VDENC_AVC_MAX_ROI_NUMBER_G9; |
| 318 |
} |
| 319 |
else |
| 320 |
{ |
| 321 |
switch (rcMode) |
| 322 |
{ |
| 323 |
case VA_RC_CQP: |
| 324 |
*maxNum = ENCODE_DP_AVC_MAX_ROI_NUMBER; |
| 325 |
break; |
| 326 |
default: |
| 327 |
*maxNum = ENCODE_DP_AVC_MAX_ROI_NUM_BRC; |
| 328 |
break; |
| 329 |
} |
| 330 |
} |
| 331 |
|
| 332 |
*isRoiInDeltaQP = true; |
| 333 |
return VA_STATUS_SUCCESS; |
| 334 |
} |