xref: /aosp_15_r20/external/intel-media-driver/media_driver/linux/common/codec/ddi/media_ddi_decode_vc1.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_vc1.h
24 //! \brief     libva(and its extension) decoder implementation
25 //!
26 
27 #ifndef __MEDIA_DDI_DECODER_VC1_H__
28 #define __MEDIA_DDI_DECODER_VC1_H__
29 
30 #include <va/va.h>
31 #include "media_ddi_decode_base.h"
32 
33 struct _DDI_MEDIA_BUFFER;
34 
35 //!
36 //! \class  DdiDecodeVC1
37 //! \brief  Ddi decode VC1
38 //!
39 class DdiDecodeVC1 : public DdiMediaDecode
40 {
41 public:
42     //!
43     //! \brief Constructor
44     //!
DdiDecodeVC1(DDI_DECODE_CONFIG_ATTR * ddiDecodeAttr)45     DdiDecodeVC1(DDI_DECODE_CONFIG_ATTR *ddiDecodeAttr) : DdiMediaDecode(ddiDecodeAttr){};
46 
47     //!
48     //! \brief Destructor
49     //!
~DdiDecodeVC1()50     virtual ~DdiDecodeVC1(){};
51 
52     // inherited virtual functions
53     virtual VAStatus BeginPicture(
54         VADriverContextP ctx,
55         VAContextID      context,
56         VASurfaceID      renderTarget) override;
57 
58     virtual void DestroyContext(
59         VADriverContextP ctx) override;
60 
61     virtual VAStatus RenderPicture(
62         VADriverContextP ctx,
63         VAContextID      context,
64         VABufferID       *buffers,
65         int32_t          num_buffers) override;
66 
67     virtual VAStatus SetDecodeParams() override;
68 
69     virtual void ContextInit(
70         int32_t picWidth,
71         int32_t picHeight) override;
72 
73     virtual VAStatus CodecHalInit(
74         DDI_MEDIA_CONTEXT *mediaCtx,
75         void              *ptr) override;
76 
77     virtual VAStatus AllocSliceControlBuffer(
78         DDI_MEDIA_BUFFER       *buf) override;
79 
80     virtual uint8_t* GetPicParamBuf(
81      DDI_CODEC_COM_BUFFER_MGR    *bufMgr) override;
82 private:
83     //!
84     //! \brief   ParaSliceParam for VC1
85     //! \details parse the sliceParam info required by VC1 decoding for
86     //!          each slice
87     //!
88     //! \param   [in] *mediaCtx
89     //!          DDI_MEDIA_CONTEXT
90     //! \param   [in] *slcParam
91     //!          VASliceParameterBufferVC1
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         VASliceParameterBufferVC1  *slcParam,
100         uint32_t                    numSlices);
101 
102     //! \brief   ParsePicParam for VC1
103     //! \details parse the PicParam info required by VC1 decoding
104     //!
105     //! \param   [in] *mediaCtx
106     //!          DDI_MEDIA_CONTEXT
107     //! \param   [in] *picParam
108     //!          VAPictureParameterBufferVC1
109     //!
110     //! \return  VA_STATUS_SUCCESS is returned if it is parsed successfully.
111     //!          else fail reason
112     VAStatus ParsePicParams(
113         DDI_MEDIA_CONTEXT           *mediaCtx,
114         VAPictureParameterBufferVC1 *picParam);
115 
116     //! \brief   Alloc SliceParam content for VC1
117     //! \details Alloc/resize SlicePram content for VC1 decoding
118     //!
119     //! \param   [in] numSlices
120     //!          uint32_t the required number of slices
121     //!
122     //! \return  VA_STATUS_SUCCESS is returned if it is parsed successfully.
123     //!          else fail reason
124     VAStatus AllocSliceParamContext(
125         uint32_t numSlices);
126 
127     //! \brief   Init Resource buffer for VC1
128     //! \details Initialize and allocate the Resource buffer for VC1
129     //!
130     //! \return  VA_STATUS_SUCCESS is returned if it is parsed successfully.
131     //!          else fail reason
132     VAStatus InitResourceBuffer(DDI_MEDIA_CONTEXT *mediaCtx);
133 
134     //! \brief   Free Resource buffer for VC1
135     //!
136     void FreeResourceBuffer();
137 
138     //! \brief   Calculate the Quant Param from PicParam for VC1
139     //! \details calculate and analyze the Quant Param from PicParam.
140     //!          The Quant config/EdgeMask are calculated.
141     //!
142     //! \param   [in] *picParam
143     //!          VAPictureParameterBufferVC1
144     //!
145     //! \param   [in] *altPquantConfig
146     //!          uint32_t
147     //!
148     //! \param   [in] *altPquantEdgeMask
149     //!          uint32_t
150     void CalculateQuantParams(
151         VAPictureParameterBufferVC1 *picParam,
152         uint32_t                    *altPquantConfig,
153         uint32_t                    *altPquantEdgeMask);
154 
155     //! \brief   Allocate the required BitPlane buffer
156     VAStatus AllocBitPlaneBuffer();
157 
158     //! \brief   Parse BitPlane parameter for VC1
159     //! \details Parse and Config the BitPlane buffer from the Input
160     //!
161     //! \param   [in] *bitPlaneBuffObject
162     //!          struct _DDI_MEDIA_BUFFER
163     //!          This is the destinatin buffer of Bitplane
164     //!
165     //! \param   [in] *buf
166     //!          uint32_t
167     //!
168     void ParseBitPlane(
169         struct _DDI_MEDIA_BUFFER *bitPlaneBuffObject,
170         uint8_t                  *buf);
171 
172     //! \brief  the flag of OLPNeeded
173     bool m_olpNeeded = false;
174 
175     //! \brief the Deblock Pic Idx for VC1
176     uint32_t m_deblockPicIdx = 0xffffffff;
177 
178     //! \brief the current Pic Idx for VC1
179     uint32_t m_currPicIdx = 0xffffffff;
180     MOS_SURFACE m_deblockSurface;
181 };
182 
183 #endif /* _MEDIA_DDI_DECODER_VC1_H */
184 
185