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