xref: /aosp_15_r20/external/intel-media-driver/media_driver/linux/common/codec/ddi/media_ddi_decode_hevc.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2015-2017, 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      media_ddi_decode_hevc.h
24 //! \brief     libva(and its extension) decoder implementation
25 //!
26 //!
27 //! \file     media_ddi_decode_hevc.h
28 //! \brief    Defines DdiDecodeHEVC class for HEVC decode
29 //!
30 
31 #ifndef __MEDIA_DDI_DECODER_HEVC_H__
32 #define __MEDIA_DDI_DECODER_HEVC_H__
33 
34 #include <va/va.h>
35 #include "media_ddi_decode_base.h"
36 
37 //!
38 //! \class  DdiDecodeHEVC
39 //! \brief  Ddi decode HEVC
40 //!
41 class DdiDecodeHEVC : public DdiMediaDecode
42 {
43 public:
44     //!
45     //! \brief Constructor
46     //!
DdiDecodeHEVC(DDI_DECODE_CONFIG_ATTR * ddiDecodeAttr)47     DdiDecodeHEVC(DDI_DECODE_CONFIG_ATTR *ddiDecodeAttr) : DdiMediaDecode(ddiDecodeAttr){};
48 
49     //!
50     //! \brief Destructor
51     //!
~DdiDecodeHEVC()52     virtual ~DdiDecodeHEVC(){};
53 
54     // inherited virtual functions
55     virtual void DestroyContext(
56         VADriverContextP ctx) override;
57 
58     virtual VAStatus RenderPicture(
59         VADriverContextP ctx,
60         VAContextID      context,
61         VABufferID       *buffers,
62         int32_t          numBuffers) override;
63 
64     virtual MOS_FORMAT GetFormat() override;
65 
66     virtual VAStatus SetDecodeParams() override;
67 
68     virtual void ContextInit(
69         int32_t picWidth,
70         int32_t picHeight) override;
71 
72     virtual VAStatus CodecHalInit(
73         DDI_MEDIA_CONTEXT *mediaCtx,
74         void              *ptr) override;
75 
76     virtual VAStatus AllocSliceControlBuffer(
77         DDI_MEDIA_BUFFER       *buf) override;
78 
79     virtual uint8_t* GetPicParamBuf(
80     DDI_CODEC_COM_BUFFER_MGR      *bufMgr) 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     virtual 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     virtual 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     virtual 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     virtual VAStatus InitResourceBuffer();
148 
149     //! \brief   Free Resource buffer for HEVC
150     //!
151     virtual 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 #endif /* _MEDIA_DDI_DECODE_HEVC_H */
184