xref: /aosp_15_r20/external/intel-media-driver/media_driver/linux/gen11/ddi/media_libva_caps_g11.h (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2017-2018, 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_libva_caps_g11.h
24 //! \brief    This file defines the C++ class/interface for gen11 media capbilities.
25 //!
26 
27 #ifndef __MEDIA_LIBVA_CAPS_G11_H__
28 #define __MEDIA_LIBVA_CAPS_G11_H__
29 
30 #include "media_libva_caps.h"
31 
32 //!
33 //! \class  MediaLibvaCapsG11
34 //! \brief  Media libva caps Gen11
35 //!
36 class MediaLibvaCapsG11 : public MediaLibvaCaps
37 {
38 public:
39     //!
40     //! \brief    Constructor
41     //!
MediaLibvaCapsG11(DDI_MEDIA_CONTEXT * mediaCtx)42     MediaLibvaCapsG11(DDI_MEDIA_CONTEXT *mediaCtx) : MediaLibvaCaps(mediaCtx)
43     {
44         // ICL supported Encode format
45         static struct EncodeFormatTable encodeFormatTableICL[] =
46         {
47             {AVC, DualPipe, VA_RT_FORMAT_YUV420},
48             {AVC, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_RGB32},
49             {HEVC, DualPipe, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP | VA_RT_FORMAT_YUV422 | VA_RT_FORMAT_YUV422_10},
50             {HEVC, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV444_10 | VA_RT_FORMAT_RGB32 | VA_RT_FORMAT_RGB32_10BPP},
51             {VP9, Vdenc, VA_RT_FORMAT_YUV420 | VA_RT_FORMAT_YUV420_10BPP | VA_RT_FORMAT_YUV444 | VA_RT_FORMAT_YUV444_10 | VA_RT_FORMAT_RGB32 | VA_RT_FORMAT_RGB32_10BPP},
52         };
53         m_encodeFormatTable = (struct EncodeFormatTable*)(&encodeFormatTableICL[0]);
54         m_encodeFormatCount = sizeof(encodeFormatTableICL)/sizeof(struct EncodeFormatTable);
55 
56         return;
57     }
58 
59     //!
Init()60     virtual VAStatus Init() override
61     {
62         return LoadProfileEntrypoints();
63     }
64 
65     virtual VAStatus QueryImageFormats(VAImageFormat *formatList, int32_t *num_formats) override;
66 
67     virtual uint32_t GetImageFormatsMaxNum() override;
68 
69     virtual bool IsImageSupported(uint32_t fourcc) override;
70 
71     //!
72     //! \brief    Populate the color masks info
73     //!
74     //! \param    [in,out] Image format
75     //!           Pointer to a VAImageFormat array. Color masks information will be populated to this
76     //!           structure.
77     //!
78     //! \return   VAStatus
79     //!           VA_STATUS_SUCCESS if succeed
80     //!
81     virtual VAStatus PopulateColorMaskInfo(VAImageFormat *vaImgFmt) override;
82 
83     //!
84     //! \brief    Return internal encode mode for given profile and entrypoint
85     //!
86     //! \param    [in] profile
87     //!           Specify the VAProfile
88     //!
89     //! \param    [in] entrypoint
90     //!           Specify the VAEntrypoint
91     //!
92     //! \return   Codehal mode
93     //!
94     CODECHAL_MODE GetEncodeCodecMode(VAProfile profile, VAEntrypoint entrypoint) override;
95 
96     //!
97     //! \brief    Return the decode codec key for given profile
98     //!
99     //! \param    [in] profile
100     //!           Specify the VAProfile
101     //!
102     //! \return   Std::string decode codec key
103     //!
104     virtual std::string GetDecodeCodecKey(VAProfile profile) override;
105 
106     //!
107     //! \brief    Return the encode codec key for given profile and entrypoint
108     //!
109     //! \param    [in] profile
110     //!           Specify the VAProfile
111     //!
112     //! \param    [in] entrypoint
113     //!           Specify the entrypoint
114     //!
115     //! \param    [in] feiFunction
116     //!           Specify the feiFunction
117     //!
118     //! \return   Std::string encode codec key
119     //!
120     std::string GetEncodeCodecKey(VAProfile profile, VAEntrypoint entrypoint, uint32_t feiFunction) override;
121 
122     //!
123     //! \brief convert Media Format to Gmm Format for GmmResCreate parameter.
124     //!
125     //! \param    [in] format
126     //!         Pointer to DDI_MEDIA_FORMAT
127     //!
128     //! \return GMM_RESOURCE_FORMAT
129     //!         Pointer to gmm format type
130     //!
131     virtual GMM_RESOURCE_FORMAT ConvertMediaFmtToGmmFmt(DDI_MEDIA_FORMAT format) override;
132 
133     //!
134     //! \brief    Get surface attributes for a given config ID
135     //!
136     //! \param    [in] configId
137     //!           VA configuration
138     //!
139     //! \param    [in,out] attribList
140     //!           Pointer to VASurfaceAttrib array. It returns
141     //!           the supported  surface attributes
142     //!
143     //! \param    [in,out] numAttribs
144     //!           The number of elements allocated on input
145     //!           Return the number of elements actually filled in output
146     //!
147     //! \return   VAStatus
148     //!           VA_STATUS_SUCCESS if success
149     //!           VA_STATUS_ERROR_MAX_NUM_EXCEEDED if size of attribList is too small
150     //!
151     VAStatus QuerySurfaceAttributes(
152             VAConfigID configId,
153             VASurfaceAttrib *attribList,
154             uint32_t *numAttribs)                                                override;
155 
156 protected:
157     static const uint32_t m_maxHevcEncWidth =
158         CODEC_8K_MAX_PIC_WIDTH; //!< maxinum width for HEVC encode
159     static const uint32_t m_maxHevcEncHeight =
160         CODEC_8K_MAX_PIC_HEIGHT; //!< maxinum height for HEVC encode
161     static const uint32_t m_maxVp9EncWidth =
162         CODEC_8K_MAX_PIC_WIDTH; //!< maxinum width for VP9 encode
163     static const uint32_t m_maxVp9EncHeight =
164         CODEC_8K_MAX_PIC_HEIGHT; //!< maxinum height for VP9 encode
165     static const uint32_t m_minVp9EncWidth =
166         CODEC_128_MIN_PIC_WIDTH; //!< minimum width for VP9 encode
167     static const uint32_t m_minVp9EncHeight =
168         CODEC_96_MIN_PIC_HEIGHT; //!< minimum height for VP9 encode
169     static const VAImageFormat m_G11ImageFormats[]; //!< Gen11 supported image formats
170     static const VAConfigAttribValEncRateControlExt m_encVp9RateControlExt; //!< External enc rate control caps for VP9 encode
171 
172     virtual VAStatus GetPlatformSpecificAttrib(VAProfile profile,
173             VAEntrypoint entrypoint,
174             VAConfigAttribType type,
175             unsigned int *value) override;
176 
177     virtual VAStatus LoadProfileEntrypoints() override;
178     virtual VAStatus LoadVp9EncProfileEntrypoints() override;
179     virtual VAStatus LoadHevcEncProfileEntrypoints() override;
180 
181     virtual VAStatus CheckEncodeResolution(
182             VAProfile profile,
183             uint32_t width,
184             uint32_t height) override;
185     virtual VAStatus CheckDecodeResolution(
186             int32_t codecMode,
187             VAProfile profile,
188             uint32_t width,
189             uint32_t height) override;
190 
191     virtual VAStatus CreateEncAttributes(
192         VAProfile profile,
193         VAEntrypoint entrypoint,
194         AttribMap **attributeList) override;
195 
196     virtual VAStatus CreateDecAttributes(
197         VAProfile profile,
198         VAEntrypoint entrypoint,
199         AttribMap **attributeList) override;
200 
201     //!
202     //! \brief    Initialize HEVC low-power encode profiles, entrypoints and attributes
203     //!
204     //! \return VAStatus
205     //!     if call succeeds
206     //!
207     VAStatus LoadHevcEncLpProfileEntrypoints();
208 
209     //!
210     //! \brief  Query AVC ROI maximum number
211     //!
212     //! \param  [in] rcMode
213     //!     RC mode
214     //! \param  [in] isVdenc
215     //!     vdenc
216     //! \param  [in] maxNum
217     //!     Maximum number
218     //! \param  [in] isRoiInDeltaQP
219     //!     Is ROI in delta QP
220     //!
221     //! \return VAStatus
222     //!     if call succeeds
223     //!
224     VAStatus QueryAVCROIMaxNum(uint32_t rcMode, bool isVdenc, uint32_t *maxNum, bool *isRoiInDeltaQP) override;
225 };
226 #endif
227