Debian Codegraph @

media_driver/agnostic/common/codec/hal/codechal_decode_sfc.h

raw
1 /*
2 * Copyright (c) 2014-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 //! \file codechal_decode_sfc.h
24 //! \brief Defines the decode interface extension for CSC and scaling via SFC.
25 //! \details Downsampling in this case is supported by the SFC fixed function HW unit.
26 //!
27
28 #ifndef __CODECHAL_DECODE_SFC_H__
29 #define __CODECHAL_DECODE_SFC_H__
30
31 #include "codechal.h"
32 #include "codechal_hw.h"
33 #include "mhw_mi.h"
34 #include "codec_def_decode.h"
35
36 #define CODECHAL_SFC_ALIGNMENT_16 16
37 #define CODECHAL_SFC_ALIGNMENT_8 8
38
39 #define CODECHAL_SFC_VEBOX_STATISTICS_SIZE (32 * 4)
40 #define CODECHAL_SFC_VEBOX_LACE_HISTOGRAM_256_BIN_PER_BLOCK (256 * 2)
41 #define CODECHAL_SFC_VEBOX_ACE_HISTOGRAM_SIZE_PER_FRAME_PER_SLICE (256 * 4)
42 #define CODECHAL_SFC_NUM_FRAME_PREVIOUS_CURRENT 2
43 #define CODECHAL_SFC_VEBOX_MAX_SLICES 2
44
45 #define CODECHAL_SFC_VEBOX_RGB_HISTOGRAM_SIZE_PER_SLICE (256 * 4)
46 #define CODECHAL_SFC_NUM_RGB_CHANNEL 3
47 #define CODECHAL_SFC_VEBOX_RGB_HISTOGRAM_SIZE (CODECHAL_SFC_VEBOX_RGB_HISTOGRAM_SIZE_PER_SLICE * \
48 CODECHAL_SFC_NUM_RGB_CHANNEL * \
49 CODECHAL_SFC_VEBOX_MAX_SLICES)
50
51 //!
52 //! \class CodechalSfcState
53 //! \brief This class defines the member fields, functions etc used by SFC State.
54 //!
55 class CodechalSfcState
56 {
57 public:
58 //!
59 //! \brief Constructor
60 //!
61 CodechalSfcState() {};
62
63 //!
64 //! \brief Destructor
65 //!
66 virtual ~CodechalSfcState();
67
68 //!
69 //! \brief Initialize Sfc State
70 //! \details Initialize Sfc State
71 //! \param [in] inDecoder
72 //! Pointer to Decode interface
73 //! \param [in] hwInterface
74 //! Pointer to hardware interface
75 //! \param [in] osInterface
76 //! Pointer to OS interface
77 //! \return MOS_STATUS
78 //! MOS_STATUS_SUCCESS if success, else fail reason
79 //!
80 MOS_STATUS InitializeSfcState(
81 CodechalDecode *inDecoder,
82 CodechalHwInterface *hwInterface,
83 PMOS_INTERFACE osInterface);
84
85 //!
86 //! \brief Initialize Sfc variables
87 //! \details Initialize Sfc variables
88 //! \param [in] decodeProcParams
89 //! Pointer to Decode Processing Params
90 //! \param [in] sfcPipeMode
91 //! Indicate which media pipe using SFC
92 //! \return MOS_STATUS
93 //! MOS_STATUS_SUCCESS if success, else fail reason
94 //!
95 MOS_STATUS Initialize(
96 DecodeProcessingParams *decodeProcParams,
97 uint8_t sfcPipeMode);
98
99 //!
100 //! \brief Send Vebox and SFC Cmd
101 //! \details Send Vebox and SFC Cmd to HW
102 //! \return MOS_STATUS
103 //! MOS_STATUS_SUCCESS if success, else fail reason
104 //!
105 MOS_STATUS RenderStart();
106
107 //!
108 //! \brief Send SFC Avs State / Ief State Cmd
109 //! \details Send SFC Avs State / Ief State Cmd
110 //! \param [in] cmdBuffer
111 //! Pointer to Command buffer
112 //! \return MOS_STATUS
113 //! MOS_STATUS_SUCCESS if success, else fail reason
114 //!
115 virtual MOS_STATUS AddSfcCommands(
116 PMOS_COMMAND_BUFFER cmdBuffer);
117
118 //!
119 //! \brief Check if specified input and output format supported by SFC
120 //! \details Check if a specified input/output pair can be supported by SFC
121 //! \param [in] inputFormat
122 //! The SFC input format
123 //! \param [in] outputFormat
124 //! The SFC output format
125 //! \return bool
126 //! true if supported, else false
127 //!
128 virtual bool IsSfcFormatSupported(
129 MOS_FORMAT inputFormat,
130 MOS_FORMAT outputFormat);
131
132 //!
133 //! \brief Check if SFC output is supported
134 //! \details Check if SFC output is supported according to Decode Processing Params
135 //! \param [in] decodeProcParams
136 //! Pointer to decode processing params
137 //! \param [in] sfcPipeMode
138 //! Indicate which media pipe using SFC
139 //! \return bool
140 //! true if supported, else false
141 //!
142 bool IsSfcOutputSupported(
143 DecodeProcessingParams *decodeProcParams,
144 uint8_t sfcPipeMode);
145
146 CodechalDecode * m_decoder = nullptr; //!< Decoder
147 PMOS_INTERFACE m_osInterface = nullptr; //!< OS Interface
148 CodechalHwInterface *m_hwInterface = nullptr; //!< HW Interface
149 MhwVeboxInterface * m_veboxInterface = nullptr; //!< Vebox Interface
150 PMHW_SFC_INTERFACE m_sfcInterface = nullptr; //!< Sfc Interface
151 MhwMiInterface * m_miInterface = nullptr; //!< Mi Interface
152
153 bool m_deblockingEnabled = false; //!< Indicate if Deblocking is enabled
154 uint32_t m_inputFrameWidth = 0; //!< Input Frame Width
155 uint32_t m_inputFrameHeight = 0; //!< Input Frame Height
156 bool m_sfcPipeOut = false; //!< Indicate Sfc Pipe Out is enabled
157 PMOS_SURFACE m_sfcOutputSurface = nullptr; //!< Pointer of Sfc Output Surface
158
159 bool m_jpegInUse = false; //!< Indicate if Jpeg is in use
160 uint8_t m_jpegChromaType = 0; //!< Jpeg Chroma Type
161
162 protected:
163 uint8_t m_sfcPipeMode = MhwSfcInterface::SFC_PIPE_MODE_VDBOX; //!< which FE engine pipe used
164
165 PMOS_SURFACE m_inputSurface = nullptr; //!< Pointer of Input Surface
166 PMOS_SURFACE m_veboxOutputSurface = nullptr; //!< Pointer of Vebox Output Surface
167
168 MOS_RESOURCE m_resAvsLineBuffer = {0}; //!< Avs Line Buffer MOS Resource
169 MOS_RESOURCE m_resLaceOrAceOrRgbHistogram = {0}; //!< Lace/Ace/Rgb Histogram MOS Resource
170 MOS_RESOURCE m_resStatisticsOutput = {0}; //!< Statistics Output MOS Resource
171
172 bool m_scaling = false; //!< Indicate if scaling is needed
173 bool m_colorFill = false; //!< Indicate if color fill is needed
174 bool m_ief = false; //!< Indicate if IEF is needed for Surface
175 bool m_csc = false; //!< Indicate if YUV->RGB/YUV->YUV CSC is enabled
176
177 float m_scaleX = 0; //!< Horizontal Scaling Ratio
178 float m_scaleY = 0; //!< Vertical Scaling Ratio
179
180 uint32_t m_rotationMode = 0; //!< Rotation Mode
181 uint32_t m_chromaSiting = 0; //!< Chroma Siting Type
182
183 CodecRectangle m_inputSurfaceRegion = {0}; //!< Input Region Resolution and Offset
184 CodecRectangle m_outputSurfaceRegion = {0}; //!< Output Region Resolution and Offset
185
186 float m_cscCoeff[9] = {0}; //!< Csc Coefficient
187 float m_cscInOffset[3] = {0}; //!< Csc In Offset
188 float m_cscOutOffset[3] = {0}; //!< Csc Out Offset
189
190 MHW_AVS_PARAMS m_avsParams = {Format_Any}; //!< Avs Params
191 MHW_SFC_AVS_LUMA_TABLE m_lumaTable = {0}; //!< Avs Luma Table
192 MHW_SFC_AVS_CHROMA_TABLE m_chromaTable = {0}; //!< Avs Chroma Table
193 MHW_SFC_AVS_STATE m_avsState = {0}; //<! Avs State
194
195 MOS_RESOURCE m_resSyncObject = {0}; //!< Sync Object
196
197 protected:
198 bool m_mmcEnabled = false;
199
200 //!
201 //! \brief Allocate Resources for SFC
202 //! \details Allocate Buffer for SFC and initialize AVS params
203 //! \return MOS_STATUS
204 //! MOS_STATUS_SUCCESS if success, else fail reason
205 //!
206 virtual MOS_STATUS AllocateResources();
207
208 //!
209 //! \brief Set Vebox State Cmd Params
210 //! \details Set Vebox State Cmd Params
211 //! \param [in] veboxCmdParams
212 //! Pointer to Vebox State Cmd Params
213 //! \return MOS_STATUS
214 //! MOS_STATUS_SUCCESS if success, else fail reason
215 //!
216 MOS_STATUS SetVeboxStateParams(
217 PMHW_VEBOX_STATE_CMD_PARAMS veboxCmdParams);
218
219 //!
220 //! \brief Set Vebox Surface State Cmd Params
221 //! \details Set Vebox Surface State Cmd Params
222 //! \param [in] veboxSurfParams
223 //! Pointer to Vebox Surface State Cmd Params
224 //! \return MOS_STATUS
225 //! MOS_STATUS_SUCCESS if success, else fail reason
226 //!
227 MOS_STATUS SetVeboxSurfaceStateParams(
228 PMHW_VEBOX_SURFACE_STATE_CMD_PARAMS veboxSurfParams);
229
230 //!
231 //! \brief Set Vebox Di Iecp Cmd Params
232 //! \details Set Vebox Di Iecp Cmd Params
233 //! \param [in] veboxDiIecpParams
234 //! Pointer to Vebox Di Iecp Cmd Params
235 //! \return MOS_STATUS
236 //! MOS_STATUS_SUCCESS if success, else fail reason
237 //!
238 MOS_STATUS SetVeboxDiIecpParams(
239 PMHW_VEBOX_DI_IECP_CMD_PARAMS veboxDiIecpParams);
240
241 //!
242 //! \brief Set Sfc State Params
243 //! \details Set Sfc State Params
244 //! \param [in] sfcStateParams
245 //! Pointer to Sfc State Params
246 //! \param [in] outSurfaceParams
247 //! Pointer to Out Surface Params
248 //! \return MOS_STATUS
249 //! MOS_STATUS_SUCCESS if success, else fail reason
250 //!
251 virtual MOS_STATUS SetSfcStateParams(
252 PMHW_SFC_STATE_PARAMS sfcStateParams,
253 PMHW_SFC_OUT_SURFACE_PARAMS outSurfaceParams);
254
255 //!
256 //! \brief Set Sfc Avs State Params
257 //! \details Set Sfc Avs State Params
258 //! \return MOS_STATUS
259 //! MOS_STATUS_SUCCESS if success, else fail reason
260 //!
261 virtual MOS_STATUS SetSfcAvsStateParams();
262
263 //!
264 //! \brief Set Sfc Ief State Params
265 //! \details Set Sfc Ief State Params
266 //! \param [in] iefStateParams
267 //! Pointer to Sfc Ief State Params
268 //! \return MOS_STATUS
269 //! MOS_STATUS_SUCCESS if success, else fail reason
270 //!
271 MOS_STATUS SetSfcIefStateParams(
272 PMHW_SFC_IEF_STATE_PARAMS iefStateParams);
273
274 //!
275 //! \brief Update Sfc State Params according to input info
276 //! \details Update Sfc State Params according to input info
277 //! \param [in] sfcStateParams
278 //! Pointer to Sfc State Params
279 //! \return MOS_STATUS
280 //! MOS_STATUS_SUCCESS if success, else fail reason
281 //!
282 virtual MOS_STATUS UpdateInputInfo(
283 PMHW_SFC_STATE_PARAMS sfcStateParams) = 0;
284 };
285
286 using PCODECHAL_SFC_STATE = CodechalSfcState*;
287
288 #endif // __CODECHAL_DECODE_SFC_H__
289