1 /*
2 * Copyright (c) 2017-2022, 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_mfx_interface.h
24 //! \brief    MHW interface for constructing MFX commands for the Vdbox engine
25 //! \details  Defines the interfaces for constructing MHW Vdbox MFX commands across all platforms
26 //!
27 
28 #ifndef _MHW_VDBOX_MFX_INTERFACE_H_
29 #define _MHW_VDBOX_MFX_INTERFACE_H_
30 
31 #include "mhw_vdbox.h"
32 #include "mhw_mi.h"
33 #include "codec_def_common_encode.h"
34 #include "codec_def_encode_vp9.h"
35 #include "codec_def_encode_vp8.h"
36 #include "codec_def_encode_hevc.h"
37 #include "codec_def_decode_mpeg2.h"
38 #include "codec_def_decode_vp8.h"
39 #include "codec_def_decode_jpeg.h"
40 #include "codec_def_vp8_probs.h"
41 
42 #define MFX_PAK_STREAMOUT_DATA_BYTE_SIZE   4
43 
44 typedef enum _MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_LUMA
45 {
46     MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_LUMA_X0Y0 = 0x0f0c0300,
47     MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_LUMA_X1Y0 = 0x0f0f0303,
48     MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_LUMA_X0Y1 = 0x0f0c0f0c,
49     MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_LUMA_X1Y1 = 0x0f0f0f0f,
50 
51 } MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_LUMA;
52 
53 typedef enum _MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_CHROMA
54 {
55     MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_CHROMA_X0Y0 = 0x00000000,
56     MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_CHROMA_X1Y0 = 0x00000303,
57     MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_CHROMA_X0Y1 = 0x00000c0c,
58     MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_CHROMA_X1Y1 = 0x00000f0f,
59 
60 } MHW_VDBOX_DECODE_VC1_IT_ILDB_EDGE_CONTROL_CHROMA;
61 
62 typedef struct _MHW_VDBOX_MPEG2_SLICE_STATE
63 {
64     PMOS_RESOURCE                   presDataBuffer;
65     PMOS_RESOURCE                   presPicHeaderBBSurf; // BRC only
66     uint32_t                        dwOffset;
67     uint32_t                        dwLength;
68     uint32_t                        dwSliceStartMbOffset;
69     uint16_t                        wPicWidthInMb;
70     uint16_t                        wPicHeightInMb;
71     bool                            bLastSlice;
72 
73     // Decoding Only
74     CodecDecodeMpeg2SliceParams    *pMpeg2SliceParams;
75 
76     // Encoding Only
77     PCODEC_PIC_ID                   pMpeg2PicIdx;
78     PCODEC_REF_LIST                *ppMpeg2RefList;
79     CodecEncodeMpeg2SequenceParams *pEncodeMpeg2SeqParams;
80     CodecEncodeMpeg2PictureParams  *pEncodeMpeg2PicParams;
81     CodecEncodeMpeg2SliceParmas    *pEncodeMpeg2SliceParams;
82     PBSBuffer                       pBsBuffer;
83     PCODECHAL_NAL_UNIT_PARAMS      *ppNalUnitParams;
84     PCODEC_ENCODER_SLCDATA          pSlcData;
85     bool                            bFirstPass;
86     bool                            bLastPass;
87     uint32_t                        dwSliceIndex;
88     uint32_t                        dwDataBufferOffset;
89     bool                            bBrcEnabled;
90     bool                            bRCPanicEnable;
91     bool                            bInsertBeforeSliceHeaders;
92 
93 } MHW_VDBOX_MPEG2_SLICE_STATE, *PMHW_VDBOX_MPEG2_SLICE_STATE;
94 
95 typedef struct _MHW_VDBOX_MPEG2_MB_STATE
96 {
97     CodecDecodeMpeg2MbParams       *pMBParams;
98     uint16_t                        wPicWidthInMb;
99     uint16_t                        wPicHeightInMb;
100     uint16_t                        wPicCodingType;
101     uint32_t                        dwDCTLength;
102     uint32_t                        dwITCoffDataAddrOffset;
103     int16_t                         sPackedMVs0[4];
104     int16_t                         sPackedMVs1[4];
105 } MHW_VDBOX_MPEG2_MB_STATE, *PMHW_VDBOX_MPEG2_MB_STATE;
106 
107 typedef struct _MHW_VDBOX_VC1_PRED_PIPE_PARAMS
108 {
109     PCODEC_VC1_PIC_PARAMS       pVc1PicParams;
110     PCODEC_REF_LIST            *ppVc1RefList;
111 } MHW_VDBOX_VC1_PRED_PIPE_PARAMS, *PMHW_VDBOX_VC1_PRED_PIPE_PARAMS;
112 
113 typedef struct _MHW_VDBOX_VC1_PIC_STATE
114 {
115     PCODEC_VC1_PIC_PARAMS       pVc1PicParams;
116     uint32_t                    Mode;
117     PCODEC_REF_LIST            *ppVc1RefList;
118     uint16_t                    wPrevAnchorPictureTFF;
119     bool                        bPrevEvenAnchorPictureIsP;
120     bool                        bPrevOddAnchorPictureIsP;
121 } MHW_VDBOX_VC1_PIC_STATE, *PMHW_VDBOX_VC1_PIC_STATE;
122 
123 typedef struct _MHW_VDBOX_VC1_DIRECTMODE_PARAMS
124 {
125     PMOS_RESOURCE                   presDmvReadBuffer;
126     PMOS_RESOURCE                   presDmvWriteBuffer;
127 } MHW_VDBOX_VC1_DIRECTMODE_PARAMS, *PMHW_VDBOX_VC1_DIRECTMODE_PARAMS;
128 
129 typedef struct _MHW_VDBOX_VC1_SLICE_STATE
130 {
131     PCODEC_VC1_SLICE_PARAMS         pSlc;
132     PMOS_RESOURCE                   presDataBuffer;
133     uint32_t                        dwOffset;
134     uint32_t                        dwLength;
135     uint32_t                        dwNextVerticalPosition;
136     bool                            bShortFormatInUse;
137 } MHW_VDBOX_VC1_SLICE_STATE, *PMHW_VDBOX_VC1_SLICE_STATE;
138 
139 typedef struct _MHW_VDBOX_VC1_MB_STATE
140 {
141     PCODEC_VC1_MB_PARAMS            pMb;
142     PCODEC_VC1_PIC_PARAMS           pVc1PicParams;
143     MEDIA_WA_TABLE                  *pWaTable;                               // WA table
144 
145     PMOS_RESOURCE                   presDataBuffer;
146     uint8_t                        *pDeblockDataBuffer;
147     uint32_t                        dwDataSize;
148     uint32_t                        dwOffset;
149     uint32_t                        dwLength;
150     uint8_t                         bMbHorizOrigin;
151     uint8_t                         bMbVertOrigin;
152     uint8_t                         DeblockData[CODEC_NUM_BLOCK_PER_MB];
153     uint32_t                        PackedLumaMvs[4];                       // packed motion vectors for Luma
154     uint32_t                        PackedChromaMv;                         // packed motion vector for Chroma
155     uint16_t                        wPicWidthInMb;                          // Picture Width in MB width count
156     uint16_t                        wPicHeightInMb;                         // Picture Height in MB height count
157     CODEC_PICTURE_FLAG              PicFlags;
158     uint8_t                         bMotionSwitch;                          // VC1 MotionSwitch
159     uint8_t                         bFieldPolarity;
160     uint8_t                         bSkipped;
161 } MHW_VDBOX_VC1_MB_STATE, *PMHW_VDBOX_VC1_MB_STATE;
162 
163 typedef struct _MHW_VDBOX_HUFF_TABLE_PARAMS
164 {
165     uint32_t    HuffTableID;
166     void       *pDCBits;
167     void       *pDCValues;
168     void       *pACBits;
169     void       *pACValues;
170 } MHW_VDBOX_HUFF_TABLE_PARAMS, *PMHW_VDBOX_HUFF_TABLE_PARAMS;
171 
172 typedef struct _MHW_VDBOX_ENCODE_HUFF_TABLE_PARAMS
173 {
174     uint32_t    HuffTableID;
175     uint8_t     pDCCodeLength[JPEG_NUM_HUFF_TABLE_DC_HUFFVAL]; // 12 values of 1 byte each
176     uint16_t    pDCCodeValues[JPEG_NUM_HUFF_TABLE_DC_HUFFVAL]; // 12 values of 2 bytes each
177     uint8_t     pACCodeLength[JPEG_NUM_HUFF_TABLE_AC_HUFFVAL]; // 162 values of 1 byte each
178     uint16_t    pACCodeValues[JPEG_NUM_HUFF_TABLE_AC_HUFFVAL]; // 162 values of 2 bytes each
179 } MHW_VDBOX_ENCODE_HUFF_TABLE_PARAMS, *PMHW_VDBOX_ENCODE_HUFF_TABLE_PARAMS;
180 
181 typedef struct _MHW_VDBOX_JPEG_BSD_PARAMS
182 {
183     uint32_t    dwIndirectDataLength;
184     uint32_t    dwDataStartAddress;
185     uint32_t    dwScanHorizontalPosition;
186     uint32_t    dwScanVerticalPosition;
187     bool        bInterleaved;
188     int16_t     sScanComponent;
189     uint32_t    dwMCUCount;
190     uint32_t    dwRestartInterval;
191 } MHW_VDBOX_JPEG_BSD_PARAMS, *PMHW_VDBOX_JPEG_BSD_PARAMS;
192 
193 typedef struct _MHW_VDBOX_JPEG_PIC_STATE
194 {
195     CodecDecodeJpegPicParams  *pJpegPicParams;
196     uint32_t                   Mode;
197     uint32_t                   dwWidthInBlocks;
198     uint32_t                   dwHeightInBlocks;
199     uint32_t                   dwOutputFormat;
200 } MHW_VDBOX_JPEG_DECODE_PIC_STATE, *PMHW_VDBOX_JPEG_PIC_STATE;
201 
202 //!
203 //! \struct    MhwVdboxJpegEncodePicState
204 //! \brief     MHW vdbox JPEG encode picture state
205 //!
206 struct MhwVdboxJpegEncodePicState
207 {
208     CodecEncodeJpegPictureParams           *pJpegEncodePicParams;
209     uint32_t                                mode;
210 };
211 
212 //!
213 //! \struct    MhwVdboxJpegScanParams
214 //! \brief     MHW vdbox JPEG scan parameters
215 //!
216 struct MhwVdboxJpegScanParams
217 {
218     CodecEncodeJpegScanHeader              *pJpegEncodeScanParams;
219     CodecEncodeJpegInputSurfaceFormat       inputSurfaceFormat;
220     uint32_t                                dwPicWidth;
221     uint32_t                                dwPicHeight;
222     uint32_t                                mode;
223 };
224 
225 typedef struct _MHW_VDBOX_VP8_PIC_STATE
226 {
227     PCODEC_VP8_PIC_PARAMS           pVp8PicParams;
228     PCODEC_VP8_IQ_MATRIX_PARAMS     pVp8IqMatrixParams;
229     PMOS_RESOURCE                   presCoefProbBuffer;
230     PMOS_RESOURCE                   presSegmentationIdStreamBuffer;
231     uint32_t                        dwCoefProbTableOffset;
232 
233     // Encoding Params
234     PCODEC_VP8_ENCODE_SEQUENCE_PARAMS       pEncodeVP8SeqParams;
235     PCODEC_VP8_ENCODE_PIC_PARAMS            pEncodeVP8PicParams;
236     PCODEC_VP8_ENCODE_QUANT_DATA            pEncodeVP8QuantData;
237     uint16_t                                wPicWidthInMb;
238     uint16_t                                wPicHeightInMb;
239     uint8_t                                 ucKernelMode;     // normal, performance, quality.
240 
241 } MHW_VDBOX_VP8_PIC_STATE, *PMHW_VDBOX_VP8_PIC_STATE;
242 
243 typedef struct _MHW_VDBOX_VP8_BSP_BUF_BASE_ADDR_PARAMS
244 {
245     PMOS_RESOURCE               presFrameHeaderBuffer;
246     PMOS_RESOURCE               presCoeffProbsBuffer;
247     PMOS_RESOURCE               presPakIntermediateBuffer;
248     PMOS_RESOURCE               presPakFinalFrameBuffer;
249     PMOS_RESOURCE               presTokenStatisticsBuffer;
250     PMOS_RESOURCE               presBsdMpcRowStoreScratchBuffer;
251     uint32_t                    dwPakIntermediateTokenSize;
252     uint32_t                    dwPakIntermediatePartition0Size;
253     uint32_t                    dwPartitions;
254 } MHW_VDBOX_VP8_BSP_BUF_BASE_ADDR_PARAMS, *PMHW_VDBOX_VP8_BSP_BUF_BASE_ADDR_PARAMS;
255 
256 typedef struct _MHW_VDBOX_VP8_ENCODER_CFG_PARAMS
257 {
258     bool                                    bFirstPass;
259     bool                                    bBRCEnabled;
260     uint32_t                                dwCfgBufferSize;               // total buffer size
261     uint32_t                                dwCfgCmdOffset;                // offset of the CFG command in
262     PCODEC_VP8_ENCODE_SEQUENCE_PARAMS       pEncodeVP8SeqParams;
263     PCODEC_VP8_ENCODE_PIC_PARAMS            pEncodeVP8PicParams;
264     PCODEC_VP8_ENCODE_QUANT_DATA            pEncodeVP8QuantData;
265 } MHW_VDBOX_VP8_ENCODER_CFG_PARAMS, *PMHW_VDBOX_VP8_ENCODER_CFG_PARAMS;
266 
267 typedef struct _MHW_VDBOX_VP8_BSD_PARAMS
268 {
269     PCODEC_VP8_PIC_PARAMS       pVp8PicParams;
270 } MHW_VDBOX_VP8_BSD_PARAMS, *PMHW_VDBOX_VP8_BSD_PARAMS;
271 
272 typedef struct _MHW_VDBOX_MPEG2_PIC_STATE
273 {
274     uint32_t                    Mode;
275 
276     // Decoding Params
277     CodecDecodeMpeg2PicParams  *pMpeg2PicParams;
278     bool                        bDeblockingEnabled;
279     uint32_t                    dwMPEG2ISliceConcealmentMode;           // Mpeg2 I slice concealment mode
280     uint32_t                    dwMPEG2PBSliceConcealmentMode;          // Mpeg2 P/B slice concealment mode
281     uint32_t                    dwMPEG2PBSlicePredBiDirMVTypeOverride;  // Mpeg2 P/B Slice Predicted BiDir Motion Type Override
282     uint32_t                    dwMPEG2PBSlicePredMVOverride;           // Mpeg2 P/B Slice Predicted Motion Vector Override
283 
284                                                                         // Encoding Params
285     CodecEncodeMpeg2SequenceParams         *pEncodeMpeg2SeqParams;
286     CodecEncodeMpeg2PictureParams          *pEncodeMpeg2PicParams;
287     PCODEC_REF_LIST                        *ppRefList;
288     bool                                    bBrcEnabled;
289     bool                                    bTrellisQuantEnable;
290     uint16_t                                wPicWidthInMb;
291     uint16_t                                wPicHeightInMb;
292     uint8_t                                 ucKernelMode;     // normal, performance, quality.
293     bool                                    bIPCMPass;
294 
295     uint32_t                                dwFrameBitRateMaxReportMask;
296     uint32_t                                dwIntraMBMaxSize;
297     uint32_t                                dwInterMBMaxSize;
298 
299     uint8_t                                 ucSliceDeltaQPMax0;
300     uint8_t                                 ucSliceDeltaQPMax1;
301     uint8_t                                 ucSliceDeltaQPMax2;
302     uint8_t                                 ucSliceDeltaQPMax3;
303 
304     uint32_t                                dwFrameBitRateMax;
305     uint32_t                                dwFrameBitRateMaxUnit;
306 } MHW_VDBOX_MPEG2_PIC_STATE, *PMHW_VDBOX_MPEG2_PIC_STATE;
307 
308 typedef struct _MHW_VDBOX_AVC_DPB_PARAMS
309 {
310     PCODEC_AVC_PIC_PARAMS                   pAvcPicParams;
311     PCODEC_MVC_EXT_PIC_PARAMS               pMvcExtPicParams;
312     PCODEC_REF_LIST                        *ppAvcRefList;
313     PCODEC_PIC_ID                           pAvcPicIdx;
314     bool                                    bPicIdRemappingInUse;
315 } MHW_VDBOX_AVC_DPB_PARAMS, *PMHW_VDBOX_AVC_DPB_PARAMS;
316 
317 typedef struct _MHW_VDBOX_AVC_DIRECTMODE_PARAMS
318 {
319     CODEC_PICTURE                   CurrPic;
320     bool                            isEncode;
321     uint32_t                        uiUsedForReferenceFlags;
322     PMOS_RESOURCE                   presAvcDmvBuffers;
323     uint8_t                         ucAvcDmvIdx;
324     PCODEC_AVC_DMV_LIST             pAvcDmvList;
325     PCODEC_PIC_ID                   pAvcPicIdx;
326     void                            **avcRefList;
327     bool                            bPicIdRemappingInUse;
328     int32_t                         CurrFieldOrderCnt[2];
329     bool                            bDisableDmvBuffers;
330     PMOS_RESOURCE                   presMvcDummyDmvBuffer;
331 } MHW_VDBOX_AVC_DIRECTMODE_PARAMS, *PMHW_VDBOX_AVC_DIRECTMODE_PARAMS;
332 
333 typedef struct _MHW_VDBOX_AVC_REF_IDX_PARAMS
334 {
335     CODEC_PICTURE                   CurrPic               = {};
336     uint32_t                        uiNumRefForList[2]    = {};
337     CODEC_PICTURE                   RefPicList[2][32]     = {};
338     PCODEC_PIC_ID                   pAvcPicIdx            = {};
339     uint32_t                        uiList                = 0;
340     void                            **avcRefList          = nullptr;
341     bool                            isEncode              = false;
342     bool                            bVdencInUse           = false;
343     bool                            bIntelEntrypointInUse = false;
344     bool                            bPicIdRemappingInUse  = false;
345     bool                            oneOnOneMapping       = false;
346     bool                            bDummyReference       = false;
347 } MHW_VDBOX_AVC_REF_IDX_PARAMS, *PMHW_VDBOX_AVC_REF_IDX_PARAMS;
348 
349 typedef struct _MHW_VDBOX_PIC_ID_PARAMS
350 {
351     bool                    bPicIdRemappingInUse;
352     PCODEC_PIC_ID           pAvcPicIdx;
353 } MHW_VDBOX_PIC_ID_PARAMS, *PMHW_VDBOX_PIC_ID_PARAMS;
354 
355 typedef struct _MHW_VDBOX_BSP_BUF_BASE_ADDR_PARAMS
356 {
357     PMOS_RESOURCE               presBsdMpcRowStoreScratchBuffer;                 // Handle of BSD/MPC Row Store Scratch data surface
358     PMOS_RESOURCE               presMprRowStoreScratchBuffer;                    // Handle of MPR Row Store Scratch data surface
359     PMOS_RESOURCE               presBitplaneBuffer;
360 } MHW_VDBOX_BSP_BUF_BASE_ADDR_PARAMS, *PMHW_VDBOX_BSP_BUF_BASE_ADDR_PARAMS;
361 
362 typedef struct _MHW_VDBOX_AVC_IMG_BITRATE_PARAMS
363 {
364     uint32_t   frameBitRateMin : 14;
365     uint32_t   frameBitRateMinUnitMode : 1;
366     uint32_t   frameBitRateMinUnit : 1;
367     uint32_t   frameBitRateMax : 14;
368     uint32_t   frameBitRateMaxUnitMode : 1;
369     uint32_t   frameBitRateMaxUnit : 1;
370     uint32_t   frameBitRateMinDelta : 15;
371     uint32_t   : 1;
372     uint32_t   frameBitRateMaxDelta : 15;
373     uint32_t   : 1;
374 } MHW_VDBOX_AVC_IMG_BITRATE_PARAMS, *PMHW_VDBOX_AVC_IMG_BITRATE_PARAMS;
375 
376 //!
377 //! \class    MhwVdboxMfxInterface
378 //! \brief    MHW Vdbox Mfx interface
379 //!
380 /*!
381 This class defines the interfaces for constructing Vdbox Mfx commands across all platforms
382 */
383 class MhwVdboxMfxInterface
384 {
385 protected:
386     static const uint8_t  m_mpeg2QuantMatrixScan[64]; //!< MPEG2 quantization table scan order
387 
388     //!
389     //! \enum     AvcSliceType
390     //! \brief    Average slice type
391     //!
392     enum AvcSliceType
393     {
394         avcSliceP = 0,
395         avcSliceB = 1,
396         avcSliceI = 2
397     };
398 
399     //!
400     //! \enum     Mpeg2Vc1MacroblockIntratype
401     //! \brief    MPEG2 VC1 macro block intra type
402     //!
403     enum Mpeg2Vc1MacroblockIntratype
404     {
405         mpeg2Vc1MacroblockNonintra  = 0,
406         mpeg2Vc1MacroblockIntra     = 1
407     };
408 
409     //!
410     //! \enum     Mpeg2Vc1PictureStructure
411     //! \brief    MPEG2 VC1 picture structure
412     //!
413     enum Mpeg2Vc1PictureStructure
414     {
415         mpeg2Vc1TopField = 1,
416         mpeg2Vc1BottomField,
417         mpeg2Vc1Frame
418     };
419 
420     //!
421     //! \enum     Vc1FrameCodingMode
422     //! \brief    VC1 frame coding mode
423     //!
424     enum Vc1FrameCodingMode
425     {
426         vc1ProgressiveFrame = 0,
427         vc1InterlacedFrame,
428         vc1TffFrame,
429         vc1BffFrame
430     };
431 
432     //!
433     //! \enum     Vc1CodedMode
434     //! \brief    VC1 coded mode
435     //!
436     enum Vc1CodedMode
437     {
438         vc1NonrawMode = 0,
439         vc1RawMode = 1
440     };
441 
442     //!
443     //! \struct   RefBoundaryReplicationMode
444     //! \brief    Reference boundary replication mode
445     //!
446     struct RefBoundaryReplicationMode
447     {
448         union
449         {
450             struct
451             {
452                 uint8_t ref0            : 1;
453                 uint8_t ref1            : 1;
454                 uint8_t ref2            : 1;
455                 uint8_t ref3            : 1;
456             };
457             struct
458             {
459                 uint8_t value;
460             };
461         } BY0;
462     };
463 
464     //!
465     //! \enum     Vc1FrameBoundaryType
466     //! \brief    VC1 frame boundary type
467     //!
468     enum Vc1FrameBoundaryType
469     {
470         vc1ProgressiveBoundary = 0,
471         vc1InterlacedBoundary  = 1
472     };
473 
474     //!
475     //! \struct   AvcRefListWrite
476     //! \brief    Average reference list write
477     //!
478     struct AvcRefListWrite
479     {
480         union
481         {
482             struct
483             {
484                 uint8_t bottomField     : 1;
485                 uint8_t frameStoreID    : 4;
486                 uint8_t fieldPicFlag    : 1;
487                 uint8_t longTermFlag    : 1;
488                 uint8_t nonExisting     : 1;
489             };
490             struct
491             {
492                 uint8_t value;
493             };
494         } UC[32];
495     };
496 
497     //!
498     //! \enum     AvcQmTypes
499     //! \brief    Average qm types
500     //!
501     enum AvcQmTypes
502     {
503         avcQmIntra4x4 = 0,
504         avcQmInter4x4 = 1,
505         avcQmIntra8x8 = 2,
506         avcQmInter8x8 = 3
507     };
508 
509     //!
510     //! \enum     Mpeg2QmTypes
511     //! \brief    MPEG2 qm types
512     //!
513     enum Mpeg2QmTypes
514     {
515         mpeg2QmIntra = 0,
516         mpeg2QmNonIntra,
517     };
518 
519     //!
520     //! \enum     AvcPicid
521     //! \brief    Average picid
522     //!
523     enum AvcPicid
524     {
525         avcPicidDisabled = 0,
526         avcPicidDefault = 0xFFFFFFFF
527     };
528 
529     //!
530     //! \enum     AvcImgStructure
531     //! \brief    Average image structure
532     //!
533     enum AvcImgStructure
534     {
535         avcFrame        = 0,
536         avcTopField     = 1,
537         avcBottomField  = 3
538     };
539 
540     //!
541     //! \enum     CodecSelect
542     //! \brief    Code select
543     //!
544     enum CodecSelect
545     {
546         decoderCodec    = 0,
547         encoderCodec    = 1
548     };
549 
550     //!
551     //! \enum     MfxDecoderModeSelect
552     //! \brief    MFX decoder mode select
553     //!
554     enum MfxDecoderModeSelect
555     {
556         mfxDecoderModeVld   = 0,
557         mfxDecoderModeIt    = 1
558     };
559 
560     static const uint16_t m_mpeg2DefaultIntraQuantizerMatrix[64]; //!< MPEG2 default quantization matrix for intra macroblock
561     static const uint16_t m_mpeg2DefaultNonIntraQuantizerMatrix[64]; //!< MPEG2 default quantization matrix for inter macroblock
562     static const uint32_t m_mpeg2SliceDeltaQPMax[4]; //! MPEG2 slice delta QP max value
563     static const uint32_t m_mpeg2InitSliceDeltaQPMin[4]; //!< MPEG2 slice delta QP min value
564     static const uint32_t m_mpeg2FrameBitrateMinMax[4]; //!< MPEG2 frame bitrate Min/Max value
565     static const uint32_t m_mpeg2FrameBitrateMinMaxDelta[4]; //!< MPEG2 frame bitrate Min/Max delta value
566 
567     static const uint8_t  m_columnScan4x4[16]; //! AVC column scan order for 4x4 block
568     static const uint8_t  m_columnScan8x8[64]; //!< AVC column scan order for 8x8 block
569     static const AvcSliceType m_AvcBsdSliceType[10]; //!< AVC BSD slice type
570 
571     static const uint8_t  m_vp8MaxNumPartitions = 8; //!< Maximal number of partitions for VP8
572 
573     static const uint32_t m_mfxErrorFlagsMask = 0xFBFF; //!< Mfx error flags mask
574                                                         //!< Bit 10 of MFD_ERROR_STATUS register is set to a random value during RC6, so it is not used
575 
576     static const uint32_t m_log2WeightDenomDefault = 5; //!< Default value of luma/chroma_log2_weight_denoms
577     static const uint32_t m_mpeg2WeightScaleSize = 16; //!< Size of MPEG2 weight scale
578 
579     PMOS_INTERFACE              m_osInterface = nullptr; //!< Pointer to OS interface
580     MhwMiInterface             *m_MiInterface = nullptr; //!< Pointer to MI interface
581     MhwCpInterface             *m_cpInterface = nullptr; //!< Pointer to CP interface
582     MEDIA_FEATURE_TABLE         *m_skuTable = nullptr; //!< Pointer to SKU table
583     MEDIA_WA_TABLE              *m_waTable = nullptr; //!< Pointer to WA table
584     bool                        m_decodeInUse = false; //!< Flag to indicate if the interface is for decoder or encoder use
585 
586     PLATFORM                    m_platform = {}; //!< Gen platform
587 
588     MHW_MEMORY_OBJECT_CONTROL_PARAMS m_cacheabilitySettings[MOS_CODEC_RESOURCE_USAGE_END_CODEC] = {}; //!< Cacheability settings
589 
590     uint32_t                    m_numBrcPakPasses = 4; //!< Number of BRC PAK passes
591     bool                        m_rhoDomainStatsEnabled = false; //!< Flag to indicate if Rho domain stats is enabled
592     bool                        m_rowstoreCachingSupported = false; //!< Flag to indicate if row store cache is supported
593 
594     MHW_VDBOX_ROWSTORE_CACHE    m_intraRowstoreCache = {}; //!< Intra rowstore cache
595     MHW_VDBOX_ROWSTORE_CACHE    m_deblockingFilterRowstoreCache = {}; //!< Deblocking filter row store cache
596     MHW_VDBOX_ROWSTORE_CACHE    m_bsdMpcRowstoreCache = {}; //!< BSD/MPC row store cache
597     MHW_VDBOX_ROWSTORE_CACHE    m_mprRowstoreCache = {}; //!< MPR row store cache
598     MHW_VDBOX_NODE_IND          m_maxVdboxIndex = MHW_VDBOX_NODE_1; //!< max vdbox index
599 
600     uint32_t                    m_avcImgStateSize = 0;  //!< size of avcImgState
601     uint8_t                     m_numVdbox = 1; //!< vdbox num
602     uint32_t                    m_brcNumPakPasses = 4; //!< Number of brc pak passes
603 
604     std::shared_ptr<void>       m_mfxItfNew       = nullptr;
605 
606     MmioRegistersMfx            m_mmioRegisters[MHW_VDBOX_NODE_MAX] = {};  //!< mfx mmio registers
607 
608 #if MOS_EVENT_TRACE_DUMP_SUPPORTED
609     bool bMMCReported = false;
610 #endif
611 
612     //!
613     //! \brief    Constructor
614     //!
615     MhwVdboxMfxInterface(
616         PMOS_INTERFACE osInterface,
617         MhwMiInterface *miInterface,
618         MhwCpInterface *cpInterface,
619         bool decodeInUse);
620 
621     //!
622     //! \brief    Get Jpeg decode output surface format
623     //! \details  VDBOX protected function to get jpeg decode output format
624     //! \param    [in] format
625     //!           MOS type format
626     //! \return   MHW_VDBOX_DECODE_JPEG_FORMAT_CODE
627     //!           output surface format
628     //!
629     MHW_VDBOX_DECODE_JPEG_FORMAT_CODE GetJpegDecodeFormat(MOS_FORMAT format);
630 
631     //!
632     //! \brief    Calculate Min/Max bitrate for AVC image state
633     //!
634     //! \param    [in, out] params
635     //!           AVC bitrate parameters
636     //!
637     //! \return   void
638     //!
639     virtual void CalcAvcImgStateMinMaxBitrate(MHW_VDBOX_AVC_IMG_BITRATE_PARAMS& params);
640 
641     //!
642     //! \brief    Add a resource to the command buffer
643     //! \details  Internal function to add either a graphics address of a resource or
644     //!           add the resource to the patch list for the requested buffer
645     //!
646     //! \param    [in] osInterface
647     //!           OS interface
648     //! \param    [in] cmdBuffer
649     //!           Command buffer to which resource is added
650     //! \param    [in] params
651     //!           Parameters necessary to add the resource
652     //!
653     //! \return   MOS_STATUS
654     //!           MOS_STATUS_SUCCESS if success, else fail reason
655     //!
656     MOS_STATUS(*AddResourceToCmd) (
657         PMOS_INTERFACE osInterface,
658         PMOS_COMMAND_BUFFER cmdBuffer,
659         PMHW_RESOURCE_PARAMS params);
660 
661     //!
662     //! \brief    Helper function for getting view order in the case of MVC
663     //!
664     //! \param    [in] params
665     //!           Pointer to AVC DPB params
666     //! \param    [in] currIdx
667     //!           Reference frame index
668     //! \param    [in] list
669     //!           forward (list0) or backword reference (list1)
670     //!
671     //! \return   uint32_t
672     //!           View order
673     //!
674     uint32_t GetViewOrder(
675         PMHW_VDBOX_AVC_DPB_PARAMS params,
676         uint32_t currIdx,
677         uint32_t list);
678 
679     //!
680     //! \brief    Check if the input mos type format is VPlane Present
681     //! \details  VDBOX protected function to check the input mos type format
682     //!
683     //! \param    [in]  format
684     //!           MOS type format
685     //! \return   bool
686     //!           return true if the input format is VPlane present
687     //!           otherwise return false
688     //!
689     bool IsVPlanePresent(
690         MOS_FORMAT  format);
691 
692     //!
693     //! \brief    Translate MOS type format to Mediastate surface format
694     //! \details  VDBOX protected function to translate mos format to media state format
695     //! \param    [in] format
696     //!           MOS type format
697     //! \return   uint32_t
698     //!           media state surface format
699     //!
700     uint32_t MosToMediaStateFormat(MOS_FORMAT format);
701 
702 public:
703     //!
704     //! \brief    Get Jpeg horizontal sampling factor by the given format
705     //! \details  Get Jpeg horizontal sampling factor by the given format
706     //! \param    [in] format
707     //!           Jpeg input surface format
708     //! \return   uint32_t
709     //!           returns the horizontal sampling factor
710     //!
711     uint32_t GetJpegHorizontalSamplingFactorForY(
712         CodecEncodeJpegInputSurfaceFormat format);
713 
714     //!
715     //! \brief    Get Jpeg vetical sampling factor by the given format
716     //! \details  Get Jpeg vetical sampling factor by the given format
717     //! \param    [in] format
718     //!           Jpeg input surface format
719     //! \return   uint32_t
720     //!           returns the vetical sampling factor
721     //!
722     uint32_t GetJpegVerticalSamplingFactorForY(
723         CodecEncodeJpegInputSurfaceFormat format);
724 
725     //!
726     //! \brief    Determines if the frame/field is of I type
727     //!
728     //! \param    [in] picture
729     //!           CODECHAL_PICTURE structure, including frame index and picture flags
730     //! \param    [in] isFirstField
731     //!           True if the picture is first field, false otherwise
732     //! \param    [in] picType
733     //!           VC1 picture type
734     //!
735     //! \return   bool
736     //!           True if it's I picture, otherwise return false
737     //!
738     bool IsVc1IPicture(
739         const CODEC_PICTURE& picture,
740         bool isFirstField,
741         uint16_t picType);
742 
743     //!
744     //! \brief    Determines if the frame/field is of P type
745     //!
746     //! \param    [in] picture
747     //!           CODECHAL_PICTURE structure, including frame index and picture flags
748     //! \param    [in] isFirstField
749     //!           True if the picture is first field, false otherwise
750     //! \param    [in] picType
751     //!           VC1 picture type
752     //!
753     //! \return   bool
754     //!           True if it's P picture, otherwise return false
755     //!
756     bool IsVc1PPicture(
757         const CODEC_PICTURE& picture,
758         bool isFirstField,
759         uint16_t picType);
760 
761     //!
762     //! \brief    Determines if the frame/field is of B type
763     //!
764     //! \param    [in] picture
765     //!           CODECHAL_PICTURE structure, including frame index and picture flags
766     //! \param    [in] isFirstField
767     //!           True if the picture is first field, false otherwise
768     //! \param    [in] picType
769     //!           VC1 picture type
770     //!
771     //! \return   bool
772     //!           True if it's B picture, otherwise return false
773     //!
774     bool IsVc1BPicture(
775         const CODEC_PICTURE& picture,
776         bool isFirstField,
777         uint16_t picType);
778 
779     //!
780     //! \brief    Determines if the frame/field is of BI type
781     //!
782     //! \param    [in] picture
783     //!           CODECHAL_PICTURE structure, including frame index and picture flags
784     //! \param    [in] isFirstField
785     //!           True if the picture is first field, false otherwise
786     //! \param    [in] picType
787     //!           VC1 picture type
788     //!
789     //! \return   bool
790     //!           True if it's BI picture, otherwise return false
791     //!
792     bool IsVc1BIPicture(
793         const CODEC_PICTURE& picture,
794         bool isFirstField,
795         uint16_t picType);
796 
797     //!
798     //! \brief    Determines if the slice is P slice
799     //! \param    [in] sliceType
800     //!           slice type
801     //! \return   bool
802     //!           True if it's P slice, otherwise return false
803     //!
IsAvcPSlice(uint8_t sliceType)804     bool IsAvcPSlice(uint8_t sliceType)
805     {
806         return (sliceType < MHW_ARRAY_SIZE(m_AvcBsdSliceType)) ?
807             (m_AvcBsdSliceType[sliceType] == avcSliceP) : false;
808     }
809 
810     //!
811     //! \brief    Determines if the slice is B slice
812     //! \param    [in] sliceType
813     //!           slice type
814     //! \return   bool
815     //!           True if it's B slice, otherwise return false
816     //!
IsAvcBSlice(uint8_t sliceType)817     bool IsAvcBSlice(uint8_t sliceType)
818     {
819         return (sliceType < MHW_ARRAY_SIZE(m_AvcBsdSliceType)) ?
820             (m_AvcBsdSliceType[sliceType] == avcSliceB) : false;
821     }
822 
823     //!
824     //! \brief    Determines if the slice is I slice
825     //! \param    [in] sliceType
826     //!           slice type
827     //! \return   bool
828     //!           True if it's I slice, otherwise return false
829     //!
IsAvcISlice(uint8_t sliceType)830     bool IsAvcISlice(uint8_t sliceType)
831     {
832         return (sliceType < MHW_ARRAY_SIZE(m_AvcBsdSliceType)) ?
833             (m_AvcBsdSliceType[sliceType] == avcSliceI) : false;
834     }
835 
836     //!
837     //! \brief    Destructor
838     //!
~MhwVdboxMfxInterface()839     virtual ~MhwVdboxMfxInterface() {}
840 
841     //!
842     //! \brief    Get new MFX interface, temporal solution before switching from
843     //!           old interface to new one
844     //!
845     //! \return   pointer to new MFX interface
846     //!
GetNewMfxInterface()847     virtual std::shared_ptr<void> GetNewMfxInterface() { return nullptr; }
848 
849     //!
850     //! \brief    Judge if decode is in use
851     //!
852     //! \return   bool
853     //!           true if decode in use, else false
854     //!
IsDecodeInUse()855     inline bool IsDecodeInUse()
856     {
857         return m_decodeInUse;
858     }
859 
860     //!
861     //! \brief    Get Mfx Error Flags Mask
862     //!
863     //! \return   [out] uint32_t
864     //!           Mask got.
865     //!
GetMfxErrorFlagsMask()866     inline uint32_t GetMfxErrorFlagsMask()
867     {
868         return m_mfxErrorFlagsMask;
869     }
870 
871     //!
872     //! \brief    Get the vdbox num
873     //!
874     //! \return   bool
875     //!           vdbox num got
876     //!
GetNumVdbox()877     inline uint8_t GetNumVdbox()
878     {
879         return m_numVdbox;
880     }
881 
882     //!
883     //! \brief    set the flag of decode in use
884     //!
885     //! \param    [in] decodeInUse
886     //!           decodeInUse flag to set
887     //!
888     //! \return   void
889     //!
SetDecodeInUse(bool decodeInUse)890     inline void SetDecodeInUse(bool decodeInUse)
891     {
892         m_decodeInUse = decodeInUse;
893     }
894 
895     //!
896     //! \brief    Judge if row store caching supported
897     //!
898     //! \return   bool
899     //!           true if supported, else false
900     //!
IsRowStoreCachingSupported()901     inline bool IsRowStoreCachingSupported()
902     {
903         return m_rowstoreCachingSupported;
904     }
905 
906     //!
907     //! \brief    Judge if intra row store caching enabled
908     //!
909     //! \return   bool
910     //!           true if enabled, else false
911     //!
IsIntraRowstoreCacheEnabled()912     inline bool IsIntraRowstoreCacheEnabled()
913     {
914         return m_intraRowstoreCache.bEnabled ? true : false;
915     }
916 
917     //!
918     //! \brief    Judge if deblocking filter row store caching enabled
919     //!
920     //! \return   bool
921     //!           true if enabled, else false
922     //!
IsDeblockingFilterRowstoreCacheEnabled()923     inline bool IsDeblockingFilterRowstoreCacheEnabled()
924     {
925         return m_deblockingFilterRowstoreCache.bEnabled ? true : false;
926     }
927 
928     //!
929     //! \brief    Judge if bsd mpc row store caching enabled
930     //!
931     //! \return   bool
932     //!           true if enabled, else false
933     //!
IsBsdMpcRowstoreCacheEnabled()934     inline bool IsBsdMpcRowstoreCacheEnabled()
935     {
936         return m_bsdMpcRowstoreCache.bEnabled ? true : false;
937     }
938 
939     //!
940     //! \brief    Judge if mpr row store caching enabled
941     //!
942     //! \return   bool
943     //!           true if enabled, else false
944     //!
IsMprRowstoreCacheEnabled()945     inline bool IsMprRowstoreCacheEnabled()
946     {
947         return m_mprRowstoreCache.bEnabled ? true : false;
948     }
949 
950     //!
951     //! \brief    Get max vdbox index
952     //!
953     //! \return   MHW_VDBOX_NODE_IND
954     //!           max vdbox index got
955     //!
GetMaxVdboxIndex()956     inline MHW_VDBOX_NODE_IND GetMaxVdboxIndex()
957     {
958         return m_maxVdboxIndex;
959     }
960 
961     //!
962     //! \brief    Get mmio registers
963     //!
964     //! \param    [in] index
965     //!           mmio registers index.
966     //!
967     //! \return   [out] MmioRegistersMfx*
968     //!           mmio registers got.
969     //!
GetMmioRegisters(MHW_VDBOX_NODE_IND index)970     inline MmioRegistersMfx* GetMmioRegisters(MHW_VDBOX_NODE_IND index)
971     {
972         if (index < MHW_VDBOX_NODE_MAX)
973         {
974             return &m_mmioRegisters[index];
975         }
976         else
977         {
978             MHW_ASSERT("index is out of range!");
979             return &m_mmioRegisters[MHW_VDBOX_NODE_1];
980         }
981     }
982 
983     //!
984     //! \brief    Convert from Mfx mmio registers to MI mmio register
985     //!
986     //! \param    [in] index
987     //!           mmio registers index.
988     //! \param    [in] mmioRegister
989     //!           reference to MHW_MI_MMIOREGISTERS.
990     //!
991     //! \return   [out] bool
992     //!           return true if mmio register if found, otherwise return false
993     //!
ConvertToMiRegister(MHW_VDBOX_NODE_IND index,MHW_MI_MMIOREGISTERS & mmioRegister)994     inline bool ConvertToMiRegister(MHW_VDBOX_NODE_IND index, MHW_MI_MMIOREGISTERS &mmioRegister)
995     {
996         MmioRegistersMfx* mfxMmioReg = GetMmioRegisters(index);
997         if (mfxMmioReg)
998         {
999             mmioRegister.generalPurposeRegister0LoOffset = mfxMmioReg->generalPurposeRegister0LoOffset;
1000             mmioRegister.generalPurposeRegister0HiOffset = mfxMmioReg->generalPurposeRegister0HiOffset;
1001             mmioRegister.generalPurposeRegister4LoOffset = mfxMmioReg->generalPurposeRegister4LoOffset;
1002             mmioRegister.generalPurposeRegister4HiOffset = mfxMmioReg->generalPurposeRegister4HiOffset;
1003             mmioRegister.generalPurposeRegister11LoOffset = mfxMmioReg->generalPurposeRegister11LoOffset;
1004             mmioRegister.generalPurposeRegister11HiOffset = mfxMmioReg->generalPurposeRegister11HiOffset;
1005             mmioRegister.generalPurposeRegister12LoOffset = mfxMmioReg->generalPurposeRegister12LoOffset;
1006             mmioRegister.generalPurposeRegister12HiOffset = mfxMmioReg->generalPurposeRegister12HiOffset;
1007             return true;
1008         }
1009         else
1010             return false;
1011     }
1012 
1013     //!
1014     //! \brief    Get brc pak passes num
1015     //! \details  Get brc pak passes num in mfx interface
1016     //!
1017     //! \return   [out] uint32_t
1018     //!           Brc pak passes num.
1019     //!
GetBrcNumPakPasses()1020     inline uint32_t GetBrcNumPakPasses()
1021     {
1022         return m_brcNumPakPasses;
1023     }
1024 
1025     //!
1026     //! \brief    Set brc pak passes num
1027     //! \details  Set brc pak passes num in hcp interface
1028     //!
1029     //! \param    [in] brcNumPakPasses
1030     //!           Brc pak passes num to set.
1031     //!
1032     //! \return   void
1033     //!
SetBrcNumPakPasses(uint32_t brcNumPakPasses)1034     inline void SetBrcNumPakPasses(uint32_t brcNumPakPasses)
1035     {
1036         m_brcNumPakPasses = brcNumPakPasses;
1037     }
1038 
1039     //!
1040     //! \brief    get AVC img state size
1041     //!
1042     //! \return   uint32_t
1043     //!           AVC img state size got
1044     //!
1045     virtual uint32_t GetAvcImgStateSize() = 0;
1046 
1047     //!
1048     //! \brief    get AVC slc state size
1049     //!
1050     //! \return   uint32_t
1051     //!           AVC slc state size got
1052     //!
1053     virtual uint32_t GetAvcSlcStateSize() = 0;
1054 
1055     //!
1056     //! \brief    Decide Which GPU Node to use for Decode
1057     //! \details  Client facing function to create gpu context used by decoder
1058     //! \param    [in] gpuNodeLimit
1059     //!           GpuNode Limitation
1060     //! \return   MOS_STATUS
1061     //!           MOS_STATUS_SUCCESS if success, else fail reason
1062     //!
1063     virtual MOS_STATUS FindGpuNodeToUse(
1064         PMHW_VDBOX_GPUNODE_LIMIT       gpuNodeLimit) = 0;
1065 
1066     //!
1067     //! \brief    Set cacheability settings
1068     //!
1069     //! \param    [in] cacheabilitySettings
1070     //!           Cacheability settings
1071     //!
1072     //! \return   MOS_STATUS
1073     //!           MOS_STATUS_SUCCESS if success, else fail reason
1074     //!
SetCacheabilitySettings(MHW_MEMORY_OBJECT_CONTROL_PARAMS cacheabilitySettings[MOS_CODEC_RESOURCE_USAGE_END_CODEC])1075     MOS_STATUS SetCacheabilitySettings(
1076         MHW_MEMORY_OBJECT_CONTROL_PARAMS cacheabilitySettings[MOS_CODEC_RESOURCE_USAGE_END_CODEC])
1077     {
1078         MHW_FUNCTION_ENTER;
1079 
1080         uint32_t size = MOS_CODEC_RESOURCE_USAGE_END_CODEC * sizeof(MHW_MEMORY_OBJECT_CONTROL_PARAMS);
1081         MOS_STATUS eStatus = MOS_SecureMemcpy(m_cacheabilitySettings, size,
1082             cacheabilitySettings, size);
1083 
1084         return eStatus;
1085     }
1086 
1087     //!
1088     //! \brief    Get average bsd slice type
1089     //!
1090     //! \param    [in] index
1091     //!           Index number
1092     //!
1093     //! \return   int32_t
1094     //!           Avc bsd slice type
1095     //!
GetAvcBsdSliceType(uint32_t index)1096     int32_t GetAvcBsdSliceType(uint32_t index)
1097     {
1098         return m_AvcBsdSliceType[index];
1099     }
1100 
1101     //!
1102     //! \brief    Calculates the maximum size for all picture level commands
1103     //! \details  Client facing function to calculate the maximum size for all picture level commands
1104     //!
1105     //! \param    [in] mode
1106     //!           codec mode
1107     //! \param    [out] commandsSize
1108     //!           The maximum command buffer size
1109     //! \param    [out] patchListSize
1110     //!           The maximum command patch list size
1111     //! \param    [in] isShortFormat
1112     //!           True if short format, false long format
1113     //!
1114     //! \return   MOS_STATUS
1115     //!           MOS_STATUS_SUCCESS if success, else fail reason
1116     //!
1117     virtual MOS_STATUS GetMfxStateCommandsDataSize(
1118         uint32_t mode,
1119         uint32_t *commandsSize,
1120         uint32_t *patchListSize,
1121         bool isShortFormat) = 0;
1122 
1123     //!
1124     //! \brief    Calculates maximum size for all slice/MB level commands
1125     //! \details  Client facing function to calculate maximum size for all slice/MB level commands
1126     //!
1127     //! \param    [in] mode
1128     //!           Codec mode
1129     //! \param    [out] commandsSize
1130     //!           The maximum command buffer size
1131     //! \param    [out] patchListSize
1132     //!           The maximum command patch list size
1133     //! \param    [in] isModeSpecific
1134     //!           Indicate the long or short format for decoder or single take phase for encoder
1135     //!
1136     //! \return   MOS_STATUS
1137     //!           MOS_STATUS_SUCCESS if success, else fail reason
1138     //!
1139     virtual MOS_STATUS GetMfxPrimitiveCommandsDataSize(
1140         uint32_t mode,
1141         uint32_t *commandsSize,
1142         uint32_t *patchListSize,
1143         bool  isModeSpecific) = 0;
1144 
1145     //!
1146     //! \brief    Adds MFX AVC Image State command in command buffer
1147     //! \details  Client facing function to add MFX AVC Image State command in command buffer
1148     //!
1149     //! \param    [in] cmdBuffer
1150     //!           Command buffer to which HW command is added
1151     //! \param    [in] batchBuffer
1152     //!           Batch buffer to which HW command is added
1153     //! \param    [in] params
1154     //!           Params structure used to populate the HW command
1155     //!
1156     //! \return   MOS_STATUS
1157     //!           MOS_STATUS_SUCCESS if success, else fail reason
1158     //!
1159     MOS_STATUS AddMfxAvcImgCmd(
1160         PMOS_COMMAND_BUFFER cmdBuffer,
1161         PMHW_BATCH_BUFFER batchBuffer,
1162         PMHW_VDBOX_AVC_IMG_PARAMS params);
1163 
1164     //!
1165     //! \brief    Adds MFX AVC weight offset command in command buffer
1166     //! \details  Client facing function to add MFX AVC weight offset command in command buffer
1167     //!
1168     //! \param    [in] cmdBuffer
1169     //!           Command buffer to which HW command is added
1170     //! \param    [in] batchBuffer
1171     //!           Batch buffer to which HW command is added
1172     //! \param    [in] params
1173     //!           Params structure used to populate the HW command
1174     //!
1175     //! \return   MOS_STATUS
1176     //!           MOS_STATUS_SUCCESS if success, else fail reason
1177     //!
1178     MOS_STATUS AddMfxAvcWeightOffset(
1179         PMOS_COMMAND_BUFFER cmdBuffer,
1180         PMHW_BATCH_BUFFER batchBuffer,
1181         PMHW_VDBOX_AVC_WEIGHTOFFSET_PARAMS params);
1182 
1183     //!
1184     //! \brief    Adds MFX AVC slice state command in command buffer
1185     //! \details  Client facing function to add MFX AVC slice state command in command buffer
1186     //!
1187     //! \param    [in] cmdBuffer
1188     //!           Command buffer to which HW command is added
1189     //! \param    [in] batchBuffer
1190     //!           Batch buffer to which HW command is added
1191     //! \param    [in] avcSliceState
1192     //!           Pointer to AVC slice state which is used to populate the HW command
1193     //!
1194     //! \return   MOS_STATUS
1195     //!           MOS_STATUS_SUCCESS if success, else fail reason
1196     //!
1197     MOS_STATUS AddMfxAvcSlice(
1198         PMOS_COMMAND_BUFFER cmdBuffer,
1199         PMHW_BATCH_BUFFER batchBuffer,
1200         PMHW_VDBOX_AVC_SLICE_STATE avcSliceState);
1201 
1202     //!
1203     //! \brief    Adds MPEG2 Image State command in command buffer
1204     //! \details  Client facing function to add MPEG2 Image State command in command buffer
1205     //!
1206     //! \param    [in] cmdBuffer
1207     //!           Command buffer to which HW command is added
1208     //! \param    [in] params
1209     //!           Params structure used to populate the HW command
1210     //!
1211     //! \return   MOS_STATUS
1212     //!           MOS_STATUS_SUCCESS if success, else fail reason
1213     //!
1214     MOS_STATUS AddMfxMpeg2PicCmd(
1215         PMOS_COMMAND_BUFFER cmdBuffer,
1216         PMHW_VDBOX_MPEG2_PIC_STATE params);
1217 
1218     //!
1219     //! \brief    Adds MFX VP8 Picture State command in command buffer
1220     //! \details  Client facing function to add MFX VP8 Picture State command in command buffer
1221     //!
1222     //! \param    [in] cmdBuffer
1223     //!           Command buffer to which HW command is added
1224     //! \param    [in] params
1225     //!           Params structure used to populate the HW command
1226     //!
1227     //! \return   MOS_STATUS
1228     //!           MOS_STATUS_SUCCESS if success, else fail reason
1229     //!
1230     MOS_STATUS AddMfxVp8PicCmd(
1231         PMOS_COMMAND_BUFFER cmdBuffer,
1232         PMHW_VDBOX_VP8_PIC_STATE params);
1233 
1234     //!
1235     //! \brief    Programs base address of rowstore scratch buffers
1236     //! \details  Internal function to get base address of rowstore scratch buffers
1237     //!
1238     //! \param    [in] rowstoreParams
1239     //!           Rowstore parameters
1240     //!
1241     //! \return   MOS_STATUS
1242     //!           MOS_STATUS_SUCCESS if success, else fail reason
1243     //!
1244     virtual MOS_STATUS GetRowstoreCachingAddrs(
1245         PMHW_VDBOX_ROWSTORE_PARAMS rowstoreParams) = 0;
1246 
1247     //!
1248     //! \brief    Adds MFX pipe mode select command in command buffer
1249     //!
1250     //! \param    [in] cmdBuffer
1251     //!           Command buffer to which HW command is added
1252     //! \param    [in] params
1253     //!           Params structure used to populate the HW command
1254     //!
1255     //! \return   MOS_STATUS
1256     //!           MOS_STATUS_SUCCESS if success, else fail reason
1257     //!
1258     virtual MOS_STATUS AddMfxPipeModeSelectCmd(
1259         PMOS_COMMAND_BUFFER cmdBuffer,
1260         PMHW_VDBOX_PIPE_MODE_SELECT_PARAMS params) = 0;
1261 
1262     //!
1263     //! \brief    Adds MFX Surface State command in command buffer
1264     //!
1265     //! \param    [in] cmdBuffer
1266     //!           Command buffer to which HW command is added
1267     //! \param    [in] params
1268     //!           Params structure used to populate the HW command
1269     //!
1270     //! \return   MOS_STATUS
1271     //!           MOS_STATUS_SUCCESS if success, else fail reason
1272     //!
1273     virtual MOS_STATUS AddMfxSurfaceCmd(
1274         PMOS_COMMAND_BUFFER cmdBuffer,
1275         PMHW_VDBOX_SURFACE_PARAMS params) = 0;
1276 
1277     //!
1278     //! \brief    Adds MFX Pipe Buffer Address State command in command buffer
1279     //!
1280     //! \param    [in] cmdBuffer
1281     //!           Command buffer to which HW command is added
1282     //! \param    [in] params
1283     //!           Params structure used to populate the HW command
1284     //!
1285     //! \return   MOS_STATUS
1286     //!           MOS_STATUS_SUCCESS if success, else fail reason
1287     //!
1288     virtual MOS_STATUS AddMfxPipeBufAddrCmd(
1289         PMOS_COMMAND_BUFFER cmdBuffer,
1290         PMHW_VDBOX_PIPE_BUF_ADDR_PARAMS params) = 0;
1291 
1292     //!
1293     //! \brief    Adds MFX Indirect Object Base Address State command in command buffer
1294     //!
1295     //! \param    [in] cmdBuffer
1296     //!           Command buffer to which HW command is added
1297     //! \param    [in] params
1298     //!           Params structure used to populate the HW command
1299     //!
1300     //! \return   MOS_STATUS
1301     //!           MOS_STATUS_SUCCESS if success, else fail reason
1302     //!
1303     virtual MOS_STATUS AddMfxIndObjBaseAddrCmd(
1304         PMOS_COMMAND_BUFFER cmdBuffer,
1305         PMHW_VDBOX_IND_OBJ_BASE_ADDR_PARAMS params) = 0;
1306 
1307     //!
1308     //! \brief    Adds MFX BSP Buffer Base Address State command in command buffer
1309     //!
1310     //! \param    [in] cmdBuffer
1311     //!           Command buffer to which HW command is added
1312     //! \param    [in] params
1313     //!           Params structure used to populate the HW command
1314     //!
1315     //! \return   MOS_STATUS
1316     //!           MOS_STATUS_SUCCESS if success, else fail reason
1317     //!
1318     virtual MOS_STATUS AddMfxBspBufBaseAddrCmd(
1319         PMOS_COMMAND_BUFFER cmdBuffer,
1320         PMHW_VDBOX_BSP_BUF_BASE_ADDR_PARAMS params) = 0;
1321 
1322     //!
1323     //! \brief    Adds MFX QM State command in command buffer
1324     //!
1325     //! \param    [in] cmdBuffer
1326     //!           Command buffer to which HW command is added
1327     //! \param    [in] params
1328     //!           Params structure used to populate the HW command
1329     //!
1330     //! \return   MOS_STATUS
1331     //!           MOS_STATUS_SUCCESS if success, else fail reason
1332     //!
1333     virtual MOS_STATUS AddMfxQmCmd(
1334         PMOS_COMMAND_BUFFER cmdBuffer,
1335         PMHW_VDBOX_QM_PARAMS params) = 0;
1336 
1337     //!
1338     //! \brief    Adds MFX FQM State command in command buffer
1339     //!
1340     //! \param    [in] cmdBuffer
1341     //!           Command buffer to which HW command is added
1342     //! \param    [in] params
1343     //!           Params structure used to populate the HW command
1344     //!
1345     //! \return   MOS_STATUS
1346     //!           MOS_STATUS_SUCCESS if success, else fail reason
1347     //!
1348     virtual MOS_STATUS AddMfxFqmCmd(
1349         PMOS_COMMAND_BUFFER cmdBuffer,
1350         PMHW_VDBOX_QM_PARAMS params) = 0;
1351 
1352     //!
1353     //! \brief    Adds MFX AVC Picture ID command in command buffer (decoder only)
1354     //!
1355     //! \param    [in] cmdBuffer
1356     //!           Command buffer to which HW command is added
1357     //! \param    [in] params
1358     //!           Params structure used to populate the HW command
1359     //!
1360     //! \return   MOS_STATUS
1361     //!           MOS_STATUS_SUCCESS if success, else fail reason
1362     //!
1363     virtual MOS_STATUS AddMfdAvcPicidCmd(
1364         PMOS_COMMAND_BUFFER cmdBuffer,
1365         PMHW_VDBOX_PIC_ID_PARAMS params) = 0;
1366 
1367     //!
1368     //! \brief    Adds MFX AVC Image State command for decoder in command buffer
1369     //!
1370     //! \param    [in] cmdBuffer
1371     //!           Command buffer to which HW command is added
1372     //! \param    [in] batchBuffer
1373     //!           Pointer to MHW batch buffer
1374     //! \param    [in] params
1375     //!           Params structure used to populate the HW command
1376     //!
1377     //! \return   MOS_STATUS
1378     //!           MOS_STATUS_SUCCESS if success, else fail reason
1379     //!
1380     virtual MOS_STATUS AddMfxDecodeAvcImgCmd(
1381         PMOS_COMMAND_BUFFER cmdBuffer,
1382         PMHW_BATCH_BUFFER batchBuffer,
1383         PMHW_VDBOX_AVC_IMG_PARAMS params) = 0;
1384 
1385     //!
1386     //! \brief    Adds MFX AVC Image State command for encoder in command buffer
1387     //!
1388     //! \param    [in] cmdBuffer
1389     //!           Command buffer to which HW command is added
1390     //! \param    [in] batchBuffer
1391     //!           Batch buffer to which HW command is added
1392     //! \param    [in] params
1393     //!           Params structure used to populate the HW command
1394     //!
1395     //! \return   MOS_STATUS
1396     //!           MOS_STATUS_SUCCESS if success, else fail reason
1397     //!
1398     virtual MOS_STATUS AddMfxEncodeAvcImgCmd(
1399         PMOS_COMMAND_BUFFER cmdBuffer,
1400         PMHW_BATCH_BUFFER batchBuffer,
1401         PMHW_VDBOX_AVC_IMG_PARAMS params) = 0;
1402 
1403     //!
1404     //! \brief    Adds AVC Directmode State command in command buffer
1405     //!
1406     //! \param    [in] cmdBuffer
1407     //!           Command buffer to which HW command is added
1408     //! \param    [in] params
1409     //!           Params structure used to populate the HW command
1410     //!
1411     //! \return   MOS_STATUS
1412     //!           MOS_STATUS_SUCCESS if success, else fail reason
1413     //!
1414     virtual MOS_STATUS AddMfxAvcDirectmodeCmd(
1415         PMOS_COMMAND_BUFFER cmdBuffer,
1416         PMHW_VDBOX_AVC_DIRECTMODE_PARAMS params) = 0;
1417 
1418     //!
1419     //! \brief    Adds MFX AVC reference frame index command in command buffer
1420     //!
1421     //! \param    [in] cmdBuffer
1422     //!           Command buffer to which HW command is added
1423     //! \param    [in] batchBuffer
1424     //!           Batch buffer to which HW command is added
1425     //! \param    [in] params
1426     //!           Params structure used to populate the HW command
1427     //!
1428     //! \return   MOS_STATUS
1429     //!           MOS_STATUS_SUCCESS if success, else fail reason
1430     //!
1431     virtual MOS_STATUS AddMfxAvcRefIdx(
1432         PMOS_COMMAND_BUFFER cmdBuffer,
1433         PMHW_BATCH_BUFFER batchBuffer,
1434         PMHW_VDBOX_AVC_REF_IDX_PARAMS params) = 0;
1435 
1436     //!
1437     //! \brief    Adds MFX AVC weight offset command for decoder in command buffer
1438     //!
1439     //! \param    [in] cmdBuffer
1440     //!           Command buffer to which HW command is added
1441     //! \param    [in] batchBuffer
1442     //!           Batch buffer to which HW command is added
1443     //! \param    [in] params
1444     //!           Params structure used to populate the HW command
1445     //!
1446     //! \return   MOS_STATUS
1447     //!           MOS_STATUS_SUCCESS if success, else fail reason
1448     //!
1449     virtual MOS_STATUS AddMfxDecodeAvcWeightOffset(
1450         PMOS_COMMAND_BUFFER cmdBuffer,
1451         PMHW_BATCH_BUFFER batchBuffer,
1452         PMHW_VDBOX_AVC_WEIGHTOFFSET_PARAMS params) = 0;
1453 
1454     //!
1455     //! \brief    Adds MFX AVC weight offset command for encoder in command buffer
1456     //!
1457     //! \param    [in] cmdBuffer
1458     //!           Command buffer to which HW command is added
1459     //! \param    [in] batchBuffer
1460     //!           Batch buffer to which HW command is added
1461     //! \param    [in] params
1462     //!           Params structure used to populate the HW command
1463     //!
1464     //! \return   MOS_STATUS
1465     //!           MOS_STATUS_SUCCESS if success, else fail reason
1466     //!
1467     virtual MOS_STATUS AddMfxEncodeAvcWeightOffset(
1468         PMOS_COMMAND_BUFFER cmdBuffer,
1469         PMHW_BATCH_BUFFER batchBuffer,
1470         PMHW_VDBOX_AVC_WEIGHTOFFSET_PARAMS params) = 0;
1471 
1472     //!
1473     //! \brief    Adds MFX AVC slice state command for decoder in command buffer
1474     //!
1475     //! \param    [in] cmdBuffer
1476     //!           Command buffer to which HW command is added
1477     //! \param    [in] batchBuffer
1478     //!           Batch buffer to which HW command is added
1479     //! \param    [in] avcSliceState
1480     //!           Pointer to AVC slice state which is used to populate the HW command
1481     //!
1482     //! \return   MOS_STATUS
1483     //!           MOS_STATUS_SUCCESS if success, else fail reason
1484     //!
1485     virtual MOS_STATUS AddMfxDecodeAvcSlice(
1486         PMOS_COMMAND_BUFFER cmdBuffer,
1487         PMHW_BATCH_BUFFER batchBuffer,
1488         PMHW_VDBOX_AVC_SLICE_STATE avcSliceState) = 0;
1489 
1490     //!
1491     //! \brief    Adds MFX AVC slice state command for encoder in command buffer
1492     //!
1493     //! \param    [in] cmdBuffer
1494     //!           Command buffer to which HW command is added
1495     //! \param    [in] batchBuffer
1496     //!           Batch buffer to which HW command is added
1497     //! \param    [in] avcSliceState
1498     //!           Pointer to AVC slice state which is used to populate the HW command
1499     //!
1500     //! \return   MOS_STATUS
1501     //!           MOS_STATUS_SUCCESS if success, else fail reason
1502     //!
1503     virtual MOS_STATUS AddMfxEncodeAvcSlice(
1504         PMOS_COMMAND_BUFFER cmdBuffer,
1505         PMHW_BATCH_BUFFER batchBuffer,
1506         PMHW_VDBOX_AVC_SLICE_STATE avcSliceState) = 0;
1507 
1508     //!
1509     //! \brief    Adds MFX AVC DPB State command in command buffer
1510     //!
1511     //! \param    [in] cmdBuffer
1512     //!           Command buffer to which HW command is added
1513     //! \param    [in] params
1514     //!           Params structure used to populate the HW command
1515     //!
1516     //! \return   MOS_STATUS
1517     //!           MOS_STATUS_SUCCESS if success, else fail reason
1518     //!
1519     virtual MOS_STATUS AddMfdAvcDpbCmd(
1520         PMOS_COMMAND_BUFFER cmdBuffer,
1521         PMHW_VDBOX_AVC_DPB_PARAMS params) = 0;
1522 
1523     //!
1524     //! \brief    Adds MFX AVC Slice Address command in command buffer
1525     //!
1526     //! \param    [in] cmdBuffer
1527     //!           Command buffer to which HW command is added
1528     //! \param    [in] avcSliceState
1529     //!           Pointer to AVC slice state which is used to populate the HW command
1530     //!
1531     //! \return   MOS_STATUS
1532     //!           MOS_STATUS_SUCCESS if success, else fail reason
1533     //!
1534     virtual MOS_STATUS AddMfdAvcSliceAddrCmd(
1535         PMOS_COMMAND_BUFFER cmdBuffer,
1536         PMHW_VDBOX_AVC_SLICE_STATE avcSliceState) = 0;
1537 
1538     //!
1539     //! \brief    Adds AVC BSD Object command in command buffer
1540     //!
1541     //! \param    [in] cmdBuffer
1542     //!           Command buffer to which HW command is added
1543     //! \param    [in] avcSliceState
1544     //!           Pointer to AVC slice state which is used to populate the HW command
1545     //!
1546     //! \return   MOS_STATUS
1547     //!           MOS_STATUS_SUCCESS if success, else fail reason
1548     //!
1549     virtual MOS_STATUS AddMfdAvcBsdObjectCmd(
1550         PMOS_COMMAND_BUFFER cmdBuffer,
1551         PMHW_VDBOX_AVC_SLICE_STATE avcSliceState) = 0;
1552 
1553     //!
1554     //! \brief    Adds AVC Image State command in command buffer
1555     //! \details  Client facing function to add AVC Image State command in command buffer
1556     //!
1557     //! \param    [in] brcImgBuffer
1558     //!           Command buffer to which HW command is added
1559     //! \param    [in] params
1560     //!           Params structure used to populate the HW command
1561     //!
1562     //! \return   MOS_STATUS
1563     //!           MOS_STATUS_SUCCESS if success, else fail reason
1564     //!
1565     virtual MOS_STATUS AddMfxAvcImgBrcBuffer(
1566         PMOS_RESOURCE brcImgBuffer,
1567         PMHW_VDBOX_AVC_IMG_PARAMS params) = 0;
1568 
1569     //!
1570     //! \brief    Adds MFX Pak Insert Object command in command buffer
1571     //!
1572     //! \param    [in] cmdBuffer
1573     //!           Command buffer to which HW command is added
1574     //! \param    [in] batchBuffer
1575     //!           Batch buffer to which HW command is added
1576     //! \param    [in] params
1577     //!           Params structure used to populate the HW command
1578     //!
1579     //! \return   MOS_STATUS
1580     //!           MOS_STATUS_SUCCESS if success, else fail reason
1581     //!
1582     virtual MOS_STATUS AddMfxPakInsertObject(
1583         PMOS_COMMAND_BUFFER cmdBuffer,
1584         PMHW_BATCH_BUFFER batchBuffer,
1585         PMHW_VDBOX_PAK_INSERT_PARAMS params) = 0;
1586 
1587     //!
1588     //! \brief    Adds MPEG2 Image State command for decoder in command buffer
1589     //!
1590     //! \param    [in] cmdBuffer
1591     //!           Command buffer to which HW command is added
1592     //! \param    [in] params
1593     //!           Params structure used to populate the HW command
1594     //!
1595     //! \return   MOS_STATUS
1596     //!           MOS_STATUS_SUCCESS if success, else fail reason
1597     //!
1598     virtual MOS_STATUS AddMfxDecodeMpeg2PicCmd(
1599         PMOS_COMMAND_BUFFER cmdBuffer,
1600         PMHW_VDBOX_MPEG2_PIC_STATE params) = 0;
1601 
1602     //!
1603     //! \brief    Adds MPEG2 Image State command for encoder in command buffer
1604     //!
1605     //! \param    [in] cmdBuffer
1606     //!           Command buffer to which HW command is added
1607     //! \param    [in] params
1608     //!           Params structure used to populate the HW command
1609     //!
1610     //! \return   MOS_STATUS
1611     //!           MOS_STATUS_SUCCESS if success, else fail reason
1612     //!
1613     virtual MOS_STATUS AddMfxEncodeMpeg2PicCmd(
1614         PMOS_COMMAND_BUFFER cmdBuffer,
1615         PMHW_VDBOX_MPEG2_PIC_STATE params) = 0;
1616 
1617     //!
1618     //! \brief    Adds MPEG2 BSD Object command in batch buffer or command buffer
1619     //!
1620     //! \param    [in] cmdBuffer
1621     //!           Command buffer to which HW command is added
1622     //! \param    [in] batchBuffer
1623     //!           Batch buffer to add to VDBOX_BUFFER_START
1624     //! \param    [in] params
1625     //!           Params structure used to populate the HW command
1626     //!
1627     //! \return   MOS_STATUS
1628     //!           MOS_STATUS_SUCCESS if success, else fail reason
1629     //!
1630     virtual MOS_STATUS AddMfdMpeg2BsdObject(
1631         PMOS_COMMAND_BUFFER cmdBuffer,
1632         PMHW_BATCH_BUFFER batchBuffer,
1633         PMHW_VDBOX_MPEG2_SLICE_STATE params) = 0;
1634 
1635     //!
1636     //! \brief    Adds Mfd mpeg2 IT object command in batch buffer or command buffer
1637     //!
1638     //! \param    [in] cmdBuffer
1639     //!           Command buffer to which HW command is added
1640     //! \param    [in] batchBuffer
1641     //!           Batch buffer to add to VDBOX_BUFFER_START
1642     //! \param    [in] params
1643     //!           Params structure used to populate the HW command
1644     //!
1645     //! \return   MOS_STATUS
1646     //!           MOS_STATUS_SUCCESS if success, else fail reason
1647     //!
1648     virtual MOS_STATUS AddMfdMpeg2ITObject(
1649         PMOS_COMMAND_BUFFER cmdBuffer,
1650         PMHW_BATCH_BUFFER batchBuffer,
1651         PMHW_VDBOX_MPEG2_MB_STATE params) = 0;
1652 
1653     //!
1654     //! \brief    Adds Mpeg2 Group Slice State command in command buffer
1655     //!
1656     //! \param    [in] cmdBuffer
1657     //!           Command buffer to which HW command is added
1658     //! \param    [in] mpeg2SliceState
1659     //!           Pointer to MPEG2 slice state
1660     //!
1661     //! \return   MOS_STATUS
1662     //!           MOS_STATUS_SUCCESS if success, else fail reason
1663     //!
1664     virtual MOS_STATUS AddMfcMpeg2SliceGroupCmd(
1665         PMOS_COMMAND_BUFFER cmdBuffer,
1666         PMHW_VDBOX_MPEG2_SLICE_STATE mpeg2SliceState) = 0;
1667 
1668     //!
1669     //! \brief    Adds mpeg2 Pak insert brc buffer command in command buffer
1670     //! \details  Client facing function to add mpeg2 Pak insert brc buffer command in command buffer
1671     //!
1672     //! \param    [in] brcPicHeaderInputBuffer
1673     //!           Picture header input buffer to which HW command is added
1674     //! \param    [in] params
1675     //!           Params structure used to populate the HW command
1676     //!
1677     //! \return   MOS_STATUS
1678     //!           MOS_STATUS_SUCCESS if success, else fail reason
1679     //!
1680     virtual MOS_STATUS AddMfcMpeg2PakInsertBrcBuffer(
1681         PMOS_RESOURCE brcPicHeaderInputBuffer,
1682         PMHW_VDBOX_PAK_INSERT_PARAMS params) = 0;
1683 
1684     //!
1685     //! \brief    Adds Mpeg2 picture State command in command buffer
1686     //! \details  Client facing function to add Mpeg2 picture State command in command buffer
1687     //!
1688     //! \param    [in] brcImgBuffer
1689     //!           Command buffer to which HW command is added
1690     //! \param    [in] params
1691     //!           Pointer to MPEG2 picture state
1692     //!
1693     //! \return   MOS_STATUS
1694     //!           MOS_STATUS_SUCCESS if success, else fail reason
1695     //!
1696     virtual MOS_STATUS AddMfxMpeg2PicBrcBuffer(
1697         PMOS_RESOURCE brcImgBuffer,
1698         PMHW_VDBOX_MPEG2_PIC_STATE params) = 0;
1699 
1700     //!
1701     //! \brief    Adds VC1 Pred Pipe command in command buffer
1702     //! \details  Client facing function to add VC1 Pred Pipe command in command buffer
1703     //!
1704     //! \param    [in] cmdBuffer
1705     //!           Command buffer to which HW command is added
1706     //! \param    [in] params
1707     //!           Params structure used to populate the HW command
1708     //!
1709     //! \return   MOS_STATUS
1710     //!           MOS_STATUS_SUCCESS if success, else fail reason
1711     //!
1712     virtual MOS_STATUS AddMfxVc1PredPipeCmd(
1713         PMOS_COMMAND_BUFFER cmdBuffer,
1714         PMHW_VDBOX_VC1_PRED_PIPE_PARAMS params) = 0;
1715 
1716     //!
1717     //! \brief    Adds VC1 long picture state command in command buffer
1718     //! \details  Client facing function to add VC1 long picture state command in command buffer
1719     //!
1720     //! \param    [in] cmdBuffer
1721     //!           Command buffer to which HW command is added
1722     //! \param    [in] vc1PicState
1723     //!           Pointer to VC1 picture state
1724     //!
1725     //! \return   MOS_STATUS
1726     //!           MOS_STATUS_SUCCESS if success, else fail reason
1727     //!
1728     virtual MOS_STATUS AddMfxVc1LongPicCmd(
1729         PMOS_COMMAND_BUFFER cmdBuffer,
1730         PMHW_VDBOX_VC1_PIC_STATE vc1PicState) = 0;
1731 
1732     //!
1733     //! \brief    Adds VC1 short picture state command in command buffer
1734     //! \details  Client facing function to add VC1 short picture state command in command buffer
1735     //!
1736     //! \param    [in] cmdBuffer
1737     //!           Command buffer to which HW command is added
1738     //! \param    [in] vc1PicState
1739     //!           Pointer to VC1 picture state
1740     //!
1741     //! \return   MOS_STATUS
1742     //!           MOS_STATUS_SUCCESS if success, else fail reason
1743     //!
1744     virtual MOS_STATUS AddMfdVc1ShortPicCmd(
1745         PMOS_COMMAND_BUFFER cmdBuffer,
1746         PMHW_VDBOX_VC1_PIC_STATE vc1PicState) = 0;
1747 
1748     //!
1749     //! \brief    Adds VC1 Direct Mode State command in command buffer
1750     //! \details  Client facing function to add VC1 Direct Mode State command in command buffer
1751     //!
1752     //! \param    [in] cmdBuffer
1753     //!           Command buffer to which HW command is added
1754     //! \param    [in] params
1755     //!           Params structure used to populate the HW command
1756     //!
1757     //! \return   MOS_STATUS
1758     //!           MOS_STATUS_SUCCESS if success, else fail reason
1759     //!
1760     virtual MOS_STATUS AddMfxVc1DirectmodeCmd(
1761         PMOS_COMMAND_BUFFER cmdBuffer,
1762         PMHW_VDBOX_VC1_DIRECTMODE_PARAMS params) = 0;
1763 
1764     //!
1765     //! \brief    Adds VC1 BSD object command in command buffer
1766     //! \details  Client facing function to add VC1 BSD object command in command buffer
1767     //!
1768     //! \param    [in] cmdBuffer
1769     //!           Command buffer to which HW command is added
1770     //! \param    [in] vc1SliceState
1771     //!           Pointer to VC1 slice state
1772     //!
1773     //! \return   MOS_STATUS
1774     //!           MOS_STATUS_SUCCESS if success, else fail reason
1775     //!
1776     virtual MOS_STATUS AddMfdVc1BsdObjectCmd(
1777         PMOS_COMMAND_BUFFER cmdBuffer,
1778         PMHW_VDBOX_VC1_SLICE_STATE vc1SliceState) = 0;
1779 
1780     //!
1781     //! \brief    Adds Mfd VC1 IT object command in batch buffer
1782     //! \details  Client facing function to add Mfd VC1 IT object command in batch buffer
1783     //!
1784     //! \param    [in] batchBuffer
1785     //!           Batch buffer to add to VDBOX_BUFFER_START
1786     //! \param    [in] vc1MbState
1787     //!           Pointer to VC1 MB state
1788     //!
1789     //! \return   MOS_STATUS
1790     //!           MOS_STATUS_SUCCESS if success, else fail reason
1791     //!
1792     virtual MOS_STATUS AddMfdVc1ItObjectCmd(
1793         PMHW_BATCH_BUFFER batchBuffer,
1794         PMHW_VDBOX_VC1_MB_STATE vc1MbState) = 0;
1795 
1796     //!
1797     //! \brief    Adds MFX JPEG Picture State command in command buffer
1798     //! \details  Client facing function to add MFX JPEG Picture State command in command buffer
1799     //!
1800     //! \param    [in] cmdBuffer
1801     //!           Command buffer to which HW command is added
1802     //! \param    [in] params
1803     //!           Params structure used to populate the HW command
1804     //!
1805     //! \return   MOS_STATUS
1806     //!           MOS_STATUS_SUCCESS if success, else fail reason
1807     //!
1808     virtual MOS_STATUS AddMfxJpegPicCmd(
1809         PMOS_COMMAND_BUFFER cmdBuffer,
1810         PMHW_VDBOX_JPEG_PIC_STATE params) = 0;
1811 
1812     //!
1813     //! \brief    Adds MFX JPEG Huffman Table State command in command buffer
1814     //! \details  Client facing function to add MFX JPEG Huffman Table State command in command buffer
1815     //!
1816     //! \param    [in] cmdBuffer
1817     //!           Command buffer to which HW command is added
1818     //! \param    [in] params
1819     //!           Params structure used to populate the HW command
1820     //!
1821     //! \return   MOS_STATUS
1822     //!           MOS_STATUS_SUCCESS if success, else fail reason
1823     //!
1824     virtual MOS_STATUS AddMfxJpegHuffTableCmd(
1825         PMOS_COMMAND_BUFFER cmdBuffer,
1826         PMHW_VDBOX_HUFF_TABLE_PARAMS params) = 0;
1827 
1828     //!
1829     //! \brief    Adds MFX JPEG BSD object command in command buffer
1830     //! \details  Client facing function to add MFX JPEG BSD object State command in command buffer
1831     //!
1832     //! \param    [in] cmdBuffer
1833     //!           Command buffer to which HW command is added
1834     //! \param    [in] params
1835     //!           Params structure used to populate the HW command
1836     //!
1837     //! \return   MOS_STATUS
1838     //!           MOS_STATUS_SUCCESS if success, else fail reason
1839     //!
1840     virtual MOS_STATUS AddMfxJpegBsdObjCmd(
1841         PMOS_COMMAND_BUFFER cmdBuffer,
1842         PMHW_VDBOX_JPEG_BSD_PARAMS params) = 0;
1843 
1844     //!
1845     //! \brief    Adds JPEG picture state command to the command buffer
1846     //! \details  Client facing function to add JPEG picture state command to the command buffer
1847     //!
1848     //! \param    [in] cmdBuffer
1849     //!           Command buffer to which HW command is added
1850     //! \param    [in] params
1851     //!           Params structure used to populate the HW command
1852     //!
1853     //! \return   MOS_STATUS
1854     //!           MOS_STATUS_SUCCESS if success, else fail reason
1855     //!
1856     virtual MOS_STATUS AddMfxJpegEncodePicStateCmd(
1857         PMOS_COMMAND_BUFFER cmdBuffer,
1858         MhwVdboxJpegEncodePicState *params) = 0;
1859 
1860     //!
1861     //! \brief    Adds JPEG FQM command to the command buffer
1862     //! \details  Client facing function to add JPEG FQM command to the command buffer
1863     //!
1864     //! \param    [in] cmdBuffer
1865     //!           Command buffer to which HW command is added
1866     //! \param    [in] params
1867     //!           Params structure used to populate the HW command
1868     //! \param    [in] numQuantTables
1869     //!           Numbe of quant tables
1870     //!
1871     //! \return   MOS_STATUS
1872     //!           MOS_STATUS_SUCCESS if success, else fail reason
1873     //!
1874     virtual MOS_STATUS AddMfxJpegFqmCmd(
1875         PMOS_COMMAND_BUFFER cmdBuffer,
1876         PMHW_VDBOX_QM_PARAMS params,
1877         uint32_t numQuantTables) = 0;
1878 
1879     //!
1880     //! \brief    Adds JPEG Huffman Table state command to the command buffer
1881     //! \details  Client facing function to add JPEG Huffman Table state command to the command buffer
1882     //!
1883     //! \param    [in] cmdBuffer
1884     //!           Command buffer to which HW command is added
1885     //! \param    [in] params
1886     //!           Params structure used to populate the HW command
1887     //!
1888     //! \return   MOS_STATUS
1889     //!           MOS_STATUS_SUCCESS if success, else fail reason
1890     //!
1891     virtual MOS_STATUS AddMfcJpegHuffTableStateCmd(
1892         PMOS_COMMAND_BUFFER cmdBuffer,
1893         PMHW_VDBOX_ENCODE_HUFF_TABLE_PARAMS params) = 0;
1894 
1895     //!
1896     //! \brief    Adds JPEG scan object command to the command buffer
1897     //! \details  Client facing function to add JPEG scan object command to the command buffer
1898     //!
1899     //! \param    [in] cmdBuffer
1900     //!           Command buffer to which HW command is added
1901     //! \param    [in] params
1902     //!           Params structure used to populate the HW command
1903     //!
1904     //! \return   MOS_STATUS
1905     //!           MOS_STATUS_SUCCESS if success, else fail reason
1906     //!
1907     virtual MOS_STATUS AddMfcJpegScanObjCmd(
1908         PMOS_COMMAND_BUFFER cmdBuffer,
1909         MhwVdboxJpegScanParams *params) = 0;
1910 
1911     //!
1912     //! \brief    Adds MFX VP8 Picture State command for decoder in command buffer
1913     //!
1914     //! \param    [in] cmdBuffer
1915     //!           Command buffer to which HW command is added
1916     //! \param    [in] params
1917     //!           Params structure used to populate the HW command
1918     //!
1919     //! \return   MOS_STATUS
1920     //!           MOS_STATUS_SUCCESS if success, else fail reason
1921     //!
1922     virtual MOS_STATUS AddMfxDecodeVp8PicCmd(
1923         PMOS_COMMAND_BUFFER cmdBuffer,
1924         PMHW_VDBOX_VP8_PIC_STATE params) = 0;
1925 
1926     //!
1927     //! \brief    Adds MFX VP8 Picture State command for encoder in command buffer
1928     //!
1929     //! \param    [in] cmdBuffer
1930     //!           Command buffer to which HW command is added
1931     //! \param    [in] params
1932     //!           Params structure used to populate the HW command
1933     //!
1934     //! \return   MOS_STATUS
1935     //!           MOS_STATUS_SUCCESS if success, else fail reason
1936     //!
1937     virtual MOS_STATUS AddMfxEncodeVp8PicCmd(
1938         PMOS_COMMAND_BUFFER cmdBuffer,
1939         PMHW_VDBOX_VP8_PIC_STATE params) = 0;
1940 
1941     //!
1942     //! \brief    Adds VP8 Decode BSD State command in command buffer
1943     //! \details  Client facing function to add VP8 Decode BSD State command in command buffer
1944     //!
1945     //! \param    [in] cmdBuffer
1946     //!           Command buffer to which HW command is added
1947     //! \param    [in] params
1948     //!           Params structure used to populate the HW command
1949     //!
1950     //! \return   MOS_STATUS
1951     //!           MOS_STATUS_SUCCESS if success, else fail reason
1952     //!
1953     virtual MOS_STATUS AddMfdVp8BsdObjectCmd(
1954         PMOS_COMMAND_BUFFER cmdBuffer,
1955         PMHW_VDBOX_VP8_BSD_PARAMS params) = 0;
1956 
1957     //!
1958     //! \brief    Initializes the encoder cfg buffer with MFX_VP8_ENCODER_CFG_CMD
1959     //! \details  Client facing function to initialize the encoder cfg buffer with MFX_VP8_ENCODER_CFG_CMD
1960     //!           Headder offsets will be updated by kernel
1961     //!           The function will also add a batch buffer at the end.
1962     //!
1963     //! \param    [in] cfgCmdBuffer
1964     //!           Command buffer to which HW command is added
1965     //! \param    [in] params
1966     //!           Params structure used to populate the HW command
1967     //!
1968     //! \return   MOS_STATUS
1969     //!           MOS_STATUS_SUCCESS if success, else fail reason
1970     //!
1971     virtual MOS_STATUS InitMfxVp8EncoderCfgCmd(
1972         PMOS_RESOURCE cfgCmdBuffer,
1973         PMHW_VDBOX_VP8_ENCODER_CFG_PARAMS params) = 0;
1974 
1975     //!
1976     //! \brief    Adds VP8 MFX BSP Buffer Base Address State command in command buffer
1977     //! \details  Client facing function to add VP8 MFX BSP Buffer Base Address State command in command buffer
1978     //!
1979     //! \param    [in] cmdBuffer
1980     //!           Command buffer to which HW command is added
1981     //! \param    [in] params
1982     //!           Params structure used to populate the HW command
1983     //!
1984     //! \return   MOS_STATUS
1985     //!           MOS_STATUS_SUCCESS if success, else fail reason
1986     //!
1987     virtual MOS_STATUS AddMfxVp8BspBufBaseAddrCmd(
1988         PMOS_COMMAND_BUFFER cmdBuffer,
1989         PMHW_VDBOX_VP8_BSP_BUF_BASE_ADDR_PARAMS params) = 0;
1990 };
1991 
1992 #endif
1993