| 1 | /* |
| 2 | * Copyright (c) 2021-2024, 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 decode_vvc_pipeline.h |
| 24 | //! \brief Defines the interface for vvc decode pipeline |
| 25 | //! |
| 26 | #ifndef __DECODE_VVC_PIPELINE_H__ |
| 27 | #define __DECODE_VVC_PIPELINE_H__ |
| 28 | |
| 29 | #include "decode_pipeline.h" |
| 30 | #include "codec_def_decode_vvc.h" |
| 31 | #include "decode_vvc_basic_feature.h" |
| 32 | #include "media_cmd_packet.h" |
| 33 | #include "media_debug_utils.h" |
| 34 | |
| 35 | namespace decode |
| 36 | { |
| 37 | class VvcDecodePkt; |
| 38 | class VvcPipeline : public DecodePipeline |
| 39 | { |
| 40 | public: |
| 41 | //! |
| 42 | //! \brief DecodePipeline constructor |
| 43 | //! \param [in] hwInterface |
| 44 | //! Pointer to CodechalHwInterface |
| 45 | //! \param [in] debugInterface |
| 46 | //! Pointer to CodechalDebugInterface |
| 47 | //! |
| 48 | VvcPipeline( |
| 49 | CodechalHwInterfaceNext * hwInterface, |
| 50 | CodechalDebugInterface *debugInterface); |
| 51 | |
| 52 | virtual ~VvcPipeline() {} |
| 53 | |
| 54 | //! |
| 55 | //! \brief Prepare interal parameters, should be invoked for each frame |
| 56 | //! \param [in] params |
| 57 | //! Pointer to the input parameters |
| 58 | //! \return MOS_STATUS |
| 59 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 60 | //! |
| 61 | virtual MOS_STATUS Prepare(void *params) final; |
| 62 | |
| 63 | //! |
| 64 | //! \brief Finish the execution for each frame |
| 65 | //! \return MOS_STATUS |
| 66 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 67 | //! |
| 68 | virtual MOS_STATUS Execute() final; |
| 69 | |
| 70 | virtual MOS_STATUS GetStatusReport(void *status, uint16_t numStatus) override; |
| 71 | |
| 72 | uint32_t GetCompletedReport(); |
| 73 | |
| 74 | virtual MOS_STATUS Destroy() override; |
| 75 | |
| 76 | MHW_BATCH_BUFFER *GetSliceLvlCmdBuffer(); |
| 77 | |
| 78 | PMHW_BATCH_BUFFER GetTileLvlCmdBuffer(); |
| 79 | uint32_t GetSliceLvlBufSize() { return m_sliceLvlBufSize; } |
| 80 | uint32_t GetTileLvlBufSize() { return m_tileLvlBufSize; } |
| 81 | |
| 82 | DeclareDecodePacketId(vvcDecodePacketId); |
| 83 | DeclareDecodePacketId(vvcDecodeS2LPktId); |
| 84 | DeclareDecodePacketId(vvcPictureSubPacketId); |
| 85 | DeclareDecodePacketId(vvcSliceSubPacketId); |
| 86 | DeclareDecodePacketId(vvcCpSubPacketId); |
| 87 | DeclareDecodePacketId(vvcDebugSubPacketId); |
| 88 | |
| 89 | protected: |
| 90 | virtual MOS_STATUS Initialize(void *settings) override; |
| 91 | virtual MOS_STATUS Uninitialize() override; |
| 92 | |
| 93 | //! |
| 94 | //! \brief User Feature Key Report |
| 95 | //! \return MOS_STATUS |
| 96 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 97 | //! |
| 98 | virtual MOS_STATUS UserFeatureReport() override; |
| 99 | |
| 100 | //! |
| 101 | //! \brief Initialize user setting |
| 102 | //! \param [in] userSettingPtr |
| 103 | //! Pointer to media user setting instance |
| 104 | //! \return MOS_STATUS |
| 105 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 106 | //! |
| 107 | virtual MOS_STATUS InitUserSetting(MediaUserSettingSharedPtr userSettingPtr) override; |
| 108 | |
| 109 | //! |
| 110 | //! \brief Create sub packets |
| 111 | //! \param [in] codecSettings |
| 112 | //! Codechal settings |
| 113 | //! \return MOS_STATUS |
| 114 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 115 | //! |
| 116 | virtual MOS_STATUS CreateSubPackets(DecodeSubPacketManager& subPacketManager, CodechalSetting &codecSettings) override; |
| 117 | |
| 118 | //! |
| 119 | //! \brief Initialize media context for decode pipeline |
| 120 | //! \return MOS_STATUS |
| 121 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 122 | //! |
| 123 | MOS_STATUS InitContext(); |
| 124 | |
| 125 | //! |
| 126 | //! \brief Initialize MMC state |
| 127 | //! |
| 128 | //! \return MOS_STATUS |
| 129 | //! MOS_STATUS_SUCCESS if success |
| 130 | //! |
| 131 | virtual MOS_STATUS InitMmcState(); |
| 132 | |
| 133 | //! |
| 134 | //! \brief Register CP subpacket if CP is enabled |
| 135 | //! |
| 136 | //! \param [in] subPacketManager |
| 137 | //! Reference to DecodeSubPacketManager |
| 138 | //! |
| 139 | //! \return MOS_STATUS |
| 140 | //! MOS_STATUS_SUCCESS if success |
| 141 | //! |
| 142 | MOS_STATUS RegisterCpSubPacket(DecodeSubPacketManager &subPacketManager); |
| 143 | |
| 144 | #if USE_CODECHAL_DEBUG_TOOL |
| 145 | //! \brief Dump the parameters |
| 146 | //! |
| 147 | //! \return MOS_STATUS |
| 148 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 149 | //! |
| 150 | MOS_STATUS DumpParams(VvcBasicFeature &basicFeature); |
| 151 | |
| 152 | //! \brief Dump the picture parameters |
| 153 | //! |
| 154 | //! \param [in] picParams |
| 155 | //! Pointer to CodecVvcPicParams |
| 156 | //! |
| 157 | //! \return MOS_STATUS |
| 158 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 159 | //! |
| 160 | MOS_STATUS DumpPicParams( |
| 161 | CodecVvcPicParams *picParams, |
| 162 | bool shortFormatInUse); |
| 163 | |
| 164 | //! \brief Dump the APS ALF parameters |
| 165 | //! |
| 166 | //! \param [in] alfDataBuf |
| 167 | //! Pointer to an array of CodecVvcAlfData |
| 168 | //! \param [in] numAlf |
| 169 | //! Number of ALF |
| 170 | //! |
| 171 | //! \return MOS_STATUS |
| 172 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 173 | //! |
| 174 | MOS_STATUS DumpApsAlfData( |
| 175 | CodecVvcAlfData *alfDataBuf, |
| 176 | uint32_t numAlf); |
| 177 | |
| 178 | //! \brief Dump the APS ALF parameters |
| 179 | //! |
| 180 | //! \param [in] lmcsDataBuf |
| 181 | //! Pointer to an array of CodecVvcLmcsData |
| 182 | //! \param [in] numLmcs |
| 183 | //! Number of LMCS |
| 184 | //! |
| 185 | //! \return MOS_STATUS |
| 186 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 187 | //! |
| 188 | MOS_STATUS DumpApsLmcsData( |
| 189 | CodecVvcLmcsData *lmcsDataBuf, |
| 190 | uint32_t numLmcs); |
| 191 | |
| 192 | //! \brief Dump the APS quant matrix parameters |
| 193 | //! |
| 194 | //! \param [in] quantMatrixBuf |
| 195 | //! Pointer to an array of CodecVvcQmData |
| 196 | //! \param [in] numScalingList |
| 197 | //! Number of scaling list |
| 198 | //! |
| 199 | //! \return MOS_STATUS |
| 200 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 201 | //! |
| 202 | MOS_STATUS DumpApsQuantMatrix( |
| 203 | CodecVvcQmData *quantMatrixBuf, |
| 204 | uint32_t numScalingList); |
| 205 | |
| 206 | //! \brief Dump the tile parameters |
| 207 | //! |
| 208 | //! \param [in] tileParams |
| 209 | //! Pointer to an array of CodecVvcTileParam |
| 210 | //! \param [in] numElements |
| 211 | //! Number of dimention value |
| 212 | //! |
| 213 | //! \return MOS_STATUS |
| 214 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 215 | //! |
| 216 | MOS_STATUS DumpTileParams( |
| 217 | CodecVvcTileParam *tileParams, |
| 218 | uint32_t numElements); |
| 219 | |
| 220 | //! \brief Dump the subpic parameters |
| 221 | //! |
| 222 | //! \param [in] subpicParamsBuf |
| 223 | //! Pointer to an array of CodecVvcSubpicParam |
| 224 | //! \param [in] numSubpics |
| 225 | //! Number of subpics |
| 226 | //! |
| 227 | //! \return MOS_STATUS |
| 228 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 229 | //! |
| 230 | MOS_STATUS DumpSubpicParams( |
| 231 | CodecVvcSubpicParam *subpicParamsBuf, |
| 232 | uint32_t numSubpics); |
| 233 | |
| 234 | //! \brief Dump the slice parameters |
| 235 | //! |
| 236 | //! \param [in] sliceStructParamsBuf |
| 237 | //! Pointer to an array of CodecVvcSliceStructure |
| 238 | //! \param [in] numSlcStruct |
| 239 | //! Number of slice structs |
| 240 | //! |
| 241 | //! \return MOS_STATUS |
| 242 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 243 | //! |
| 244 | MOS_STATUS DumpSliceStructParams( |
| 245 | CodecVvcSliceStructure *sliceStructParamsBuf, |
| 246 | uint32_t numSlcStruct); |
| 247 | |
| 248 | //! \brief Dump the RPL parameters |
| 249 | //! |
| 250 | //! \param [in] rplParams |
| 251 | //! Pointer to an array of CodecVvcRplStructure |
| 252 | //! \param [in] numRpls |
| 253 | //! Number of RPLs |
| 254 | //! |
| 255 | //! \return MOS_STATUS |
| 256 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 257 | //! |
| 258 | MOS_STATUS DumpRplStructParams( |
| 259 | CodecVvcRplStructure *rplParams, |
| 260 | uint32_t numRpls, |
| 261 | bool shortFormatInUse); |
| 262 | |
| 263 | //! \brief Dump the slice control parameters |
| 264 | //! |
| 265 | //! \param [in] sliceParams |
| 266 | //! Pointer to an array of CodecVvcSliceParams |
| 267 | //! \param [in] numSlices |
| 268 | //! Number of slices |
| 269 | //! \param [in] shortFormatInUse |
| 270 | //! short format flag |
| 271 | //! |
| 272 | //! \return MOS_STATUS |
| 273 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 274 | //! |
| 275 | MOS_STATUS DumpSliceParams( |
| 276 | CodecVvcSliceParams* sliceParams, |
| 277 | uint32_t numSlices, |
| 278 | bool shortFormatInUse); |
| 279 | #endif |
| 280 | |
| 281 | //! |
| 282 | //! \brief Active decode packets |
| 283 | //! \return MOS_STATUS |
| 284 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 285 | //! |
| 286 | MOS_STATUS ActivateDecodePackets(); |
| 287 | |
| 288 | //! |
| 289 | //! \brief Create VVC Decode feature manager for Gen12 |
| 290 | //! \return MOS_STATUS |
| 291 | //! MOS_STATUS_SUCCESS if success, else fail reason |
| 292 | //! |
| 293 | MOS_STATUS CreateFeatureManager() override; |
| 294 | |
| 295 | virtual MOS_STATUS AllocateResources(VvcBasicFeature &basicFeature); |
| 296 | |
| 297 | |
| 298 | |
| 299 | private: |
| 300 | CodechalHwInterfaceNext* m_hwInterface = nullptr; |
| 301 | |
| 302 | |
| 303 | protected: |
| 304 | VvcBasicFeature *m_basicFeature = nullptr; //!< VVC Basic Feature |
| 305 | uint16_t m_passNum = 1; //!< Decode pass number |
| 306 | bool m_isFirstSliceInFrm = true; //!< First tile in the first frame |
| 307 | BatchBufferArray *m_sliceLevelBBArray = nullptr; //!< Point to slice level batch buffer |
| 308 | BatchBufferArray *m_tileLevelBBArray = nullptr; //!< Pointer to third level batch buffer |
| 309 | uint32_t m_sliceLvlBufSize = 0; |
| 310 | uint32_t m_tileLvlBufSize = 0; |
| 311 | VvcDecodePkt *m_vvcDecodePkt = nullptr; //!< VVC decode packet |
| 312 | CmdPacket *m_vvcDecodeS2LPkt = nullptr; //!< VVC decode S2L packet |
| 313 | |
| 314 | MEDIA_CLASS_DEFINE_END(decode__VvcPipeline) |
| 315 | }; |
| 316 | |
| 317 | #if USE_CODECHAL_DEBUG_TOOL |
| 318 | void DumpDecodeVvcPicParams(CodecVvcPicParams *picParams, std::string fileName, bool shortFormatInUse); |
| 319 | void DumpDecodeVvcAlfParams(CodecVvcAlfData *alfDataBuf, uint32_t numAlf, std::string fileName); |
| 320 | void DumpDecodeVvcLmcsParams(CodecVvcLmcsData *lmcsDataBuf, uint32_t numLmcs, std::string fileName); |
| 321 | void DumpDecodeVvcIqParams(CodecVvcQmData *quantMatrixBuf, uint32_t numScalingList, std::string fileName); |
| 322 | void DumpDecodeVvcTileParams(CodecVvcTileParam *tileParams, uint32_t numElements, std::string fileName); |
| 323 | void DumpDecodeVvcSubpicParams(CodecVvcSubpicParam *subpicParamsBuf, uint32_t numSubpics, std::string fileName); |
| 324 | void DumpDecodeVvcSliceStructureParams(CodecVvcSliceStructure *sliceStructParamsBuf, uint32_t numSlcStruct, std::string fileName); |
| 325 | void DumpDecodeVvcRplStructureParams(CodecVvcRplStructure *rplParams, uint32_t numRpls, std::string fileName); |
| 326 | void DumpDecodeVvcSliceParams(CodecVvcSliceParams *sliceParams, uint32_t numSlices, std::string fileName, bool shortFormatInUse); |
| 327 | #endif |
| 328 | } |
| 329 | #endif // !__DECODE_VVC_PIPELINE_H__ |