1 /*
2 * Copyright (c) 2021-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     decode_mpeg2_picture_packet.cpp
24 //! \brief    Defines the interface for mpeg2 decode picture packet
25 //!
26 #include "decode_mpeg2_picture_packet.h"
27 #include "codechal_debug.h"
28 #include "decode_common_feature_defs.h"
29 #include "decode_mpeg2_mem_compression.h"
30 
31 namespace decode{
32 
~Mpeg2DecodePicPkt()33 Mpeg2DecodePicPkt::~Mpeg2DecodePicPkt()
34 {
35     FreeResources();
36 }
37 
FreeResources()38 MOS_STATUS Mpeg2DecodePicPkt::FreeResources()
39 {
40     DECODE_FUNC_CALL();
41 
42     if (m_allocator != nullptr)
43     {
44         m_allocator->Destroy(m_resMfdDeblockingFilterRowStoreScratchBuffer);
45         m_allocator->Destroy(m_resBsdMpcRowStoreScratchBuffer);
46     }
47 
48     return MOS_STATUS_SUCCESS;
49 }
50 
Init()51 MOS_STATUS Mpeg2DecodePicPkt::Init()
52 {
53     DECODE_FUNC_CALL();
54 
55     DECODE_CHK_NULL(m_featureManager);
56     DECODE_CHK_NULL(m_hwInterface);
57     DECODE_CHK_NULL(m_osInterface);
58     DECODE_CHK_NULL(m_miItf);
59     DECODE_CHK_NULL(m_mpeg2Pipeline);
60     DECODE_CHK_NULL(m_mfxItf);
61 
62     m_mpeg2BasicFeature = dynamic_cast<Mpeg2BasicFeature*>(m_featureManager->GetFeature(FeatureIDs::basicFeature));
63     DECODE_CHK_NULL(m_mpeg2BasicFeature);
64 
65     m_allocator = m_pipeline ->GetDecodeAllocator();
66     DECODE_CHK_NULL(m_allocator);
67 
68     DECODE_CHK_STATUS(AllocateFixedResources());
69 
70     return MOS_STATUS_SUCCESS;
71 }
72 
Prepare()73 MOS_STATUS Mpeg2DecodePicPkt::Prepare()
74 {
75     DECODE_FUNC_CALL();
76 
77     m_mpeg2PicParams = m_mpeg2BasicFeature->m_mpeg2PicParams;
78     DECODE_CHK_NULL(m_mpeg2PicParams);
79 
80 #ifdef _MMC_SUPPORTED
81     m_mmcState = m_mpeg2Pipeline->GetMmcState();
82     DECODE_CHK_NULL(m_mmcState);
83 #endif
84 
85     return MOS_STATUS_SUCCESS;
86 }
87 
AllocateFixedResources()88 MOS_STATUS Mpeg2DecodePicPkt::AllocateFixedResources()
89 {
90     DECODE_FUNC_CALL();
91 
92     uint16_t picWidthInMb  = m_mpeg2BasicFeature->m_picWidthInMb;
93     uint16_t picHeightInMb = m_mpeg2BasicFeature->m_picHeightInMb;
94 
95     // Deblocking Filter Row Store Scratch buffer
96     // (Num MacroBlock Width) * (Num Cachlines) * (Cachline size)
97     m_resMfdDeblockingFilterRowStoreScratchBuffer= m_allocator->AllocateBuffer(
98         picWidthInMb * 7 * CODECHAL_CACHELINE_SIZE,
99         "DeblockingFilterScratch",
100         resourceInternalReadWriteCache,
101         notLockableVideoMem);
102 
103     // MPR Row Store Scratch buffer
104     // (FrameWidth in MB) * (CacheLine size per MB) * 2
105     m_resBsdMpcRowStoreScratchBuffer= m_allocator->AllocateBuffer(
106         ((uint32_t)(picWidthInMb * CODECHAL_CACHELINE_SIZE)) * 2,
107         "MprScratchBuffer",
108         resourceInternalReadWriteCache,
109         notLockableVideoMem);
110 
111     return MOS_STATUS_SUCCESS;
112 }
113 
FixMfxPipeBufAddrParams() const114 MOS_STATUS Mpeg2DecodePicPkt::FixMfxPipeBufAddrParams() const
115 {
116     DECODE_FUNC_CALL();
117 
118     auto &        par      = m_mfxItf->MHW_GETPAR_F(MFX_PIPE_BUF_ADDR_STATE)();
119     PMOS_RESOURCE dummyRef = &(m_mpeg2BasicFeature->m_dummyReference.OsResource);
120 
121     // set all ref pic addresses to valid addresses for error concealment purpose
122     for (uint32_t i = 0; i < CODEC_MAX_NUM_REF_FRAME_NON_AVC; i++)
123     {
124         if (m_mpeg2BasicFeature->m_useDummyReference && !m_allocator->ResourceIsNull(dummyRef) &&
125             par.presReferences[i] == nullptr)
126         {
127             par.presReferences[i] = dummyRef;
128         }
129     }
130 
131     return MOS_STATUS_SUCCESS;
132 }
133 
MHW_SETPAR_DECL_SRC(MFX_PIPE_MODE_SELECT,Mpeg2DecodePicPkt)134 MHW_SETPAR_DECL_SRC(MFX_PIPE_MODE_SELECT, Mpeg2DecodePicPkt)
135 {
136     params.streamOutEnable                                = m_mpeg2BasicFeature->m_streamOutEnabled;
137     params.postDeblockingOutputEnablePostdeblockoutenable = m_mpeg2BasicFeature->m_deblockingEnabled;
138     params.preDeblockingOutputEnablePredeblockoutenable   = !m_mpeg2BasicFeature->m_deblockingEnabled;
139     params.decoderShortFormatMode                         = true;
140 
141     if (CodecHalIsDecodeModeVLD(m_mpeg2BasicFeature->m_mode))
142     {
143         params.decoderModeSelect = mfxDecoderModeVld;
144     }
145     else if (CodecHalIsDecodeModeIT(m_mpeg2BasicFeature->m_mode))
146     {
147         params.decoderModeSelect = mfxDecoderModeIt;
148     }
149 
150     params.standardSelect = CodecHal_GetStandardFromMode(m_mpeg2BasicFeature->m_mode);
151 
152     return MOS_STATUS_SUCCESS;
153 }
154 
MHW_SETPAR_DECL_SRC(MFX_SURFACE_STATE,Mpeg2DecodePicPkt)155 MHW_SETPAR_DECL_SRC(MFX_SURFACE_STATE, Mpeg2DecodePicPkt)
156 {
157     // set cmd function
158     MOS_SURFACE *psSurface = &m_mpeg2BasicFeature->m_destSurface;
159 
160 #ifdef _MMC_SUPPORTED
161     DECODE_CHK_STATUS(m_mmcState->SetSurfaceMmcState(&(m_mpeg2BasicFeature->m_destSurface)));
162     DECODE_CHK_STATUS(m_mmcState->GetSurfaceMmcState(psSurface, &params.mmcState));
163     DECODE_CHK_STATUS(m_mmcState->GetSurfaceMmcFormat(psSurface, &params.compressionFormat));
164 #endif
165 
166     params.height           = psSurface->dwHeight - 1;
167     params.width            = psSurface->dwWidth - 1;
168     params.surfacePitch     = psSurface->dwPitch - 1;
169     params.interleaveChroma = 1;
170     params.surfaceFormat    = SURFACE_FORMAT_PLANAR4208;
171 
172     params.tilemode = m_mfxItf->MosGetHWTileType(psSurface->TileType, psSurface->TileModeGMM, psSurface->bGMMTileEnabled);
173 
174     uint32_t uvPlaneAlignment = MHW_VDBOX_MFX_UV_PLANE_ALIGNMENT_LEGACY;
175     if (params.surfaceId == CODECHAL_MFX_SRC_SURFACE_ID)
176     {
177         uvPlaneAlignment = MHW_VDBOX_MFX_RAW_UV_PLANE_ALIGNMENT_GEN9;
178     }
179     else
180     {
181         uvPlaneAlignment = MHW_VDBOX_MFX_UV_PLANE_ALIGNMENT_LEGACY;
182     }
183 
184     if (psSurface->Format == Format_P8)  // monochrome format
185     {
186         params.interleaveChroma = 0;
187     }
188 
189     params.yOffsetForUCb = MOS_ALIGN_CEIL((psSurface->UPlaneOffset.iSurfaceOffset - psSurface->dwOffset) /
190         psSurface->dwPitch + psSurface->RenderOffset.YUV.U.YOffset, uvPlaneAlignment);
191     params.yOffsetForVCr = MOS_ALIGN_CEIL((psSurface->VPlaneOffset.iSurfaceOffset - psSurface->dwOffset) /
192         psSurface->dwPitch + psSurface->RenderOffset.YUV.V.YOffset, uvPlaneAlignment);
193 
194     return MOS_STATUS_SUCCESS;
195 }
196 
MHW_SETPAR_DECL_SRC(MFX_PIPE_BUF_ADDR_STATE,Mpeg2DecodePicPkt)197 MHW_SETPAR_DECL_SRC(MFX_PIPE_BUF_ADDR_STATE, Mpeg2DecodePicPkt)
198 {
199     if (m_mpeg2BasicFeature->m_deblockingEnabled)
200     {
201         params.psPostDeblockSurface = &(m_mpeg2BasicFeature->m_destSurface);
202     }
203     else
204     {
205         params.psPreDeblockSurface = &(m_mpeg2BasicFeature->m_destSurface);
206     }
207     params.presMfdDeblockingFilterRowStoreScratchBuffer = &m_resMfdDeblockingFilterRowStoreScratchBuffer->OsResource;
208 
209     if (m_mpeg2BasicFeature->m_streamOutEnabled)
210     {
211         params.presStreamOutBuffer = m_mpeg2BasicFeature->m_streamOutBuffer;
212     }
213 
214     Mpeg2ReferenceFrames &refFrames = m_mpeg2BasicFeature->m_refFrames;
215 
216     // when there is not a forward or backward reference,
217     // the index is set to the destination frame index
218     params.presReferences[CodechalDecodeFwdRefTop] =
219         params.presReferences[CodechalDecodeFwdRefBottom] =
220             params.presReferences[CodechalDecodeBwdRefTop] =
221                 params.presReferences[CodechalDecodeBwdRefBottom] =
222                     &m_mpeg2BasicFeature->m_destSurface.OsResource;
223 
224     if (m_mpeg2BasicFeature->m_fwdRefIdx < CODECHAL_NUM_UNCOMPRESSED_SURFACE_MPEG2)
225     {
226         params.presReferences[CodechalDecodeFwdRefTop] =
227             params.presReferences[CodechalDecodeFwdRefBottom] =
228                 &refFrames.m_refList[m_mpeg2BasicFeature->m_fwdRefIdx]->resRefPic;
229     }
230     if (m_mpeg2BasicFeature->m_bwdRefIdx < CODECHAL_NUM_UNCOMPRESSED_SURFACE_MPEG2)
231     {
232         params.presReferences[CodechalDecodeBwdRefTop] =
233             params.presReferences[CodechalDecodeBwdRefBottom] =
234                 &refFrames.m_refList[m_mpeg2BasicFeature->m_bwdRefIdx]->resRefPic;
235     }
236 
237     // special case for second fields
238     if (m_mpeg2PicParams->m_secondField && m_mpeg2PicParams->m_pictureCodingType == P_TYPE)
239     {
240         if (m_mpeg2PicParams->m_topFieldFirst)
241         {
242             params.presReferences[CodechalDecodeFwdRefTop] =
243                 &m_mpeg2BasicFeature->m_destSurface.OsResource;
244         }
245         else
246         {
247             params.presReferences[CodechalDecodeFwdRefBottom] =
248                 &m_mpeg2BasicFeature->m_destSurface.OsResource;
249         }
250     }
251 
252 #ifdef _MMC_SUPPORTED
253     DECODE_CHK_STATUS(m_mmcState->GetSurfaceMmcState(params.psPreDeblockSurface, &params.PreDeblockSurfMmcState));
254 #endif
255 
256     DECODE_CHK_STATUS(FixMfxPipeBufAddrParams());
257 
258     CODECHAL_DEBUG_TOOL(DumpResources(params));
259 
260 #ifdef _MMC_SUPPORTED
261     Mpeg2DecodeMemComp *mpeg2DecodeMemComp = dynamic_cast<Mpeg2DecodeMemComp *>(m_mmcState);
262     DECODE_CHK_NULL(mpeg2DecodeMemComp);
263     DECODE_CHK_STATUS(mpeg2DecodeMemComp->CheckReferenceList(*m_mpeg2BasicFeature, params.PreDeblockSurfMmcState, params.PostDeblockSurfMmcState));
264 #endif
265 
266     return MOS_STATUS_SUCCESS;
267 }
268 
MHW_SETPAR_DECL_SRC(MFX_IND_OBJ_BASE_ADDR_STATE,Mpeg2DecodePicPkt)269 MHW_SETPAR_DECL_SRC(MFX_IND_OBJ_BASE_ADDR_STATE, Mpeg2DecodePicPkt)
270 {
271     params.Mode            = m_mpeg2BasicFeature->m_mode;
272     params.dwDataSize      = m_mpeg2BasicFeature->m_copiedDataBufferInUse ?
273         m_mpeg2BasicFeature->m_copiedDataBufferSize : m_mpeg2BasicFeature->m_dataSize;
274     params.presDataBuffer  = m_mpeg2BasicFeature->m_copiedDataBufferInUse ?
275         &(m_mpeg2BasicFeature->m_copiedDataBuf->OsResource) : &(m_mpeg2BasicFeature->m_resDataBuffer.OsResource);
276 
277     return MOS_STATUS_SUCCESS;
278 }
279 
MHW_SETPAR_DECL_SRC(MFX_BSP_BUF_BASE_ADDR_STATE,Mpeg2DecodePicPkt)280 MHW_SETPAR_DECL_SRC(MFX_BSP_BUF_BASE_ADDR_STATE, Mpeg2DecodePicPkt)
281 {
282     params.presBsdMpcRowStoreScratchBuffer = &m_resBsdMpcRowStoreScratchBuffer->OsResource;
283 
284     return MOS_STATUS_SUCCESS;
285 }
286 
MHW_SETPAR_DECL_SRC(MFX_MPEG2_PIC_STATE,Mpeg2DecodePicPkt)287 MHW_SETPAR_DECL_SRC(MFX_MPEG2_PIC_STATE, Mpeg2DecodePicPkt)
288 {
289     params.ScanOrder                    = m_mpeg2PicParams->W0.m_scanOrder;
290     params.IntraVlcFormat               = m_mpeg2PicParams->W0.m_intraVlcFormat;
291     params.QuantizerScaleType           = m_mpeg2PicParams->W0.m_quantizerScaleType;
292     params.ConcealmentMotionVectorFlag  = m_mpeg2PicParams->W0.m_concealmentMVFlag;
293     params.FramePredictionFrameDct      = m_mpeg2PicParams->W0.m_frameDctPrediction;
294     params.TffTopFieldFirst             = (CodecHal_PictureIsFrame(m_mpeg2PicParams->m_currPic)) ?
295         m_mpeg2PicParams->W0.m_topFieldFirst : m_mpeg2PicParams->m_topFieldFirst;
296 
297     params.PictureStructure  = (CodecHal_PictureIsFrame(m_mpeg2PicParams->m_currPic)) ?
298         mpeg2Vc1Frame : (CodecHal_PictureIsTopField(m_mpeg2PicParams->m_currPic)) ?
299         mpeg2Vc1TopField : mpeg2Vc1BottomField;
300     params.IntraDcPrecision  = m_mpeg2PicParams->W0.m_intraDCPrecision;
301     params.FCode00           = m_mpeg2PicParams->W1.m_fcode00;
302     params.FCode01           = m_mpeg2PicParams->W1.m_fcode01;
303     params.FCode10           = m_mpeg2PicParams->W1.m_fcode10;
304     params.FCode11           = m_mpeg2PicParams->W1.m_fcode11;
305     params.PictureCodingType = m_mpeg2PicParams->m_pictureCodingType;
306 
307     if (m_mpeg2BasicFeature->m_mode == CODECHAL_DECODE_MODE_MPEG2VLD)
308     {
309         params.ISliceConcealmentMode                                             = m_mpeg2BasicFeature->m_mpeg2ISliceConcealmentMode;
310         params.PBSliceConcealmentMode                                            = m_mpeg2BasicFeature->m_mpeg2PbSliceConcealmentMode;
311         params.PBSlicePredictedBidirMotionTypeOverrideBiDirectionMvTypeOverride  = m_mpeg2BasicFeature->m_mpeg2PbSlicePredBiDirMvTypeOverride;
312         params.PBSlicePredictedMotionVectorOverrideFinalMvValueOverride          = m_mpeg2BasicFeature->m_mpeg2PbSlicePredMvOverride;
313 
314         params.SliceConcealmentDisableBit = 1;
315     }
316 
317     uint16_t widthInMbs =
318         (m_mpeg2PicParams->m_horizontalSize + CODECHAL_MACROBLOCK_WIDTH - 1) /
319         CODECHAL_MACROBLOCK_WIDTH;
320 
321     uint16_t heightInMbs =
322         (m_mpeg2PicParams->m_verticalSize + CODECHAL_MACROBLOCK_HEIGHT - 1) /
323         CODECHAL_MACROBLOCK_HEIGHT;
324 
325     params.Framewidthinmbsminus170PictureWidthInMacroblocks   = widthInMbs - 1;
326     params.Frameheightinmbsminus170PictureHeightInMacroblocks = (CodecHal_PictureIsField(m_mpeg2PicParams->m_currPic)) ?
327         ((heightInMbs * 2) - 1) : heightInMbs - 1;
328 
329     if (m_mpeg2BasicFeature->m_deblockingEnabled)
330     {
331         params.mfxMpeg2PicStatePar0 = 9;
332     }
333 
334     return MOS_STATUS_SUCCESS;
335 }
336 
AddAllCmds_MFX_QM_STATE(MOS_COMMAND_BUFFER & cmdBuffer)337 MOS_STATUS Mpeg2DecodePicPkt::AddAllCmds_MFX_QM_STATE(MOS_COMMAND_BUFFER &cmdBuffer)
338 {
339     auto pMpeg2IqMatrix = m_mpeg2BasicFeature->m_mpeg2IqMatrixBuffer;
340     MHW_MI_CHK_NULL(pMpeg2IqMatrix);
341 
342     auto &params = m_mfxItf->MHW_GETPAR_F(MFX_QM_STATE)();
343     params       = {};
344 
345     uint8_t *qMatrix  = (uint8_t *)params.quantizermatrix;
346 
347     for (auto i = 0; i < 64; i++)
348     {
349         qMatrix[i] = 0;
350     }
351 
352     params.qmType = m_mpeg2BasicFeature->Mpeg2QmTypes::mpeg2QmIntra;
353     if (pMpeg2IqMatrix->m_loadIntraQuantiserMatrix)
354     {
355         uint8_t *src = pMpeg2IqMatrix->m_intraQuantiserMatrix;
356         for (auto i = 0; i < 64; i++)
357         {
358             qMatrix[i] = (uint8_t)(src[m_mpeg2BasicFeature->m_mpeg2QuantMatrixScan[i]]);
359         }
360     }
361     else
362     {
363         for (auto i = 0; i < 64; i++)
364         {
365             qMatrix[i] = (uint8_t)(m_mpeg2BasicFeature->m_mpeg2DefaultIntraQuantizerMatrix[i]);
366         }
367     }
368 
369     DECODE_CHK_STATUS(m_mfxItf->MHW_ADDCMD_F(MFX_QM_STATE)(&cmdBuffer));
370 
371     params.qmType = m_mpeg2BasicFeature->Mpeg2QmTypes::mpeg2QmNonIntra;
372     if (pMpeg2IqMatrix->m_loadNonIntraQuantiserMatrix)
373     {
374         uint8_t *src = pMpeg2IqMatrix->m_nonIntraQuantiserMatrix;
375         for (auto i = 0; i < 64; i++)
376         {
377             qMatrix[i] = (uint8_t)(src[m_mpeg2BasicFeature->m_mpeg2QuantMatrixScan[i]]);
378         }
379     }
380     else
381     {
382         for (auto i = 0; i < 64; i++)
383         {
384             qMatrix[i] = (uint8_t)(m_mpeg2BasicFeature->m_mpeg2DefaultNonIntraQuantizerMatrix[i]);
385         }
386     }
387 
388     DECODE_CHK_STATUS(m_mfxItf->MHW_ADDCMD_F(MFX_QM_STATE)(&cmdBuffer));
389 
390     return MOS_STATUS_SUCCESS;
391 }
392 
393 
394 
CalculateCommandSize(uint32_t & commandBufferSize,uint32_t & requestedPatchListSize)395 MOS_STATUS Mpeg2DecodePicPkt::CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize)
396 {
397     DECODE_FUNC_CALL();
398 
399     commandBufferSize = m_pictureStatesSize;
400     requestedPatchListSize = m_picturePatchListSize;
401 
402     return MOS_STATUS_SUCCESS;
403 }
404 
405 #if USE_CODECHAL_DEBUG_TOOL
DumpResources(MFX_PIPE_BUF_ADDR_STATE_PAR & pipeBufAddrParams) const406     MOS_STATUS Mpeg2DecodePicPkt::DumpResources(MFX_PIPE_BUF_ADDR_STATE_PAR &pipeBufAddrParams) const
407     {
408         DECODE_FUNC_CALL();
409 
410         CodechalDebugInterface *debugInterface = m_pipeline->GetDebugInterface();
411         DECODE_CHK_NULL(debugInterface);
412 
413         if (m_mpeg2PicParams->m_pictureCodingType != I_TYPE)
414         {
415             for (uint16_t n = 0; n <= CodechalDecodeBwdRefBottom; n++)
416             {
417                 if (pipeBufAddrParams.presReferences[n])
418                 {
419                     MOS_SURFACE refSurface;
420                     MOS_ZeroMemory(&refSurface, sizeof(MOS_SURFACE));
421                     refSurface.OsResource = *(pipeBufAddrParams.presReferences[n]);
422                     DECODE_CHK_STATUS(m_allocator->GetSurfaceInfo(&refSurface));
423 
424                     debugInterface->m_refIndex = n;
425                     std::string refSurfName    = "RefSurf[" + std::to_string(static_cast<uint32_t>(debugInterface->m_refIndex)) + "]";
426                     DECODE_CHK_STATUS(debugInterface->DumpYUVSurface(
427                         &refSurface,
428                         CodechalDbgAttr::attrDecodeReferenceSurfaces,
429                         refSurfName.c_str()));
430                 }
431             }
432         }
433 
434         return MOS_STATUS_SUCCESS;
435     }
436 #endif
437 
AddAllCmds_MFX_PIPE_MODE_SELECT(MOS_COMMAND_BUFFER & cmdBuffer)438 MOS_STATUS Mpeg2DecodePicPkt::AddAllCmds_MFX_PIPE_MODE_SELECT(MOS_COMMAND_BUFFER &cmdBuffer)
439 {
440     DECODE_FUNC_CALL();
441 
442     //for gen 12, we need to add MFX wait for both KIN and VRT before and after MFX Pipemode select.
443     auto &mfxWaitParams               = m_miItf->MHW_GETPAR_F(MFX_WAIT)();
444     mfxWaitParams                     = {};
445     mfxWaitParams.iStallVdboxPipeline = true;
446     DECODE_CHK_STATUS((m_miItf->MHW_ADDCMD_F(MFX_WAIT)(&cmdBuffer)));
447 
448     DECODE_CHK_NULL(m_mfxItf);
449     SETPAR_AND_ADDCMD(MFX_PIPE_MODE_SELECT, m_mfxItf, &cmdBuffer);
450 
451     //for gen 12, we need to add MFX wait for both KIN and VRT before and after MFX Pipemode select.
452     mfxWaitParams                     = {};
453     mfxWaitParams.iStallVdboxPipeline = true;
454     DECODE_CHK_STATUS((m_miItf->MHW_ADDCMD_F(MFX_WAIT)(&cmdBuffer)));
455 
456     return MOS_STATUS_SUCCESS;
457 }
458 
459 }  // namespace decode
460