| 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 mhw_vdbox_vvcp_itf.h |
| 24 | //! \brief MHW VDBOX VVCP interface common base |
| 25 | //! \details |
| 26 | //! |
| 27 | |
| 28 | #ifndef __MHW_VDBOX_VVCP_ITF_H__ |
| 29 | #define __MHW_VDBOX_VVCP_ITF_H__ |
| 30 | |
| 31 | #include "mhw_itf.h" |
| 32 | #include "mhw_vdbox.h" |
| 33 | #include "mhw_cp_interface.h" |
| 34 | #include "mhw_vdbox_vvcp_cmdpar.h" |
| 35 | |
| 36 | // add all VVCP cmds here |
| 37 | #define _VVCP_CMD_DEF(DEF) \ |
| 38 | DEF(VVCP_VD_CONTROL_STATE); \ |
| 39 | DEF(VVCP_PIPE_MODE_SELECT); \ |
| 40 | DEF(VVCP_SURFACE_STATE); \ |
| 41 | DEF(VVCP_PIPE_BUF_ADDR_STATE); \ |
| 42 | DEF(VVCP_IND_OBJ_BASE_ADDR_STATE); \ |
| 43 | DEF(VVCP_PIC_STATE); \ |
| 44 | DEF(VVCP_DPB_STATE); \ |
| 45 | DEF(VVCP_SLICE_STATE); \ |
| 46 | DEF(VVCP_BSD_OBJECT); \ |
| 47 | DEF(VVCP_REF_IDX_STATE); \ |
| 48 | DEF(VVCP_WEIGHTOFFSET_STATE); \ |
| 49 | DEF(VVCP_TILE_CODING); |
| 50 | |
| 51 | namespace mhw |
| 52 | { |
| 53 | namespace vdbox |
| 54 | { |
| 55 | namespace vvcp |
| 56 | { |
| 57 | |
| 58 | class Itf |
| 59 | { |
| 60 | public: |
| 61 | class ParSetting |
| 62 | { |
| 63 | public: |
| 64 | virtual ~ParSetting() = default; |
| 65 | |
| 66 | _VVCP_CMD_DEF(_MHW_SETPAR_DEF); |
| 67 | }; |
| 68 | |
| 69 | virtual ~Itf() = default; |
| 70 | |
| 71 | //! |
| 72 | //! \brief Set cacheability settings |
| 73 | //! |
| 74 | //! \param [in] settings |
| 75 | //! Cacheability settings |
| 76 | //! |
| 77 | //! \return MOS_STATUS |
| 78 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 79 | //! |
| 80 | virtual MOS_STATUS SetCacheabilitySettings(MHW_MEMORY_OBJECT_CONTROL_PARAMS settings[MOS_CODEC_RESOURCE_USAGE_END_CODEC]) = 0; |
| 81 | |
| 82 | //! |
| 83 | //! \brief Get the required buffer size for VDBOX |
| 84 | //! \details Internal function to get required buffer size for VVC codec |
| 85 | //! |
| 86 | //! \param [in] bufferType |
| 87 | //! VVC Buffer type |
| 88 | //! \param [in, out] vvcpBufSizeParam |
| 89 | //! VVCP buffer size parameters |
| 90 | //! |
| 91 | //! \return MOS_STATUS |
| 92 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 93 | //! |
| 94 | virtual MOS_STATUS GetVvcpBufSize(VvcpBufferType bufferType, VvcpBufferSizePar *vvcpBufSizeParam) = 0; |
| 95 | |
| 96 | //! |
| 97 | //! \brief Judge if row store caching is supported, overall flag for VVCP |
| 98 | //! |
| 99 | //! \return bool |
| 100 | //! true if supported, else false |
| 101 | //! |
| 102 | virtual bool IsRowStoreCachingSupported() = 0; |
| 103 | |
| 104 | //! |
| 105 | //! \brief Judge if row store cache of a particular buffer type is enabled |
| 106 | //! |
| 107 | //! \param [in] bufferType |
| 108 | //! VVC Buffer type |
| 109 | //! |
| 110 | //! \return bool |
| 111 | //! true if enabled, else false |
| 112 | //! |
| 113 | virtual bool IsBufferRowstoreCacheEnabled(VvcpBufferType bufferType) = 0; |
| 114 | |
| 115 | virtual MOS_STATUS GetRowstoreCachingAddrs(PMHW_VDBOX_ROWSTORE_PARAMS rowstoreParams) = 0; |
| 116 | |
| 117 | //! |
| 118 | //! \brief Calculates the maximum size for VVCP picture level commands |
| 119 | //! \details Client facing function to calculate the maximum size for VVCP picture level commands |
| 120 | //! \param [out] commandsSize |
| 121 | //! The maximum command buffer size |
| 122 | //! \param [out] patchListSize |
| 123 | //! The maximum command patch list size |
| 124 | //! \param [in] params |
| 125 | //! Indicate the command size parameters |
| 126 | //! \return MOS_STATUS |
| 127 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 128 | //! |
| 129 | virtual MOS_STATUS GetVvcpStateCmdSize(uint32_t *commandsSize, uint32_t *patchListSize, PMHW_VDBOX_STATE_CMDSIZE_PARAMS params) = 0; |
| 130 | |
| 131 | virtual MOS_STATUS GetVvcpSliceLvlCmdSize(uint32_t *sliceLvlCmdSize) = 0; |
| 132 | |
| 133 | //! |
| 134 | //! \brief Calculates maximum size for VVCP primitive level commands |
| 135 | //! \details Client facing function to calculate maximum size for VVCP primitive level commands |
| 136 | //! \param [out] sliceCommandsSize |
| 137 | //! The maximum command buffer size for slice |
| 138 | //! \param [out] slicePatchListSize |
| 139 | //! The maximum command patch list size for slice |
| 140 | //! \param [out] tileCommandsSize |
| 141 | //! The maximum command buffer size for tile |
| 142 | //! \param [out] tilePatchListSize |
| 143 | //! The maximum command patch list size for tile |
| 144 | //! \return MOS_STATUS |
| 145 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 146 | //! \return MOS_STATUS |
| 147 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 148 | //! |
| 149 | virtual MOS_STATUS GetVvcpPrimitiveCmdSize( |
| 150 | uint32_t *sliceCommandsSize, |
| 151 | uint32_t *slicePatchListSize, |
| 152 | uint32_t *tileCommandsSize, |
| 153 | uint32_t *tilePatchListSize) = 0; |
| 154 | |
| 155 | //! |
| 156 | //! \brief Store VVCP ALF APS data to the given ALF buffer |
| 157 | //! |
| 158 | //! \param [in, out] buffer |
| 159 | //! Buffer to store ALF APS data |
| 160 | //! \param [in] alfApsArray |
| 161 | //! Pointer to VVC ALF data array |
| 162 | //! \param [in] activeAlfMask |
| 163 | //! Active ALF mask |
| 164 | //! |
| 165 | //! \return MOS_STATUS |
| 166 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 167 | //! |
| 168 | virtual MOS_STATUS SetAlfApsDataBuffer(uint32_t *buffer, CodecVvcAlfData *alfApsArray, uint8_t activeAlfMask) = 0; |
| 169 | |
| 170 | //! |
| 171 | //! \brief Determines if the slice is P slice |
| 172 | //! \param [in] sliceType |
| 173 | //! slice type |
| 174 | //! \return bool |
| 175 | //! True if it's P slice, otherwise return false |
| 176 | //! |
| 177 | inline bool IsVvcPSlice(uint8_t sliceType) |
| 178 | { |
| 179 | return (sliceType < MHW_ARRAY_SIZE(m_vvcBsdSliceType)) ? (m_vvcBsdSliceType[sliceType] == vvcSliceP) : false; |
| 180 | } |
| 181 | |
| 182 | //! |
| 183 | //! \brief Determines if the slice is B slice |
| 184 | //! \param [in] sliceType |
| 185 | //! slice type |
| 186 | //! \return bool |
| 187 | //! True if it's B slice, otherwise return false |
| 188 | //! |
| 189 | inline bool IsVvcBSlice(uint8_t sliceType) |
| 190 | { |
| 191 | return (sliceType < MHW_ARRAY_SIZE(m_vvcBsdSliceType)) ? (m_vvcBsdSliceType[sliceType] == vvcSliceB) : false; |
| 192 | } |
| 193 | |
| 194 | //! |
| 195 | //! \brief Determines if the slice is I slice |
| 196 | //! \param [in] sliceType |
| 197 | //! slice type |
| 198 | //! \return bool |
| 199 | //! True if it's I slice, otherwise return false |
| 200 | //! |
| 201 | inline bool IsVvcISlice(uint8_t sliceType) |
| 202 | { |
| 203 | return (sliceType < MHW_ARRAY_SIZE(m_vvcBsdSliceType)) ? (m_vvcBsdSliceType[sliceType] == vvcSliceI) : false; |
| 204 | } |
| 205 | |
| 206 | uint32_t GetMappedCoeff(uint32_t coeffValue) |
| 207 | { |
| 208 | uint32_t mappedCoeff = 0; |
| 209 | if(alfCoeffMap.find(coeffValue) != alfCoeffMap.end()) |
| 210 | { |
| 211 | mappedCoeff = alfCoeffMap.find(coeffValue)->second; |
| 212 | } |
| 213 | return mappedCoeff; |
| 214 | } |
| 215 | |
| 216 | _VVCP_CMD_DEF(_MHW_CMD_ALL_DEF_FOR_ITF); |
| 217 | |
| 218 | private: |
| 219 | const VvcSliceType m_vvcBsdSliceType[3] = |
| 220 | { |
| 221 | vvcSliceB, |
| 222 | vvcSliceP, |
| 223 | vvcSliceI |
| 224 | }; |
| 225 | const std::map<uint32_t, uint32_t> alfCoeffMap = { |
| 226 | {1, 1}, |
| 227 | {2, 2}, |
| 228 | {4, 3}, |
| 229 | {8, 4}, |
| 230 | {16, 5}, |
| 231 | {32, 6}, |
| 232 | {64, 7} |
| 233 | }; |
| 234 | |
| 235 | MEDIA_CLASS_DEFINE_END(mhw__vdbox__vvcp__Itf) |
| 236 | }; |
| 237 | |
| 238 | } // namespace vvcp |
| 239 | } // namespace vdbox |
| 240 | } // namespace mhw |
| 241 | |
| 242 | #endif // __MHW_VDBOX_VVCP_ITF_H__ |