• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2022-2023, 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      ddi_decode_hevc_specific.h
24 //! \brief     HEVC class definition for DDI media decoder
25 //!
26 
27 #ifndef __DDI_DECODE_HEVC_SPECIFIC_H__
28 #define __DDI_DECODE_HEVC_SPECIFIC_H__
29 
30 #include "ddi_decode_base_specific.h"
31 
32 namespace decode
33 {
34 
35 //!
36 //! \class  DdiDecodeHevc
37 //! \brief  DDI Decode HEVC
38 //!
39 class DdiDecodeHevc : public DdiDecodeBase
40 {
41 public:
42     //!
43     //! \brief Constructor
44     //!
DdiDecodeHevc()45     DdiDecodeHevc() : DdiDecodeBase() {};
46 
47     //!
48     //! \brief Destructor
49     //!
~DdiDecodeHevc()50     virtual ~DdiDecodeHevc(){};
51 
52     // inherited virtual functions
53     virtual void DestroyContext(
54         VADriverContextP ctx) override;
55 
56     virtual VAStatus RenderPicture(
57         VADriverContextP ctx,
58         VAContextID      context,
59         VABufferID       *buffers,
60         int32_t          numBuffers) override;
61 
62     virtual MOS_FORMAT GetFormat() override;
63 
64     virtual VAStatus SetDecodeParams() override;
65 
66     virtual void ContextInit(
67         int32_t picWidth,
68         int32_t picHeight) override;
69 
70     virtual VAStatus CodecHalInit(
71         DDI_MEDIA_CONTEXT *mediaCtx,
72         void              *ptr) override;
73 
74     virtual VAStatus AllocSliceControlBuffer(
75         DDI_MEDIA_BUFFER  *buf) override;
76 
77     virtual uint8_t* GetPicParamBuf(
78         DDI_CODEC_COM_BUFFER_MGR *bufMgr) override;
79 
80     virtual bool IsRextProfile() override;
81 
82 protected:
83     //!
84     //! \brief   ParaSliceParam for HEVC
85     //! \details parse the sliceParam info required by HEVC decoding for
86     //!          each slice
87     //!
88     //! \param   [in] *mediaCtx
89     //!          DDI_MEDIA_CONTEXT
90     //! \param   [in] *slcParam
91     //!          VASliceParameterBufferHEVC
92     //! \param   [in] numSlices
93     //!             uint32_t
94     //!
95     //! \return  VA_STATUS_SUCCESS is returned if it is parsed successfully
96     //!          else fail reason
97     VAStatus ParseSliceParams(
98         DDI_MEDIA_CONTEXT          *mediaCtx,
99         VASliceParameterBufferHEVC *slcParam,
100         uint32_t                   numSlices);
101 
102     //!
103     //! \brief   ParseIQMatrixParam for HEVC
104     //! \details parse the QMatrix info required by HEVC decoding
105     //!
106     //! \param   [in] *mediaCtx
107     //!          DDI_MEDIA_CONTEXT
108     //! \param   [in] *qMatrix
109     //!          VAIQMatrixBufferHEVC
110     //!
111     //! \return  VA_STATUS_SUCCESS is returned if it is parsed successfully.
112     //!          else fail reason
113     VAStatus ParseIQMatrix(
114         DDI_MEDIA_CONTEXT    *mediaCtx,
115         VAIQMatrixBufferHEVC *matrix);
116 
117     //! \brief   ParsePicParam for HEVC
118     //! \details parse the PicParam info required by HEVC decoding
119     //!
120     //! \param   [in] *mediaCtx
121     //!          DDI_MEDIA_CONTEXT
122     //! \param   [in] *qMatrix
123     //!          VAIQMatrixBufferH264
124     //!
125     //! \return  VA_STATUS_SUCCESS is returned if it is parsed successfully
126     //!          else fail reason
127     VAStatus ParsePicParams(
128         DDI_MEDIA_CONTEXT            *mediaCtx,
129         VAPictureParameterBufferHEVC *picParam);
130 
131     //! \brief   Alloc SliceParam content for HEVC
132     //! \details Alloc/resize SlicePram content for HEVC decoding
133     //!
134     //! \param   [in] numSlices
135     //!          uint32_t the required number of slices
136     //!
137     //! \return  VA_STATUS_SUCCESS is returned if it is parsed successfully
138     //!          else fail reason
139     VAStatus AllocSliceParamContext(
140         uint32_t numSlices);
141 
142     //! \brief   Init Resource buffer for HEVC
143     //! \details Initialize and allocate the Resource buffer for HEVC
144     //!
145     //! \return  VA_STATUS_SUCCESS is returned if it is parsed successfully
146     //!          else fail reason
147     VAStatus InitResourceBuffer();
148 
149     //! \brief   Free Resource buffer for HEVC
150     //!
151     void FreeResourceBuffer();
152 
153     //!
154     //! \brief    Setup Codec Picture for Hevc
155     //!
156     //! \param    [in] mediaCtx
157     //!           Pointer to DDI_MEDIA_CONTEXT
158     //! \param    [in] rtTbl
159     //!           Pointer to DDI_CODEC_RENDER_TARGET_TABLE
160     //! \param    [in] vaPic
161     //!           HEVC VAPicture structure
162     //! \param    [in] fieldPicFlag
163     //!           Field picture flag
164     //! \param    [in] bottomFieldFlag
165     //!           Bottom field flag
166     //! \param    [in] picReference
167     //!           Reference picture flag
168     //! \param    [out] codecHalPic
169     //!           Pointer to CODEC_PICTURE
170     //!
171     //! \return   void
172     //!
173     void SetupCodecPicture(
174     DDI_MEDIA_CONTEXT             *mediaCtx,
175     DDI_CODEC_RENDER_TARGET_TABLE *rtTbl,
176     CODEC_PICTURE                 *codecHalPic,
177     VAPictureHEVC                 vaPic,
178     bool                          fieldPicFlag,
179     bool                          bottomFieldFlag,
180     bool                          picReference);
181 
182     //!
183     //! \brief    If it is hevc scc profile
184     //!
185     //! \return   true or false
186     //!
187     bool IsSccProfile();
188 
189 MEDIA_CLASS_DEFINE_END(decode__DdiDecodeHevc)
190 };
191 
192 } // namespace decode
193 #endif /* __DDI_DECODER_HEVC_SPECIFIC_H__ */
194