1 /* 2 * Copyright (c) 2018-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 decode_hevc_pipeline.h 24 //! \brief Defines the interface for hevc decode pipeline 25 //! 26 #ifndef __DECODE_HEVC_PIPELINE_H__ 27 #define __DECODE_HEVC_PIPELINE_H__ 28 29 #include "decode_pipeline.h" 30 #include "decode_hevc_basic_feature.h" 31 #include "decode_hevc_scalability_defs.h" 32 #include "decode_hevc_scalability_option.h" 33 #include "decode_phase.h" 34 35 namespace decode { 36 37 class HevcPipeline : public DecodePipeline 38 { 39 public: 40 enum HevcDecodeMode 41 { 42 baseDecodeMode, //!< Legacy decode mode with single pipe 43 virtualTileDecodeMode, //!< virtual tile decode mode 44 separateTileDecodeMode, //!< IBC/PAL multiple tile decode mode with single pipe 45 realTileDecodeMode, //!< Real tile decode mode 46 }; 47 48 //! 49 //! \brief HevcPipeline constructor 50 //! \param [in] hwInterface 51 //! Pointer to CodechalHwInterface 52 //! \param [in] debugInterface 53 //! Pointer to CodechalDebugInterface 54 //! 55 HevcPipeline(CodechalHwInterfaceNext *hwInterface, CodechalDebugInterface *debugInterface); 56 ~HevcPipeline()57 virtual ~HevcPipeline() {} 58 59 //! 60 //! \brief Return if short format decode in use 61 //! \return bool 62 //! True if short format in use, else false 63 //! 64 bool IsShortFormat(); 65 66 //! 67 //! \brief Return the Hevc decode mode 68 //! \return bool 69 //! True if short format in use, else false 70 //! 71 HevcDecodeMode GetDecodeMode(); 72 73 //! \brief Get FE separate submission flag 74 //! \return bool 75 //! Return true if FE separate submission, else return false 76 //! 77 bool IsFESeparateSubmission(); 78 79 //! 80 //! \brief Return the slice level command buffer 81 //! \return MHW_BATCH_BUFFER* 82 //! Point to slice level command buffer if success, else nullptr 83 //! 84 MHW_BATCH_BUFFER* GetSliceLvlCmdBuffer(); 85 //! 86 //! \brief Declare Regkeys in the scope of hevc decode 87 //! \return MOS_STATUS 88 //! MOS_STATUS_SUCCESS if success, else fail reason 89 virtual MOS_STATUS InitUserSetting(MediaUserSettingSharedPtr userSettingPtr) override; 90 91 DeclareDecodePacketId(hucS2lPacketId); 92 DeclareDecodePacketId(hevcLongPacketId); 93 DeclareDecodePacketId(hevcFrontEndPacketId); 94 DeclareDecodePacketId(hevcBackEndPacketId); 95 DeclareDecodePacketId(hevcRealTilePacketId); 96 DeclareDecodePacketId(hevcPictureSubPacketId); 97 DeclareDecodePacketId(hevcSliceSubPacketId); 98 DeclareDecodePacketId(hevcTileSubPacketId); 99 100 protected: 101 //! 102 //! \brief Initialize the decode pipeline 103 //! \param [in] settings 104 //! Pointer to the initialize settings 105 //! \return MOS_STATUS 106 //! MOS_STATUS_SUCCESS if success, else fail reason 107 //! 108 virtual MOS_STATUS Initialize(void *settings) override; 109 110 //! 111 //! \brief Uninitialize the decode pipeline 112 //! \return MOS_STATUS 113 //! MOS_STATUS_SUCCESS if success, else fail reason 114 //! 115 virtual MOS_STATUS Uninitialize() override; 116 117 //! 118 //! \brief Finish the execution for each frame 119 //! \return MOS_STATUS 120 //! MOS_STATUS_SUCCESS if success, else fail reason 121 //! 122 virtual MOS_STATUS Execute() override; 123 124 //! 125 //! \brief User Feature Key Report 126 //! \return MOS_STATUS 127 //! MOS_STATUS_SUCCESS if success, else fail reason 128 //! 129 virtual MOS_STATUS UserFeatureReport() override; 130 131 //! 132 //! \brief create media feature manager 133 //! \return MOS_STATUS 134 //! MOS_STATUS_SUCCESS if success, else fail reason 135 //! 136 virtual MOS_STATUS CreateFeatureManager() override; 137 138 //! 139 //! \brief Create sub packets 140 //! \param [in] codecSettings 141 //! Point to codechal settings 142 //! \return MOS_STATUS 143 //! MOS_STATUS_SUCCESS if success, else fail reason 144 //! 145 virtual MOS_STATUS CreateSubPackets(DecodeSubPacketManager& subPacketManager, CodechalSetting &codecSettings) override; 146 147 //! 148 //! \brief Initialize context option 149 //! \param [in] scalPars 150 //! Hevc scalability parameters 151 //! \return MOS_STATUS 152 //! MOS_STATUS_SUCCESS if success, else fail reason 153 //! 154 virtual MOS_STATUS InitContexOption(HevcScalabilityPars& scalPars); 155 156 //! 157 //! \brief Initialize Hevc decode mode 158 //! \param [in] scalabMode 159 //! Decode scalability mode 160 //! \param [in] basicFeature 161 //! Hevc decode basic feature 162 //! \return MOS_STATUS 163 //! MOS_STATUS_SUCCESS if success, else fail reason 164 //! 165 MOS_STATUS InitDecodeMode(ScalabilityMode scalabMode, HevcBasicFeature &basicFeature); 166 167 //! 168 //! \brief Add one phase with pass number and pipe number 169 //! \param [in] pass 170 //! Pass number for phase 171 //! \param [in] pipe 172 //! Pipe number for phase 173 //! \param [in] activePipeNum 174 //! Acutive pipe number for current pass 175 //! \return MOS_STATUS 176 //! MOS_STATUS_SUCCESS if success, else fail reason 177 //! 178 template<typename T> 179 MOS_STATUS CreatePhase(uint8_t pass = 0, uint8_t pipe = 0, uint8_t activePipeNum = 1); 180 181 //! 182 //! \brief Create hevc decode phase list for current frame 183 //! \param [in] basicFeature 184 //! Hevc decode basic feature 185 //! \param [in] scalabMode 186 //! Decode scalability mode 187 //! \param [in] numPipe 188 //! Number of pipe for currently scalability mode 189 //! \return MOS_STATUS 190 //! MOS_STATUS_SUCCESS if success, else fail reason 191 //! 192 MOS_STATUS CreatePhaseList(HevcBasicFeature &basicFeature, const ScalabilityMode scalabMode, const uint8_t numPipe); 193 194 //! 195 //! \brief Destroy hevc decode phase list 196 //! \return MOS_STATUS 197 //! MOS_STATUS_SUCCESS if success, else fail reason 198 //! 199 MOS_STATUS DestoryPhaseList(); 200 201 //! 202 //! \brief Store dest surface to RefList. 203 // If deblocking present with SCC IBC Mode, the reference is temporal surface HevcBasicFeature::m_referenceBeforeLoopFilter, 204 // need to recover with dest surface after decode finished. 205 //! \param [in] basicFeature 206 //! Hevc decode basic feature 207 //! \return MOS_STATUS 208 //! MOS_STATUS_SUCCESS if success, else fail reason 209 //! 210 MOS_STATUS StoreDestToRefList(HevcBasicFeature &basicFeature); 211 212 #if (_DEBUG || _RELEASE_INTERNAL) 213 //! 214 //! \brief Earlier stop for hw error status 215 //! \param [in] status 216 //! Status report from HW 217 //! \return MOS_STATUS 218 //! MOS_STATUS_SUCCESS if success, else fail reason 219 //! 220 virtual MOS_STATUS HwStatusCheck(const DecodeStatusMfx &status) override; 221 #endif 222 223 #if USE_CODECHAL_DEBUG_TOOL 224 //! \brief Dump the picture parameters 225 //! 226 //! \param [in] picParams 227 //! Pointer to CODEC_HEVC_PIC_PARAMS 228 //! \param [in] extPicParams 229 //! Pointer to CODEC_HEVC_EXT_PIC_PARAMS 230 //! \param [in] sccPicParams 231 //! Pointer to CODEC_HEVC_SCC_PIC_PARAMS 232 //! 233 //! \return MOS_STATUS 234 //! MOS_STATUS_SUCCESS if success, else fail reason 235 //! 236 MOS_STATUS DumpPicParams( 237 PCODEC_HEVC_PIC_PARAMS picParams, 238 PCODEC_HEVC_EXT_PIC_PARAMS extPicParams, 239 PCODEC_HEVC_SCC_PIC_PARAMS sccPicParams); 240 241 //! \brief Dump the slice parameters 242 //! 243 //! \param [in] sliceParams 244 //! Pointer to CODEC_HEVC_SLICE_PARAMS 245 //! \param [in] extSliceParams 246 //! Pointer to CODEC_HEVC_EXT_SLICE_PARAMS 247 //! \param [in] numSlices 248 //! Number of slices 249 //! \param [in] shortFormatInUse 250 //! short format flag 251 //! 252 //! \return MOS_STATUS 253 //! MOS_STATUS_SUCCESS if success, else fail reason 254 //! 255 MOS_STATUS DumpSliceParams( 256 PCODEC_HEVC_SLICE_PARAMS sliceParams, 257 PCODEC_HEVC_EXT_SLICE_PARAMS extSliceParams, 258 uint32_t numSlices, 259 bool shortFormatInUse); 260 261 //! \brief Dump the subsets parameters 262 //! 263 //! \param [in] subsetsParams 264 //! Pointer to CODEC_HEVC_SUBSET_PARAMS 265 //! 266 //! \return MOS_STATUS 267 //! MOS_STATUS_SUCCESS if success, else fail reason 268 //! 269 MOS_STATUS DumpSubsetsParams(PCODEC_HEVC_SUBSET_PARAMS subsetsParams); 270 271 //! \brief Dump the quantization matrix parameters 272 //! 273 //! \param [in] matrixData 274 //! Pointer to CODECHAL_HEVC_IQ_MATRIX_PARAMS 275 //! 276 //! \return MOS_STATUS 277 //! MOS_STATUS_SUCCESS if success, else fail reason 278 //! 279 MOS_STATUS DumpIQParams(PCODECHAL_HEVC_IQ_MATRIX_PARAMS matrixData); 280 281 //! \brief Dump the second level batch buffer 282 //! 283 //! \return MOS_STATUS 284 //! MOS_STATUS_SUCCESS if success, else fail reason 285 //! 286 virtual MOS_STATUS DumpSecondLevelBatchBuffer(); 287 #endif 288 289 protected: 290 HevcBasicFeature *m_basicFeature = nullptr; //!< Point to hevc basic feature 291 292 HevcDecodeMode m_decodeMode = baseDecodeMode; 293 294 BatchBufferArray *m_secondLevelBBArray = nullptr; //!< Point to second level batch buffer 295 const uint32_t m_secondLevelBBNum = 8; //!< Number of second level batch buffer 296 297 DecodeHevcScalabilityOption m_scalabOption; //!< Hevc decode scalability option 298 299 std::vector<DecodePhase *> m_phaseList; //!< Phase list 300 301 bool m_allowVirtualNodeReassign = false; //!< Whether allow virtual node reassign 302 303 #if (_DEBUG || _RELEASE_INTERNAL) 304 uint32_t m_rtFrameCount = 0; //!< frame count for real tile decoding 305 uint32_t m_vtFrameCount = 0; //!< frame count for virtual tile decoding 306 uint32_t m_spFrameCount = 0; //!< frame count for single pipe decoding 307 bool m_reportHucStatus = false; //!< Flag for reporting huc status to regkey 308 bool m_reportHucCriticalError = false; //!< Flag for reporting huc critical error to regkey 309 #endif 310 311 MEDIA_CLASS_DEFINE_END(decode__HevcPipeline) 312 }; 313 314 } 315 #endif // !__DECODE_HEVC_PIPELINE_H__ 316