Debian Codegraph @

media_softlet/agnostic/common/shared/media_sfc_interface/media_sfc_interface.h

raw
1 /*
2 * Copyright (c) 2020-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 media_sfc_interface.h
24 //! \brief Common interface and structure used in sfc interface
25 //! \details Common interface and structure used in sfc interface which are platform independent
26 //!
27 #ifndef __MEDIA_SFC_INTERFACE_H__
28 #define __MEDIA_SFC_INTERFACE_H__
29
30 #include <stdint.h>
31 #include "mos_os_specific.h"
32 #include "media_defs.h"
33 #include "media_common_defs.h"
34 #include "mos_defs.h"
35 #include "mos_defs_specific.h"
36 #include "mos_os.h"
37 #include "mos_resource_defs.h"
38
39 class MediaSfcRender;
40 class MediaMemComp;
41
42 struct VEBOX_SFC_PARAMS
43 {
44 // Input
45 struct
46 {
47 PMOS_SURFACE surface;
48 MEDIA_CSPACE colorSpace; //!< Color Space
49 uint32_t chromaSiting; //!< ChromaSiting
50 RECT rcSrc; //!< rectangle on input surface before scaling.
51 MEDIA_ROTATION rotation; //!< rotation setting
52 } input;
53
54 // Output
55 struct
56 {
57 PMOS_SURFACE surface;
58 MEDIA_CSPACE colorSpace; //!< Color Space
59 uint32_t chromaSiting; //!< ChromaSiting
60 RECT rcDst; //!< rectangle on output surface after scaling.
61 } output;
62 };
63
64 struct SCALABILITY_PARAMS
65 {
66 int32_t numPipe = 1; //!< Number of pipes for scalability
67 int32_t curPipe = 0; //!< Current pipe index
68 // Scalability parameters for HCP-to-SFC mode
69 uint32_t engineMode = 0; //!< 0 - single, 1 - left most column, 2 - right most column, 3 - middle column
70 uint32_t tileType = 0; //!< Real tile = 0, virtual tile = 1
71 uint32_t srcStartX = 0; //!< Source surface column horizontal start position in pixel
72 uint32_t srcEndX = 0; //!< Source surface column horizontal end position in pixel
73 uint32_t dstStartX = 0; //!< Output surface column horizontal start position in pixel
74 uint32_t dstEndX = 0; //!< Output surface column horizontal end position in pixel
75 };
76
77 struct FIELD_PARAMS
78 {
79 bool isFieldToInterleaved = false; //!< true if input being field frame and output being interlaved frame.
80 bool isBottomField = false; //!< true if input frame being bottom field. Valid only when true == isFieldToInterleaved.
81 bool isBottomFirst = false; //!< true if output frame being interlaved frame with bottom first.
82 //!< Valid only when true == isFieldToInterleaved.
83 };
84
85 struct VIDEO_PARAMS
86 {
87 CODECHAL_STANDARD codecStandard;
88 union
89 {
90 struct
91 {
92 CodecDecodeJpegChromaType jpegChromaType;
93 } jpeg;
94 struct
95 {
96 bool deblockingEnabled;
97 } avc, vp8;
98 struct
99 {
100 uint32_t lcuSize;
101 } hevc;
102 struct
103 {
104 uint32_t lcuSize;
105 bool lossless;
106 bool superResInuse;
107 bool intraBC;
108 uint32_t tileCols;
109 uint32_t tileRows;
110 } av1;
111 };
112
113 FIELD_PARAMS fieldParams = {};
114
115 // scalability parameters
116 SCALABILITY_PARAMS scalabilityParams = {};
117 };
118
119 struct VDBOX_SFC_PARAMS
120 {
121 // Input
122 struct
123 {
124 uint32_t width; //!< Effective width of SFC input, which may
125 //!< be smaller than frame width.
126 uint32_t height; //!< Effective height of SFC input, which may
127 //!< be smaller than frame height.
128 uint32_t effectiveWidth; //!< exclude right padding area on input surface,
129 //!< which may be smaller than Effective width.
130 uint32_t effectiveHeight; //!< exclude bottom padding area on input surface,
131 //!< which may be smaller than Effective height.
132 MOS_FORMAT format; //!< Format of SFC input
133 MEDIA_CSPACE colorSpace; //!< Color Space
134 uint32_t chromaSiting; //!< ChromaSiting
135 bool mirrorEnabled; //!< Is mirror needed.
136 } input;
137
138 // Output
139 struct
140 {
141 PMOS_SURFACE surface;
142 PMOS_BUFFER histogramBuf; //!< Histogram output buffer
143 MEDIA_CSPACE colorSpace; //!< Color Space
144 uint32_t chromaSiting; //!< ChromaSiting
145 RECT rcDst; //!< rectangle on output surface after scaling.
146 } output;
147
148 VIDEO_PARAMS videoParams = {}; //!< standard related params.
149 CODECHAL_SCALING_MODE scalingMode = CODECHAL_SCALING_BILINEAR;
150 };
151
152 union MEDIA_SFC_INTERFACE_MODE
153 {
154 struct
155 {
156 uint32_t veboxSfcEnabled : 1;
157 uint32_t vdboxSfcEnabled : 1;
158 };
159 uint32_t value = 3;
160 };
161
162 class MediaSfcInterface
163 {
164 public:
165 //!
166 //! \brief MediaSfcInterface constructor
167 //! \details Initialize the MediaSfcInterface members.
168 //! \param osInterface
169 //! [in] Pointer to MOS_INTERFACE.
170 //! \param mmc
171 //! [in] Pointer to MediaMemComp.
172 //!
173 MediaSfcInterface(PMOS_INTERFACE osInterface, MediaMemComp *mmc = nullptr);
174
175 virtual ~MediaSfcInterface();
176
177 virtual void Destroy();
178
179 //!
180 //! \brief Check whether the Parameter for VDBOX-SFC supported
181 //! \details Only valid when MEDIA_SFC_INTERFACE_MODE::vdboxSfcEnabled being 1.
182 //! \param param
183 //! [in] Pointer to VDBOX_SFC_PARAMS.
184 //! \return MOS_STATUS
185 //! Return MOS_STATUS_SUCCESS if supported, otherwise failed
186 //!
187 MOS_STATUS IsParameterSupported(VDBOX_SFC_PARAMS &param);
188
189 //!
190 //! \brief Check whether the Parameter for VEBOX-SFC supported
191 //! \details Only valid when MEDIA_SFC_INTERFACE_MODE::veboxSfcEnabled being 1.
192 //! \param param
193 //! [in] Pointer to VEBOX_SFC_PARAMS.
194 //! \return MOS_STATUS
195 //! Return MOS_STATUS_SUCCESS if supported, otherwise failed
196 //!
197 MOS_STATUS IsParameterSupported(VEBOX_SFC_PARAMS &param);
198
199 //!
200 //! \brief Render Vdbox-SFC States
201 //! \details Only valid when MEDIA_SFC_INTERFACE_MODE::vdboxSfcEnabled being 1.
202 //! \param cmdBuffer
203 //! [in/out] Command Buffer to be Filled.
204 //! \param param
205 //! [in] Pointer to VDBOX_SFC_PARAMS.
206 //! \return MOS_STATUS
207 //! Return MOS_STATUS_SUCCESS if supported, otherwise failed
208 //!
209 MOS_STATUS Render(MOS_COMMAND_BUFFER *cmdBuffer, VDBOX_SFC_PARAMS &param);
210
211 //!
212 //! \brief Render Vebox-SFC States
213 //! \details Only valid when MEDIA_SFC_INTERFACE_MODE::veboxSfcEnabled being 1.
214 //! \param param
215 //! [in] Pointer to VEBOX_SFC_PARAMS.
216 //! \return MOS_STATUS
217 //! Return MOS_STATUS_SUCCESS if supported, otherwise failed
218 //!
219 MOS_STATUS Render(VEBOX_SFC_PARAMS &param);
220
221 //!
222 //! \brief Sfc Command Size
223 //! \details Calculate Command size of SFC commands.
224 //! \return uint32_t
225 //! Return calculated size
226 //!
227 uint32_t GetSfcCommandSize();
228
229 //!
230 //! \brief MediaSfcInterface initialize
231 //! \details Initialize the MediaSfcInterface.
232 //! \param mode
233 //! [in] 1: VEBOX-SFC only, 2: VDBOX-SFC only, 3: Both VEBOX-SFC and VDBOX-SFC.
234 //! \return MOS_STATUS
235 //! Return MOS_STATUS_SUCCESS if successful, otherwise failed
236 //!
237 virtual MOS_STATUS Initialize(MEDIA_SFC_INTERFACE_MODE mode);
238
239 bool IsRenderInitialized();
240
241 protected:
242 PMOS_INTERFACE m_osInterface = nullptr;
243 MediaSfcRender *m_sfcRender = nullptr;
244 MediaMemComp *m_mmc = nullptr;
245 MEDIA_CLASS_DEFINE_END(MediaSfcInterface)
246 };
247
248 #endif // __MEDIA_SFC_INTERFACE_H__