Debian Codegraph @

media_softlet/agnostic/common/codec/hal/dec/hevc/pipeline/decode_hevc_pipeline.h

raw
1 /*
2 * Copyright (c) 2018-2025, 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
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 DeclareDecodePacketId(hevcDecodeAqmId);
100 DeclareDecodePacketId(hevcDebugPacketId);
101 DeclareDecodePacketId(hevcDebugSubPacketId);
102
103 protected:
104 //!
105 //! \brief Initialize the decode pipeline
106 //! \param [in] settings
107 //! Pointer to the initialize settings
108 //! \return MOS_STATUS
109 //! MOS_STATUS_SUCCESS if success, else fail reason
110 //!
111 virtual MOS_STATUS Initialize(void *settings) override;
112
113 //!
114 //! \brief Uninitialize the decode pipeline
115 //! \return MOS_STATUS
116 //! MOS_STATUS_SUCCESS if success, else fail reason
117 //!
118 virtual MOS_STATUS Uninitialize() override;
119
120 //!
121 //! \brief Finish the execution for each frame
122 //! \return MOS_STATUS
123 //! MOS_STATUS_SUCCESS if success, else fail reason
124 //!
125 virtual MOS_STATUS Execute() override;
126
127 //!
128 //! \brief User Feature Key Report
129 //! \return MOS_STATUS
130 //! MOS_STATUS_SUCCESS if success, else fail reason
131 //!
132 virtual MOS_STATUS UserFeatureReport() override;
133
134 //!
135 //! \brief create media feature manager
136 //! \return MOS_STATUS
137 //! MOS_STATUS_SUCCESS if success, else fail reason
138 //!
139 virtual MOS_STATUS CreateFeatureManager() override;
140
141 //!
142 //! \brief Create sub packets
143 //! \param [in] codecSettings
144 //! Point to codechal settings
145 //! \return MOS_STATUS
146 //! MOS_STATUS_SUCCESS if success, else fail reason
147 //!
148 virtual MOS_STATUS CreateSubPackets(DecodeSubPacketManager& subPacketManager, CodechalSetting &codecSettings) override;
149
150 //!
151 //! \brief Initialize context option
152 //! \param [in] scalPars
153 //! Hevc scalability parameters
154 //! \return MOS_STATUS
155 //! MOS_STATUS_SUCCESS if success, else fail reason
156 //!
157 virtual MOS_STATUS InitContexOption(HevcScalabilityPars& scalPars);
158
159 //!
160 //! \brief Initialize Hevc decode mode
161 //! \param [in] scalabMode
162 //! Decode scalability mode
163 //! \param [in] basicFeature
164 //! Hevc decode basic feature
165 //! \return MOS_STATUS
166 //! MOS_STATUS_SUCCESS if success, else fail reason
167 //!
168 MOS_STATUS InitDecodeMode(ScalabilityMode scalabMode, HevcBasicFeature &basicFeature);
169
170 //!
171 //! \brief Add one phase with pass number and pipe number
172 //! \param [in] pass
173 //! Pass number for phase
174 //! \param [in] pipe
175 //! Pipe number for phase
176 //! \param [in] activePipeNum
177 //! Acutive pipe number for current pass
178 //! \return MOS_STATUS
179 //! MOS_STATUS_SUCCESS if success, else fail reason
180 //!
181 template<typename T>
182 MOS_STATUS CreatePhase(uint8_t pass = 0, uint8_t pipe = 0, uint8_t activePipeNum = 1);
183
184 //!
185 //! \brief Create hevc decode phase list for current frame
186 //! \param [in] basicFeature
187 //! Hevc decode basic feature
188 //! \param [in] scalabMode
189 //! Decode scalability mode
190 //! \param [in] numPipe
191 //! Number of pipe for currently scalability mode
192 //! \return MOS_STATUS
193 //! MOS_STATUS_SUCCESS if success, else fail reason
194 //!
195 MOS_STATUS CreatePhaseList(HevcBasicFeature &basicFeature, const ScalabilityMode scalabMode, const uint8_t numPipe);
196
197 //!
198 //! \brief Destroy hevc decode phase list
199 //! \return MOS_STATUS
200 //! MOS_STATUS_SUCCESS if success, else fail reason
201 //!
202 MOS_STATUS DestoryPhaseList();
203
204 //!
205 //! \brief Store dest surface to RefList.
206 // If deblocking present with SCC IBC Mode, the reference is temporal surface HevcBasicFeature::m_referenceBeforeLoopFilter,
207 // need to recover with dest surface after decode finished.
208 //! \param [in] basicFeature
209 //! Hevc decode basic feature
210 //! \return MOS_STATUS
211 //! MOS_STATUS_SUCCESS if success, else fail reason
212 //!
213 MOS_STATUS StoreDestToRefList(HevcBasicFeature &basicFeature);
214
215 #if (_DEBUG || _RELEASE_INTERNAL)
216 //!
217 //! \brief Earlier stop for hw error status
218 //! \param [in] status
219 //! Status report from HW
220 //! \return MOS_STATUS
221 //! MOS_STATUS_SUCCESS if success, else fail reason
222 //!
223 virtual MOS_STATUS HwStatusCheck(const DecodeStatusMfx &status) override;
224 #endif
225
226 #if USE_CODECHAL_DEBUG_TOOL
227 //! \brief Dump the picture parameters
228 //!
229 //! \param [in] picParams
230 //! Pointer to CODEC_HEVC_PIC_PARAMS
231 //! \param [in] extPicParams
232 //! Pointer to CODEC_HEVC_EXT_PIC_PARAMS
233 //! \param [in] sccPicParams
234 //! Pointer to CODEC_HEVC_SCC_PIC_PARAMS
235 //!
236 //! \return MOS_STATUS
237 //! MOS_STATUS_SUCCESS if success, else fail reason
238 //!
239 MOS_STATUS DumpPicParams(
240 PCODEC_HEVC_PIC_PARAMS picParams,
241 PCODEC_HEVC_EXT_PIC_PARAMS extPicParams,
242 PCODEC_HEVC_SCC_PIC_PARAMS sccPicParams);
243
244 //! \brief Dump the slice parameters
245 //!
246 //! \param [in] sliceParams
247 //! Pointer to CODEC_HEVC_SLICE_PARAMS
248 //! \param [in] extSliceParams
249 //! Pointer to CODEC_HEVC_EXT_SLICE_PARAMS
250 //! \param [in] numSlices
251 //! Number of slices
252 //! \param [in] shortFormatInUse
253 //! short format flag
254 //!
255 //! \return MOS_STATUS
256 //! MOS_STATUS_SUCCESS if success, else fail reason
257 //!
258 MOS_STATUS DumpSliceParams(
259 PCODEC_HEVC_SLICE_PARAMS sliceParams,
260 PCODEC_HEVC_EXT_SLICE_PARAMS extSliceParams,
261 uint32_t numSlices,
262 bool shortFormatInUse);
263
264 //! \brief Dump the subsets parameters
265 //!
266 //! \param [in] subsetsParams
267 //! Pointer to CODEC_HEVC_SUBSET_PARAMS
268 //!
269 //! \return MOS_STATUS
270 //! MOS_STATUS_SUCCESS if success, else fail reason
271 //!
272 MOS_STATUS DumpSubsetsParams(PCODEC_HEVC_SUBSET_PARAMS subsetsParams);
273
274 //! \brief Dump the quantization matrix parameters
275 //!
276 //! \param [in] matrixData
277 //! Pointer to CODECHAL_HEVC_IQ_MATRIX_PARAMS
278 //!
279 //! \return MOS_STATUS
280 //! MOS_STATUS_SUCCESS if success, else fail reason
281 //!
282 MOS_STATUS DumpIQParams(PCODECHAL_HEVC_IQ_MATRIX_PARAMS matrixData);
283
284 //! \brief Dump the second level batch buffer
285 //!
286 //! \return MOS_STATUS
287 //! MOS_STATUS_SUCCESS if success, else fail reason
288 //!
289 virtual MOS_STATUS DumpSecondLevelBatchBuffer();
290 #endif
291
292 protected:
293 HevcBasicFeature *m_basicFeature = nullptr; //!< Point to hevc basic feature
294
295 HevcDecodeMode m_decodeMode = baseDecodeMode;
296
297 BatchBufferArray *m_secondLevelBBArray = nullptr; //!< Point to second level batch buffer
298 const uint32_t m_secondLevelBBNum = 8; //!< Number of second level batch buffer
299
300 DecodeHevcScalabilityOption m_scalabOption; //!< Hevc decode scalability option
301
302 std::vector<DecodePhase *> m_phaseList; //!< Phase list
303
304 bool m_allowVirtualNodeReassign = false; //!< Whether allow virtual node reassign
305
306 #if (_DEBUG || _RELEASE_INTERNAL)
307 uint32_t m_rtFrameCount = 0; //!< frame count for real tile decoding
308 uint32_t m_vtFrameCount = 0; //!< frame count for virtual tile decoding
309 uint32_t m_spFrameCount = 0; //!< frame count for single pipe decoding
310 bool m_reportHucStatus = false; //!< Flag for reporting huc status to regkey
311 bool m_reportHucCriticalError = false; //!< Flag for reporting huc critical error to regkey
312 #endif
313
314 MEDIA_CLASS_DEFINE_END(decode__HevcPipeline)
315 };
316
317 }
318 #endif // !__DECODE_HEVC_PIPELINE_H__