| 1 |
/* |
| 2 |
* Copyright (c) 2021-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_mtl_base.h |
| 25 |
//! \brief This file defines the C++ class/interface for MTL media capbilities. |
| 26 |
//! |
| 27 |
|
| 28 |
#ifndef __MEDIA_LIBVA_CAPS_MTL_BASE_H__ |
| 29 |
#define __MEDIA_LIBVA_CAPS_MTL_BASE_H__ |
| 30 |
|
| 31 |
#include "media_libva_caps.h" |
| 32 |
#include "media_libva_util.h" |
| 33 |
|
| 34 |
//! |
| 35 |
//! \class MediaLibvaCapsMtlBase |
| 36 |
//! \brief Media libva caps mtl |
| 37 |
//! |
| 38 |
class MediaLibvaCapsMtlBase : public MediaLibvaCaps |
| 39 |
{ |
| 40 |
public: |
| 41 |
//! |
| 42 |
//! \brief Constructor |
| 43 |
//! |
| 44 |
MediaLibvaCapsMtlBase(DDI_MEDIA_CONTEXT *mediaCtx) : MediaLibvaCaps(mediaCtx) |
| 45 |
{ |
| 46 |
// MTL supported Encode format |
| 47 |
static struct EncodeFormatTable encodeFormatTableMTL[] = |
| 48 |
{ |
| 49 |
{AVC, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_RGB32}, |
| 50 |
{HEVC, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP | |
| 51 |
VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV444_10 | VA_RT_FORMAT_RGB32 | |
| 52 |
VA_RT_FORMAT_RGB32_10BPP}, |
| 53 |
{VP9, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP | |
| 54 |
VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV444_10 | VA_RT_FORMAT_RGB32 | |
| 55 |
VA_RT_FORMAT_RGB32_10BPP} |
| 56 |
}; |
| 57 |
m_encodeFormatTable = (struct EncodeFormatTable*)(&encodeFormatTableMTL[0]); |
| 58 |
m_encodeFormatCount = sizeof(encodeFormatTableMTL)/sizeof(struct EncodeFormatTable); |
| 59 |
|
| 60 |
return; |
| 61 |
} |
| 62 |
|
| 63 |
//! |
| 64 |
//! \brief Destructor |
| 65 |
//! |
| 66 |
virtual ~MediaLibvaCapsMtlBase() {}; |
| 67 |
|
| 68 |
// |
| 69 |
virtual VAStatus Init() override |
| 70 |
{ |
| 71 |
return LoadProfileEntrypoints(); |
| 72 |
} |
| 73 |
|
| 74 |
//! |
| 75 |
//! \brief Initialize AVC Low-power encode profiles, entrypoints and attributes |
| 76 |
//! |
| 77 |
virtual VAStatus LoadAvcEncLpProfileEntrypoints() override; |
| 78 |
|
| 79 |
//! |
| 80 |
//! \brief Initialize HEVC encode profiles, entrypoints and attributes |
| 81 |
//! |
| 82 |
//! \return VAStatus |
| 83 |
//! if call succeeds |
| 84 |
//! |
| 85 |
virtual VAStatus LoadHevcEncProfileEntrypoints() override; |
| 86 |
|
| 87 |
//! |
| 88 |
//! \brief Initialize AVC encode profiles, entrypoints and attributes |
| 89 |
//! |
| 90 |
//! \return VAStatus |
| 91 |
//! if call succeeds |
| 92 |
//! |
| 93 |
virtual VAStatus LoadAvcEncProfileEntrypoints() override; |
| 94 |
|
| 95 |
//! |
| 96 |
//! \brief Initialize AV1 encode profiles, entrypoints and attributes |
| 97 |
//! |
| 98 |
//! \return VAStatus |
| 99 |
//! if call succeeds |
| 100 |
//! |
| 101 |
virtual VAStatus LoadAv1EncProfileEntrypoints(); |
| 102 |
|
| 103 |
virtual CODECHAL_MODE GetDecodeCodecMode(VAProfile profile) override; |
| 104 |
|
| 105 |
//! |
| 106 |
//! \brief Return the decode codec key for given profile |
| 107 |
//! |
| 108 |
//! \param [in] profile |
| 109 |
//! Specify the VAProfile |
| 110 |
//! |
| 111 |
//! \return Std::string decode codec key |
| 112 |
//! |
| 113 |
virtual std::string GetDecodeCodecKey(VAProfile profile) override; |
| 114 |
|
| 115 |
//! |
| 116 |
//! \brief Return the encode codec key for given profile and entrypoint |
| 117 |
//! |
| 118 |
//! \param [in] profile |
| 119 |
//! Specify the VAProfile |
| 120 |
//! |
| 121 |
//! \param [in] entrypoint |
| 122 |
//! Specify the entrypoint |
| 123 |
//! |
| 124 |
//! \param [in] feiFunction |
| 125 |
//! Specify the feiFunction |
| 126 |
//! |
| 127 |
//! \return Std::string encode codec key |
| 128 |
//! |
| 129 |
virtual std::string GetEncodeCodecKey( |
| 130 |
VAProfile profile, |
| 131 |
VAEntrypoint entrypoint, |
| 132 |
uint32_t feiFunction) override; |
| 133 |
|
| 134 |
//! |
| 135 |
//! \brief Return internal encode mode for given profile and entrypoint |
| 136 |
//! |
| 137 |
//! \param [in] profile |
| 138 |
//! Specify the VAProfile |
| 139 |
//! |
| 140 |
//! \param [in] entrypoint |
| 141 |
//! Specify the VAEntrypoint |
| 142 |
//! |
| 143 |
//! \return Codehal mode |
| 144 |
//! |
| 145 |
virtual CODECHAL_MODE GetEncodeCodecMode( |
| 146 |
VAProfile profile, |
| 147 |
VAEntrypoint entrypoint) override; |
| 148 |
|
| 149 |
//! |
| 150 |
//! \brief Check if the resolution is valid for a encode profile |
| 151 |
//! |
| 152 |
//! \param [in] profile |
| 153 |
//! Specify the VAProfile |
| 154 |
//! |
| 155 |
//! \param [in] width |
| 156 |
//! Specify the width for checking |
| 157 |
//! |
| 158 |
//! \param [in] height |
| 159 |
//! Specify the height for checking |
| 160 |
//! |
| 161 |
//! \return VAStatus |
| 162 |
//! VA_STATUS_SUCCESS if the resolution is supported |
| 163 |
//! VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED if the resolution isn't valid |
| 164 |
//! |
| 165 |
virtual VAStatus CheckEncodeResolution( |
| 166 |
VAProfile profile, |
| 167 |
uint32_t width, |
| 168 |
uint32_t height) override; |
| 169 |
|
| 170 |
//! |
| 171 |
//! \brief Check the encode RT format according to platform and encode format |
| 172 |
//! |
| 173 |
//! \param [in] profile |
| 174 |
//! VAProfile |
| 175 |
//! |
| 176 |
//! \param [in] entrypoint |
| 177 |
//! VAEntrypoint |
| 178 |
//! |
| 179 |
//! \param [in,out] attrib |
| 180 |
//! Pointer to a pointer of VAConfigAttrib that will be created |
| 181 |
//! |
| 182 |
//! \return VAStatus |
| 183 |
//! VA_STATUS_SUCCESS if success |
| 184 |
//! |
| 185 |
virtual VAStatus CheckEncRTFormat( |
| 186 |
VAProfile profile, |
| 187 |
VAEntrypoint entrypoint, |
| 188 |
VAConfigAttrib* attrib) override; |
| 189 |
|
| 190 |
// Implementation is the same as g12. |
| 191 |
virtual VAStatus QueryImageFormats(VAImageFormat *formatList, int32_t *num_formats) override; |
| 192 |
|
| 193 |
// Implementation is the same as g12. |
| 194 |
virtual uint32_t GetImageFormatsMaxNum() override; |
| 195 |
|
| 196 |
//! |
| 197 |
//! \brief Populate the color masks info |
| 198 |
//! |
| 199 |
//! \param [in,out] Image format |
| 200 |
//! Pointer to a VAImageFormat array. Color masks information will be populated to this |
| 201 |
//! structure. |
| 202 |
//! |
| 203 |
//! \return VAStatus |
| 204 |
//! VA_STATUS_SUCCESS if succeed |
| 205 |
//! Implementation is the same as g12. |
| 206 |
virtual VAStatus PopulateColorMaskInfo(VAImageFormat *vaImgFmt) override; |
| 207 |
|
| 208 |
virtual bool IsImageSupported(uint32_t fourcc) override; |
| 209 |
|
| 210 |
//! |
| 211 |
//! \brief Query AVC ROI maximum number |
| 212 |
//! |
| 213 |
//! \param [in] rcMode |
| 214 |
//! RC mode |
| 215 |
//! \param [in] isVdenc |
| 216 |
//! vdenc |
| 217 |
//! \param [in] maxNum |
| 218 |
//! Maximum number |
| 219 |
//! \param [in] isRoiInDeltaQP |
| 220 |
//! Is ROI in delta QP |
| 221 |
//! |
| 222 |
//! \return VAStatus |
| 223 |
//! if call succeeds |
| 224 |
//! |
| 225 |
VAStatus QueryAVCROIMaxNum(uint32_t rcMode, bool isVdenc, uint32_t *maxNum, bool *isRoiInDeltaQP) override; |
| 226 |
|
| 227 |
virtual VAStatus LoadProfileEntrypoints() override; |
| 228 |
|
| 229 |
virtual VAStatus GetPlatformSpecificAttrib(VAProfile profile, |
| 230 |
VAEntrypoint entrypoint, |
| 231 |
VAConfigAttribType type, |
| 232 |
unsigned int *value) override; |
| 233 |
|
| 234 |
//! |
| 235 |
//! \brief Initialize AV1 decode profiles, entrypoints and attributes |
| 236 |
//! |
| 237 |
VAStatus LoadAv1DecProfileEntrypoints(); |
| 238 |
|
| 239 |
//! |
| 240 |
//! \brief Initialize HEVC low-power encode profiles, entrypoints and attributes |
| 241 |
//! |
| 242 |
//! \return VAStatus |
| 243 |
//! if call succeeds |
| 244 |
//! |
| 245 |
virtual VAStatus LoadHevcEncLpProfileEntrypoints(); |
| 246 |
|
| 247 |
static const VAConfigAttribValEncRateControlExt m_encVp9RateControlExt; //!< External enc rate control caps for VP9 encode |
| 248 |
|
| 249 |
//! |
| 250 |
//! \brief Initialize VP9 encode profiles, entrypoints and attributes |
| 251 |
//! |
| 252 |
virtual VAStatus LoadVp9EncProfileEntrypoints() override; |
| 253 |
|
| 254 |
//! |
| 255 |
//! \brief Initialize HEVC decode profiles, entrypoints and attributes |
| 256 |
//! |
| 257 |
virtual VAStatus LoadHevcDecProfileEntrypoints() override; |
| 258 |
|
| 259 |
virtual GMM_RESOURCE_FORMAT ConvertMediaFmtToGmmFmt(DDI_MEDIA_FORMAT format) override; |
| 260 |
|
| 261 |
//! |
| 262 |
//! \brief Add surface attributes for Encoding |
| 263 |
//! |
| 264 |
//! \param [in] profile |
| 265 |
//! VAProfile of the configuration |
| 266 |
//! |
| 267 |
//! \param [in] entrypoint |
| 268 |
//! VAEntrypoint of the configuration |
| 269 |
//! |
| 270 |
//! \param [in,out] attribList |
| 271 |
//! Pointer to VASurfaceAttrib array. It returns |
| 272 |
//! the supported surface attributes |
| 273 |
//! |
| 274 |
//! \param [in,out] numAttribs |
| 275 |
//! The number of elements allocated on input |
| 276 |
//! Return the number of elements actually filled in output |
| 277 |
//! |
| 278 |
//! \return VAStatus |
| 279 |
//! VA_STATUS_SUCCESS if success |
| 280 |
//! |
| 281 |
virtual VAStatus AddEncSurfaceAttributes( |
| 282 |
VAProfile profile, |
| 283 |
VAEntrypoint entrypoint, |
| 284 |
VASurfaceAttrib *attribList, |
| 285 |
uint32_t & numAttribs); |
| 286 |
|
| 287 |
//! |
| 288 |
//! \brief Get surface attributes for a given config ID |
| 289 |
//! |
| 290 |
//! \param [in] configId |
| 291 |
//! VA configuration |
| 292 |
//! |
| 293 |
//! \param [in,out] attribList |
| 294 |
//! Pointer to VASurfaceAttrib array. It returns |
| 295 |
//! the supported surface attributes |
| 296 |
//! |
| 297 |
//! \param [in,out] numAttribs |
| 298 |
//! The number of elements allocated on input |
| 299 |
//! Return the number of elements actually filled in output |
| 300 |
//! |
| 301 |
//! \return VAStatus |
| 302 |
//! VA_STATUS_SUCCESS if success |
| 303 |
//! VA_STATUS_ERROR_MAX_NUM_EXCEEDED if size of attribList is too small |
| 304 |
//! |
| 305 |
VAStatus QuerySurfaceAttributes( |
| 306 |
VAConfigID configId, |
| 307 |
VASurfaceAttrib *attribList, |
| 308 |
uint32_t * numAttribs) override; |
| 309 |
|
| 310 |
//! |
| 311 |
//! \brief Check if the give profile is HEVC |
| 312 |
//! |
| 313 |
//! \param [in] profile |
| 314 |
//! Specify the VAProfile |
| 315 |
//! |
| 316 |
//! \return True if the profile is a HEVC profile |
| 317 |
//! False if the profile isn't a HEVC profile |
| 318 |
//! |
| 319 |
virtual bool IsHevcProfile(VAProfile profile) override; |
| 320 |
|
| 321 |
//! \brief To check if target resolution support on this platform |
| 322 |
//! |
| 323 |
virtual VAStatus CheckDecodeResolution( |
| 324 |
int32_t codecMode, |
| 325 |
VAProfile profile, |
| 326 |
uint32_t width, |
| 327 |
uint32_t height) override; |
| 328 |
|
| 329 |
VAStatus CreateDecAttributes(VAProfile profile, VAEntrypoint entrypoint, AttribMap **attributeList) override; |
| 330 |
|
| 331 |
virtual VAStatus CreateEncAttributes( |
| 332 |
VAProfile profile, |
| 333 |
VAEntrypoint entrypoint, |
| 334 |
AttribMap **attributeList) override; |
| 335 |
|
| 336 |
//! \brief Get surface drm modifier |
| 337 |
//! |
| 338 |
//! \param [in] mediaSurface |
| 339 |
//! Pointer to the media surface |
| 340 |
//! \param [out] modifier |
| 341 |
//! reference of the modifier |
| 342 |
//! |
| 343 |
//! \return VAStatus |
| 344 |
//! VA_STATUS_SUCCESS if success |
| 345 |
//! |
| 346 |
virtual VAStatus GetSurfaceModifier(DDI_MEDIA_SURFACE* mediaSurface, uint64_t &modifier) override; |
| 347 |
|
| 348 |
//! \brief Set tile format according to external surface's modifier |
| 349 |
//! |
| 350 |
//! \param [in] mediaSurface |
| 351 |
//! Pointer to the media surface |
| 352 |
//! \param [out] tileformat |
| 353 |
//! Reference to the tileformat |
| 354 |
//! \param [out] bMemCompEnable |
| 355 |
//! Reference to the memory compress flag |
| 356 |
//! \param [out] bMemCompRC |
| 357 |
//! Reference to the memory compress rate control |
| 358 |
//! |
| 359 |
//! \return VAStatus |
| 360 |
//! VA_STATUS_SUCCESS if success |
| 361 |
//! |
| 362 |
virtual VAStatus SetExternalSurfaceTileFormat(DDI_MEDIA_SURFACE* mediaSurface, |
| 363 |
uint32_t &tileformat, |
| 364 |
bool &bMemCompEnable, |
| 365 |
bool &bMemCompRC) override; |
| 366 |
|
| 367 |
//! |
| 368 |
//! \brief Check if the give profile is AV1 |
| 369 |
//! |
| 370 |
//! \param [in] profile |
| 371 |
//! Specify the VAProfile |
| 372 |
//! |
| 373 |
//! \return True if the profile is a AV1 profile |
| 374 |
//! False if the profile isn't a AV1 profile |
| 375 |
//! |
| 376 |
static bool IsAV1Profile(VAProfile profile); |
| 377 |
|
| 378 |
protected: |
| 379 |
static const uint32_t m_maxHevcEncWidth = |
| 380 |
CODEC_16K_MAX_PIC_WIDTH; //!< maxinum width for HEVC encode |
| 381 |
static const uint32_t m_maxHevcEncHeight = |
| 382 |
CODEC_12K_MAX_PIC_HEIGHT; //!< maxinum height for HEVC encode |
| 383 |
static const uint32_t m_decAvcMaxWidth = |
| 384 |
CODEC_4K_MAX_PIC_WIDTH; //!< Maximum width for AVC decode |
| 385 |
static const uint32_t m_decAvcMaxHeight = |
| 386 |
CODEC_4K_MAX_PIC_HEIGHT; //!< Maximum height for AVC decode |
| 387 |
static const uint32_t m_decHevcMax16kWidth = |
| 388 |
CODEC_16K_MAX_PIC_WIDTH; //!< Maximum width for HEVC decode |
| 389 |
static const uint32_t m_decHevcMax16kHeight = |
| 390 |
CODEC_16K_MAX_PIC_HEIGHT; //!< Maximum height for HEVC decode |
| 391 |
static const uint32_t m_decVp9Max16kWidth = |
| 392 |
CODEC_16K_MAX_PIC_WIDTH; //!< Maximum width for VP9 decode |
| 393 |
static const uint32_t m_decVp9Max16kHeight = |
| 394 |
CODEC_16K_MAX_PIC_HEIGHT; //!< Maximum height for VP9 decode |
| 395 |
static const uint32_t m_decAv1Max16kWidth = |
| 396 |
CODEC_16K_MAX_PIC_WIDTH; //!< Maximum width for AV1 decode |
| 397 |
static const uint32_t m_decAv1Max16kHeight = |
| 398 |
CODEC_16K_MAX_PIC_HEIGHT; //!< Maximum height for AV1 decode |
| 399 |
static const uint32_t m_maxVp9EncWidth = |
| 400 |
CODEC_8K_MAX_PIC_WIDTH; //!< maximum width for VP9 encode |
| 401 |
static const uint32_t m_maxVp9EncHeight = |
| 402 |
CODEC_8K_MAX_PIC_HEIGHT; //!< maximum height for VP9 encode |
| 403 |
static const uint32_t m_minVp9EncWidth = |
| 404 |
CODEC_128_MIN_PIC_WIDTH; //!< minimum width for VP9 encode |
| 405 |
static const uint32_t m_minVp9EncHeight = |
| 406 |
CODEC_96_MIN_PIC_HEIGHT; //!< minimum height for VP9 encode |
| 407 |
static const uint32_t m_minAv1EncWidth = |
| 408 |
CODEC_128_MIN_PIC_WIDTH; //!< minimum width for AV1 encode |
| 409 |
static const uint32_t m_minAv1EncHeight = |
| 410 |
CODEC_96_MIN_PIC_HEIGHT; //!< minimum height for AV1 encode |
| 411 |
MEDIA_CLASS_DEFINE_END(MediaLibvaCapsMtlBase) |
| 412 |
}; |
| 413 |
#endif |