Debian Codegraph @

media_softlet/agnostic/common/shared/pipeline/media_pipeline.h

raw
1 /*
2 * Copyright (c) 2018-2020, 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 //!
24 //! \file media_pipeline.h
25 //! \brief Defines the common interface for media pipeline
26 //! \details The media pipeline interface is further sub-divided by component,
27 //! this file is for the base interface which is shared by all components.
28 //!
29
30 #ifndef __MEDIA_PIPELINE_H__
31 #define __MEDIA_PIPELINE_H__
32 #include <map>
33 #include <functional>
34 #include "mos_defs.h"
35 #include "mos_os.h"
36 #include "media_task.h"
37 #include "media_context.h"
38 #include "media_status_report.h"
39 #include "media_feature_manager.h"
40 #include "media_perf_profiler.h"
41 #include "media_copy_wrapper.h"
42 #include "media_user_setting.h"
43 class MediaPacket;
44 class CodechalDebugInterface;
45 class MediaPipeline
46 {
47 public:
48 //!
49 //! \brief Media pipeline constructor
50 //! \param [in] osInterface
51 //! Pointer to MOS_INTERFACE
52 //!
53 MediaPipeline(PMOS_INTERFACE osInterface);
54
55 //!
56 //! \brief Media pipeline destructor
57 //!
58 virtual ~MediaPipeline();
59
60 //!
61 //! \brief Initialize the media pipeline
62 //! \return MOS_STATUS
63 //! MOS_STATUS_SUCCESS if success, else fail reason
64 //!
65 virtual MOS_STATUS Init(void *settings) = 0;
66
67 //!
68 //! \brief Prepare interal parameters, should be invoked for each frame
69 //! \param [in] params
70 //! Pointer to the input parameters
71 //! \return MOS_STATUS
72 //! MOS_STATUS_SUCCESS if success, else fail reason
73 //!
74 virtual MOS_STATUS Prepare(void *params) = 0;
75
76 //!
77 //! \brief Finish the execution for each frame
78 //! \return MOS_STATUS
79 //! MOS_STATUS_SUCCESS if success, else fail reason
80 //!
81 virtual MOS_STATUS Execute() = 0;
82
83 //!
84 //! \brief Get media pipeline execution status
85 //! \param [out] status
86 //! The point to encode status
87 //! \param [in] numStatus
88 //! The requested number of status reports
89 //! \return MOS_STATUS
90 //! MOS_STATUS_SUCCESS if success, else fail reason
91 //!
92 virtual MOS_STATUS GetStatusReport(void *status, uint16_t numStatus) = 0;
93
94 //!
95 //! \brief Destory the media pipeline and release internal resources
96 //! \return MOS_STATUS
97 //! MOS_STATUS_SUCCESS if success, else fail reason
98 //!
99 virtual MOS_STATUS Destroy() = 0;
100
101 //!
102 //! \brief Delete the packet
103 //! \return MOS_STATUS
104 //! MOS_STATUS_SUCCESS if success, else fail reason
105 //!
106 virtual MOS_STATUS DeletePackets();
107
108 //!
109 //! \brief Delete the tasks
110 //! \return MOS_STATUS
111 //! MOS_STATUS_SUCCESS if success, else fail reason
112 //!
113 virtual MOS_STATUS DeleteTasks();
114
115 MediaStatusReport* GetStatusReportInstance() { return m_statusReport; }
116
117 MediaContext *GetMediaContext() { return m_mediaContext; }
118 virtual MediaFeatureManager *GetFeatureManager() { return m_featureManager; };
119
120 std::shared_ptr<MediaFeatureManager::ManagerLite> GetPacketLevelFeatureManager(int packetId) { return m_featureManager->GetPacketLevelFeatureManager(packetId); }
121
122 MediaScalability* &GetMediaScalability() { return m_scalability; }
123
124 MediaUserSettingSharedPtr GetUserSetting() { return m_userSettingPtr; }
125
126 //!
127 //! \brief Get if frame tracking is enabled from scalability
128 //! \return bool
129 //! true if enabled, else false
130 //!
131 bool IsFrameTrackingEnabled();
132
133 protected:
134 //!
135 //! \brief User Feature Key Report
136 //! \return MOS_STATUS
137 //! MOS_STATUS_SUCCESS if success, else fail reason
138 //!
139 virtual MOS_STATUS UserFeatureReport();
140
141 //!
142 //! \brief Initialize the platform infos
143 //! \return MOS_STATUS
144 //! MOS_STATUS_SUCCESS if success, else fail reason
145 //!
146 virtual MOS_STATUS InitPlatform();
147
148 //!
149 //! \brief Get or create packet based on packet ID
150 //! \param [in] packetId
151 //! Packet Id
152 //! \return MediaPacket *
153 //! Pointer to packet
154 //!
155 MediaPacket *GetOrCreate(uint32_t packetId);
156
157 //!
158 //! \brief Register packets into packet pool
159 //! \param [in] packetId
160 //! Packet Id
161 //! \param [in] packet
162 //! Pointer to created packet
163 //! \return MOS_STATUS
164 //! MOS_STATUS_SUCCESS if success, else fail reason
165 //!
166 MOS_STATUS RegisterPacket(uint32_t packetId, MediaPacket* packet);
167
168 //!
169 //! \brief Register packets into packet pool
170 //! \param [in] packetId
171 //! Packet Id
172 //! \param [in] creator
173 //! Packet creator
174 //! \return void
175 //! No return value
176 //!
177 void RegisterPacket(uint32_t packetId, std::function<MediaPacket *()> &&creator)
178 {
179 m_packetCreators[packetId] = creator; // insert if key does not exist
180 }
181
182 //!
183 //! \brief Retrieve the task with given Id
184 //! \param [in] taskId
185 //! Task Id
186 //! \return MediaTask*
187 //! Pointer to media task if success, else nullptr
188 //!
189 MediaTask* GetTask(MediaTask::TaskType type);
190
191 //!
192 //! \brief Activate packet and add it to active packet list
193 //! \param [in] packetId
194 //! Packet Id
195 //! \param [in] immediateSubmit
196 //! Indicate if this packet to activate is needed to submit immediately after been added to task
197 //! \param [in] pass
198 //! pass belongs to the Packet
199 //! \param [in] pipe
200 //! pipe belongs to the Packet
201 //! \param [in] pipe numbers
202 //! pipe numbers the Packet needs to use
203 //! \return MOS_STATUS
204 //! MOS_STATUS_SUCCESS if success, else fail reason
205 //!
206 MOS_STATUS ActivatePacket(uint32_t packetId, bool immediateSubmit, uint16_t pass, uint8_t pipe, uint8_t pipeNum = 1, uint8_t subPass = 0, uint8_t rowNum = 0);
207
208 //!
209 //! \brief Activate packet and add it to active packet list
210 //! \param [in] packetId
211 //! Packet Id
212 //! \param [in] immediateSubmit
213 //! Indicate if this packet to activate is needed to submit immediately after been added to task
214 //! \param [in] stateProperty
215 //! State property of packet
216 //! \return MOS_STATUS
217 //! MOS_STATUS_SUCCESS if success, else fail reason
218 //!
219 MOS_STATUS ActivatePacket(uint32_t packetId, bool immediateSubmit, StateParams &stateProperty);
220
221 //!
222 //! \brief Finish the active packets execution
223 //! \return MOS_STATUS
224 //! MOS_STATUS_SUCCESS if success, else fail reason
225 //!
226 virtual MOS_STATUS ExecuteActivePackets();
227
228 //!
229 //! \brief Create task and add into packet pool
230 //! \param [in] type
231 //! Task type
232 //! \return MediaTask*
233 //! pointer to MediaTask
234 //!
235 MediaTask* CreateTask(MediaTask::TaskType type);
236
237 //!
238 //! \brief create media feature manager
239 //! \return MOS_STATUS
240 //! MOS_STATUS_SUCCESS if success, else fail reason
241 //!
242 virtual MOS_STATUS CreateFeatureManager();
243
244 //!
245 //! \brief Create media copy wrapper
246 //! \return MOS_STATUS
247 //! MOS_STATUS_SUCCESS if success, else fail reason
248 //!
249 virtual MOS_STATUS CreateMediaCopyWrapper();
250
251 //!
252 //! \brief media user setting
253 //! \return MOS_STATUS
254 //! MOS_STATUS_SUCCESS if success, else fail reason
255 //!
256 virtual MOS_STATUS InitUserSetting(MediaUserSettingSharedPtr userSettingPtr);
257
258 protected:
259 PMOS_INTERFACE m_osInterface = nullptr; //!< OS interface
260 CodechalDebugInterface *m_debugInterface = nullptr; //!< Interface used for debug dumps
261 PLATFORM m_platform = {}; //!< The platorm info
262 MEDIA_FEATURE_TABLE *m_skuTable = nullptr; //!< SKU table
263 MEDIA_WA_TABLE *m_waTable = nullptr; //!< WA table
264 MEDIA_SYSTEM_INFO *m_gtSystemInfo = nullptr; //!< GT system infomation
265
266 MediaScalability *m_scalability = nullptr;
267 MediaContext *m_mediaContext = nullptr;
268 MediaStatusReport *m_statusReport = nullptr;
269 MediaFeatureManager *m_featureManager = nullptr;
270 MediaCopyWrapper *m_mediaCopyWrapper = nullptr;
271
272 std::map<uint32_t, MediaPacket *> m_packetList; //!< Packets list
273 std::map<uint32_t, std::function<MediaPacket *()>> m_packetCreators; //!< Packets creators
274 std::vector<PacketProperty> m_activePacketList; //!< Active packets property list
275 std::map<MediaTask::TaskType, MediaTask *> m_taskList; //!< Task list
276 MediaUserSettingSharedPtr m_userSettingPtr = nullptr; //!< usersettingInstance
277 MEDIA_CLASS_DEFINE_END(MediaPipeline)
278 };
279 #endif // !__MEDIA_PIPELINE_H__