1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353
|
/*
* Copyright (c) 2018-2019, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
//!
//! \file media_libva_caps_g12.h
//! \brief This file defines the C++ class/interface for gen12 media capbilities.
//!
#ifndef __MEDIA_LIBVA_CAPS_G12_H__
#define __MEDIA_LIBVA_CAPS_G12_H__
#include "media_libva_caps.h"
//!
//! \class MediaLibvaCapsG12
//! \brief Media libva caps Gen12
//!
class MediaLibvaCapsG12 : public MediaLibvaCaps
{
public:
//!
//! \brief Constructor
//!
MediaLibvaCapsG12(DDI_MEDIA_CONTEXT *mediaCtx) : MediaLibvaCaps(mediaCtx)
{
// TGL supported Encode format
static struct EncodeFormatTable encodeFormatTableTGL[] =
{
{AVC, DualPipe, VA_RT_FORMAT_YUV420},
{AVC, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_RGB32},
{HEVC, DualPipe, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP | VA_RT_FORMAT_YUV420_12 |
VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV422_10 | VA_RT_FORMAT_YUV422_12},
{HEVC, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP |
VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV444_10 | VA_RT_FORMAT_RGB32 |
VA_RT_FORMAT_RGB32_10BPP | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV422_10},
{VP9, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP |
VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV444_10 | VA_RT_FORMAT_RGB32 |
VA_RT_FORMAT_RGB32_10BPP},
};
m_encodeFormatTable = (struct EncodeFormatTable*)(&encodeFormatTableTGL[0]);
m_encodeFormatCount = sizeof(encodeFormatTableTGL)/sizeof(struct EncodeFormatTable);
return;
}
//!
virtual VAStatus Init() override
{
return LoadProfileEntrypoints();
}
virtual VAStatus QueryImageFormats(VAImageFormat *formatList, int32_t *num_formats) override;
virtual uint32_t GetImageFormatsMaxNum() override;
virtual bool IsImageSupported(uint32_t fourcc) override;
//!
//! \brief Populate the color masks info
//!
//! \param [in,out] Image format
//! Pointer to a VAImageFormat array. Color masks information will be populated to this
//! structure.
//!
//! \return VAStatus
//! VA_STATUS_SUCCESS if succeed
//!
virtual VAStatus PopulateColorMaskInfo(VAImageFormat *vaImgFmt) override;
//!
//! \brief Return internal encode mode for given profile and entrypoint
//!
//! \param [in] profile
//! Specify the VAProfile
//!
//! \param [in] entrypoint
//! Specify the VAEntrypoint
//!
//! \return Codehal mode
//!
CODECHAL_MODE GetEncodeCodecMode(VAProfile profile, VAEntrypoint entrypoint) override;
//!
//! \brief Return the decode codec key for given profile
//!
//! \param [in] profile
//! Specify the VAProfile
//!
//! \return Std::string decode codec key
//!
virtual std::string GetDecodeCodecKey(VAProfile profile) override;
//!
//! \brief Return the encode codec key for given profile and entrypoint
//!
//! \param [in] profile
//! Specify the VAProfile
//!
//! \param [in] entrypoint
//! Specify the entrypoint
//!
//! \param [in] feiFunction
//! Specify the feiFunction
//!
//! \return Std::string encode codec key
//!
std::string GetEncodeCodecKey(VAProfile profile,
VAEntrypoint entrypoint,
uint32_t feiFunction) override;
virtual CODECHAL_MODE GetDecodeCodecMode(VAProfile profile) override;
//!
//! \brief Add surface attributes for Encoding
//!
//! \param [in] profile
//! VAProfile of the configuration
//!
//! \param [in] entrypoint
//! VAEntrypoint of the configuration
//!
//! \param [in,out] attribList
//! Pointer to VASurfaceAttrib array. It returns
//! the supported surface attributes
//!
//! \param [in,out] numAttribs
//! The number of elements allocated on input
//! Return the number of elements actually filled in output
//!
//! \return VAStatus
//! VA_STATUS_SUCCESS if success
//!
virtual VAStatus AddEncSurfaceAttributes(VAProfile profile,
VAEntrypoint entrypoint,
VASurfaceAttrib *attribList,
uint32_t &numAttribs);
//!
//! \brief Get surface attributes for a given config ID
//!
//! \param [in] configId
//! VA configuration
//!
//! \param [in,out] attribList
//! Pointer to VASurfaceAttrib array. It returns
//! the supported surface attributes
//!
//! \param [in,out] numAttribs
//! The number of elements allocated on input
//! Return the number of elements actually filled in output
//!
//! \return VAStatus
//! VA_STATUS_SUCCESS if success
//! VA_STATUS_ERROR_MAX_NUM_EXCEEDED if size of attribList is too small
//!
VAStatus QuerySurfaceAttributes(VAConfigID configId,
VASurfaceAttrib *attribList,
uint32_t *numAttribs) override;
virtual bool IsHevcProfile(VAProfile profile) override;
virtual GMM_RESOURCE_FORMAT ConvertMediaFmtToGmmFmt(DDI_MEDIA_FORMAT format) override;
//! \brief Get surface drm modifier
//!
//! \param [in] mediaSurface
//! Pointer to the media surface
//! \param [out] modifier
//! reference of the modifier
//!
//! \return VAStatus
//! VA_STATUS_SUCCESS if success
//!
virtual VAStatus GetSurfaceModifier(DDI_MEDIA_SURFACE* mediaSurface, uint64_t &modifier) override;
//! \brief Set tile format according to external surface's modifier
//!
//! \param [in] mediaSurface
//! Pointer to the media surface
//! \param [out] tileformat
//! Reference to the tileformat
//! \param [out] bMemCompEnable
//! Reference to the memory compress flag
//! \param [out] bMemCompRC
//! Reference to the memory compress rate control
//!
//! \return VAStatus
//! VA_STATUS_SUCCESS if success
//!
virtual VAStatus SetExternalSurfaceTileFormat(DDI_MEDIA_SURFACE* mediaSurface,
uint32_t &tileformat,
bool &bMemCompEnable,
bool &bMemCompRC) override;
protected:
static const uint32_t m_maxHevcEncWidth =
CODEC_16K_MAX_PIC_WIDTH; //!< maxinum width for HEVC encode
static const uint32_t m_maxHevcEncHeight =
CODEC_12K_MAX_PIC_HEIGHT; //!< maxinum height for HEVC encode
static const uint32_t m_decAvcMaxWidth =
CODEC_4K_MAX_PIC_WIDTH; //!< Maximum width for AVC decode
static const uint32_t m_decAvcMaxHeight =
CODEC_4K_MAX_PIC_HEIGHT; //!< Maximum height for AVC decode
static const uint32_t m_decHevcMax16kWidth =
CODEC_16K_MAX_PIC_WIDTH; //!< Maximum width for HEVC decode
static const uint32_t m_decHevcMax16kHeight =
CODEC_16K_MAX_PIC_HEIGHT; //!< Maximum height for HEVC decode
static const uint32_t m_decVp9Max16kWidth =
CODEC_16K_MAX_PIC_WIDTH; //!< Maximum width for VP9 decode
static const uint32_t m_decVp9Max16kHeight =
CODEC_16K_MAX_PIC_HEIGHT; //!< Maximum height for VP9 decode
static const uint32_t m_decAv1Max16kWidth =
CODEC_16K_MAX_PIC_WIDTH; //!< Maximum width for AV1 decode
static const uint32_t m_decAv1Max16kHeight =
CODEC_16K_MAX_PIC_HEIGHT; //!< Maximum height for AV1 decode
static const uint32_t m_maxVp9EncWidth =
CODEC_8K_MAX_PIC_WIDTH; //!< maximum width for VP9 encode
static const uint32_t m_maxVp9EncHeight =
CODEC_8K_MAX_PIC_HEIGHT; //!< maximum height for VP9 encode
static const uint32_t m_minVp9EncWidth =
CODEC_128_MIN_PIC_WIDTH; //!< minimum width for VP9 encode
static const uint32_t m_minVp9EncHeight =
CODEC_96_MIN_PIC_HEIGHT; //!< minimum height for VP9 encode
static const VAImageFormat m_G12ImageFormats[]; //!< Gen12 supported image formats
static const VAConfigAttribValEncRateControlExt m_encVp9RateControlExt; //!< External enc rate control caps for VP9 encode
virtual VAStatus GetPlatformSpecificAttrib(VAProfile profile,
VAEntrypoint entrypoint,
VAConfigAttribType type,
unsigned int *value) override;
virtual VAStatus LoadProfileEntrypoints() override;
virtual VAStatus LoadJpegDecProfileEntrypoints();
virtual VAStatus LoadVp9EncProfileEntrypoints() override;
virtual VAStatus LoadHevcEncProfileEntrypoints() override;
virtual VAStatus CheckEncodeResolution(
VAProfile profile,
uint32_t width,
uint32_t height) override;
virtual VAStatus CheckDecodeResolution(
int32_t codecMode,
VAProfile profile,
uint32_t width,
uint32_t height) override;
virtual VAStatus CreateEncAttributes(
VAProfile profile,
VAEntrypoint entrypoint,
AttribMap **attributeList) override;
virtual VAStatus CreateDecAttributes(
VAProfile profile,
VAEntrypoint entrypoint,
AttribMap **attributeList) override;
virtual VAStatus LoadHevcDecProfileEntrypoints() override;
//!
//! \brief Initialize HEVC low-power encode profiles, entrypoints and attributes
//!
//! \return VAStatus
//! if call succeeds
//!
virtual VAStatus LoadHevcEncLpProfileEntrypoints();
//!
//! \brief Check if the give profile is AV1
//!
//! \param [in] profile
//! Specify the VAProfile
//!
//! \return True if the profile is a AV1 profile
//! False if the profile isn't a AV1 profile
//!
static bool IsAV1Profile(VAProfile profile);
//!
//! \brief Initialize AV1 decode profiles, entrypoints and attributes
//!
VAStatus LoadAv1DecProfileEntrypoints();
//!
//! \brief Query AVC ROI maximum number
//!
//! \param [in] rcMode
//! RC mode
//! \param [in] isVdenc
//! vdenc
//! \param [in] maxNum
//! Maximum number
//! \param [in] isRoiInDeltaQP
//! Is ROI in delta QP
//!
//! \return VAStatus
//! if call succeeds
//!
VAStatus QueryAVCROIMaxNum(uint32_t rcMode, bool isVdenc, uint32_t *maxNum, bool *isRoiInDeltaQP) override;
//!
//! \brief Get display attributes
//! returns the current attributes values in "attribList"
//!
//! \param [in, out] attribList
//! the attrib type should be filled.
//! returns the supported display attributes
//!
//! \param [in] numAttribs
//! the number of supported attributes
//!
//! \return VAStatus
//! VA_STATUS_SUCCESS if success
//! VA_STATUS_ERROR_MAX_NUM_EXCEEDED if size of attribList is too small
//!
virtual VAStatus GetDisplayAttributes(
VADisplayAttribute *attribList,
int32_t numAttribs) override;
//!
//! \brief Check if the give profile is HEVC SCC
//!
//! \param [in] profile
//! Specify the VAProfile
//!
//! \return True if the profile is a HEVC SCC profile
//! False if the profile isn't a HEVC profile
//!
bool IsHevcSccProfile(VAProfile profile)
{
return (
(profile == VAProfileHEVCSccMain) ||
(profile == VAProfileHEVCSccMain10) ||
(profile == VAProfileHEVCSccMain444) ||
(profile == VAProfileHEVCSccMain444_10)
);
}
};
#endif
|