xref: /aosp_15_r20/external/intel-media-driver/media_driver/agnostic/common/codec/hal/codechal_decoder.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2011-2021, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file     codechal_decoder.h
24 //! \brief    Defines the decode interface for CodecHal.
25 //! \details  The decode interface is further sub-divided by standard, this file is for the base interface which is shared by all decode standards.
26 //!
27 
28 #ifndef __CODECHAL_DECODER_H__
29 #define __CODECHAL_DECODER_H__
30 
31 #include "codechal.h"
32 #include "codechal_setting.h"
33 #include "codechal_hw.h"
34 #include "codechal_debug.h"
35 #include "codechal_oca_debug.h"
36 #include "codechal_decode_downsampling.h"
37 #include "codechal_decode_sfc.h"
38 #include "codechal_mmc.h"
39 #include "codechal_utilities.h"
40 #include "codec_def_decode.h"
41 #include "cm_wrapper.h"
42 #include "media_perf_profiler.h"
43 #include "codec_def_cenc_decode.h"
44 
45 class CodechalSecureDecodeInterface;
46 class CodechalDecodeHistogram;
47 
48 //------------------------------------------------------------------------------
49 // Macros specific to MOS_CODEC_SUBCOMP_DECODE sub-comp
50 //------------------------------------------------------------------------------
51 #define CODECHAL_DECODE_ASSERT(_expr)                                                   \
52     MOS_ASSERT(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _expr)
53 
54 #define CODECHAL_DECODE_COND_ASSERTMESSAGE(_expr, _message, ...)                        \
55     if (_expr)                                                                          \
56     {                                                                                   \
57         CODECHAL_DECODE_ASSERTMESSAGE(_message, ##__VA_ARGS__)                          \
58     }
59 
60 #define CODECHAL_DECODE_ASSERTMESSAGE(_message, ...)                                    \
61     MOS_ASSERTMESSAGE(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _message, ##__VA_ARGS__)
62 
63 #define CODECHAL_DECODE_NORMALMESSAGE(_message, ...)                                    \
64     MOS_NORMALMESSAGE(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _message, ##__VA_ARGS__)
65 
66 #define CODECHAL_DECODE_VERBOSEMESSAGE(_message, ...)                                   \
67     MOS_VERBOSEMESSAGE(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _message, ##__VA_ARGS__)
68 
69 #define CODECHAL_DECODE_FUNCTION_ENTER                                                  \
70     MOS_FUNCTION_ENTER(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE)
71 
72 #define CODECHAL_DECODE_CHK_STATUS(_stmt)                                               \
73     MOS_CHK_STATUS(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _stmt)
74 
75 #define CODECHAL_DECODE_CHK_STATUS_RETURN(_stmt)                                        \
76     MOS_CHK_STATUS_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _stmt)
77 
78 #define CODECHAL_DECODE_CHK_STATUS_BREAK(_stmt)                                         \
79     MOS_CHK_STATUS_BREAK(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _stmt)
80 
81 #define CODECHAL_DECODE_CHK_STATUS_MESSAGE(_stmt, _message, ...)                        \
82     MOS_CHK_STATUS_MESSAGE(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _stmt, _message, ##__VA_ARGS__)
83 
84 #define CODECHAL_DECODE_CHK_STATUS_MESSAGE_RETURN(_stmt, _message, ...)                        \
85     MOS_CHK_STATUS_MESSAGE_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _stmt, _message, ##__VA_ARGS__)
86 
87 #define CODECHAL_DECODE_CHK_NULL(_ptr)                                                  \
88     MOS_CHK_NULL(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _ptr)
89 
90 #define CODECHAL_DECODE_CHK_NULL_RETURN(_ptr)                                           \
91     MOS_CHK_NULL_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _ptr)
92 
93 #define CODECHAL_DECODE_CHK_NULL_NO_STATUS(_ptr)                                        \
94     MOS_CHK_NULL_NO_STATUS(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _ptr)
95 
96 #define CODECHAL_DECODE_CHK_NULL_NO_STATUS_RETURN(_ptr)                                 \
97     MOS_CHK_NULL_NO_STATUS_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE, _ptr)
98 
99 #define CODECHAL_DECODE_CHK_COND(_expr, _message, ...)                                  \
100     MOS_CHK_COND(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE,_expr,_message, ##__VA_ARGS__)
101 
102 #define CODECHAL_DECODE_CHK_COND_RETURN(_expr, _message, ...)                           \
103     MOS_CHK_COND_RETURN(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_DECODE,_expr,_message, ##__VA_ARGS__)
104 
105 #define CODECHAL_DECODE_NUM_STREAM_OUT_BUFFERS 5
106 
107 #define CODECHAL_DECODE_STATUS_NUM             512
108 
109 typedef enum _CODECHAL_CS_ENGINE_ID_DEF
110 {
111     // Instance ID
112     CODECHAL_CS_INSTANCE_ID_VDBOX0 = 0,
113     CODECHAL_CS_INSTANCE_ID_VDBOX1 = 1,
114     CODECHAL_CS_INSTANCE_ID_VDBOX2 = 2,
115     CODECHAL_CS_INSTANCE_ID_VDBOX3 = 3,
116     CODECHAL_CS_INSTANCE_ID_VDBOX4 = 4,
117     CODECHAL_CS_INSTANCE_ID_VDBOX5 = 5,
118     CODECHAL_CS_INSTANCE_ID_VDBOX6 = 6,
119     CODECHAL_CS_INSTANCE_ID_VDBOX7 = 7,
120     CODECHAL_CS_INSTANCE_ID_MAX,
121     // Class ID
122     CODECHAL_CLASS_ID_VIDEO_ENGINE = 1,
123 } CODECHAL_CS_ENGINE_ID_DEF;
124 
125 typedef union _CODECHAL_CS_ENGINE_ID
126 {
127     struct
128     {
129         uint32_t       ClassId            : 3;    //[0...4]
130         uint32_t       ReservedFiled1     : 1;    //[0]
131         uint32_t       InstanceId         : 6;    //[0...7]
132         uint32_t       ReservedField2     : 22;   //[0]
133     } fields;
134     uint32_t            value;
135 } CODECHAL_CS_ENGINE_ID, *PCODECHAL_CS_ENGINE_ID;
136 
137 typedef struct _CODECHAL_VLD_SLICE_RECORD
138 {
139     uint32_t   dwSkip;
140     uint32_t   dwOffset;
141     uint32_t   dwLength;
142     uint32_t   dwSliceStartMbOffset;
143     bool       bIsLastSlice;
144 } CODECHAL_VLD_SLICE_RECORD, *PCODECHAL_VLD_SLICE_RECORD;
145 
146 //!
147 //! \struct CodechalDecodeStatusReport
148 //! \brief  Information pertaining to a particular picture's decode operation
149 //!
150 struct CodechalDecodeStatusReport
151 {
152     //! \brief Status for the picture associated with this status report
153     CODECHAL_STATUS         m_codecStatus = CODECHAL_STATUS_SUCCESSFUL;
154     //! \brief Status report number associated with the picture in this status report provided in Execute()
155     uint32_t                m_statusReportNumber = 0;
156     //! \brief Uncompressed frame information for the picture associated with this status report
157     CODEC_PICTURE           m_currDecodedPic = {0};
158     //! \brief Applies for VC1 and MPEG2 only, uncompressed frame information for the out of loop deblock destination
159     CODEC_PICTURE           m_currDeblockedPic = {0};
160     //! \brief Pointer to the resource for the decode render target for the picture associated with this status report
161     MOS_RESOURCE            m_currDecodedPicRes = {0};
162     //! \brief Applies when debug dumps are enabled for VC1 only, resource of deblocked picture
163     MOS_RESOURCE            m_deblockedPicResOlp = {0};
164     //! \brief number of MBs decoded or if unused set to 0xFFFF
165     uint16_t                m_numMbsAffected = 0;
166     //! \brief Crc of frame from MMIO
167     uint32_t                m_frameCrc = 0;
168 
169 #if (_DEBUG || _RELEASE_INTERNAL)
170     //! \brief Applies when debug dumps are enabled, pointer to SFC output resource for the picture associated with this status report
171     PMOS_RESOURCE           m_currSfcOutputPicRes = nullptr;
172     //! \brief Applies when debug dumps are enabled, pointer to histogram output resource for the picture associated with this status report
173     PMOS_RESOURCE           m_currHistogramOutBuf = nullptr;
174     //! \brief Applies when debug dumps are enabled, pointer to AV1 film grain output resource for the picture associated with this status report
175     PMOS_RESOURCE           m_currFgOutputPicRes = nullptr;
176     //! \brief Applies when debug dumps are enabled, stream out buffer (legacy)
177     PMOS_RESOURCE           m_streamOutBuf = nullptr;
178     //! \brief Applies when debug dumps are enabled, index of the streamout buffer (legacy)
179     uint32_t                m_streamoutIdx = 0;
180     //! \brief Applies when debug dumps are enabled, stream in buffer
181     MOS_RESOURCE            m_streamInBufRes = {0};
182     //! \brief Applies when debug dumps are enabled, stream out buffer
183     MOS_RESOURCE            m_streamOutBufRes = {0};
184     //! \brief Applies when debug dumps are enabled, stream size
185     uint32_t                m_streamSize = 0;
186     //! \brief Applies when debug dumps are enabled, indicates whether or not this is the final field in the frame.
187     bool                    m_secondField = false;
188     //! \brief Applies to VC1 only, indicates whether or not the frame required OLP.
189     bool                    m_olpNeeded = false;
190     //! \brief Applies when debug dumps are enabled, frame type (I/P/B)
191     uint16_t                m_frameType = 0;
192 #endif // (_DEBUG || _RELEASE_INTERNAL)
193 };
194 
195 //!
196 //! \struct CodechalDecodeStatus
197 //! \brief  Codechal decode status for the frame
198 //!
199 struct CodechalDecodeStatus
200 {
201     //! \brief Value stored by MFX engine
202     uint32_t                m_hwStoredData = 0;
203     //! \brief SW(driver) stored value
204     uint32_t                m_swStoredData = 0;
205     //! \brief Value of MMIO decoding effor eStatus register
206     uint32_t                m_mmioErrorStatusReg = 0;
207     //! \brief Value of MMIO decoding MB error register
208     uint32_t                m_mmioMBCountReg = 0;
209     //! \brief Frame CRC related to current frames
210     uint32_t                m_mmioFrameCrcReg = 0;
211     //! \brief Value of MMIO CS Engine ID register for each BB
212     uint32_t                m_mmioCsEngineIdReg[CODECHAL_CS_INSTANCE_ID_MAX] = {0};
213     //! \brief Huc error for HEVC Fix Function, DWORD0: mask value, DWORD1: reg value
214     uint64_t                m_hucErrorStatus2 = 0;
215     //! \brief Huc error for HEVC Fix Function, DWORD0: mask value, DWORD1: reg value
216     uint64_t                m_hucErrorStatus = 0;
217 
218     CodechalDecodeStatusReport m_decodeStatusReport;
219 };
220 
221 //!
222 //! \struct CodechalDecodeStatusBuffer
223 //! \brief  Codechal decode status buffer
224 //!
225 struct CodechalDecodeStatusBuffer
226 {
227     //! \brief Codechal decode status
228     CodechalDecodeStatus    *m_decodeStatus = nullptr;
229     //! \brief Handle of status buffer
230     MOS_RESOURCE            m_statusBuffer = {0};
231     //! \brief Locked data point of status buffer
232     uint32_t                *m_data = nullptr;
233     //! \brief Software store data
234     uint32_t                m_swStoreData = 0;
235     //! \brief First index for status buffer
236     uint16_t                m_firstIndex = 0;
237     //! \brief Current index for status buffer
238     uint16_t                m_currIndex = 0;
239     //! \brief Offset to store data
240     uint8_t                 m_storeDataOffset = 0;
241     //! \brief Offset to decode error status
242     uint8_t                 m_decErrorStatusOffset = 0;
243     //! \brief Offset to decode frame CRC
244     uint8_t                 m_decFrameCrcOffset = 0;
245     //! \brief Offset to decode MB count
246     uint8_t                 m_decMBCountOffset = 0;
247     //! \brief Offset to CS engine ID
248     uint8_t                 m_csEngineIdOffset = 0;
249 
250     //! \brief Offset to mask of MMIO HuCErrorStatus2
251     uint8_t                 m_hucErrorStatus2MaskOffset = 0;
252     //! \brief Offset to MMIO HuCErrorStatus2
253     uint8_t                 m_hucErrorStatus2RegOffset = 0;
254     //! \brief Offset to mask of MMIO HuCErrorStatus
255     uint8_t                 m_hucErrorStatusMaskOffset = 0;
256     //! \brief Offset to MMIO HuCErrorStatus
257     uint8_t                 m_hucErrorStatusRegOffset = 0;
258 };
259 
260 //!
261 //! \class CodechalDecode
262 //! \brief This class defines the common member fields, functions etc as decode base class.
263 //!
264 class CodechalDecode : public Codechal
265 {
266 public:
267     //!
268     //! \enum   CodechalHcpDecodePhase
269     //! \brief  enum constant for HEVC/VP9 decode pass control
270     //!
271     enum CodechalHcpDecodePhase
272     {
273         CodechalHcpDecodePhaseInitialized = 0x00,  //!< Initial phase
274         CodechalHcpDecodePhaseLegacyLong,          //!< Legacy long format phase
275         CodechalHcpDecodePhaseLegacyS2L,           //!< Legacy short to long phase
276         CodechalHcpDecodePhaseMax                  //!< Maximal phases
277     };
278 
279     //!
280     //! \enum  CodechalDecodeMotionType
281     //! \brief Codechal decode motion type
282     //!
283     enum CodechalDecodeMotionType
284     {
285         CodechalDecodeMcField = 1,  //!< Field motion type
286         CodechalDecodeMcFrame = 2,  //!< Frame motion type
287         CodechalDecodeMc16x8  = 2,  //!< 16x8 motion type
288         CodechalDecodeMcDmv   = 3   //!< DMV motion type
289     };
290 
291     //!
292     //! \enum  CodechalDecodeMvPacking
293     //! \brief For motion vector packing: the equivilant derefences of a [2][2][2] array mapped as a [8] array
294     //!
295     enum CodechalDecodeMvPacking
296     {
297         CodechalDecodeRstFirstForwHorz = 0,  //!< first forward horizontal
298         CodechalDecodeRstFirstForwVert = 1,  //!< first forward vertical
299         CodechalDecodeRstFirstBackHorz = 2,  //!< first backward horizontal
300         CodechalDecodeRstFirstBackVert = 3,  //!< first backward vertical
301         CodechalDecodeRstSecndForwHorz = 4,  //!< second forward horizontal
302         CodechalDecodeRstSecndForwVert = 5,  //!< second forward vertical
303         CodechalDecodeRstSecndBackHorz = 6,  //!< second backward horizontal
304         CodechalDecodeRstSecndBackVert = 7   //!< second backward vertical
305     };
306 
307     //!
308     //! \enum  CodechalDecodeRefAddrIndex
309     //! \brief Reference address indexes
310     //!
311     enum CodechalDecodeRefAddrIndex
312     {
313         // MPEG2/VC1 reference address indexes
314         CodechalDecodeFwdRefTop    = 0,  //!< forward reference top field
315         CodechalDecodeBwdRefTop    = 1,  //!< backward reference top field
316         CodechalDecodeFwdRefBottom = 2,  //!< forward reference bottom field
317         CodechalDecodeBwdRefBottom = 3,  //!< backward reference bottom field
318         // VP8/VP9 reference address indexes
319         CodechalDecodeLastRef      = 0,  //!< last reference
320         CodechalDecodeGoldenRef    = 1,  //!< golden reference
321         CodechalDecodeAlternateRef = 2   //!< alternate reference
322     };
323 
324     //!
325     //! \brief    Constructor
326     //! \param    [in] hwInterface
327     //!           Hardware interface
328     //! \param    [in] debugInterface
329     //!           Debug interface
330     //! \param    [in] standardInfo
331     //!           The information of decode standard for this instance
332     //!
333     CodechalDecode(
334         CodechalHwInterface    *hwInterface,
335         CodechalDebugInterface *debugInterface,
336         PCODECHAL_STANDARD_INFO standardInfo);
337 
338     //!
339     //! \brief    Copy constructor
340     //!
341     CodechalDecode(const CodechalDecode &) = delete;
342 
343     //!
344     //! \brief    Copy assignment operator
345     //!
346     CodechalDecode &operator=(const CodechalDecode &) = delete;
347 
348     //!
349     //! \brief  Destructor
350     //!
351     virtual ~CodechalDecode();
352 
353     //!
354     //! \brief  Get picture width for decode
355     //! \return Width value
356     //!
GetWidth()357     virtual uint32_t GetWidth() { return m_width; }
358 
359     //!
360     //! \brief  Get picture height for decode
361     //! \return Height value
362     //!
GetHeight()363     virtual uint32_t GetHeight() { return m_height; }
364 
GetHwInterface()365     CodechalHwInterface *GetHwInterface()
366     {
367         return m_hwInterface;
368     }
369 
370     //!
371     //! \brief  Help function to allocate a 1D linear buffer for each decode standard
372     //! \param  [in,out] resource
373     //!         Pointer to allocated buffer
374     //! \param  [in] size
375     //!         Buffer size
376     //! \param  [in] name
377     //!         Buffer name
378     //! \param  [in] initialize
379     //!         Initialization flag, by default is false
380     //! \param  [in] value
381     //!         Initialization value when intialize flag is true, by default is 0
382     //! \return MOS_STATUS
383     //!         MOS_STATUS_SUCCESS if success, else fail reason
384     //!
385     MOS_STATUS AllocateBuffer(
386         PMOS_RESOURCE resource,
387         uint32_t size,
388         const char* name,
389         bool initialize = false,
390         uint8_t value = 0,
391         bool bPersistent = false);
392 
393     //!
394     //! \brief    Help function to allocate a NV12 TILE_Y surface
395     //! \details  Help function to allocate a NV12 TILE_Y surface for each decode standard
396     //!
397     //! \param    [in,out] surface
398     //!           Pointer to allocated surface
399     //! \param    [in] width
400     //!           Surface width
401     //! \param    [in] height
402     //!           Surface height
403     //! \param    [in] name
404     //!           Surface name
405     //! \param    [in] format
406     //!           Surface format, by default is NV12
407     //! \param    [in] isCompressible
408     //!           Compressible flag, by default is false
409     MOS_STATUS AllocateSurface(
410         PMOS_SURFACE surface,
411         uint32_t width,
412         uint32_t height,
413         const char* name,
414         MOS_FORMAT format = Format_NV12,
415         bool isCompressible = false);
416 
417     MOS_STATUS DestroySurface(PMOS_SURFACE surface);
418 
419     //!
420     //! \brief  Entry to allocate and intialize the decode instance
421     //! \param  [in] codecHalSettings
422     //!         The settings to inialize the decode instance
423     //! \return MOS_STATUS
424     //!         MOS_STATUS_SUCCESS if success, else fail reason
425     //!
426     MOS_STATUS Allocate(CodechalSetting * codecHalSettings) override;
427 
428     //!
429     //! \brief  The handle at the end of each frame.
430     //! \return MOS_STATUS
431     //!         MOS_STATUS_SUCCESS if success, else fail reason
432     //!
433     MOS_STATUS EndFrame() override;
434 
435     //!
436     //! \brief  The entry to decode each frame.
437     //! \param  [in] params
438     //!         Pointer to decode parameters of this frame
439     //! \return MOS_STATUS
440     //!         MOS_STATUS_SUCCESS if success, else fail reason
441     //!
442     MOS_STATUS Execute(void *params) override;
443 
444     //!
445     //! \brief  Inserts the generic prologue command for a command buffer
446     //! \param  [in] cmdBuffer
447     //!         Command buffer
448     //! \param  [in] frameTrackingRequested
449     //!         frame Tracking Requested
450     //! \return MOS_STATUS
451     //!         MOS_STATUS_SUCCESS if success, else fail reason
452     //!
453     MOS_STATUS SendPrologWithFrameTracking(
454         PMOS_COMMAND_BUFFER cmdBuffer,
455         bool                frameTrackingRequested);
456 
457     //!
458     //! \brief  Inserts predication command for a command buffer
459     //! \param  [in] cmdBuffer
460     //!         Command buffer
461     //! \return MOS_STATUS
462     //!         MOS_STATUS_SUCCESS if success, else fail reason
463     //!
464     MOS_STATUS SendPredicationCommand(
465         PMOS_COMMAND_BUFFER cmdBuffer);
466 
467     //!
468     //! \brief  Inserts marker commands for a command buffer
469     //! \param  [in] cmdBuffer
470     //!         Command buffer
471     //! \param  [in] isRender
472     //!         Whether render engine workload or not
473     //! \return MOS_STATUS
474     //!         MOS_STATUS_SUCCESS if success, else fail reason
475     //!
476     MOS_STATUS SendMarkerCommand(
477         PMOS_COMMAND_BUFFER cmdBuffer,
478         bool isRender);
479 
480     //!
481     //! \brief  The entry to get status report.
482     //! \param  [out] status
483     //!         The point to decode status
484     //! \param  [in] numStatus
485     //!         The requested number of status reports
486     //! \return MOS_STATUS
487     //!         MOS_STATUS_SUCCESS if success, else fail reason
488     //!
489     MOS_STATUS GetStatusReport(
490         void        *status,
491         uint16_t    numStatus) override;
492 
493     //!
494     //! \brief  Reset status report for GEN specific decoder
495     //! \param  [in] nullHwInUse
496     //!         Indicates whether or not null hardware is inuse
497     //! \return MOS_STATUS
498     //!         MOS_STATUS_SUCCESS if success, else fail reason
499     //!
500     MOS_STATUS ResetStatusReport(
501         bool nullHwInUse);
502 
503     //!
504     //! \brief    Help function to copy resource
505     //! \details  Help function to copy resource via Huc stream out function.
506     //! \param    [out] cmdBuffer
507     //!           Pointer to command buffer
508     //! \param    [in] src
509     //!           Pointer to source resource
510     //! \param    [out] dst
511     //!           Pointer to destination resource
512     //! \param    [in] copyLength
513     //!           The copy length starts from source offset
514     //! \param    [in] copyInputOffset
515     //!           The copy offset relative to source offset, by default is 0.
516     //! \param    [in] copyOutputOffset
517     //!           The output offset relative to destination offset, by default is 0.
518     //! \return   MOS_STATUS
519     //!           MOS_STATUS_SUCCESS if success, else fail reason
520     //!
521     virtual MOS_STATUS HucCopy(
522         PMOS_COMMAND_BUFFER cmdBuffer,
523         PMOS_RESOURCE src,
524         PMOS_RESOURCE dst,
525         uint32_t copyLength,
526         uint32_t copyInputOffset = 0,
527         uint32_t copyOutputOffset = 0);
528 
529     //!
530     //! \brief  Gets the decode mode
531     //! \return The decode mode \see m_mode
532     //!
GetMode()533     uint32_t GetMode() { return m_mode; }
534 
535     //!
536     //! \brief  Get the perf profiler pointer
537     //! \return The perf profiler \see m_perfProfiler
538     //!
GetPerfProfiler()539     MediaPerfProfiler *GetPerfProfiler()
540     {
541         return m_perfProfiler;
542     }
543 
544     //!
545     //! \brief  Gets the decode standard
546     //! \return The decode standard \see m_standard
547     //!
GetStandard()548     uint32_t GetStandard() { return m_standard; }
549 
550     //!
551     //! \brief  Gets video context
552     //! \return The video context \see m_videoContext
553     //!
GetVideoContext()554     MOS_GPU_CONTEXT GetVideoContext() { return m_videoContext; }
555 
556     //!
557     //! \brief  Sets video context
558     //! \return The video context \see m_videoContext
559     //!
SetVideoContext(MOS_GPU_CONTEXT context)560     void SetVideoContext(MOS_GPU_CONTEXT context) { m_videoContext = context; }
561 
562     //!
563     //! \brief  Gets video WA context
564     //! \return The video WA context \see m_videoContextForWa
565     //!
GetVideoWAContext()566     MOS_GPU_CONTEXT GetVideoWAContext() { return m_videoContextForWa; }
567 
568     //!
569     //! \brief  Sets cenc decoder batch buffer
570     //! \param    [in] cmdBuffer
571     //!           Pointer of command buffer.
572     //! \return   MOS_STATUS
573     //!           MOS_STATUS_SUCCESS if success, else fail reason
574     //!
575     virtual MOS_STATUS SetCencBatchBuffer( PMOS_COMMAND_BUFFER cmdBuffer);
576 
577     //!
578     //! \brief  Indicates whether or not the status query reporting is enabled
579     //! \return If status query reporting is enabled \see m_statusQueryReportingEnabled
580     //!
IsStatusQueryReportingEnabled()581     bool IsStatusQueryReportingEnabled() { return m_statusQueryReportingEnabled; }
582 
583     //!
584     //! \brief  Gets decode status buffer
585     //! \return The decode status buffer \see m_decodeStatusBuf
586     //!
GetDecodeStatusBuf()587     CodechalDecodeStatusBuffer *GetDecodeStatusBuf() { return &m_decodeStatusBuf; }
588 
589     //!
590     //! \brief  Gets vdbox index
591     //! \return The vdbox index \see m_vdboxIndex
592     //!
GetVdboxIndex()593     MHW_VDBOX_NODE_IND  GetVdboxIndex() { return m_vdboxIndex; }
594 
595     //!
596     //! \brief  Indicates whether or not the first execute call
597     //! \return If first execute call \see m_executeCallIndex
598     //!
IsFirstExecuteCall()599     inline bool IsFirstExecuteCall() { return (m_executeCallIndex == 0); }
600 
601     //!
602     //! \brief  Indicates whether or not the decoder is inuse
603     //! \return If decoder is inuse \see m_isHybridDecoder
604     //!
IsHybridDecoder()605     bool IsHybridDecoder() { return m_isHybridDecoder; }
606 
607     //!
608     //! \brief  Indicates whether or not the picture is incomplete
609     //! \return If picture is incomplete \see m_incompletePicture
610     //!
IsIncompletePicture()611     bool IsIncompletePicture() { return m_incompletePicture; }
612 
613     //!
614     //! \brief  Indicates whether or not the jpeg scan is incomplete
615     //! \return If jpeg scan is incomplete \see m_incompleteJpegScan
616     //!
IsIncompleteJpegScan()617     virtual bool IsIncompleteJpegScan() { return false; }
618 
619     //!
620     //! \brief  Gets flags which indicates whether video context uses null hardware
621     //! \return Flags which indicates whether video context uses null hardware \see m_videoContextUsesNullHw
622     //!
GetVideoContextUsesNullHw()623     bool GetVideoContextUsesNullHw() { return m_videoContextUsesNullHw; }
624 
625     //!
626     //! \brief  Gets flags which indicates whether video context for using null hardware
627     //! \return Flags which indicates whether video context for using null hardware \see m_videoContextForWaUsesNullHw
628     //!
GetVideoContextForWaUsesNullHw()629     bool GetVideoContextForWaUsesNullHw() { return m_videoContextForWaUsesNullHw; }
630 
631     //!
632     //! \brief  Gets flags which indicates whether render context uses null hardware
633     //! \return Flags which indicates whether render context uses null hardware \see m_renderContextUsesNullHw
634     //!
GetRenderContextUsesNullHw()635     bool GetRenderContextUsesNullHw() { return m_renderContextUsesNullHw; }
636 
637     //!
638     //! \brief  Set decode histogram
639     //! \return No return
640     //!
SetDecodeHistogram(CodechalDecodeHistogram * decodeHistogram)641     void SetDecodeHistogram(CodechalDecodeHistogram *decodeHistogram) { m_decodeHistogram = decodeHistogram; }
642 
643     //!
644     //! \brief  Get decode histogram
645     //! \return Pointer of codechal decode histogram
646     //!
GetDecodeHistogram()647     CodechalDecodeHistogram* GetDecodeHistogram() { return m_decodeHistogram; }
648 
649 #ifdef _DECODE_PROCESSING_SUPPORTED
650     //!
651     //! \brief  Indicates whether or not the vd sfc is supported
652     //! \return If vd sfc is supported \see m_vdSfcSupported
653     //!
IsVdSfcSupported()654     bool IsVdSfcSupported() { return m_vdSfcSupported; }
655 
656     //!
657     //! \brief  Set if vd sfc supported
658     //! \return No return
659     //!
SetVdSfcSupportedFlag(bool isVdSfcSpported)660     void SetVdSfcSupportedFlag(bool isVdSfcSpported) { m_vdSfcSupported = isVdSfcSpported; }
661 
662     //! \brief Field scaling interface
663     FieldScalingInterface       *m_fieldScalingInterface = nullptr;
664 #endif
665 
666     //!
667     //! \brief  Get dummy reference surface
668     //! \return Pointer of reference surface
669     //!
GetDummyReference()670     MOS_SURFACE* GetDummyReference() { return &m_dummyReference; }
671 
672     //!
673     //! \brief  Get dummy reference status
674     //! \return CODECHAL_DUMMY_REFERENCE_STATUS
675     //!
GetDummyReferenceStatus()676     CODECHAL_DUMMY_REFERENCE_STATUS GetDummyReferenceStatus() { return m_dummyReferenceStatus; }
677 
678     //!
679     //! \brief  Set dummy reference status
680     //! \return void
681     //!
SetDummyReferenceStatus(CODECHAL_DUMMY_REFERENCE_STATUS status)682     void SetDummyReferenceStatus(CODECHAL_DUMMY_REFERENCE_STATUS status)
683     {
684         m_dummyReferenceStatus = status;
685     }
686 
687     //!
688     //! \brief  Get mmc enable flag
689     //! \return bool
690     //!
IsDecoderMmcEnabled()691     bool IsDecoderMmcEnabled(){return m_mmc ? m_mmc->IsMmcEnabled() : false;}
692 
693     MOS_STATUS CheckDecodeOutputBufSize(MOS_SURFACE &dstSurface);
694 
695 protected:
696 
697     //!
698     //! \brief  Set up params for gpu context creation
699     //! \return   MOS_STATUS
700     //!           MOS_STATUS_SUCCESS if success, else fail reason
701     //!
702     virtual MOS_STATUS SetGpuCtxCreatOption(CodechalSetting * settings);
703 
704     //!
705     //! \brief  Allocate and initialize GEN specific decoder standard
706     //! \param  [in] settings
707     //!         Pointer to CodechalSetting
708     //! \return MOS_STATUS
709     //!         MOS_STATUS_SUCCESS if success, else fail reason
710     //!
711     virtual MOS_STATUS AllocateStandard(CodechalSetting * settings)   = 0;
712 
713     //!
714     //! \brief  Set states for each frame to prepare for decode
715     //! \return MOS_STATUS
716     //!         MOS_STATUS_SUCCESS if success, else fail reason
717     //!
718     virtual MOS_STATUS SetFrameStates()     = 0;
719 
720     //!
721     //! \brief  State level function for standard specific decoder
722     //! \return MOS_STATUS
723     //!         MOS_STATUS_SUCCESS if success, else fail reason
724     //!
725     virtual MOS_STATUS DecodeStateLevel()     = 0;
726 
727     //!
728     //! \brief  Primitive level function for GEN specific decoder
729     //! \return MOS_STATUS
730     //!         MOS_STATUS_SUCCESS if success, else fail reason
731     //!
732     virtual MOS_STATUS DecodePrimitiveLevel() = 0;
733 
734     //!
735     //! \brief  Calculate downsample param for GEN specific decoder
736     //! \param  [in] picParams
737     //!         Pointer to picture parameter
738     //! \param  [in] refSurfWidth
739     //!         Reference surface width
740     //! \param  [in] refSurfHeight
741     //!         Reference surface height
742     //! \param  [in] format
743     //!         Pointer to MOS_FORMAT
744     //! \param  [in] frameIdx
745     //!         Frame index
746     //!
747     //! \return MOS_STATUS
748     //!         MOS_STATUS_SUCCESS if success, else fail reason
749     //!
CalcDownsamplingParams(void * picParams,uint32_t * refSurfWidth,uint32_t * refSurfHeight,MOS_FORMAT * format,uint8_t * frameIdx)750     virtual MOS_STATUS CalcDownsamplingParams(
751         void *picParams,
752         uint32_t *refSurfWidth,
753         uint32_t *refSurfHeight,
754         MOS_FORMAT *format,
755         uint8_t *frameIdx)
756     {
757         CODECHAL_DECODE_ASSERTMESSAGE("Unsupported Downsampling for current Codec !");
758         return MOS_STATUS_UNIMPLEMENTED;
759     }
760 
761     //!
762     //! \brief  Get decoder status for GEN specific hybird decoder
763     //! \param  [in] decodeStatus
764     //!         Decode status
765     //! \param  [in] index
766     //!         Index of status buffer
767     //! \param  [in] defaultStatus
768     //!         Default status
769     //!
770     //! \return MOS_STATUS
771     //!         MOS_STATUS_SUCCESS if success, else fail reason
772     //!
DecodeGetHybridStatus(CodechalDecodeStatus * decodeStatus,uint32_t index,uint32_t defaultStatus)773     virtual MOS_STATUS DecodeGetHybridStatus(
774         CodechalDecodeStatus *decodeStatus,
775         uint32_t index,
776         uint32_t defaultStatus)
777     {
778         return MOS_STATUS_SUCCESS;
779     }
780 
781     //!
782     //! \brief  Start status report for GEN specific decoder
783     //! \param  [out] cmdBuffer
784     //!         Pointer to command buffer
785     //! \return MOS_STATUS
786     //!         MOS_STATUS_SUCCESS if success, else fail reason
787     //!
788     MOS_STATUS StartStatusReport(PMOS_COMMAND_BUFFER cmdBuffer);
789 
790     //!
791     //! \brief  End status report for GEN specific decoder
792     //! \param  [in] decodeStatusReport
793     //!         Decode status
794     //! \param  [out] cmdBuffer
795     //!         Pointer to command buffer
796     //! \return MOS_STATUS
797     //!         MOS_STATUS_SUCCESS if success, else fail reason
798     //!
799     virtual MOS_STATUS EndStatusReport(
800         CodechalDecodeStatusReport &decodeStatusReport,
801         PMOS_COMMAND_BUFFER cmdBuffer);
802 
803     //!
804     //! \brief  Initialize MMC state for specified decode device
805     //!
806     //! \return MOS_STATUS
807     //!         MOS_STATUS_SUCCESS if success, else fail reason
808     //!
InitMmcState()809     virtual MOS_STATUS InitMmcState()
810     {
811         return MOS_STATUS_SUCCESS;
812     }
813 
814     //!
815     //! \brief  Linear to Y tiled address
816     //!
817     //! \param  [in] x
818     //!         Position of X
819     //! \param  [in] y
820     //!         Position of Y
821     //! \param  [in] pitch
822     //!         Pitch
823     //! \return uint32_t
824     //!         Return 0 if success, else -1 if fail
825     //!
826     uint32_t LinearToYTiledAddress(
827         uint32_t x,
828         uint32_t y,
829         uint32_t pitch);
830 
831 #if USE_CODECHAL_DEBUG_TOOL
832     MOS_STATUS DumpProcessingParams(
833         DecodeProcessingParams *decProcParams);
834 
835 #endif
836 
837 private:
838 
839     //!
840     //! \brief    Calculate command buffer size needed for picture level and slice level commands
841     //! \param    [out] requestedSize
842     //!           Return command buffer size for picture level and slice level command
843     //! \param    [out] additionalSizeNeeded
844     //!           Return additianl size needed
845     //! \param    [out] requestedPatchListSize
846     //!           return patch list size used in this command buffer
847     //! \return   None
848     //!
849     virtual void CalcRequestedSpace(
850         uint32_t       &requestedSize,
851         uint32_t       &additionalSizeNeeded,
852         uint32_t       &requestedPatchListSize);
853 
854     //!
855     //! \brief  Verify command buffer size and patch list size, reallocate if required
856     //! \return MOS_STATUS
857     //!         MOS_STATUS_SUCCESS if success, else fail reason
858     //!
859     MOS_STATUS VerifySpaceAvailable ();
860 
861     //!
862     //! \brief  Create GPU context for GEN specific decoder
863     //! \param  [in] codecHalSettings
864     //!         Pointer to CODECHAL Settings
865     //! \return MOS_STATUS
866     //!         MOS_STATUS_SUCCESS if success, else fail reason
867     //!
868     MOS_STATUS CreateGpuContexts(
869         CodechalSetting * codecHalSettings);
870 
871     //!
872     //! \brief  Indicates whether or not the SFC is inuse
873     //! \param  [in] codecHalSettings
874     //!         Pointer to CODECHAL Settings
875     //! \return If SFC is inuse
876     //!
IsSfcInUse(CodechalSetting * codecHalSettings)877     virtual bool IsSfcInUse(CodechalSetting * codecHalSettings) { return false; }
878 
879     //!
880     //! \brief  Indicates whether or not the frame level multiple thread is enable
881     //! \return If frame level multiple thread is enable
882     //!
IsFrameMTEnabled()883     virtual bool IsFrameMTEnabled() { return false; }
884 
885     //!
886     //! \brief  The virtual function for decode standard to override the requested space size
887     //! \param  [in] requestedSize
888     //!         The intial request size computed by picture level and slice level
889     //! \return The final requested space size
890     //!
RequestedSpaceSize(uint32_t requestedSize)891     virtual uint32_t RequestedSpaceSize(uint32_t requestedSize) { return requestedSize; }
892 
893     //!
894     //! \brief  The virtual function for decode standard to override the extra requested space size
895     //! \param  [in] requestedSize
896     //!         The intial request size computed by picture level and slice level
897     //! \param  [in] additionalSizeNeeded
898     //!         The additional request size for command buffer
899     //! \return The extra requested space size
900     //!
VerifyExtraSpace(uint32_t requestedSize,uint32_t additionalSizeNeeded)901     virtual MOS_STATUS VerifyExtraSpace(
902         uint32_t requestedSize,
903         uint32_t additionalSizeNeeded)
904     {
905         return MOS_STATUS_SUCCESS;
906     }
907 
908     //!
909     //! \brief    Allocate reference surfaces
910     //! \details  Allocate reference surfaces for decode downsampling for all codec types
911     //! \param    allocWidth
912     //!           [in] Width of the surfaces to be allocated
913     //! \param    allocHeight
914     //!           [in] Height of the surfaces to be allocated
915     //! \param    format
916     //!           [in] Flag to indicate the format of the surfaces to be allocated
917     //! \return   MOS_STATUS
918     //!           MOS_STATUS_SUCCESS if success, else fail reason
919     //!
920     MOS_STATUS AllocateRefSurfaces(
921         uint32_t allocWidth,
922         uint32_t allocHeight,
923         MOS_FORMAT format);
924 
925     bool isSyncFreeNeededForMMCSurface(PMOS_SURFACE surface);
926     //!
927     //! \brief    Resize specific reference surfaces
928     //! \details  Resize specific reference surfaces for decode downsampling for all codec types
929     //! \param    frameIdx
930     //!           [in] index of surfaces array
931     //! \param    width
932     //!           [in] Width of the surfaces to be allocated
933     //! \param    height
934     //!           [in] Height of the surfaces to be allocated
935     //! \param    format
936     //!           [in] Flag to indicate the format of the surfaces to be allocated
937     //! \return   MOS_STATUS
938     //!           MOS_STATUS_SUCCESS if success, else fail reason
939     //!
940    MOS_STATUS RefSurfacesResize(
941         uint32_t     frameIdx,
942         uint32_t     width,
943         uint32_t     height,
944         MOS_FORMAT   format);
945 
946    //!
947    //! \brief    Allocate Decode Output Buffer
948    //! \details  To Allocate Decode Output Buffer for media debug hook.
949    //! \param    dstSurface
950    //!           Decoded dstSurface
951    //! \return   MOS_STATUS
952    //!           MOS_STATUS_SUCCESS if success, else fail reason
953    //!
954    MOS_STATUS AllocateDecodeOutputBuf();
955 
956     //!
957     //! \brief    Deallocate specific reference surfaces
958     //! \details  Deallocate specific reference surfaces for decode downsampling for all codec types
959     //! \param    frameIdx
960     //!           [in] index of surfaces array
961     //! \return   N/A
962     //!
963     void DeallocateSpecificRefSurfaces(uint32_t frameIdx);
964     //!
965     //! \brief    Deallocate reference surfaces
966     //! \details  Deallocate reference surfaces for decode downsampling for all codec types
967     //! \return   N/A
968     //!
969     void DeallocateRefSurfaces();
970 
971     //!
972     //! \brief    Set dummy reference
973     //! \details  Set dummy reference for error concealment
974     //! \return   MOS_STATUS
975     //!           MOS_STATUS_SUCCESS if success, else fail reason
976     //!
977     MOS_STATUS SetDummyReference();
978 
979 protected:
980     //! \brief Mfx Interface
981     MhwVdboxMfxInterface        *m_mfxInterface     = nullptr;
982     //! \brief Hcp Interface
983     MhwVdboxHcpInterface        *m_hcpInterface     = nullptr;
984     //! \brief Huc Interface
985     MhwVdboxHucInterface        *m_hucInterface     = nullptr;
986     //! \brief Vdenc Interface
987     MhwVdboxVdencInterface      *m_vdencInterface   = nullptr;
988     //! \brief Common Mi Interface
989     MhwMiInterface              *m_miInterface      = nullptr;
990     //! \brief Cp Interface
991     MhwCpInterface              *m_cpInterface      = nullptr;
992 
993     //! \brief Security Decode
994     CodechalSecureDecodeInterface *m_secureDecoder    = nullptr;
995 
996     //! \brief WA table
997     MEDIA_WA_TABLE              *m_waTable           = nullptr;
998     //! \brief SKU table
999     MEDIA_FEATURE_TABLE         *m_skuTable          = nullptr;
1000 
1001     //!< mmc state
1002     CodecHalMmcState            *m_mmc              = nullptr;
1003     //! \brief Decode parameters
1004     CodechalDecodeParams        m_decodeParams;
1005     //! \brief Decode mode
1006     uint32_t                    m_mode              = CODECHAL_UNSUPPORTED_MODE;
1007     //! \brief Decode standard
1008     uint32_t                    m_standard          = CODECHAL_UNDEFINED;
1009     //! \brief Current frame number
1010     uint32_t                    m_frameNum          = 0;
1011     //! \brief Indicates if current field is second field
1012     bool                        m_secondField       = false;
1013     //! \brief Indidates if fields are completed
1014     uint32_t                    m_fullFieldsFrame     = 0;
1015     //! \brief picture information of current render target
1016     CODEC_PICTURE               m_crrPic            = {0};
1017     //! \brief Video GPU node inuse
1018     MOS_GPU_NODE                m_videoGpuNode      = MOS_GPU_NODE_MAX;
1019     //! \brief Video context inuse
1020     MOS_GPU_CONTEXT             m_videoContext      = MOS_GPU_CONTEXT_INVALID_HANDLE;
1021     //! \brief Video WA context inuse
1022     MOS_GPU_CONTEXT             m_videoContextForWa = MOS_GPU_CONTEXT_INVALID_HANDLE;
1023     //! \brief Render context inuse
1024     MOS_GPU_CONTEXT             m_renderContext     = MOS_GPU_CONTEXT_RENDER;
1025     //! \brief Picture Width
1026     uint32_t                    m_width             = 0;
1027     //! \brief Picture Height
1028     uint32_t                    m_height            = 0;
1029 
1030     //! \brief Picture level command buffer size is required
1031     uint32_t                    m_commandBufferSizeNeeded = 0;
1032     //! \brief Picture level patch list size is required
1033     uint32_t                    m_commandPatchListSizeNeeded = 0;
1034     //! \brief Slice level command buffer size is required
1035     uint32_t                    m_standardDecodeSizeNeeded = 0;
1036     //! \brief Slice level patch list size is required
1037     uint32_t                    m_standardDecodePatchListSizeNeeded = 0;
1038     //! \brief Indicates if current input bitstream is incomplete
1039     bool                        m_incompletePicture = false;
1040     //! \brief The index of execution call in multiple execution call mode
1041     bool                        m_executeCallIndex  = 0;
1042     //! \brief Indicates if current is frist execution call in multiple execution call mode
1043     bool                        m_consecutiveMbErrorConcealmentInUse = false;
1044     //! \brief Indicates if phantom MBs is required for MPEG2 decode
1045     bool                        m_decodePhantomMbs  = false;
1046 
1047     //! \brief Flag to indicate if we support eStatus query reporting on current platform
1048     bool                        m_statusQueryReportingEnabled = false;
1049     //! \brief Flag to indicate if UMD Perf Profiler FE BE timing measurement is enabled
1050     bool                        m_perfFEBETimingEnabled = false;
1051 
1052 #ifdef _DECODE_PROCESSING_SUPPORTED
1053     //! \brief Flag to indicate if vd sfc is supported
1054     bool                        m_vdSfcSupported = false;
1055 #endif
1056 
1057     //! \brief Stores all the status_query related data
1058     CodechalDecodeStatusBuffer  m_decodeStatusBuf;
1059     //! \brief The feedback number reported by app in picparams call
1060     uint32_t                    m_statusReportFeedbackNumber = 0;
1061     //! \brief Flag to indicate if report frame CRC
1062     bool                        m_reportFrameCrc = false;
1063 
1064     //! \brief Indicates if stream out enabled
1065     bool                        m_streamOutEnabled  = false;
1066     //! \brief Stream out buffers
1067     MOS_RESOURCE                m_streamOutBuffer[CODECHAL_DECODE_NUM_STREAM_OUT_BUFFERS] = {{0}};
1068     //! \brief Indicates if stream out buffer is inuse with same index
1069     uint32_t                    m_streamOutCurrStatusIdx[CODECHAL_DECODE_NUM_STREAM_OUT_BUFFERS] = {CODECHAL_DECODE_STATUS_NUM};
1070     //! \brief Current stream out buffer index
1071     uint32_t                    m_streamOutCurrBufIdx = 0;
1072 
1073     //! \brief Performance testing parameters
1074     uint16_t                    m_perfType          = 0;
1075 
1076     //! \brief Indicates if video context uses null hardware
1077     bool                        m_videoContextUsesNullHw = false;
1078     //! \brief Indicates if video WA context uses null hardware
1079     bool                        m_videoContextForWaUsesNullHw = false;
1080     //! \brief Indicates if render context uses null hardware
1081     bool                        m_renderContextUsesNullHw = false;
1082 
1083     //! \brief Indicates if decode sync lock is disabled
1084     bool                        m_disableDecodeSyncLock = false;
1085     //! \brief Indicates if transcoe lock is disabled
1086     bool                        m_disableLockForTranscode = false;
1087 
1088     //! \brief Indicate how many passes is needed to finish decoding a picture
1089     //! \details Initialize decode pass number to 1, for those decoder need more than 1 decoding pass,
1090     //!          modify this value in specific decoder files.
1091     uint16_t                     m_decodePassNum     = 1;
1092 
1093     //! \brief MMIO Hcp Frame CRC report offset
1094     uint32_t                    m_hcpFrameCrcRegOffset = 0;
1095 
1096     //! \brief The vdbox index for current frame
1097     MHW_VDBOX_NODE_IND          m_vdboxIndex = MHW_VDBOX_NODE_1;
1098     //! \brief Indicates if HCP is inuse
1099     bool                        m_hcpInUse          = false;
1100 
1101     //! \brief Indicates if decoder is inuse
1102     bool                        m_isHybridDecoder   = false;
1103 
1104     //! \brief Indicates if downsampling is required
1105     bool                        m_downsamplingHinted = false;
1106     //! \brief Reference surface for downsampling
1107     PMOS_SURFACE                m_refSurfaces       = nullptr;
1108     //! \brief Number of reference surface for downsampling
1109     uint32_t                    m_refFrmCnt         = 0;
1110 
1111     //! \brief Internal buffer for predication
1112     MOS_RESOURCE               m_predicationBuffer = { 0 };
1113 
1114     MOS_RESOURCE               m_frameCountTypeBuf = { 0 };
1115 
1116     MOS_RESOURCE               m_crcBuf = { 0 };
1117 
1118     CodechalOcaDumper          *m_pCodechalOcaDumper = nullptr;
1119 
1120 #if (_DEBUG || _RELEASE_INTERNAL)
1121     //! \brief Downsampled surfaces
1122     PMOS_SURFACE                m_downsampledSurfaces = nullptr;
1123 #endif
1124     uint8_t*                    m_decodeOutputBuf = nullptr;
1125 
1126     uint32_t                    m_decodeOutputBufSize = 0;
1127     //! \brief    Decode histogram interface
1128     //! \details  Support YUV Luma histogram.
1129     CodechalDecodeHistogram    *m_decodeHistogram = nullptr;
1130     PMOS_GPUCTX_CREATOPTIONS   m_gpuCtxCreatOpt = nullptr;
1131 
1132     //! \brief Performance data profiler
1133     MediaPerfProfiler           *m_perfProfiler    = nullptr;
1134 
1135     // CencDecode buffer
1136     CencDecodeShareBuf          *m_cencBuf    = nullptr;
1137 
1138     //! \brief Dummy reference surface
1139     MOS_SURFACE                 m_dummyReference;
1140 
1141     //! \brief Indicate the status of dummy reference
1142     CODECHAL_DUMMY_REFERENCE_STATUS m_dummyReferenceStatus = CODECHAL_DUMMY_REFERENCE_INVALID;
1143 
1144     CodechalHwInterface* m_hwInterface = nullptr;
1145 };
1146 
1147 #endif  // __CODECHAL_DECODER_H__
1148