Debian Codegraph @

media_softlet/agnostic/common/codec/hal/dec/avc/packet/decode_avc_packet.h

raw
1 /*
2 * Copyright (c) 2018-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_avc_packet.h
24 //! \brief Defines the interface for avc decode packet.
25 //!
26
27 #ifndef __DECODE_AVC_PACKET_H__
28 #define __DECODE_AVC_PACKET_H__
29
30 #include "media_cmd_packet.h"
31 #include "codec_hw_next.h"
32 #include "decode_vdbox_mfx_common.h"
33 #include "decode_avc_basic_feature.h"
34 #include "decode_avc_pipeline.h"
35 #include "decode_utils.h"
36 #include "decode_avc_picture_packet.h"
37 #include "decode_avc_slice_packet.h"
38
39 #if (_DEBUG || _RELEASE_INTERNAL)
40 #include "decode_avc_debug_packet.h"
41 #endif
42
43 namespace decode
44 {
45
46 class AvcDecodeDebugPkt;
47
48 class AvcDecodePkt : public CmdPacket, public MediaStatusReportObserver
49 {
50 public:
51 AvcDecodePkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext*hwInterface)
52 : CmdPacket(task)
53 {
54 if (pipeline != nullptr)
55 {
56 m_statusReport = pipeline->GetStatusReportInstance();
57 m_featureManager = pipeline->GetFeatureManager();
58 m_avcPipeline = dynamic_cast<AvcPipeline *>(pipeline);
59 }
60 if (hwInterface != nullptr)
61 {
62 m_hwInterface = hwInterface;
63 m_miItf = hwInterface->GetMiInterfaceNext();
64 m_osInterface = hwInterface->GetOsInterface();
65 }
66 }
67 virtual ~AvcDecodePkt(){};
68
69 //!
70 //! \brief Initialize the media packet, allocate required resources
71 //! \return MOS_STATUS
72 //! MOS_STATUS_SUCCESS if success, else fail reason
73 //!
74 virtual MOS_STATUS Init() override;
75
76 //!
77 //! \brief Prepare interal parameters, should be invoked for each frame
78 //! \return MOS_STATUS
79 //! MOS_STATUS_SUCCESS if success, else fail reason
80 //!
81 virtual MOS_STATUS Prepare() override;
82
83 //!
84 //! \brief Destroy the media packet and release the resources
85 //! \return MOS_STATUS
86 //! MOS_STATUS_SUCCESS if success, else fail reason
87 //!
88 virtual MOS_STATUS Destroy() override;
89
90 //!
91 //! \brief One frame is completed
92 //! \param [in] mfxStatus
93 //! pointer to status buffer which for mfx
94 //! \param [in] rcsStatus
95 //! pointer to status buffer which for RCS
96 //! \param [in, out] statusReport
97 //! pointer of DecoderStatusReport
98 //! \return MOS_STATUS
99 //! MOS_STATUS_SUCCESS if success, else fail reason
100 //!
101 virtual MOS_STATUS Completed(void *mfxStatus, void *rcsStatus, void *statusReport) override;
102
103 //!
104 //! \brief Calculate Command Size
105 //!
106 //! \param [in, out] commandBufferSize
107 //! requested size
108 //! \param [in, out] requestedPatchListSize
109 //! requested size
110 //! \return MOS_STATUS
111 //! status
112 //!
113 MOS_STATUS CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize) override;
114
115 //!
116 //! \brief Get Packet Name
117 //! \return std::string
118 //!
119 virtual std::string GetPacketName() override
120 {
121 return "AVC_DECODE";
122 }
123
124 protected:
125 //!
126 //! \brief Calculate Command Buffer Size
127 //!
128 //! \return uint32_t
129 //! Command buffer size calculated
130 //!
131 virtual uint32_t CalculateCommandBufferSize();
132
133 //!
134 //! \brief Calculate Patch List Size
135 //!
136 //! \return uint32_t
137 //! Patchlist size calculated
138 //!
139 virtual uint32_t CalculatePatchListSize();
140
141 void SetPerfTag(CODECHAL_MODE mode, uint16_t picCodingType);
142
143 bool IsPrologRequired();
144
145 MOS_STATUS SendPrologWithFrameTracking(MOS_COMMAND_BUFFER &cmdBuffer, bool frameTrackingRequested);
146
147 MOS_STATUS MiFlush(MOS_COMMAND_BUFFER &cmdBuffer);
148
149 MOS_STATUS AddForceWakeup(MOS_COMMAND_BUFFER &cmdBuffer);
150
151 MOS_STATUS ReadMfxStatus(MediaStatusReport *statusReport, MOS_COMMAND_BUFFER &cmdBuffer);
152
153 MOS_STATUS SetCencBatchBuffer(PMOS_COMMAND_BUFFER cmdBuffer);
154
155 virtual MOS_STATUS StartStatusReport(uint32_t srType, MOS_COMMAND_BUFFER *cmdBuffer) override;
156 virtual MOS_STATUS EndStatusReport(uint32_t srType, MOS_COMMAND_BUFFER *cmdBuffer) override;
157
158 MediaFeatureManager * m_featureManager = nullptr;
159 AvcPipeline * m_avcPipeline = nullptr;
160 DecodeAllocator * m_allocator = nullptr;
161 AvcBasicFeature * m_avcBasicFeature = nullptr;
162 CodechalHwInterfaceNext* m_hwInterface = nullptr;
163 DecodeMemComp * m_mmcState = nullptr;
164
165 AvcDecodePicPkt *m_picturePkt = nullptr;
166 AvcDecodeSlcPkt *m_slicePkt = nullptr;
167
168 // Parameters passed from application
169 const CODEC_AVC_PIC_PARAMS *m_avcPicParams = nullptr; //!< Pointer to picture parameter
170
171 uint32_t m_pictureStatesSize = 0;
172 uint32_t m_picturePatchListSize = 0;
173 uint32_t m_sliceStatesSize = 0;
174 uint32_t m_slicePatchListSize = 0;
175
176 #if (_DEBUG || _RELEASE_INTERNAL)
177 AvcDecodeDebugPkt *m_debugPkt = nullptr;
178 #endif
179
180 MEDIA_CLASS_DEFINE_END(decode__AvcDecodePkt)
181 };
182 } // namespace decode
183 #endif // !__DECODE_AVC_PACKET_H__