Debian Codegraph @

media_softlet/agnostic/common/codec/hal/dec/av1/packet/decode_av1_packet.h

raw
1 /*
2 * Copyright (c) 2021, 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_av1_packet.h
24 //! \brief Defines the implementation of av1 decode packet
25 //!
26
27 #ifndef __DECODE_AV1_PACKET_H__
28 #define __DECODE_AV1_PACKET_H__
29
30 #include "media_cmd_packet.h"
31 #include "decode_av1_pipeline.h"
32 #include "decode_utils.h"
33 #include "decode_av1_basic_feature.h"
34 #include "decode_status_report.h"
35 #include "decode_av1_picture_packet.h"
36 #include "decode_av1_tile_packet.h"
37 #ifdef _DECODE_PROCESSING_SUPPORTED
38 #include "decode_av1_aqm_packet.h"
39 #endif
40
41 namespace decode
42 {
43
44 class Av1DecodeDebugPkt;
45
46 class Av1DecodePkt : public CmdPacket, public MediaStatusReportObserver
47 {
48 public:
49 Av1DecodePkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext*hwInterface)
50 : CmdPacket(task)
51 {
52 if (pipeline != nullptr)
53 {
54 m_statusReport = pipeline->GetStatusReportInstance();
55 m_featureManager = pipeline->GetFeatureManager();
56 m_av1Pipeline = dynamic_cast<Av1Pipeline*>(pipeline);
57 }
58 if (hwInterface != nullptr)
59 {
60 m_hwInterface = hwInterface;
61 m_miItf = std::static_pointer_cast<mhw::mi::Itf>(hwInterface->GetMiInterfaceNext());
62 m_osInterface = hwInterface->GetOsInterface();
63 m_vdencItf = std::static_pointer_cast<mhw::vdbox::vdenc::Itf>(hwInterface->GetVdencInterfaceNext());
64 }
65 }
66 virtual ~Av1DecodePkt() {};
67
68 //!
69 //! \brief Initialize the media packet, allocate required resources
70 //! \return MOS_STATUS
71 //! MOS_STATUS_SUCCESS if success, else fail reason
72 //!
73 virtual MOS_STATUS Init() override;
74
75 //!
76 //! \brief Prepare interal parameters, should be invoked for each frame
77 //! \return MOS_STATUS
78 //! MOS_STATUS_SUCCESS if success, else fail reason
79 //!
80 virtual MOS_STATUS Prepare() override;
81
82 //!
83 //! \brief Destroy the media packet and release the resources
84 //! \return MOS_STATUS
85 //! MOS_STATUS_SUCCESS if success, else fail reason
86 //!
87 virtual MOS_STATUS Destroy() override;
88
89 //!
90 //! \brief One frame is completed
91 //! \param [in] mfxStatus
92 //! pointer to status buffer which for mfx
93 //! \param [in] rcsStatus
94 //! pointer to status buffer which for RCS
95 //! \param [in, out] statusReport
96 //! pointer of DecoderStatusReport
97 //! \return MOS_STATUS
98 //! MOS_STATUS_SUCCESS if success, else fail reason
99 //!
100 virtual MOS_STATUS Completed(void *mfxStatus, void *rcsStatus, void *statusReport) override;
101
102 //!
103 //! \brief Calculate Command Size
104 //!
105 //! \param [in, out] commandBufferSize
106 //! requested size
107 //! \param [in, out] requestedPatchListSize
108 //! requested size
109 //! \return MOS_STATUS
110 //! status
111 //!
112 MOS_STATUS CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize) override;
113
114 //!
115 //! \brief Get Packet Name
116 //! \return std::string
117 //!
118 virtual std::string GetPacketName() override
119 {
120 return "AV1_DECODE";
121 }
122
123 PMHW_BATCH_BUFFER GetSecondLvlBB() { return m_batchBuf; };
124
125 protected:
126 //!
127 //! \brief Calculate Command Buffer Size
128 //!
129 //! \return uint32_t
130 //! Command buffer size calculated
131 //!
132 virtual uint32_t CalculateCommandBufferSize();
133
134 //!
135 //! \brief Calculate Patch List Size
136 //!
137 //! \return uint32_t
138 //! Patchlist size calculated
139 //!
140 virtual uint32_t CalculatePatchListSize();
141
142 void SetPerfTag(CODECHAL_MODE mode, uint16_t picCodingType);
143 bool IsPrologRequired();
144
145 // TODO, rafactor these functions when Mi MHW softlet enabled
146 MOS_STATUS SendPrologWithFrameTracking(MOS_COMMAND_BUFFER &cmdBuffer, bool frameTrackingRequested);
147 MOS_STATUS VdPipelineFlush(MOS_COMMAND_BUFFER & cmdBuffer);
148 MOS_STATUS MiFlush(MOS_COMMAND_BUFFER & cmdBuffer);
149 MOS_STATUS AddForceWakeup(MOS_COMMAND_BUFFER &cmdBuffer);
150
151 virtual MOS_STATUS ReadAvpStatus(MediaStatusReport* statusReport, MOS_COMMAND_BUFFER& cmdBuffer);
152 virtual MOS_STATUS StartStatusReport(uint32_t srType, MOS_COMMAND_BUFFER* cmdBuffer) override;
153 virtual MOS_STATUS EndStatusReport(uint32_t srType, MOS_COMMAND_BUFFER* cmdBuffer) override;
154
155 //!
156 //! \brief Status report per tile
157 //! \param [in] cmdBuffer
158 //! Command buffer
159 //! \param [in] idx
160 //! Tile index
161 //! \return MOS_STATUS
162 //! MOS_STATUS_SUCCESS if success, else fail reason
163 //!
164 MOS_STATUS StatusReportPerTile(MOS_COMMAND_BUFFER *cmdBuffer, int16_t idx);
165
166 MOS_STATUS InitPicLevelCmdBuffer(MHW_BATCH_BUFFER &batchBuffer, uint8_t *batchBufBase);
167
168 MediaFeatureManager *m_featureManager = nullptr;
169 Av1Pipeline *m_av1Pipeline = nullptr;
170 DecodeAllocator *m_allocator = nullptr;
171 Av1BasicFeature *m_av1BasicFeature = nullptr;
172 CodechalHwInterfaceNext *m_hwInterface = nullptr;
173 DecodeMemComp *m_mmcState = nullptr;
174
175 Av1DecodePicPkt *m_picturePkt = nullptr;
176 Av1DecodeTilePkt *m_tilePkt = nullptr;
177 #ifdef _DECODE_PROCESSING_SUPPORTED
178 Av1DecodeAqmPkt *m_aqmPkt = nullptr;
179 #endif
180 bool m_isLastTileInPartialFrm = false;
181 bool m_isFirstTileInPartialFrm = false;
182
183 // Parameters passed from application
184 const CodecAv1PicParams *m_av1PicParams = nullptr; //!< Pointer to picture parameter
185
186 uint32_t m_pictureStatesSize = 0;
187 uint32_t m_picturePatchListSize = 0;
188 uint32_t m_tileStatesSize = 0;
189 uint32_t m_tilePatchListSize = 0;
190 #ifdef _DECODE_PROCESSING_SUPPORTED
191 uint32_t m_aqmStatesSize = 0;
192 uint32_t m_aqmPatchListSize = 0;
193 #endif
194
195 BatchBufferArray *m_secondLevelBBArray = nullptr; //!< Point to second level batch buffer
196 MOS_COMMAND_BUFFER m_picCmdBuffer;
197 PMHW_BATCH_BUFFER m_batchBuf = nullptr;
198 std::shared_ptr<mhw::vdbox::vdenc::Itf> m_vdencItf = nullptr;
199
200 private:
201 Av1DecodeDebugPkt *m_av1DebugPkt = nullptr; //!< AV1 debug packet for debug functionality
202
203 MEDIA_CLASS_DEFINE_END(decode__Av1DecodePkt)
204 };
205
206 } // namespace decode
207 #endif // !__DECODE_AV1_PACKET_H__
208