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