| 1 |
/* |
| 2 |
* Copyright (c) 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 ddi_encode_functions.h |
| 24 |
//! \brief ddi encode functions head file |
| 25 |
//! |
| 26 |
|
| 27 |
#ifndef __DDI_ENCODE_FUNCTIONS_H__ |
| 28 |
#define __DDI_ENCODE_FUNCTIONS_H__ |
| 29 |
|
| 30 |
#include "ddi_media_functions.h" |
| 31 |
#include "media_libva_caps_next.h" |
| 32 |
#include "ddi_libva_encoder_specific.h" |
| 33 |
|
| 34 |
class DdiEncodeFunctions :public DdiMediaFunctions |
| 35 |
{ |
| 36 |
public: |
| 37 |
|
| 38 |
virtual ~DdiEncodeFunctions() override{}; |
| 39 |
|
| 40 |
//! |
| 41 |
//! \brief Create a configuration |
| 42 |
//! \details It passes in the attribute list that specifies the attributes it |
| 43 |
//! cares about, with the rest taking default values. |
| 44 |
//! |
| 45 |
//! \param [in] ctx |
| 46 |
//! Pointer to VA driver context |
| 47 |
//! \param [in] profile |
| 48 |
//! VA profile |
| 49 |
//! \param [in] entrypoint |
| 50 |
//! VA entrypoint |
| 51 |
//! \param [in] attribList |
| 52 |
//! Pointer to VAConfigAttrib array that specifies the attributes |
| 53 |
//! \param [in] numAttribs |
| 54 |
//! Number of VAConfigAttrib in the array attribList |
| 55 |
//! \param [out] configId |
| 56 |
//! Pointer to returned VAConfigID if success |
| 57 |
//! |
| 58 |
//! \return VAStatus |
| 59 |
//! VA_STATUS_SUCCESS if success |
| 60 |
//! |
| 61 |
virtual VAStatus CreateConfig( |
| 62 |
VADriverContextP ctx, |
| 63 |
VAProfile profile, |
| 64 |
VAEntrypoint entrypoint, |
| 65 |
VAConfigAttrib *attribList, |
| 66 |
int32_t numAttribs, |
| 67 |
VAConfigID *configId |
| 68 |
) override; |
| 69 |
|
| 70 |
//! |
| 71 |
//! \brief Create context |
| 72 |
//! |
| 73 |
//! \param [in] ctx |
| 74 |
//! Pointer to VA driver context |
| 75 |
//! \param [in] configId |
| 76 |
//! VA config id |
| 77 |
//! \param [in] pictureWidth |
| 78 |
//! Picture width |
| 79 |
//! \param [in] pictureHeight |
| 80 |
//! Picture height |
| 81 |
//! \param [out] flag |
| 82 |
//! Create flag |
| 83 |
//! \param [in] renderTargets |
| 84 |
//! VA render traget |
| 85 |
//! \param [in] renderTargetsNum |
| 86 |
//! Number of render targets |
| 87 |
//! \param [out] context |
| 88 |
//! VA created context |
| 89 |
//! |
| 90 |
//! \return VAStatus |
| 91 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 92 |
//! |
| 93 |
virtual VAStatus CreateContext ( |
| 94 |
VADriverContextP ctx, |
| 95 |
VAConfigID configId, |
| 96 |
int32_t pictureWidth, |
| 97 |
int32_t pictureHeight, |
| 98 |
int32_t flag, |
| 99 |
VASurfaceID *renderTargets, |
| 100 |
int32_t renderTargetsNum, |
| 101 |
VAContextID *context |
| 102 |
) override; |
| 103 |
|
| 104 |
//! |
| 105 |
//! \brief Destroy context |
| 106 |
//! |
| 107 |
//! \param [in] ctx |
| 108 |
//! Pointer to VA driver context |
| 109 |
//! \param [in] context |
| 110 |
//! VA context to destroy |
| 111 |
//! |
| 112 |
//! \return VAStatus |
| 113 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 114 |
//! |
| 115 |
virtual VAStatus DestroyContext ( |
| 116 |
VADriverContextP ctx, |
| 117 |
VAContextID context |
| 118 |
) override; |
| 119 |
|
| 120 |
//! |
| 121 |
//! \brief Create buffer |
| 122 |
//! |
| 123 |
//! \param [in] ctx |
| 124 |
//! Pointer to VA driver context |
| 125 |
//! \param [in] context |
| 126 |
//! VA context id |
| 127 |
//! \param [in] type |
| 128 |
//! VA buffer type |
| 129 |
//! \param [in] size |
| 130 |
//! Buffer size |
| 131 |
//! \param [out] elementsNum |
| 132 |
//! Number of elements |
| 133 |
//! \param [in] data |
| 134 |
//! Buffer data |
| 135 |
//! \param [out] bufId |
| 136 |
//! VA buffer id |
| 137 |
//! |
| 138 |
//! \return VAStatus |
| 139 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 140 |
//! |
| 141 |
virtual VAStatus CreateBuffer ( |
| 142 |
VADriverContextP ctx, |
| 143 |
VAContextID context, |
| 144 |
VABufferType type, |
| 145 |
uint32_t size, |
| 146 |
uint32_t elementsNum, |
| 147 |
void *data, |
| 148 |
VABufferID *bufId |
| 149 |
) override; |
| 150 |
|
| 151 |
//! |
| 152 |
//! \brief Map data store of the buffer into the client's address space |
| 153 |
//! vaCreateBuffer() needs to be called with "data" set to nullptr before |
| 154 |
//! calling vaMapBuffer() |
| 155 |
//! |
| 156 |
//! \param [in] mediaCtx |
| 157 |
//! Pointer to media context |
| 158 |
//! \param [in] buf_id |
| 159 |
//! VA buffer ID |
| 160 |
//! \param [out] pbuf |
| 161 |
//! Pointer to buffer |
| 162 |
//! \param [in] flag |
| 163 |
//! Flag |
| 164 |
//! |
| 165 |
//! \return VAStatus |
| 166 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 167 |
//! |
| 168 |
virtual VAStatus MapBufferInternal( |
| 169 |
DDI_MEDIA_CONTEXT *mediaCtx, |
| 170 |
VABufferID buf_id, |
| 171 |
void **pbuf, |
| 172 |
uint32_t flag |
| 173 |
) override; |
| 174 |
|
| 175 |
//! |
| 176 |
//! \brief Unmap buffer |
| 177 |
//! |
| 178 |
//! \param [in] ctx |
| 179 |
//! Pointer to VA driver context |
| 180 |
//! \param [in] buf_id |
| 181 |
//! VA buffer ID |
| 182 |
//! |
| 183 |
//! \return VAStatus |
| 184 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 185 |
//! |
| 186 |
virtual VAStatus UnmapBuffer ( |
| 187 |
DDI_MEDIA_CONTEXT *mediaCtx, |
| 188 |
VABufferID buf_id |
| 189 |
) override; |
| 190 |
|
| 191 |
//! |
| 192 |
//! \brief Destroy buffer |
| 193 |
//! |
| 194 |
//! \param [in] mediaCtx |
| 195 |
//! Pointer to media context |
| 196 |
//! \param [in] buffer_id |
| 197 |
//! VA buffer ID |
| 198 |
//! |
| 199 |
//! \return VAStatus |
| 200 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 201 |
//! |
| 202 |
virtual VAStatus DestroyBuffer( |
| 203 |
DDI_MEDIA_CONTEXT *mediaCtx, |
| 204 |
VABufferID buffer_id |
| 205 |
) override; |
| 206 |
|
| 207 |
//! |
| 208 |
//! \brief Get ready to decode a picture to a target surface |
| 209 |
//! |
| 210 |
//! \param [in] ctx |
| 211 |
//! Pointer to VA driver context |
| 212 |
//! \param [in] context |
| 213 |
//! VA context id |
| 214 |
//! \param [in] renderTarget |
| 215 |
//! VA render target surface |
| 216 |
//! |
| 217 |
//! \return VAStatus |
| 218 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 219 |
//! |
| 220 |
virtual VAStatus BeginPicture ( |
| 221 |
VADriverContextP ctx, |
| 222 |
VAContextID context, |
| 223 |
VASurfaceID renderTarget |
| 224 |
) override; |
| 225 |
|
| 226 |
//! |
| 227 |
//! \brief Send decode buffers to the server |
| 228 |
//! \details Buffers are automatically destroyed afterwards |
| 229 |
//! \param [in] ctx |
| 230 |
//! Pointer to VA driver context |
| 231 |
//! \param [in] context |
| 232 |
//! VA buffer id |
| 233 |
//! \param [in] buffer |
| 234 |
//! Pointer to VA buffer id |
| 235 |
//! \param [in] buffersNum |
| 236 |
//! number of buffers |
| 237 |
//! |
| 238 |
//! \return VAStatus |
| 239 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 240 |
//! |
| 241 |
virtual VAStatus RenderPicture ( |
| 242 |
VADriverContextP ctx, |
| 243 |
VAContextID context, |
| 244 |
VABufferID *buffers, |
| 245 |
int32_t buffersNum |
| 246 |
) override; |
| 247 |
|
| 248 |
//! |
| 249 |
//! \brief Make the end of rendering for a picture |
| 250 |
//! \details The server should start processing all pending operations for this |
| 251 |
//! surface. This call is non-blocking. The client can start another |
| 252 |
//! Begin/Render/End sequence on a different render target |
| 253 |
//! \param [in] ctx |
| 254 |
//! Pointer to VA driver context |
| 255 |
//! \param [in] context |
| 256 |
//! VA buffer id |
| 257 |
//! |
| 258 |
//! \return VAStatus |
| 259 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 260 |
//! |
| 261 |
virtual VAStatus EndPicture ( |
| 262 |
VADriverContextP ctx, |
| 263 |
VAContextID context |
| 264 |
) override; |
| 265 |
|
| 266 |
//! |
| 267 |
//! \brief Clean and free encode context structure |
| 268 |
//! |
| 269 |
//! \param [in] encCtx |
| 270 |
//! Pointer to ddi encode context |
| 271 |
//! |
| 272 |
void CleanUp(encode::PDDI_ENCODE_CONTEXT encCtx); |
| 273 |
|
| 274 |
//! |
| 275 |
//! \brief Set Encode Gpu Priority |
| 276 |
//! |
| 277 |
//! \param [in] encode context |
| 278 |
//! Pointer to encode context |
| 279 |
//! \param [in] priority |
| 280 |
//! priority |
| 281 |
//! \return VAStatus |
| 282 |
//! |
| 283 |
VAStatus SetGpuPriority( |
| 284 |
encode::PDDI_ENCODE_CONTEXT encCtx, |
| 285 |
int32_t priority |
| 286 |
); |
| 287 |
|
| 288 |
//! |
| 289 |
//! \brief Coded buffer exist in status report |
| 290 |
//! |
| 291 |
//! \param [in] encCtx |
| 292 |
//! Pointer to ddi encode context |
| 293 |
//! \param [in] buf |
| 294 |
//! Pointer to ddi media buffer |
| 295 |
//! |
| 296 |
//! \return bool |
| 297 |
//! true if call success, else false |
| 298 |
//! |
| 299 |
bool CodedBufferExistInStatusReport( |
| 300 |
encode::PDDI_ENCODE_CONTEXT encCtx, |
| 301 |
PDDI_MEDIA_BUFFER buf); |
| 302 |
|
| 303 |
//! |
| 304 |
//! \brief Status report |
| 305 |
//! |
| 306 |
//! \param [in] encCtx |
| 307 |
//! Pointer to ddi encode context |
| 308 |
//! \param [in] mediaBuf |
| 309 |
//! Ddi media buffer |
| 310 |
//! \param [out] buf |
| 311 |
//! Pointer buffer |
| 312 |
//! |
| 313 |
//! \return VAStatus |
| 314 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 315 |
//! |
| 316 |
VAStatus StatusReport ( |
| 317 |
encode::PDDI_ENCODE_CONTEXT encCtx, |
| 318 |
DDI_MEDIA_BUFFER *mediaBuf, |
| 319 |
void **buf |
| 320 |
); |
| 321 |
|
| 322 |
//! |
| 323 |
//! \brief Pre encode buffer exist in status report |
| 324 |
//! |
| 325 |
//! \param [in] encCtx |
| 326 |
//! Pointer to ddi encode context |
| 327 |
//! \param [in] buf |
| 328 |
//! Pointer to ddi media buffer |
| 329 |
//! \param [in] typeIdx |
| 330 |
//! Ddi encode PRE encode buffer type |
| 331 |
//! |
| 332 |
//! \return bool |
| 333 |
//! true if call success, else false |
| 334 |
//! |
| 335 |
bool PreEncBufferExistInStatusReport( |
| 336 |
encode::PDDI_ENCODE_CONTEXT encCtx, |
| 337 |
PDDI_MEDIA_BUFFER buf, |
| 338 |
encode::DDI_ENCODE_PRE_ENC_BUFFER_TYPE typeIdx); |
| 339 |
|
| 340 |
//! |
| 341 |
//! \brief Pre encode status report |
| 342 |
//! |
| 343 |
//! \param [in] encCtx |
| 344 |
//! Pointer to ddi encode context |
| 345 |
//! \param [in] mediaBuf |
| 346 |
//! Ddi media buffer |
| 347 |
//! \param [out] pbuf |
| 348 |
//! Pointer buffer |
| 349 |
//! |
| 350 |
//! \return VAStatus |
| 351 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 352 |
//! |
| 353 |
VAStatus PreEncStatusReport( |
| 354 |
encode::PDDI_ENCODE_CONTEXT encCtx, |
| 355 |
DDI_MEDIA_BUFFER* mediaBuf, |
| 356 |
void** buf); |
| 357 |
|
| 358 |
//! |
| 359 |
//! \brief Encode buffer exist in status report |
| 360 |
//! |
| 361 |
//! \param [in] encCtx |
| 362 |
//! Pointer to ddi encode context |
| 363 |
//! \param [in] buf |
| 364 |
//! Pointer to ddi media buffer |
| 365 |
//! \param [in] typeIdx |
| 366 |
//! Ddi encode FEI encode buffer type |
| 367 |
//! |
| 368 |
//! \return bool |
| 369 |
//! true if call success, else false |
| 370 |
//! |
| 371 |
bool EncBufferExistInStatusReport( |
| 372 |
encode::PDDI_ENCODE_CONTEXT encCtx, |
| 373 |
PDDI_MEDIA_BUFFER buf, |
| 374 |
encode::DDI_ENCODE_FEI_ENC_BUFFER_TYPE typeIdx); |
| 375 |
|
| 376 |
//! |
| 377 |
//! \brief Encode status report |
| 378 |
//! |
| 379 |
//! \param [in] encCtx |
| 380 |
//! Pointer to ddi encode context |
| 381 |
//! \param [in] mediaBuf |
| 382 |
//! Ddi media buffer |
| 383 |
//! \param [out] pbuf |
| 384 |
//! Pointer buffer |
| 385 |
//! |
| 386 |
//! \return VAStatus |
| 387 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 388 |
//! |
| 389 |
VAStatus EncStatusReport ( |
| 390 |
encode::PDDI_ENCODE_CONTEXT encCtx, |
| 391 |
DDI_MEDIA_BUFFER *mediaBuf, |
| 392 |
void **pbuf |
| 393 |
); |
| 394 |
|
| 395 |
//! |
| 396 |
//! \brief Remove form preencode status report queue |
| 397 |
//! |
| 398 |
//! \param [in] encCtx |
| 399 |
//! Pointer to ddi encode context |
| 400 |
//! \param [in] buf |
| 401 |
//! Pointer to ddi media buffer |
| 402 |
//! \param [in] idx |
| 403 |
//! Ddi encode PRE encode buffer type |
| 404 |
//! |
| 405 |
//! \return VAStatus |
| 406 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 407 |
//! |
| 408 |
VAStatus RemoveFromPreEncStatusReportQueue( |
| 409 |
encode::PDDI_ENCODE_CONTEXT encCtx, |
| 410 |
PDDI_MEDIA_BUFFER buf, |
| 411 |
encode::DDI_ENCODE_PRE_ENC_BUFFER_TYPE typeIdx); |
| 412 |
|
| 413 |
//! |
| 414 |
//! \brief Remove form preencode status report queue |
| 415 |
//! |
| 416 |
//! \param [in] encCtx |
| 417 |
//! Pointer to ddi encode context |
| 418 |
//! \param [in] buf |
| 419 |
//! Pointer to ddi media buffer |
| 420 |
//! \param [in] idx |
| 421 |
//! Ddi encode PRE encode buffer type |
| 422 |
//! |
| 423 |
//! \return VAStatus |
| 424 |
//! VA_STATUS_SUCCESS if success, else fail reason |
| 425 |
//! |
| 426 |
VAStatus RemoveFromEncStatusReportQueue( |
| 427 |
encode::PDDI_ENCODE_CONTEXT encCtx, |
| 428 |
PDDI_MEDIA_BUFFER buf, |
| 429 |
encode::DDI_ENCODE_FEI_ENC_BUFFER_TYPE typeIdx); |
| 430 |
|
| 431 |
MEDIA_CLASS_DEFINE_END(DdiEncodeFunctions) |
| 432 |
}; |
| 433 |
|
| 434 |
#endif //__DDI_ENCODE_FUNCTIONS_H__ |