Debian Codegraph @

media_driver/agnostic/common/hw/vdbox/mhw_vdbox_avp_interface.h

raw
1 /*
2 * Copyright (c) 2020-2024, 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 mhw_vdbox_avp_interface.h
24 //! \brief MHW interface for constructing AVP commands for the Vdbox engine
25 //! \details Defines the interfaces for constructing MHW Vdbox AVP commands across all platforms
26 //!
27
28 #ifndef _MHW_VDBOX_AVP_INTERFACE_H_
29 #define _MHW_VDBOX_AVP_INTERFACE_H_
30
31 #include "mhw_vdbox.h"
32 #include "mhw_mi.h"
33 #include "codec_def_decode_av1.h"
34
35 struct MhwVdboxAvpTileCodingParams
36 {
37 uint16_t m_tileId;
38 uint16_t m_tgTileNum; //!< Tile ID in its Tile group
39 uint16_t m_tileGroupId;
40
41 uint16_t m_tileColPositionInSb;
42 uint16_t m_tileRowPositionInSb;
43
44 uint16_t m_tileWidthInSbMinus1; //!< Tile width minus 1 in SB unit
45 uint16_t m_tileHeightInSbMinus1; //!< Tile height minus 1 in SB unit
46
47 bool m_tileRowIndependentFlag;
48 bool m_firstTileInAFrame;
49 bool m_isLastTileOfColumn;
50 bool m_isLastTileOfRow;
51 bool m_isFirstTileOfTileGroup;
52 bool m_isLastTileOfTileGroup;
53 bool m_isLastTileOfFrame;
54 bool m_disableCdfUpdateFlag;
55 bool m_disableFrameContextUpdateFlag;
56
57 uint8_t m_numOfActiveBePipes;
58 uint16_t m_numOfTileColumnsInFrame;
59 uint16_t m_numOfTileRowsInFrame;
60 uint16_t m_outputDecodedTileColumnPositionInSBUnit;
61 uint16_t m_outputDecodedTileRowPositionInSBUnit;
62 };
63
64 struct MhwVdboxAvpPicStateParams
65 {
66 // Decode
67 CodecAv1PicParams *m_picParams;
68 PCODEC_REF_LIST_AV1 *m_refList;
69
70 union
71 {
72 struct
73 {
74 uint8_t m_keyFrame : 1; // [0..1]
75 uint8_t m_intraOnly : 1; // [0..1]
76 uint8_t m_display : 1; // [0..1]
77 uint8_t m_reservedField : 5; // [0]
78 } m_fields;
79 uint8_t m_value;
80 } m_prevFrameParams;
81
82 uint32_t m_prevFrmWidth;
83 uint32_t m_prevFrmHeight;
84
85 //driver internally
86 uint8_t m_referenceFrameSignBias[8];
87 int8_t m_skipModeFrame[2]; //offset to LAST_FRAME, should be sign value
88 uint32_t m_lumaPlaneXStepQn;
89 uint32_t m_lumaPlaneX0Qn;
90 uint32_t m_chromaPlaneXStepQn;
91 uint32_t m_chromaPlaneX0Qn;
92
93 uint8_t m_refOrderHints[7];
94 uint8_t m_savedRefOrderHints[7][7];
95 uint8_t m_refMaskMfProj;
96 uint8_t m_validRefPicIdx;
97 };
98
99 struct MhwVdboxAvpPakInsertObjParams
100 {
101 PBSBuffer pBsBuffer;
102 // also reuse dwBitSize for passing SrcDataEndingBitInclusion when (pEncoder->bLastPicInStream || pEncoder->bLastPicInSeq)
103 uint32_t dwBitSize;
104 uint32_t dwOffset;
105 uint32_t uiSkipEmulationCheckCount;
106 bool bLastPicInSeq;
107 bool bLastPicInStream;
108 bool m_lastHeader;
109 bool bEmulationByteBitsInsert;
110 bool bSetLastPicInStreamData;
111 bool bSliceHeaderIndicator;
112 bool bHeaderLengthExcludeFrmSize;
113 uint32_t * pdwMpeg2PicHeaderTotalBufferSize;
114 uint32_t * pdwMpeg2PicHeaderDataStartOffset;
115 bool bResetBitstreamStartingPos;
116 uint32_t m_endOfHeaderInsertion;
117 uint32_t dwLastPicInSeqData;
118 uint32_t dwLastPicInStreamData;
119 PMHW_BATCH_BUFFER pBatchBufferForPakSlices;
120 bool bVdencInUse;
121 };
122
123 struct MhwVdboxAvpSegmentStateParams
124 {
125 CodecAv1SegmentsParams *m_av1SegmentParams;
126 uint8_t m_currentSegmentId;
127 };
128
129 struct MhwVdboxAvpBsdParams
130 {
131 uint32_t m_bsdDataLength;
132 uint32_t m_bsdDataStartOffset;
133 };
134
135 class MhwVdboxAvpPipeBufAddrParams
136 {
137 public:
138 uint32_t m_mode = 0;
139
140 MOS_RESOURCE *m_references[8] = {}; //!< Reference Frame Buffer
141 MOS_SURFACE *m_decodedPic = nullptr; //!< Decoded Output Frame Buffer
142 MOS_RESOURCE *m_intrabcDecodedOutputFrameBuffer = nullptr; //!< IntraBC Decoded output frame buffer
143 MOS_RESOURCE *m_cdfTableInitializationBuffer = nullptr; //!< CDF Tables Initialization Buffer
144 uint32_t m_cdfTableInitializationBufferOffset = 0; //!< CDF Tables Initialization Buffer Size
145 MOS_RESOURCE *m_cdfTableBwdAdaptationBuffer = nullptr; //!< CDF Tables Backward Adaptation Buffer
146
147 MOS_RESOURCE *m_segmentIdReadBuffer = nullptr; //!< AV1 Segment ID Read Buffer
148 MOS_RESOURCE *m_segmentIdWriteBuffer = nullptr; //!< AV1 Segment ID Write Buffer
149 MOS_RESOURCE *m_colMvTemporalBuffer[9] = {}; //!< Collocated MV temporal buffer
150 MOS_RESOURCE *m_curMvTemporalBuffer = nullptr; //!< Current MV temporal buffer
151 MOS_RESOURCE *m_bitstreamDecoderEncoderLineRowstoreReadWriteBuffer = nullptr; //!< Handle of Bitstream Decode Line Rowstore buffer, can be programmed to use Local Media Storage VMM instead of Memory
152 MOS_RESOURCE *m_bitstreamDecoderEncoderTileLineRowstoreReadWriteBuffer = nullptr; //!< Handle of Bitstream Decode Tile Line buffer
153 MOS_RESOURCE *m_intraPredictionLineRowstoreReadWriteBuffer = nullptr; //!< Handle of Intra Prediction Line Rowstore Read/Write Buffer
154 MOS_RESOURCE *m_intraPredictionTileLineRowstoreReadWriteBuffer = nullptr; //!< Handle of Intra Prediction Tile Line Rowstore Read/Write Buffer
155 MOS_RESOURCE *m_spatialMotionVectorLineReadWriteBuffer = nullptr; //!< Handle of Spatial Motion Vector Line rowstore buffer, can be programmed to use Local Media Storage VMM instead of Memory
156 MOS_RESOURCE *m_spatialMotionVectorCodingTileLineReadWriteBuffer = nullptr; //!< Handle of Spatial Motion Vector Tile Line buffer
157 MOS_RESOURCE *m_loopRestorationMetaTileColumnReadWriteBuffer = nullptr; //!< Loop Restoration Meta Tile Column Read/Write Buffer Address
158 MOS_RESOURCE *m_loopRestorationFilterTileReadWriteLineYBuffer = nullptr; //!< Loop Restoration Filter Tile Read/Write Line Y Buffer Address
159 MOS_RESOURCE *m_loopRestorationFilterTileReadWriteLineUBuffer = nullptr; //!< Loop Restoration Filter Tile Read/Write Line U Buffer Address
160 MOS_RESOURCE *m_loopRestorationFilterTileReadWriteLineVBuffer = nullptr; //!< Loop Restoration Filter Tile Read/Write Line V Buffer Address
161 MOS_RESOURCE *m_deblockerFilterLineReadWriteYBuffer = nullptr; //!< Deblocker Filter Line Read/Write Y Buffer Address
162 MOS_RESOURCE *m_deblockerFilterLineReadWriteUBuffer = nullptr; //!< Deblocker Filter Line Read/Write U Buffer Address
163 MOS_RESOURCE *m_deblockerFilterLineReadWriteVBuffer = nullptr; //!< Deblocker Filter Line Read/Write V Buffer Address
164 MOS_RESOURCE *m_deblockerFilterTileLineReadWriteYBuffer = nullptr; //!< Deblocker Filter Tile Line Read/Write Y Buffer Address
165 MOS_RESOURCE *m_deblockerFilterTileLineReadWriteVBuffer = nullptr; //!< Deblocker Filter Tile Line Read/Write V Buffer Address
166 MOS_RESOURCE *m_deblockerFilterTileLineReadWriteUBuffer = nullptr; //!< Deblocker Filter Tile Line Read/Write U Buffer Address
167 MOS_RESOURCE *m_deblockerFilterTileColumnReadWriteYBuffer = nullptr; //!< Deblocker Filter Tile Column Read/Write Y Buffer Address
168 MOS_RESOURCE *m_deblockerFilterTileColumnReadWriteUBuffer = nullptr; //!< Deblocker Filter Tile Column Read/Write U Buffer Address
169 MOS_RESOURCE *m_deblockerFilterTileColumnReadWriteVBuffer = nullptr; //!< Deblocker Filter Tile Column Read/Write V Buffer Address
170 MOS_RESOURCE *m_cdefFilterLineReadWriteBuffer = nullptr; //!< CDEF Filter Line Read/Write Y Buffer Address
171 MOS_RESOURCE *m_cdefFilterTileLineReadWriteBuffer = nullptr; //!< CDEF Filter Tile Line Read/Write Y Buffer Address
172 MOS_RESOURCE *m_cdefFilterTileColumnReadWriteBuffer = nullptr; //!< CDEF Filter Tile Column Read/Write Y Buffer Address
173 MOS_RESOURCE *m_cdefFilterMetaTileLineReadWriteBuffer = nullptr; //!< CDEF Filter Meta Tile Line Read/Write Buffer Address
174 MOS_RESOURCE *m_cdefFilterMetaTileColumnReadWriteBuffer = nullptr; //!< CDEF Filter Meta Tile Column Read/Write Buffer Address
175 MOS_RESOURCE *m_cdefFilterTopLeftCornerReadWriteBuffer = nullptr; //!< CDEF Filter Top-Left Corner Read/Write Buffer Address
176 MOS_RESOURCE *m_superResTileColumnReadWriteYBuffer = nullptr; //!< Super-Res Tile Column Read/Write Y Buffer Address
177 MOS_RESOURCE *m_superResTileColumnReadWriteUBuffer = nullptr; //!< Super-Res Tile Column Read/Write U Buffer Address
178 MOS_RESOURCE *m_superResTileColumnReadWriteVBuffer = nullptr; //!< Super-Res Tile Column Read/Write V Buffer Address
179 MOS_RESOURCE *m_loopRestorationFilterTileColumnReadWriteYBuffer = nullptr; //!< Loop Restoration Filter Tile Column Read/Write Y Buffer Address
180 MOS_RESOURCE *m_loopRestorationFilterTileColumnReadWriteUBuffer = nullptr; //!< Loop Restoration Filter Tile Column Read/Write U Buffer Address
181 MOS_RESOURCE *m_loopRestorationFilterTileColumnReadWriteVBuffer = nullptr; //!< Loop Restoration Filter Tile Column Read/Write V Buffer Address
182 MOS_RESOURCE *m_decodedFrameStatusErrorBuffer = nullptr; //!< Decoded Frame Status/Error Buffer Base Address
183 MOS_RESOURCE *m_decodedBlockDataStreamoutBuffer = nullptr; //!< Decoded Block Data Streamout Buffer Address
184
185 //MMC supported
186 MOS_MEMCOMP_STATE m_preDeblockSurfMmcState = {};
187 MOS_MEMCOMP_STATE m_streamOutBufMmcState = {};
188 MOS_MEMCOMP_STATE m_rawSurfMmcState = {};
189
190 virtual void Initialize();
191 //!
192 //! \brief Destructor
193 //!
194 virtual ~MhwVdboxAvpPipeBufAddrParams() { }
195 };
196
197 struct MhwVdboxAvpBufferSizeParams
198 {
199 uint8_t m_bitDepthIdc;
200 uint32_t m_picWidth; // picWidth in SB
201 uint32_t m_picHeight; // picHeight in SB
202 uint32_t m_tileWidth; // tileWidth in SB
203 uint32_t m_bufferSize;
204 bool m_isSb128x128;
205 uint32_t m_curFrameTileNum;
206 uint32_t m_numTileCol;
207 uint8_t m_numOfActivePipes;
208 };
209
210 struct MhwVdboxAvpBufferReallocParams
211 {
212 uint8_t m_bitDepthIdc;
213 uint16_t m_prevFrameTileNum;
214 uint16_t m_curFrameTileNum;
215 bool m_isSb128x128;
216 uint32_t m_tileWidth;
217 uint32_t m_numTileCol;
218 uint32_t m_numTileColAllocated;
219 uint32_t m_picWidth;
220 uint32_t m_picHeight;
221 uint32_t m_picWidthAlloced;
222 uint32_t m_picHeightAlloced;
223 uint32_t m_bufferSizeAlloced;
224 bool m_needBiggerSize;
225 };
226
227 //NOTE: When changing MhwVdboxAvpInternalBufferType, please change CodecAv1BufferSize[][][]/CodecAv1BufferSizeExt[][][] accordingly!!!
228 enum MhwVdboxAvpInternalBufferType
229 {
230 segmentIdBuf = 0, //!< segment ID temporal buffers
231 mvTemporalBuf, //!< MV temporal buffers of both current and collocated
232 bsdLineBuf, //!< bitstream decode line buffer
233 bsdTileLineBuf, //!< bitstream decode tile line buffer
234 intraPredLine, //!< intra prediction line buffer
235 intraPredTileLine,
236 spatialMvLineBuf,
237 spatialMvTileLineBuf,
238 lrMetaTileCol, //!< Loop Restoration Meta Tile Column Read/Write Buffer Address
239 lrTileLineY, //!< Loop Restoration Filter Tile Read/Write Line Y Buffer Address
240 lrTileLineU, //!< Loop Restoration Filter Tile Read/Write Line U Buffer Address
241 lrTileLineV, //!< Loop Restoration Filter Tile Read/Write Line V Buffer Address
242 deblockLineYBuf,
243 deblockLineUBuf,
244 deblockLineVBuf,
245 deblockTileLineYBuf,
246 deblockTileLineVBuf,
247 deblockTileLineUBuf,
248 deblockTileColYBuf,
249 deblockTileColUBuf,
250 deblockTileColVBuf,
251 cdefLineBuf,
252 cdefTileLineBuf,
253 cdefTileColBuf,
254 cdefMetaTileLine,
255 cdefMetaTileCol,
256 cdefTopLeftCornerBuf,
257 superResTileColYBuf,
258 superResTileColUBuf,
259 superResTileColVBuf,
260 lrTileColYBuf,
261 lrTileColUBuf,
262 lrTileColVBuf,
263 frameStatusErrBuf,
264 dbdStreamoutBuf,
265 fgTileColBuf,
266 fgSampleTmpBuf,
267 lrTileColAlignBuf,
268 tileSzStreamOutBuf,
269 tileStatStreamOutBuf,
270 cuStreamoutBuf,
271 sseLineBuf,
272 sseTileLineBuf,
273 avpInternalBufMax
274 };
275
276 //AVP internal buffer size table [buffer_index][bitdepthIdc][IsSb128x128]
277 static const uint8_t CodecAv1BufferSize[avpInternalBufMax][2][2] =
278 {
279 { 2 , 8 , 2 , 8 }, //segmentIdBuf,
280 { 4 , 16 , 4 , 16 }, //mvTemporalBuf,
281 { 2 , 4 , 2 , 4 }, //bsdLineBuf,
282 { 2 , 4 , 2 , 4 }, //bsdTileLineBuf,
283 { 2 , 4 , 4 , 8 }, //intraPredLine,
284 { 2 , 4 , 4 , 8 }, //intraPredTileLine,
285 { 4 , 8 , 4 , 8 }, //spatialMvLineBuf,
286 { 4 , 8 , 4 , 8 }, //spatialMvTileLineBuf,
287 { 1 , 1 , 1 , 1 }, //lrMetaTileCol,
288 { 7 , 7 , 7 , 7 }, //lrTileLineY,
289 { 5 , 5 , 5 , 5 }, //lrTileLineU,
290 { 5 , 5 , 5 , 5 }, //lrTileLineV,
291 { 9 , 17 , 11 , 21 }, //deblockLineYBuf,
292 { 3 , 4 , 3 , 5 }, //deblockLineUBuf,
293 { 3 , 4 , 3 , 5 }, //deblockLineVBuf,
294 { 9 , 17 , 11 , 21 }, //deblockTileLineYBuf,
295 { 3 , 4 , 3 , 5 }, //deblockTileLineVBuf,
296 { 3 , 4 , 3 , 5 }, //deblockTileLineUBuf,
297 { 8 , 16 , 10 , 20 }, //deblockTileColYBuf,
298 { 2 , 4 , 3 , 5 }, //deblockTileColUBuf,
299 { 2 , 4 , 3 , 5 }, //deblockTileColVBuf,
300 { 8 , 16 , 10 , 20 }, //cdefLineBuf,
301 { 8 , 16 , 10 , 20 }, //cdefTileLineBuf,
302 { 8 , 16 , 10 , 20 }, //cdefTileColBuf,
303 { 1 , 1 , 1 , 1 }, //cdefMetaTileLine,
304 { 1 , 1 , 1 , 1 }, //cdefMetaTileCol,
305 { 1 , 1 , 1 , 1 }, //cdefTopLeftCornerBuf,
306 { 22, 44 , 29 , 58 }, //superResTileColYBuf,
307 { 8 , 16 , 10 , 20 }, //superResTileColUBuf,
308 { 8 , 16 , 10 , 20 }, //superResTileColVBuf,
309 { 9 , 17 , 11 , 22 }, //lrTileColYBuf,
310 { 5 , 9 , 6 , 12 }, //lrTileColUBuf,
311 { 5 , 9 , 6 , 12 }, //lrTileColVBuf,
312 { 0 , 0 , 0 , 0 }, //frameStatusErrBuf,
313 { 0 , 0 , 0 , 0 }, //dbdStreamoutBuf,
314 { 2 , 4 , 3 , 5 }, //fgTileColBuf
315 { 96, 96 , 192 , 192 },//fgSampleTmpBuf
316 { 4, 8 , 5 , 10 }, //lrTileColAlignBuf
317 };
318
319 static const uint8_t CodecAv1BufferSizeExt[avpInternalBufMax][2][2] =
320 {
321 { 0 , 0 , 0 , 0 }, //segmentIdBuf,
322 { 0 , 0 , 0 , 0 }, //mvTemporalBuf,
323 { 0 , 0 , 0 , 0 }, //bsdLineBuf,
324 { 0 , 0 , 0 , 0 }, //bsdTileLineBuf,
325 { 0 , 0 , 0 , 0 }, //intraPredLine,
326 { 0 , 0 , 0 , 0 }, //intraPredTileLine,
327 { 0 , 0 , 0 , 0 }, //spatialMvLineBuf,
328 { 0 , 0 , 0 , 0 }, //spatialMvTileLineBuf,
329 { 1 , 1 , 1 , 1 }, //lrMetaTileCol,
330 { 0 , 0 , 0 , 0 }, //lrTileLineY,
331 { 0 , 0 , 0 , 0 }, //lrTileLineU,
332 { 0 , 0 , 0 , 0 }, //lrTileLineV,
333 { 0 , 0 , 0 , 0 }, //deblockLineYBuf,
334 { 0 , 0 , 0 , 0 }, //deblockLineUBuf,
335 { 0 , 0 , 0 , 0 }, //deblockLineVBuf,
336 { 0 , 0 , 0 , 0 }, //deblockTileLineYBuf,
337 { 0 , 0 , 0 , 0 }, //deblockTileLineVBuf,
338 { 0 , 0 , 0 , 0 }, //deblockTileLineUBuf,
339 { 0 , 0 , 0 , 0 }, //deblockTileColYBuf,
340 { 0 , 0 , 0 , 0 }, //deblockTileColUBuf,
341 { 0 , 0 , 0 , 0 }, //deblockTileColVBuf,
342 { 1 , 1 , 2 , 2 }, //cdefLineBuf,
343 { 1 , 1 , 2 , 2 }, //cdefTileLineBuf,
344 { 1 , 1 , 2 , 2 }, //cdefTileColBuf,
345 { 0 , 0 , 0 , 0 }, //cdefMetaTileLine,
346 { 1 , 1 , 1 , 1 }, //cdefMetaTileCol,
347 { 0 , 0 , 0 , 0 }, //cdefTopLeftCornerBuf,
348 { 22, 44 , 29 , 58 }, //superResTileColYBuf,
349 { 8 , 16 , 10 , 20 }, //superResTileColUBuf,
350 { 8 , 16 , 10 , 20 }, //superResTileColVBuf,
351 { 2 , 2 , 2 , 2 }, //lrTileColYBuf,
352 { 1 , 1 , 1 , 1 }, //lrTileColUBuf,
353 { 1 , 1 , 1 , 1 }, //lrTileColVBuf,
354 { 0 , 0 , 0 , 0 }, //frameStatusErrBuf,
355 { 0 , 0 , 0 , 0 }, //dbdStreamoutBuf,
356 { 1 , 1 , 1 , 1 }, //fgTileColBuf,
357 { 0 , 0 , 0 , 0 }, //fgSampleTmpBuf,
358 { 1 , 1 , 1 , 1 }, //lrTileColAlignBuf,
359 };
360
361 //!
362 //! \struct MmioRegistersAvp
363 //! \brief MMIO registers AVP
364 //!
365 struct MmioRegistersAvp
366 {
367 uint32_t avpAv1BitstreamByteCountTileRegOffset = 0;
368 uint32_t avpAv1BitstreamByteCountTileNoHeaderRegOffset = 0;
369 uint32_t avpAv1CabacBinCountTileRegOffset = 0;
370 uint32_t avpAv1CabacInsertionCountRegOffset = 0;
371 uint32_t avpAv1MinSizePaddingCountRegOffset = 0;
372 uint32_t avpAv1ImageStatusMaskRegOffset = 0;
373 uint32_t avpAv1ImageStatusControlRegOffset = 0;
374 uint32_t avpAv1QpStatusCountRegOffset = 0;
375 uint32_t avpAv1DecErrorStatusAddrRegOffset = 0;
376 };
377
378 //! MHW Vdbox Avp interface
379 /*!
380 This class defines the interfaces for constructing Vdbox Avp commands across all platforms
381 */
382 class MhwVdboxAvpInterface
383 {
384 protected:
385 PMOS_INTERFACE m_osInterface = nullptr; //!< Pointer to OS interface
386 MhwMiInterface *m_miInterface = nullptr; //!< Pointer to MI interface
387 MhwCpInterface *m_cpInterface = nullptr; //!< Pointer to CP interface
388 MEDIA_FEATURE_TABLE *m_skuTable = nullptr; //!< Pointer to SKU table
389 MEDIA_WA_TABLE *m_waTable = nullptr; //!< Pointer to WA table
390 bool m_decodeInUse = false; //!< Flag to indicate if the interface is for decoder or encoder use
391
392 MHW_MEMORY_OBJECT_CONTROL_PARAMS m_cacheabilitySettings[MOS_CODEC_RESOURCE_USAGE_END_CODEC] = {}; //!< Cacheability settings
393 MmioRegistersAvp m_mmioRegisters[MHW_VDBOX_NODE_MAX] = {}; //!< AVP mmio registers
394 bool m_rowstoreCachingSupported = false; //!< Flag to indicate if row store cache is supported
395
396 MHW_VDBOX_ROWSTORE_CACHE m_btdlRowstoreCache = {}; //! Bitstream Decoder/Encode Line Rowstore (BTDL)
397 MHW_VDBOX_ROWSTORE_CACHE m_smvlRowstoreCache = {}; //! Spatial Motion Vector Line Rowstore (SMVL)
398 MHW_VDBOX_ROWSTORE_CACHE m_ipdlRowstoreCache = {}; //! Intra Prediction Line Rowstore (IPDL)
399 MHW_VDBOX_ROWSTORE_CACHE m_dflyRowstoreCache = {}; //! Deblocker Filter Line Y Buffer (DFLY)
400 MHW_VDBOX_ROWSTORE_CACHE m_dfluRowstoreCache = {}; //! Deblocker Filter Line U Buffe (DFLU)
401 MHW_VDBOX_ROWSTORE_CACHE m_dflvRowstoreCache = {}; //! Deblocker Filter Line V Buffe (DFLV)
402 MHW_VDBOX_ROWSTORE_CACHE m_cdefRowstoreCache = {}; //! CDEF Filter Line Buffer (CDEF)
403
404 std::shared_ptr<void> m_avpItfNew = nullptr;
405
406 #if MOS_EVENT_TRACE_DUMP_SUPPORTED
407 bool bMMCReported = false;
408 #endif
409 //!
410 //! \brief Constructor
411 //!
412 MhwVdboxAvpInterface(
413 PMOS_INTERFACE osInterface,
414 MhwMiInterface *miInterface,
415 MhwCpInterface *cpInterface,
416 bool decodeInUse);
417
418 //!
419 //! \brief Add a resource to the command buffer
420 //! \details Internal function to add either a graphics address of a resource or
421 //! add the resource to the patch list for the requested buffer
422 //!
423 //! \param [in] osInterface
424 //! OS interface
425 //! \param [in] cmdBuffer
426 //! Command buffer to which resource is added
427 //! \param [in] params
428 //! Parameters necessary to add the resource
429 //!
430 //! \return MOS_STATUS
431 //! MOS_STATUS_SUCCESS if success, else fail reason
432 //!
433 MOS_STATUS(*AddResourceToCmd) (
434 PMOS_INTERFACE osInterface,
435 PMOS_COMMAND_BUFFER cmdBuffer,
436 PMHW_RESOURCE_PARAMS params);
437
438 public:
439 //!
440 //! \brief Destructor
441 //!
442 virtual ~MhwVdboxAvpInterface() {}
443
444 //!
445 //! \brief Get new AVP interface, temporal solution before switching from
446 //! old interface to new one
447 //!
448 //! \return pointer to new AVP interface
449 //!
450 virtual std::shared_ptr<void> GetNewAvpInterface() { return nullptr; }
451
452 //!
453 //! \brief Judge if row store caching supported
454 //!
455 //! \return bool
456 //! true if supported, else false
457 //!
458 inline bool IsRowStoreCachingSupported()
459 {
460 return m_rowstoreCachingSupported;
461 }
462
463 //!
464 //! \brief Judge if AV1 Bitstream Decoder/Encode Line Rowstore (BTDL) caching enabled
465 //!
466 //! \return bool
467 //! true if enabled, else false
468 //!
469 inline bool IsBtdlRowstoreCacheEnabled()
470 {
471 return m_btdlRowstoreCache.bEnabled ? true : false;
472 }
473
474 //!
475 //! \brief Judge if AV1 Spatial Motion Vector Line Rowstore caching enabled
476 //!
477 //! \return bool
478 //! true if enabled, else false
479 //!
480 inline bool IsSmvlRowstoreCacheEnabled()
481 {
482 return m_smvlRowstoreCache.bEnabled ? true : false;
483 }
484
485 //!
486 //! \brief Judge if AV1 Intra Prediction Line Rowstore (IPDL) caching enabled
487 //!
488 //! \return bool
489 //! true if enabled, else false
490 //!
491 inline bool IsIpdlRowstoreCacheEnabled()
492 {
493 return m_ipdlRowstoreCache.bEnabled ? true : false;
494 }
495
496 //!
497 //! \brief Judge if AV1 Deblocker Filter Line Y Buffer (DFLY) caching enabled
498 //!
499 //! \return bool
500 //! true if enabled, else false
501 //!
502 inline bool IsDflyRowstoreCacheEnabled()
503 {
504 return m_dflyRowstoreCache.bEnabled ? true : false;
505 }
506
507 //!
508 //! \brief Judge if AV1 Deblocker Filter Line U Buffe (DFLU) caching enabled
509 //!
510 //! \return bool
511 //! true if enabled, else false
512 //!
513 inline bool IsDfluRowstoreCacheEnabled()
514 {
515 return m_dfluRowstoreCache.bEnabled ? true : false;
516 }
517
518
519 //!
520 //! \brief Judge if AV1 Deblocker Filter Line V Buffe (DFLV) caching enabled
521 //!
522 //! \return bool
523 //! true if enabled, else false
524 //!
525 inline bool IsDflvRowstoreCacheEnabled()
526 {
527 return m_dflvRowstoreCache.bEnabled ? true : false;
528 }
529
530 //!
531 //! \brief Judge if AV1 CDEF Filter Line Buffer (CDEF) caching enabled
532 //!
533 //! \return bool
534 //! true if enabled, else false
535 //!
536 inline bool IsCdefRowstoreCacheEnabled()
537 {
538 return m_cdefRowstoreCache.bEnabled ? true : false;
539 }
540
541 //!
542 //! \brief Get mmio registers
543 //!
544 //! \param [in] index
545 //! mmio registers index.
546 //!
547 //! \return [out] MmioRegistersAvp*
548 //! mmio registers got.
549 //!
550 inline MmioRegistersAvp* GetMmioRegisters(MHW_VDBOX_NODE_IND index)
551 {
552 if (index < MHW_VDBOX_NODE_MAX)
553 {
554 return &m_mmioRegisters[index];
555 }
556 else
557 {
558 MHW_ASSERT("index is out of range!");
559 return &m_mmioRegisters[MHW_VDBOX_NODE_1];
560 }
561 }
562
563 //!
564 //! \brief Set cacheability settings
565 //!
566 //! \param [in] cacheabilitySettings
567 //! Cacheability settings
568 //!
569 //! \return MOS_STATUS
570 //! MOS_STATUS_SUCCESS if success, else fail reason
571 //!
572 MOS_STATUS SetCacheabilitySettings(
573 MHW_MEMORY_OBJECT_CONTROL_PARAMS cacheabilitySettings[MOS_CODEC_RESOURCE_USAGE_END_CODEC])
574 {
575 MHW_FUNCTION_ENTER;
576
577 uint32_t size = MOS_CODEC_RESOURCE_USAGE_END_CODEC * sizeof(MHW_MEMORY_OBJECT_CONTROL_PARAMS);
578 MOS_STATUS eStatus = MOS_SecureMemcpy(m_cacheabilitySettings, size,
579 cacheabilitySettings, size);
580
581 return eStatus;
582 }
583
584 //!
585 //! \brief Calculates the maximum size for AVP picture level commands
586 //! \details Client facing function to calculate the maximum size for AVP picture level commands
587 //! \param [out] commandsSize
588 //! The maximum command buffer size
589 //! \param [out] patchListSize
590 //! The maximum command patch list size
591 //! \param [in] params
592 //! Indicate the command size parameters
593 //! \return MOS_STATUS
594 //! MOS_STATUS_SUCCESS if success, else fail reason
595 //!
596 virtual MOS_STATUS GetAvpStateCommandSize(
597 uint32_t *commandsSize,
598 uint32_t *patchListSize,
599 PMHW_VDBOX_STATE_CMDSIZE_PARAMS params) = 0;
600
601 //!
602 //! \brief Calculates maximum size for AVP slice/MB level commands
603 //! \details Client facing function to calculate maximum size for AVP slice/MB level commands
604 //! \param [out] commandsSize
605 //! The maximum command buffer size
606 //! \param [out] patchListSize
607 //! The maximum command patch list size
608 //! \return MOS_STATUS
609 //! MOS_STATUS_SUCCESS if success, else fail reason
610 //!
611 virtual MOS_STATUS GetAvpPrimitiveCommandSize(
612 uint32_t *commandsSize,
613 uint32_t *patchListSize) = 0;
614
615 //!
616 //! \brief Get the required buffer size for VDBOX
617 //! \details Internal function to judge if buffer realloc is needed for AV1 codec
618 //!
619 //! \param [in] bufferType
620 //! AV1 Buffer type
621 //! \param [in, out] reallocParam
622 //! AVP Re-allocate parameters
623 //!
624 //! \return MOS_STATUS
625 //! MOS_STATUS_SUCCESS if success, else fail reason
626 //!
627 virtual MOS_STATUS IsAv1BufferReallocNeeded(
628 MhwVdboxAvpInternalBufferType bufferType,
629 MhwVdboxAvpBufferReallocParams *reallocParam) = 0;
630
631 //!
632 //! \brief Get the required buffer size for VDBOX
633 //! \details Internal function to get required buffer size for AV1 codec
634 //!
635 //! \param [in] bufferType
636 //! AV1 Buffer type
637 //! \param [in, out] avpBufSizeParam
638 //! AVP buffer size parameters
639 //!
640 //! \return MOS_STATUS
641 //! MOS_STATUS_SUCCESS if success, else fail reason
642 //!
643 virtual MOS_STATUS GetAv1BufferSize(
644 MhwVdboxAvpInternalBufferType bufferType,
645 MhwVdboxAvpBufferSizeParams *avpBufSizeParam) = 0;
646
647 //!
648 //! \brief Adds AVP Surface State command in command buffer
649 //! \details Client facing function to add AVP Surface State command in command buffer
650 //!
651 //! \param [in] cmdBuffer
652 //! Command buffer to which HW command is added
653 //! \param [in] params
654 //! Params structure used to populate the HW command
655 //!
656 //! \return MOS_STATUS
657 //! MOS_STATUS_SUCCESS if success, else fail reason
658 //!
659 virtual MOS_STATUS AddAvpSurfaceCmd(
660 PMOS_COMMAND_BUFFER cmdBuffer,
661 PMHW_VDBOX_SURFACE_PARAMS params);
662
663 //!
664 //! \brief Adds AVP Segment State command in command buffer
665 //! \details Client facing function to add AVP Segment State command in command buffer
666 //!
667 //! \param [in] cmdBuffer
668 //! Command buffer to which HW command is added
669 //! \param [in] params
670 //! Params structure used to populate the HW command
671 //!
672 //! \return MOS_STATUS
673 //! MOS_STATUS_SUCCESS if success, else fail reason
674 //!
675 virtual MOS_STATUS AddAvpSegmentStateCmd(
676 PMOS_COMMAND_BUFFER cmdBuffer,
677 MhwVdboxAvpSegmentStateParams *params) = 0;
678
679 //!
680 //! \brief Programs base address of rowstore scratch buffers
681 //! \details Internal function to get base address of rowstore scratch buffers
682 //!
683 //! \param [in] rowstoreParams
684 //! Rowstore parameters
685 //!
686 //! \return MOS_STATUS
687 //! MOS_STATUS_SUCCESS if success, else fail reason
688 //!
689 virtual MOS_STATUS GetRowstoreCachingAddrs(
690 PMHW_VDBOX_ROWSTORE_PARAMS rowstoreParams) = 0;
691
692 //!
693 //! \brief Adds AVP Pipe Pipe Mode Select command in command buffer
694 //!
695 //! \param [in] cmdBuffer
696 //! Command buffer to which HW command is added
697 //! \param [in] params
698 //! Params structure used to populate the HW command
699 //!
700 //! \return MOS_STATUS
701 //! MOS_STATUS_SUCCESS if success, else fail reason
702 //!
703 virtual MOS_STATUS AddAvpPipeModeSelectCmd(
704 PMOS_COMMAND_BUFFER cmdBuffer,
705 PMHW_VDBOX_PIPE_MODE_SELECT_PARAMS params) = 0;
706
707 //!
708 //! \brief Adds AVP Surface State command for decode in command buffer
709 //!
710 //! \param [in] cmdBuffer
711 //! Command buffer to which HW command is added
712 //! \param [in] params
713 //! Params structure used to populate the HW command
714 //!
715 //! \return MOS_STATUS
716 //! MOS_STATUS_SUCCESS if success, else fail reason
717 //!
718 virtual MOS_STATUS AddAvpDecodeSurfaceStateCmd(
719 PMOS_COMMAND_BUFFER cmdBuffer,
720 PMHW_VDBOX_SURFACE_PARAMS params) = 0;
721
722 //!
723 //! \brief Adds AVP Pipe Buffer Address State command in command buffer
724 //!
725 //! \param [in] cmdBuffer
726 //! Command buffer to which HW command is added
727 //! \param [in] params
728 //! Params structure used to populate the HW command
729 //!
730 //! \return MOS_STATUS
731 //! MOS_STATUS_SUCCESS if success, else fail reason
732 //!
733 virtual MOS_STATUS AddAvpPipeBufAddrCmd(
734 PMOS_COMMAND_BUFFER cmdBuffer,
735 MhwVdboxAvpPipeBufAddrParams *params) = 0;
736
737 //!
738 //! \brief Adds AVP Indirect Object Base Address State command in command buffer
739 //!
740 //! \param [in] cmdBuffer
741 //! Command buffer to which HW command is added
742 //! \param [in] params
743 //! Params structure used to populate the HW command
744 //!
745 //! \return MOS_STATUS
746 //! MOS_STATUS_SUCCESS if success, else fail reason
747 //!
748 virtual MOS_STATUS AddAvpIndObjBaseAddrCmd(
749 PMOS_COMMAND_BUFFER cmdBuffer,
750 PMHW_VDBOX_IND_OBJ_BASE_ADDR_PARAMS params) = 0;
751
752 //!
753 //! \brief Adds AVP picture State command for decode in command buffer
754 //!
755 //! \param [in] cmdBuffer
756 //! Command buffer to which HW command is added
757 //! \param [in] batchBuffer
758 //! Batch buffer to which HW command is added
759 //! \param [in] params
760 //! Params structure used to populate the HW command
761 //!
762 //! \return MOS_STATUS
763 //! MOS_STATUS_SUCCESS if success, else fail reason
764 //!
765 virtual MOS_STATUS AddAvpDecodePicStateCmd(
766 PMOS_COMMAND_BUFFER cmdBuffer,
767 MhwVdboxAvpPicStateParams *params) = 0;
768
769 //!
770 //! \brief Adds AVP BSD object state command in command buffer
771 //!
772 //! \param [in] cmdBuffer
773 //! Command buffer to which HW command is added
774 //! \param [in] params
775 //! Params structure used to populate the HW command
776 //!
777 //! \return MOS_STATUS
778 //! MOS_STATUS_SUCCESS if success, else fail reason
779 //!
780 virtual MOS_STATUS AddAvpBsdObjectCmd(
781 PMOS_COMMAND_BUFFER cmdBuffer,
782 PMHW_BATCH_BUFFER batchBuffer,
783 MhwVdboxAvpBsdParams *params) = 0;
784
785 //!
786 //! \brief Adds AVP tile coding command in command buffer for decoder
787 //!
788 //! \param [in] cmdBuffer
789 //! Command buffer to which HW command is added
790 //! \param [in] params
791 //! Params structure used to populate the HW command
792 //!
793 //! \return MOS_STATUS
794 //! MOS_STATUS_SUCCESS if success, else fail reason
795 //!
796 virtual MOS_STATUS AddAvpDecodeTileCodingCmd(
797 PMOS_COMMAND_BUFFER cmdBuffer,
798 PMHW_BATCH_BUFFER batchBuffer,
799 MhwVdboxAvpTileCodingParams *params) = 0;
800
801 //!
802 //! \brief Adds AVP tile coding command in command buffer when Large Scale Tile decoding is supported
803 //!
804 //! \param [in] cmdBuffer
805 //! Command buffer to which HW command is added
806 //! \param [in] params
807 //! Params structure used to populate the HW command
808 //!
809 //! \return MOS_STATUS
810 //! MOS_STATUS_SUCCESS if success, else fail reason
811 //!
812 virtual MOS_STATUS AddAvpDecodeTileCodingCmdLst(
813 PMOS_COMMAND_BUFFER cmdBuffer,
814 PMHW_BATCH_BUFFER batchBuffer,
815 MhwVdboxAvpTileCodingParams *params) = 0;
816
817 //!
818 //! \brief Adds AVP tile coding command in command buffer
819 //!
820 //! \param [in] cmdBuffer
821 //! Command buffer to which HW command is added
822 //! \param [in] params
823 //! Params structure used to populate the HW command
824 //!
825 //! \return MOS_STATUS
826 //! MOS_STATUS_SUCCESS if success, else fail reason
827 //!
828 virtual MOS_STATUS AddAvpTileCodingCmd(
829 PMOS_COMMAND_BUFFER cmdBuffer,
830 PMHW_BATCH_BUFFER batchBuffer,
831 MhwVdboxAvpTileCodingParams *params) = 0;
832
833 //!
834 //! \brief Adds AVP Inloop Filter State command for decode in command buffer
835 //!
836 //! \param [in] cmdBuffer
837 //! Command buffer to which HW command is added
838 //! \param [in] params
839 //! Params structure used to populate the HW command
840 //!
841 //! \return MOS_STATUS
842 //! MOS_STATUS_SUCCESS if success, else fail reason
843 //!
844 virtual MOS_STATUS AddAvpInloopFilterStateCmd(
845 PMOS_COMMAND_BUFFER cmdBuffer,
846 MhwVdboxAvpPicStateParams *params) = 0;
847
848 //!
849 //! \brief Adds AVP Inter Prediction State command
850 //! \details function to add AVP Inter Prediction State command in command buffer
851 //!
852 //! \param [in] cmdBuffer
853 //! Command buffer to which HW command is added
854 //! \param [in] params
855 //! Params structure used to populate the HW command
856 //!
857 //! \return MOS_STATUS
858 //! MOS_STATUS_SUCCESS if success, else fail reason
859 //!
860 virtual MOS_STATUS AddAvpInterPredStateCmd(
861 PMOS_COMMAND_BUFFER cmdBuffer,
862 MhwVdboxAvpPicStateParams *params) = 0;
863 };
864
865 #endif