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