1 /* 2 * Copyright (c) 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_codec_base_specific.h 24 //! \brief Defines base class for softlet DDI codec encode/decoder 25 //! 26 27 #ifndef _DDI_CODEC_BASE_SPECIFIC_H_ 28 #define _DDI_CODEC_BASE_SPECIFIC_H_ 29 30 #include <stdint.h> 31 #include <va/va.h> 32 #include <va/va_backend.h> 33 34 #include "ddi_codec_def_specific.h" 35 #include "media_libva_common_next.h" 36 37 namespace codec 38 { 39 #define SURFACE_STATE_INACTIVE 0 //!< Surface state inactive flag, should be transfer from inactive->inuse->active->inactive 40 #define SURFACE_STATE_ACTIVE_IN_LASTFRAME 1 //!< Surface state active in last frame flag, means surface appears in DPB of last frame and certainly some of them will appear in DPB of current frame. 41 #define SURFACE_STATE_ACTIVE_IN_CURFRAME 64 //!< Surface state active in current frame flag, means surface will be used in current frame. 42 43 //! 44 //! \class DdiCodecBase 45 //! \brief Ddi codec base class 46 //! 47 class DdiCodecBase 48 { 49 public: 50 //! 51 //! \brief Constructor 52 //! DdiCodecBase()53 DdiCodecBase(){}; 54 55 //! 56 //! \brief Destructor 57 //! ~DdiCodecBase()58 virtual ~DdiCodecBase(){}; 59 60 //! 61 //! \brief Get ready to process for a target surface 62 //! \details It begins the process (encode/decode/vp) for a specified target surface 63 //! 64 //! \param [in] ctx 65 //! Pointer to VA driver context 66 //! \param [in] context 67 //! Already created context for the process 68 //! \param [in] renderTarget 69 //! Specified target surface 70 //! 71 //! \return VAStatus 72 //! VA_STATUS_SUCCESS if success, else fail reason 73 //! 74 virtual VAStatus BeginPicture( 75 VADriverContextP ctx, 76 VAContextID context, 77 VASurfaceID renderTarget) = 0; 78 79 //! 80 //! \brief Send required buffers to for process 81 //! \details It sends needed buffers by the process (encode/decode/vp) to the driver 82 //! 83 //! \param [in] ctx 84 //! Pointer to VA driver context 85 //! \param [in] context 86 //! Already created context for the process 87 //! \param [in] buffers 88 //! Pointer to the buffer array 89 //! \param [in] numBuffers 90 //! Number of buffers in above array 91 //! 92 //! \return VAStatus 93 //! VA_STATUS_SUCCESS if success, else fail reason 94 //! 95 virtual VAStatus RenderPicture( 96 VADriverContextP ctx, 97 VAContextID context, 98 VABufferID *buffers, 99 int32_t numBuffers) = 0; 100 101 //! 102 //! \brief Make the end of rendering for a picture 103 //! \details The driver will start processing the corresponding decoding/encoding/vp for 104 //! given context. This call is non-blocking. The app can start another 105 //! Begin/Render/End sequence on a different render target 106 //! 107 //! \param [in] ctx 108 //! Pointer to VA driver context 109 //! \param [in] context 110 //! Already created context for the process 111 //! 112 //! \return VAStatus 113 //! VA_STATUS_SUCCESS if success, else fail reason 114 //! 115 virtual VAStatus EndPicture( 116 VADriverContextP ctx, 117 VAContextID context) = 0; 118 119 //! 120 //! \brief Register Render Target Surface 121 //! \details Register surface in render target table 122 //! 123 //! \param [in] rtTbl 124 //! Pointer to DDI_CODEC_RENDER_TARGET_TABLE 125 //! \param [in] surface 126 //! Pointer to DDI_MEDIA_SURFACE 127 //! 128 //! \return VAStatus 129 //! VA_STATUS_SUCCESS if success, else fail reason 130 //! 131 VAStatus RegisterRTSurfaces(DDI_CODEC_RENDER_TARGET_TABLE *rtTbl, DDI_MEDIA_SURFACE *surface); 132 133 //! 134 //! \brief Unregister Render Target Surface 135 //! \details Unregister surface in render target table 136 //! 137 //! \param [in] rtTbl 138 //! Pointer to DDI_CODEC_RENDER_TARGET_TABLE 139 //! \param [in] surface 140 //! Pointer to DDI_MEDIA_SURFACE 141 //! 142 //! \return VAStatus 143 //! VA_STATUS_SUCCESS if success, else fail reason 144 //! 145 VAStatus UnRegisterRTSurfaces(DDI_CODEC_RENDER_TARGET_TABLE *rtTbl, DDI_MEDIA_SURFACE *surface); 146 147 protected: 148 //! 149 //! \brief Get Render Target Index 150 //! \details Get surface index in render target table 151 //! 152 //! \param [in] rtTbl 153 //! Pointer to DDI_CODEC_RENDER_TARGET_TABLE 154 //! \param [in] surface 155 //! Pointer to DDI_MEDIA_SURFACE 156 //! 157 //! \return int32_t 158 //! Render target index 159 //! 160 int32_t GetRenderTargetID(DDI_CODEC_RENDER_TARGET_TABLE *rtTbl, DDI_MEDIA_SURFACE *surface); 161 162 //! 163 //! \brief Clear Reference List 164 //! \details Clear surface state in render target table 165 //! 166 //! \param [in] rtTbl 167 //! Pointer to DDI_CODEC_RENDER_TARGET_TABLE 168 //! \param [in] withDpb 169 //! Dpb flag 170 //! 171 //! \return VAStatus 172 //! VA_STATUS_SUCCESS if success, else fail reason 173 //! 174 VAStatus ClearRefList(DDI_CODEC_RENDER_TARGET_TABLE *rtTbl, bool withDpb); 175 176 //! 177 //! \brief Update Registered Render Target Surface Flag 178 //! \details Check if surface need to be registered in render target table 179 //! 180 //! \param [in] rtTbl 181 //! Pointer to DDI_CODEC_RENDER_TARGET_TABLE 182 //! \param [in] surface 183 //! Pointer to DDI_MEDIA_SURFACE 184 //! 185 //! \return VAStatus 186 //! VA_STATUS_SUCCESS if success, else fail reason 187 //! 188 VAStatus UpdateRegisteredRTSurfaceFlag(DDI_CODEC_RENDER_TARGET_TABLE *rtTbl, DDI_MEDIA_SURFACE *surface); 189 MEDIA_CLASS_DEFINE_END(codec__DdiCodecBase) 190 }; 191 192 } 193 #endif /* _DDI_CODEC_BASE_SPECIFIC_H_ */ 194