Debian Codegraph @

media_driver/agnostic/gen11/codec/hal/codechal_huc_cmd_initializer_g11.h

raw
1 /*
2 * Copyright (c) 2018, 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_huc_cmd_initializer_g11.h
24 //! \brief Defines class for G11 HUC cmd initializer encoder.
25 //!
26
27 #ifndef __CODECHAL_CMD_INITIALIZER_G11_H__
28 #define __CODECHAL_CMD_INITIALIZER_G11_H__
29
30 #include "codechal_huc_cmd_initializer.h"
31
32 #if defined (_HEVC_ENCODE_VME_SUPPORTED) || defined (_HEVC_ENCODE_VDENC_SUPPORTED)
33 #include "codechal_encode_hevc_base.h"
34 #endif
35 #include "codechal_encoder_base.h"
36
37 //!
38 //! \struct HucInputCmd1
39 //! \brief The struct of Huc input command 1
40 //!
41 struct HucInputCmd1G11
42 {
43 // Shared
44 uint32_t FrameWidthInMinCbMinus1;
45
46 uint32_t FrameHeightInMinCbMinus1;
47
48 uint32_t log2_min_coding_block_size_minus3;
49
50 uint8_t VdencStreamInEnabled;
51 uint8_t PakOnlyMultipassEnable;
52 uint16_t num_ref_idx_l0_active_minus1;
53
54 uint16_t SADQPLambda;
55 uint16_t RDQPLambda;
56
57 // HEVC
58 uint16_t num_ref_idx_l1_active_minus1;
59 uint8_t tiles_enabled_flag;
60 uint8_t ROIStreamInEnabled;
61
62 int8_t ROIDeltaQp[8]; // [-3..3] or [-51..51]
63
64 uint8_t FwdPocNumForRefId0inL0;
65 uint8_t FwdPocNumForRefId0inL1;
66 uint8_t FwdPocNumForRefId1inL0;
67 uint8_t FwdPocNumForRefId1inL1;
68
69 uint8_t FwdPocNumForRefId2inL0;
70 uint8_t FwdPocNumForRefId2inL1;
71 uint8_t FwdPocNumForRefId3inL0;
72 uint8_t FwdPocNumForRefId3inL1;
73
74 uint8_t EnableRollingIntraRefresh;
75 int8_t QpDeltaForInsertedIntra;
76 uint16_t IntraInsertionSize;
77
78 uint32_t IntraInsertionReferenceLocation[3];
79
80 uint16_t IntraInsertionLocation;
81 int8_t QpY;
82 uint8_t RoundingEnabled;
83
84 uint8_t UseDefaultQpDeltas;
85 uint8_t PanicEnabled;
86 uint8_t TemporalMvpEnableFlag;
87 uint8_t TransformSkip;
88 uint32_t Intra32X32ModeMask;
89
90 // VP9
91 uint16_t SrcFrameWidth;
92 uint16_t SrcFrameHeight;
93
94 uint8_t SegmentationEnabled;
95 uint8_t PrevFrameSegEnabled;
96 uint8_t SegMapStreamInEnabled;
97 uint8_t LumaACQIndex;
98
99 int8_t LumaDCQIndexDelta;
100 uint8_t log2_tile_columns;
101 uint8_t log2_tile_rows;
102 uint8_t DynamicScalingEnabled;
103
104 int16_t SegmentQIndexDelta[8];
105
106 // for hevc max/min qp
107 uint8_t BRCMaxQp;
108 uint8_t BRCMinQp;
109
110 // for VP9 VDEnc Gen11
111 uint8_t dysVdencMultiPassEnabled;
112
113 uint8_t Rsvd[1];
114 };
115
116 //!
117 //! \struct HucInputCmd3G11
118 //! \brief The struct of Huc input command 3
119 //!
120 struct HucInputCmd3G11
121 {
122 uint8_t SelectionForIndData = 0;
123 uint8_t CmdMode = 0;
124 uint16_t LengthOfTable = 0;
125
126 uint32_t SrcBaseOffset = 0;
127 uint32_t DestBaseOffset = 0;
128
129 uint32_t Reserved[3] = { 0 };
130
131 uint32_t CopySize = 0; // use this as indicator of size for copy base addr cmd. Since encode will not implement CopySize for copy cmd
132
133 uint32_t ReservedCounter[4] = {0};
134
135 uint32_t SrcAddrBottom = 0;
136 uint32_t SrcAddrTop = 0;
137 uint32_t DestAddrBottom = 0;
138 uint32_t DestAddrTop = 0;
139 };
140
141 //!
142 //! \struct HucCopyParams
143 //! \brief The struct of params used for huc copy
144 //!
145 struct HucCopyParams
146 {
147 PMOS_RESOURCE presSrc = nullptr;
148 PMOS_RESOURCE presDst = nullptr;
149 uint32_t size = 0;
150 uint16_t lengthOfTable = 0;
151 };
152
153 //!
154 //! \class CodechalCmdInitializer
155 //! \brief Command Initializer class
156 //!
157 class CodechalCmdInitializerG11 : public CodechalCmdInitializer
158 {
159 public:
160 //!
161 //! \brief Constructor
162 //!
163
164 CodechalCmdInitializerG11(CodechalEncoderState *encoder);
165
166 //!
167 //! \brief Default Constructor
168 //!
169 CodechalCmdInitializerG11() {};
170
171 //!
172 //! \brief Destructor
173 //!
174 virtual ~CodechalCmdInitializerG11() {};
175
176 //! Inherited virtual functions
177 virtual MOS_STATUS CmdInitializerAllocateResources(
178 CodechalHwInterface* m_hwInterface) override;
179
180 //!
181 //! \brief Free Resources
182 //!
183 virtual void CmdInitializerFreeResources() override;
184
185 //!
186 //! \brief Add copy commands of command initializer HuC FW
187 //!
188 //! \param [in] cmdBuffer
189 //! Command Buffer
190 //! \param [in] params
191 //! Params used to add copy commands
192 //!
193 //! \return MOS_STATUS
194 //! MOS_STATUS_SUCCESS if success, else fail reason
195 //!
196 virtual MOS_STATUS AddCopyCmds(
197 PMOS_COMMAND_BUFFER cmdBuffer,
198 HucCopyParams* params);
199
200 #if defined (_HEVC_ENCODE_VME_SUPPORTED) || defined (_HEVC_ENCODE_VDENC_SUPPORTED)
201 virtual MOS_STATUS CmdInitializerSetDmem(bool brcEnabled) override;
202
203 //!
204 //! \brief Add command of initializer HuC FW
205 //!
206 //! \param [in] cmdId
207 //! id of the command
208 //! \param [in] data
209 //! content of the command
210 //! \param [in] size
211 //! size of the command
212 //! \param [in] startOffset
213 //! start offset of the command in slb
214 //!
215 //! \return MOS_STATUS
216 //! MOS_STATUS_SUCCESS if success, else fail reason
217 //!
218 virtual MOS_STATUS AddCmdConstData(
219 uint16_t cmdId,
220 uint32_t* data,
221 uint16_t size,
222 uint32_t startOffset
223 );
224 #endif
225
226 #ifdef _VP9_ENCODE_VDENC_SUPPORTED
227 //!
228 //! \brief Set DMEM of command initializer HuC FW for VP9
229 //! \return MOS_STATUS
230 //! MOS_STATUS_SUCCESS if success, else fail reason
231 //!
232 MOS_STATUS CmdInitializerVp9SetDmem() override;
233
234 //!
235 //! \brief Executes VP9 command initializer HuC FW
236 //!
237 //! \param [in] cmdBuffer
238 //! Command buffer
239 //! \param [in] picStateBuffer
240 //! Picture state buffer
241 //!
242 //! \return MOS_STATUS
243 //! MOS_STATUS_SUCCESS if success, else fail reason
244 //!
245 MOS_STATUS CmdInitializerVp9Execute(PMOS_COMMAND_BUFFER cmdBuffer, PMOS_RESOURCE picStateBuffer) override;
246 #endif
247
248 bool m_hevcVisualQualityImprovement = false; //!< VQI enable flag
249
250 protected:
251 #if defined (_HEVC_ENCODE_VME_SUPPORTED) || defined (_HEVC_ENCODE_VDENC_SUPPORTED)
252 MOS_STATUS ConstructHevcHucCmd1ConstData(
253 PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS seqParams,
254 PCODEC_HEVC_ENCODE_PICTURE_PARAMS picParams,
255 PCODEC_HEVC_ENCODE_SLICE_PARAMS sliceParams,
256 struct HucComData * hucConstData) override;
257
258 MOS_STATUS ConstructHevcHucCmd2ConstData(
259 PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS seqParams,
260 PCODEC_HEVC_ENCODE_PICTURE_PARAMS picParams,
261 PCODEC_HEVC_ENCODE_SLICE_PARAMS sliceParams,
262 struct HucComData * hucConstData) override;
263
264 uint16_t GetCmd2StartOffset(bool brcEnabled) override;
265 uint16_t GetCmd1StartOffset(bool brcEnabled) override;
266 virtual uint16_t GetCmd5StartOffset(bool brcEnabled);
267 #endif
268
269 MOS_RESOURCE m_cmdInitializerCopyDmemBuffer[CODECHAL_ENCODE_RECYCLED_BUFFER_NUM][CODECHAL_VDENC_BRC_NUM_OF_PASSES]; //!< Dmem buffer for huc cmd initialization copy
270 MOS_RESOURCE m_cmdInitializerCopyDataBuffer[CODECHAL_ENCODE_RECYCLED_BUFFER_NUM][CODECHAL_VDENC_BRC_NUM_OF_PASSES]; //!< Data buffer for huc cmd initialization copy
271 MHW_BATCH_BUFFER m_vdencCopyBatchBuffer = {}; //!< SLB for huc cmd initialization copy
272
273 //!
274 //! \brief Set dmem buffer for huc cmd initialization copy
275 //!
276 //! \return MOS_STATUS
277 //! MOS_STATUS_SUCCESS if success, else fail reason
278 //!
279 MOS_STATUS SetCopyDmem();
280
281 //!
282 //! \brief Set data buffer for huc cmd initialization copy
283 //!
284 //! \return MOS_STATUS
285 //! MOS_STATUS_SUCCESS if success, else fail reason
286 //!
287 MOS_STATUS SetCopyData(
288 HucCopyParams* params);
289 };
290 using PCODECHAL_CMD_INITIALIZER_G11 = class CodechalCmdInitializerG11*;
291
292 #endif //__CODECHAL_CMD_INITIALIZER_G11_H__