Debian Codegraph @

media_softlet/agnostic/common/codec/hal/dec/vvc/packet/decode_vvc_packet.h

raw
1 /*
2 * Copyright (c) 2021-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_vvc_packet.h
24 //! \brief Defines the implementation of VVC decode packet
25 //!
26
27 #ifndef __DECODE_VVC_PACKET_H__
28 #define __DECODE_VVC_PACKET_H__
29
30 #include "media_cmd_packet.h"
31 #include "decode_vvc_pipeline.h"
32 #include "decode_utils.h"
33 #include "decode_status_report.h"
34 #include "decode_vvc_basic_feature.h"
35 #include "decode_vvc_picture_packet.h"
36 #include "decode_vvc_slice_packet.h"
37 #include "mhw_vdbox_vvcp_itf.h"
38
39 namespace decode
40 {
41 class VvcPipeline;
42 class VvcDecodePicPkt;
43 class VvcDecodeDebugPkt;
44 class VvcDecodePkt : public CmdPacket, public MediaStatusReportObserver
45 {
46 public:
47 VvcDecodePkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface)
48 : CmdPacket(task)
49 {
50 if (pipeline != nullptr)
51 {
52 m_statusReport = pipeline->GetStatusReportInstance();
53 m_featureManager = pipeline->GetFeatureManager();
54 m_vvcPipeline = dynamic_cast<VvcPipeline*>(pipeline);
55 }
56 if (hwInterface != nullptr)
57 {
58 m_hwInterface = hwInterface;
59 m_osInterface = hwInterface->GetOsInterface();
60 m_miItf = std::static_pointer_cast<mhw::mi::Itf>(hwInterface->GetMiInterfaceNext());
61 m_vdencItf = std::static_pointer_cast<mhw::vdbox::vdenc::Itf>(hwInterface->GetVdencInterfaceNext());
62 if (m_hwInterface != nullptr)
63 {
64 m_vvcpItf = std::static_pointer_cast<mhw::vdbox::vvcp::Itf>(m_hwInterface->GetVvcpInterfaceNext());
65 }
66 }
67 }
68 virtual ~VvcDecodePkt(){};
69
70 //!
71 //! \brief Initialize the media packet, allocate required resources
72 //! \return MOS_STATUS
73 //! MOS_STATUS_SUCCESS if success, else fail reason
74 //!
75 virtual MOS_STATUS Init() override;
76
77 //!
78 //! \brief Prepare interal parameters, should be invoked for each frame
79 //! \return MOS_STATUS
80 //! MOS_STATUS_SUCCESS if success, else fail reason
81 //!
82 virtual MOS_STATUS Prepare() override;
83
84 //!
85 //! \brief Destroy the media packet and release the resources
86 //! \return MOS_STATUS
87 //! MOS_STATUS_SUCCESS if success, else fail reason
88 //!
89 virtual MOS_STATUS Destroy() override;
90
91 //!
92 //! \brief One frame is completed
93 //! \param [in] mfxStatus
94 //! pointer to status buffer which for mfx
95 //! \param [in] rcsStatus
96 //! pointer to status buffer which for RCS
97 //! \param [in, out] statusReport
98 //! pointer of DecoderStatusReport
99 //! \return MOS_STATUS
100 //! MOS_STATUS_SUCCESS if success, else fail reason
101 //!
102 virtual MOS_STATUS Completed(void *mfxStatus, void *rcsStatus, void *statusReport) override;
103
104 //!
105 //! \brief Calculate Command Size
106 //!
107 //! \param [in, out] commandBufferSize
108 //! requested size
109 //! \param [in, out] requestedPatchListSize
110 //! requested size
111 //! \return MOS_STATUS
112 //! status
113 //!
114 MOS_STATUS CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize) override;
115
116 //!
117 //! \brief Get Packet Name
118 //! \return std::string
119 //!
120 virtual std::string GetPacketName() override
121 {
122 return "VVC_DECODE";
123 }
124
125 PMHW_BATCH_BUFFER GetPictureLvlBB() { return m_picBatchBuf; };
126
127 //!
128 //! \brief Add the command sequence into the commandBuffer and
129 //! and return to the caller task
130 //! \param [in] commandBuffer
131 //! Pointer to the command buffer which is allocated by caller
132 //! \return MOS_STATUS
133 //! MOS_STATUS_SUCCESS if success, else fail reason
134 //!
135 virtual MOS_STATUS Submit(MOS_COMMAND_BUFFER* commandBuffer, uint8_t packetPhase = otherPacket) override;
136
137 protected:
138 //!
139 //! \brief Calculate Command Buffer Size
140 //!
141 //! \return uint32_t
142 //! Command buffer size calculated
143 //!
144 virtual uint32_t CalculateCommandBufferSize();
145
146 //!
147 //! \brief Calculate Patch List Size
148 //!
149 //! \return uint32_t
150 //! Patchlist size calculated
151 //!
152 virtual uint32_t CalculatePatchListSize();
153
154 //!
155 //! \brief Calculate pic-level command size
156 //! \return uint32_t
157 //! Pic-level command size calculated
158 //!
159 virtual uint32_t CalculatePicCommandSize();
160
161 //!
162 //! \brief Calculate pic-level patch list size
163 //! \return uint32_t
164 //! Pic-level patch list size calculated
165 //!
166 virtual uint32_t CalculatePicPatchListSize();
167
168 void CalculateVvcSliceLvlCmdSize();
169
170 void SetPerfTag(CODECHAL_MODE mode, uint16_t picCodingType);
171 bool IsPrologRequired();
172 MOS_STATUS SendPrologWithFrameTracking(MOS_COMMAND_BUFFER &cmdBuffer, bool frameTrackingRequested);
173 MOS_STATUS VdPipelineFlush(MOS_COMMAND_BUFFER & cmdBuffer);
174 MOS_STATUS MiFlush(MOS_COMMAND_BUFFER & cmdBuffer);
175 MOS_STATUS AddForceWakeup(MOS_COMMAND_BUFFER &cmdBuffer);
176
177 virtual MOS_STATUS ReadVvcpStatus(MediaStatusReport* statusReport, MOS_COMMAND_BUFFER& cmdBuffer);
178 virtual MOS_STATUS StartStatusReport(uint32_t srType, MOS_COMMAND_BUFFER* cmdBuffer) override;
179 virtual MOS_STATUS EndStatusReport(uint32_t srType, MOS_COMMAND_BUFFER* cmdBuffer) override;
180
181 MOS_STATUS InitPicLevelCmdBuffer(MHW_BATCH_BUFFER &batchBuffer, uint8_t *batchBufBase);
182
183 #if USE_CODECHAL_DEBUG_TOOL
184 //! \brief Dump the output resources in status report callback function
185 //!
186 //! \param [in] decodeStatusMfx
187 //! Pointer to decoder status for vdbox
188 //! \param [in] statusReportData
189 //! Pointer to decoder status report data
190 //!
191 //! \return MOS_STATUS
192 //! MOS_STATUS_SUCCESS if success, else fail reason
193 //!
194 MOS_STATUS DumpResources(
195 DecodeStatusMfx *decodeStatusMfx,
196 DecodeStatusReportData *statusReportData);
197 #endif
198
199 MOS_STATUS PackPictureLevelCmds(MOS_COMMAND_BUFFER &cmdBuffer);
200 MOS_STATUS PackSliceLevelCmds(MOS_COMMAND_BUFFER &cmdBuffer);
201 MOS_STATUS PackS2LSliceLevelCmds(MOS_COMMAND_BUFFER &cmdBuffer);
202 MOS_STATUS VdMemoryFlush(MOS_COMMAND_BUFFER &cmdBuffer);
203 MOS_STATUS EnsureAllCommandsExecuted(MOS_COMMAND_BUFFER &cmdBuffer);
204
205 MediaFeatureManager *m_featureManager = nullptr;
206 VvcPipeline *m_vvcPipeline = nullptr;
207 DecodeAllocator *m_allocator = nullptr;
208 VvcBasicFeature *m_vvcBasicFeature = nullptr;
209 DecodeMemComp *m_mmcState = nullptr;
210 VvcDecodePicPkt *m_picturePkt = nullptr;
211 VvcDecodeSlicePkt *m_slicePkt = nullptr;
212 #if (_DEBUG || _RELEASE_INTERNAL)
213 VvcDecodeDebugPkt *m_debugPkt = nullptr; //!< Pointer to debug packet for command counter override
214 uint32_t m_debugStatesSize = 0; //!< Debug packet command buffer size
215 uint32_t m_debugPatchListSize = 0; //!< Debug packet patch list size
216 #endif
217 bool m_isFirstSliceInFrame = true;
218 bool m_isLastSliceInFrame = false;
219 const CodecVvcPicParams *m_vvcPicParams = nullptr; //!< Pointer to picture parameter
220
221 uint32_t m_pictureStatesSize = 0;
222 uint32_t m_picturePatchListSize = 0;
223 uint32_t m_sliceStatesSize = 0;
224 uint32_t m_slicePatchListSize = 0;
225 uint32_t m_tileStateSize = 0;
226 uint32_t m_tilePatchListSize = 0;
227 uint32_t m_vvcpSliceCmdSize = 0; //Slice Lvl Command Size
228
229 MOS_COMMAND_BUFFER m_picCmdBuffer; //!< picture command buffer
230 PMHW_BATCH_BUFFER m_picBatchBuf = nullptr; //!< Pointer to batch buffer
231 bool m_picCmdSizeCalculated = false; //!< flag to indicate if pic-level cmd size is included
232
233 PMHW_BATCH_BUFFER m_tileLevelBB = nullptr;
234 CodechalHwInterfaceNext *m_hwInterface = nullptr;
235 std::shared_ptr<mhw::vdbox::vdenc::Itf> m_vdencItf = nullptr;
236 std::shared_ptr<mhw::vdbox::vvcp::Itf> m_vvcpItf = nullptr;
237
238
239 MEDIA_CLASS_DEFINE_END(decode__VvcDecodePkt)
240 };
241
242 } // namespace decode
243 #endif // !__DECODE_VVC_PACKET_H__
244