1 /*############################################################################
2   # Copyright Intel Corporation
3   #
4   # SPDX-License-Identifier: MIT
5   ############################################################################*/
6 
7 #ifndef __MFXSTRUCTURES_H__
8 #define __MFXSTRUCTURES_H__
9 #include "mfxcommon.h"
10 
11 #if !defined (__GNUC__)
12 #pragma warning(disable: 4201)
13 #endif
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 
20 /* Frame ID for MVC */
21 MFX_PACK_BEGIN_USUAL_STRUCT()
22 /*! Describes the view and layer of a frame picture. */
23 typedef struct {
24     mfxU16      TemporalId;  /*!< The temporal identifier as defined in the annex H of the ITU*-T H.264 specification. */
25     mfxU16      PriorityId;  /*!< Reserved and must be zero. */
26     union {
27         struct {
28             mfxU16  DependencyId; /*!< Reserved for future use. */
29             mfxU16  QualityId;    /*!< Reserved for future use. */
30         };
31         struct {
32             mfxU16  ViewId; /*!< The view identifier as defined in the annex H of the ITU-T H.264 specification. */
33         };
34     };
35 } mfxFrameId;
36 MFX_PACK_END()
37 
38 /* This struct has 4-byte alignment for binary compatibility with previously released versions of API. */
39 MFX_PACK_BEGIN_USUAL_STRUCT()
40 /*! Specifies properties of video frames. See also "Configuration Parameter Constraints" chapter. */
41 typedef struct {
42     mfxU32  reserved[4]; /*!< Reserved for future use. */
43     /*! The unique ID of each VPP channel set by application. It's required that during Init/Reset application fills ChannelId for
44         each mfxVideoChannelParam provided by the application and the SDK sets it back to the correspondent
45         mfxSurfaceArray::mfxFrameSurface1 to distinguish different channels. It's expected that surfaces for some channels might be
46         returned with some delay so application has to use mfxFrameInfo::ChannelId to distinguish what returned surface belongs to
47         what VPP channel. Decoder's initialization parameters are always sent through channel with mfxFrameInfo::ChannelId equals to
48         zero. It's allowed to skip setting of decoder's parameters for simplified decoding procedure */
49     mfxU16  ChannelId;
50     /*! Number of bits used to represent luma samples.
51         @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported. */
52     mfxU16  BitDepthLuma;
53     /*! Number of bits used to represent chroma samples.
54         @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported. */
55     mfxU16  BitDepthChroma;
56     /*! When the value is not zero, indicates that values of luma and chroma samples are shifted. Use BitDepthLuma and BitDepthChroma to calculate
57         shift size. Use zero value to indicate absence of shift. See example data alignment below.
58 
59         @note Not all codecs and implementations support this value. Use the Query API  function to check if this feature is supported.
60     */
61     mfxU16  Shift;
62     mfxFrameId FrameId; /*!< Describes the view and layer of a frame picture. */
63     mfxU32  FourCC;     /*!< FourCC code of the color format. See the ColorFourCC enumerator for details. */
64     union {
65         struct { /* Frame parameters */
66             mfxU16  Width;  /*!< Width of the video frame in pixels. Must be a multiple of 16. */
67             mfxU16  Height; /*!< Height of the video frame in pixels. Must be a multiple of 16 for progressive frame sequence and a multiple of 32 otherwise. */
68 
69             /*! @{
70              @name ROI
71              The region of interest of the frame. Specify the display width and height in mfxVideoParam. */
72             mfxU16  CropX; /*!< X coordinate. */
73             mfxU16  CropY; /*!< Y coordinate. */
74             mfxU16  CropW; /*!< Width in pixels. */
75             mfxU16  CropH; /*!< Height in pixels. */
76             /*! @} */
77         };
78         struct { /* Buffer parameters (for plain formats like P8) */
79             mfxU64 BufferSize; /*!< Size of frame buffer in bytes. Valid only for plain formats (when FourCC is P8). In this case, Width, Height, and crop values are invalid. */
80             mfxU32 reserved5;
81         };
82     };
83 
84     /*! @{
85         @name FrameRate
86         Specify the frame rate with the following formula: FrameRateExtN / FrameRateExtD.
87 
88         For encoding, frame rate must be specified. For decoding, frame rate may be unspecified (FrameRateExtN and FrameRateExtD
89         are all zeros.) In this case, the frame rate is defaulted to 30 frames per second.
90     */
91     mfxU32  FrameRateExtN; /*!< Frame rate numerator. */
92     mfxU32  FrameRateExtD; /*!< Frame rate denominator. */
93     /*! @} */
94     mfxU16  reserved3;
95 
96     /*! @{
97         @name AspectRatio
98         AspectRatioW and AspectRatioH are used to specify the sample aspect ratio. If sample aspect ratio is explicitly defined by the standards (see
99         Table 6-3 in the MPEG-2 specification or Table E-1 in the H.264 specification), AspectRatioW and AspectRatioH should be the defined values.
100         Otherwise, the sample aspect ratio can be derived as follows:
101 
102         @li @c AspectRatioW=display_aspect_ratio_width*display_height
103 
104         @li @c AspectRatioH=display_aspect_ratio_height*display_width
105 
106         For MPEG-2, the above display aspect ratio must be one of the defined values in Table 6-3 in the MPEG-2 specification. For H.264, there is no restriction
107         on display aspect ratio values.
108 
109         If both parameters are zero, the encoder uses the default value of sample aspect ratio.
110     */
111     mfxU16  AspectRatioW; /*!< Aspect Ratio for width. */
112     mfxU16  AspectRatioH; /*!< Aspect Ratio for height. */
113     /*! @} */
114 
115     mfxU16  PicStruct;    /*!< Picture type as specified in the PicStruct enumerator. */
116     mfxU16  ChromaFormat; /*!< Color sampling method. Value is the same as that of ChromaFormatIdc.
117                                ChromaFormat is not defined if FourCC is zero.*/
118     mfxU16  reserved2;
119 } mfxFrameInfo;
120 MFX_PACK_END()
121 
122 /*! The ColorFourCC enumerator itemizes color formats. */
123 enum {
124     MFX_FOURCC_NV12         = MFX_MAKEFOURCC('N','V','1','2'),   /*!< NV12 color planes. Native format for 4:2:0/8b Gen hardware implementation. */
125     MFX_FOURCC_YV12         = MFX_MAKEFOURCC('Y','V','1','2'),   /*!< YV12 color planes. */
126     MFX_FOURCC_NV16         = MFX_MAKEFOURCC('N','V','1','6'),   /*!< 4:2:2 color format with similar to NV12 layout. */
127     MFX_FOURCC_YUY2         = MFX_MAKEFOURCC('Y','U','Y','2'),   /*!< YUY2 color planes. */
128     MFX_FOURCC_RGB565       = MFX_MAKEFOURCC('R','G','B','2'),   /*!< 2 bytes per pixel, uint16 in little-endian format, where 0-4 bits are blue, bits 5-10 are green and bits 11-15 are red. */
129     /*! RGB 24 bit planar layout (3 separate channels, 8-bits per sample each). This format should be mapped to D3DFMT_R8G8B8 or VA_FOURCC_RGBP. */
130     MFX_FOURCC_RGBP         = MFX_MAKEFOURCC('R','G','B','P'),
131     MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_FOURCC_RGB3)         = MFX_MAKEFOURCC('R','G','B','3'),   /* Deprecated. */
132     MFX_FOURCC_RGB4         = MFX_MAKEFOURCC('R','G','B','4'),   /*!< RGB4 (RGB32) color planes. BGRA is the order, ‘B’ is 8 MSBs, then 8 bits for ‘G’ channel, then ‘R’ and ‘A’ channels. */
133     /*!
134        Internal color format. The application should use the following functions to create a surface that corresponds to the Direct3D* version in use.
135 
136        For Direct3D* 9: IDirectXVideoDecoderService::CreateSurface()
137 
138        For Direct3D* 11: ID3D11Device::CreateBuffer()
139     */
140     MFX_FOURCC_P8           = 41,
141     /*!
142        Internal color format. The application should use the following functions to create a surface that corresponds to the Direct3D* version in use.
143 
144        For Direct3D 9: IDirectXVideoDecoderService::CreateSurface()
145 
146        For Direct3D 11: ID3D11Device::CreateTexture2D()
147     */
148     MFX_FOURCC_P8_TEXTURE   = MFX_MAKEFOURCC('P','8','M','B'),
149     MFX_FOURCC_P010         = MFX_MAKEFOURCC('P','0','1','0'), /*!< P010 color format. This is 10 bit per sample format with similar to NV12 layout. This format should be mapped to DXGI_FORMAT_P010. */
150     MFX_FOURCC_P016         = MFX_MAKEFOURCC('P','0','1','6'), /*!< P016 color format. This is 16 bit per sample format with similar to NV12 layout. This format should be mapped to DXGI_FORMAT_P016. */
151     MFX_FOURCC_P210         = MFX_MAKEFOURCC('P','2','1','0'), /*!< 10 bit per sample 4:2:2 color format with similar to NV12 layout. */
152     MFX_FOURCC_BGR4         = MFX_MAKEFOURCC('B','G','R','4'), /*!< RGBA color format. It is similar to MFX_FOURCC_RGB4 but with different order of channels. ‘R’ is 8 MSBs, then 8 bits for ‘G’ channel, then ‘B’ and ‘A’ channels. */
153     MFX_FOURCC_A2RGB10      = MFX_MAKEFOURCC('R','G','1','0'), /*!< 10 bits ARGB color format packed in 32 bits. ‘A’ channel is two MSBs, then ‘R’, then ‘G’ and then ‘B’ channels. This format should be mapped to DXGI_FORMAT_R10G10B10A2_UNORM or D3DFMT_A2R10G10B10. */
154     MFX_FOURCC_ARGB16       = MFX_MAKEFOURCC('R','G','1','6'), /*!< 10 bits ARGB color format packed in 64 bits. ‘A’ channel is 16 MSBs, then ‘R’, then ‘G’ and then ‘B’ channels. This format should be mapped to DXGI_FORMAT_R16G16B16A16_UINT or D3DFMT_A16B16G16R16 formats. */
155     MFX_FOURCC_ABGR16       = MFX_MAKEFOURCC('B','G','1','6'), /*!< 10 bits ABGR color format packed in 64 bits. ‘A’ channel is 16 MSBs, then ‘B’, then ‘G’ and then ‘R’ channels. This format should be mapped to DXGI_FORMAT_R16G16B16A16_UINT or D3DFMT_A16B16G16R16 formats. */
156     MFX_FOURCC_R16          = MFX_MAKEFOURCC('R','1','6','U'), /*!< 16 bits single channel color format. This format should be mapped to DXGI_FORMAT_R16_TYPELESS or D3DFMT_R16F. */
157     MFX_FOURCC_AYUV         = MFX_MAKEFOURCC('A','Y','U','V'), /*!< YUV 4:4:4, AYUV color format. This format should be mapped to DXGI_FORMAT_AYUV. */
158     MFX_FOURCC_AYUV_RGB4    = MFX_MAKEFOURCC('A','V','U','Y'), /*!< RGB4 stored in AYUV surface. This format should be mapped to DXGI_FORMAT_AYUV. */
159     MFX_FOURCC_UYVY         = MFX_MAKEFOURCC('U','Y','V','Y'), /*!< UYVY color planes. Same as YUY2 except the byte order is reversed. */
160     MFX_FOURCC_Y210         = MFX_MAKEFOURCC('Y','2','1','0'), /*!< 10 bit per sample 4:2:2 packed color format with similar to YUY2 layout. This format should be mapped to DXGI_FORMAT_Y210. */
161     MFX_FOURCC_Y410         = MFX_MAKEFOURCC('Y','4','1','0'), /*!< 10 bit per sample 4:4:4 packed color format. This format should be mapped to DXGI_FORMAT_Y410. */
162     MFX_FOURCC_Y216         = MFX_MAKEFOURCC('Y','2','1','6'), /*!< 16 bit per sample 4:2:2 packed color format with similar to YUY2 layout. This format should be mapped to DXGI_FORMAT_Y216. */
163     MFX_FOURCC_Y416         = MFX_MAKEFOURCC('Y','4','1','6'), /*!< 16 bit per sample 4:4:4 packed color format. This format should be mapped to DXGI_FORMAT_Y416. */
164     MFX_FOURCC_NV21         = MFX_MAKEFOURCC('N', 'V', '2', '1'), /*!< Same as NV12 but with weaved V and U values. */
165     MFX_FOURCC_IYUV         = MFX_MAKEFOURCC('I', 'Y', 'U', 'V'), /*!< Same as  YV12 except that the U and V plane order is reversed. */
166     MFX_FOURCC_I010         = MFX_MAKEFOURCC('I', '0', '1', '0'), /*!< 10-bit YUV 4:2:0, each component has its own plane. */
167     MFX_FOURCC_I210         = MFX_MAKEFOURCC('I', '2', '1', '0'), /*!< 10-bit YUV 4:2:2, each component has its own plane. */
168     MFX_FOURCC_I420         = MFX_FOURCC_IYUV,                 /*!< Alias for the IYUV color format. */
169     MFX_FOURCC_I422         = MFX_MAKEFOURCC('I', '4', '2', '2'), /*!< Same as YV16 except that the U and V plane order is reversed */
170     MFX_FOURCC_BGRA         = MFX_FOURCC_RGB4,                 /*!< Alias for the RGB4 color format. */
171     /*! BGR 24 bit planar layout (3 separate channels, 8-bits per sample each). This format should be mapped to VA_FOURCC_BGRP. */
172     MFX_FOURCC_BGRP         = MFX_MAKEFOURCC('B','G','R','P'),
173 };
174 
175 /* PicStruct */
176 enum {
177     MFX_PICSTRUCT_UNKNOWN       =0x00,  /*!< Unspecified or mixed progressive/interlaced/field pictures. */
178     MFX_PICSTRUCT_PROGRESSIVE   =0x01,  /*!< Progressive picture. */
179     MFX_PICSTRUCT_FIELD_TFF     =0x02,  /*!< Top field in first interlaced picture.  */
180     MFX_PICSTRUCT_FIELD_BFF     =0x04,  /*!< Bottom field in first interlaced picture.  */
181 
182     MFX_PICSTRUCT_FIELD_REPEATED=0x10,  /*!< First field repeated: pic_struct=5 or 6 in H.264. */
183     MFX_PICSTRUCT_FRAME_DOUBLING=0x20,  /*!< Double the frame for display: pic_struct=7 in H.264. */
184     MFX_PICSTRUCT_FRAME_TRIPLING=0x40,  /*!< Triple the frame for display: pic_struct=8 in H.264. */
185 
186     MFX_PICSTRUCT_FIELD_SINGLE      =0x100, /*!< Single field in a picture. */
187     MFX_PICSTRUCT_FIELD_TOP         =MFX_PICSTRUCT_FIELD_SINGLE | MFX_PICSTRUCT_FIELD_TFF, /*!< Top field in a picture: pic_struct = 1 in H.265. */
188     MFX_PICSTRUCT_FIELD_BOTTOM      =MFX_PICSTRUCT_FIELD_SINGLE | MFX_PICSTRUCT_FIELD_BFF, /*!< Bottom field in a picture: pic_struct = 2 in H.265. */
189     MFX_PICSTRUCT_FIELD_PAIRED_PREV =0x200, /*!< Paired with previous field: pic_struct = 9 or 10 in H.265. */
190     MFX_PICSTRUCT_FIELD_PAIRED_NEXT =0x400, /*!< Paired with next field: pic_struct = 11 or 12 in H.265 */
191 };
192 
193 /* The ChromaFormatIdc enumerator itemizes color-sampling formats. */
194 enum {
195     MFX_CHROMAFORMAT_MONOCHROME =0, /*!< Monochrome. */
196     MFX_CHROMAFORMAT_YUV420     =1, /*!< 4:2:0 color. */
197     MFX_CHROMAFORMAT_YUV422     =2, /*!< 4:2:2 color. */
198     MFX_CHROMAFORMAT_YUV444     =3, /*!< 4:4:4 color. */
199     MFX_CHROMAFORMAT_YUV400     = MFX_CHROMAFORMAT_MONOCHROME, /*!< Equal to monochrome. */
200     MFX_CHROMAFORMAT_YUV411     = 4, /*!< 4:1:1 color. */
201     MFX_CHROMAFORMAT_YUV422H    = MFX_CHROMAFORMAT_YUV422, /*!< 4:2:2 color, horizontal sub-sampling. It is equal to 4:2:2 color. */
202     MFX_CHROMAFORMAT_YUV422V    = 5, /*!< 4:2:2 color, vertical sub-sampling. */
203     MFX_CHROMAFORMAT_RESERVED1  = 6  /*!< Reserved. */
204 };
205 
206 enum {
207     MFX_TIMESTAMP_UNKNOWN = -1 /*!< Indicates that time stamp is unknown for this frame/bitstream portion. */
208 };
209 
210 enum {
211     MFX_FRAMEORDER_UNKNOWN = -1 /*!< Unused entry or API functions that generate the frame output do not use this frame. */
212 };
213 
214 /* The FrameDataFlag enumerator itemizes DataFlag value in mfxFrameData. */
215 enum {
216     MFX_FRAMEDATA_TIMESTAMP_UNKNOWN  = 0x0000,/*!< Indicates the time stamp of this frame is unknown and will be calculated by SDK. */
217     MFX_FRAMEDATA_ORIGINAL_TIMESTAMP = 0x0001 /*!< Indicates the time stamp of this frame is not calculated and is a pass-through of the original time stamp. */
218 };
219 
220 /* Corrupted in mfxFrameData */
221 enum {
222     MFX_CORRUPTION_NO              = 0x0000, /*!< No corruption. */
223     MFX_CORRUPTION_MINOR           = 0x0001, /*!< Minor corruption in decoding certain macro-blocks. */
224     MFX_CORRUPTION_MAJOR           = 0x0002, /*!< Major corruption in decoding the frame - incomplete data, for example. */
225     MFX_CORRUPTION_ABSENT_TOP_FIELD           = 0x0004, /*!< Top field of frame is absent in bitstream. Only bottom field has been decoded. */
226     MFX_CORRUPTION_ABSENT_BOTTOM_FIELD           = 0x0008, /*!< Bottom field of frame is absent in bitstream. Only top filed has been decoded. */
227     MFX_CORRUPTION_REFERENCE_FRAME = 0x0010, /*!< Decoding used a corrupted reference frame. A corrupted reference frame was used for decoding this
228                                                 frame. For example, if the frame uses a reference frame that was decoded with minor/major corruption flag, then this
229                                                 frame is also marked with a reference corruption flag. */
230     MFX_CORRUPTION_REFERENCE_LIST  = 0x0020  /*!< The reference list information of this frame does not match what is specified in the Reference Picture Marking
231                                                   Repetition SEI message. (ITU-T H.264 D.1.8 dec_ref_pic_marking_repetition) */
232 };
233 
234 MFX_PACK_BEGIN_USUAL_STRUCT()
235 /*! Specifies "pixel" in Y410 color format. */
236 typedef struct
237 {
238     mfxU32 U : 10; /*!< U component. */
239     mfxU32 Y : 10; /*!< Y component. */
240     mfxU32 V : 10; /*!< V component. */
241     mfxU32 A :  2; /*!< A component. */
242 } mfxY410;
243 MFX_PACK_END()
244 
245 MFX_PACK_BEGIN_USUAL_STRUCT()
246 /*! Specifies "pixel" in Y416 color format. */
247 typedef struct
248 {
249     mfxU32 U : 16; /*!< U component. */
250     mfxU32 Y : 16; /*!< Y component. */
251     mfxU32 V : 16; /*!< V component. */
252     mfxU32 A : 16; /*!< A component. */
253 } mfxY416;
254 MFX_PACK_END()
255 
256 MFX_PACK_BEGIN_USUAL_STRUCT()
257 /*! Specifies "pixel" in A2RGB10 color format */
258 typedef struct
259 {
260     mfxU32 B : 10; /*!< B component. */
261     mfxU32 G : 10; /*!< G component. */
262     mfxU32 R : 10; /*!< R component. */
263     mfxU32 A :  2; /*!< A component. */
264 } mfxA2RGB10;
265 MFX_PACK_END()
266 
267 /*! Describes frame buffer pointers. */
268 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
269 typedef struct {
270     /*!  @name Extension Buffers */
271     /*! @{ */
272     union {
273         mfxExtBuffer **ExtParam; /*!< Points to an array of pointers to the extra configuration structures. See the ExtendedBufferID
274                                       enumerator for a list of extended configurations. */
275         mfxU64       reserved2;
276     };
277     mfxU16  NumExtParam; /*!< The number of extra configuration structures attached to this structure. */
278     /*! @} */
279 
280     /*!  @name General members */
281     /*! @{ */
282     mfxU16      reserved[9]; /*!< Reserved for future use. */
283     mfxU16      MemType;     /*!< Allocated memory type. See the ExtMemFrameType enumerator for details. Used for better integration of
284                                   3rd party plugins into the pipeline. */
285     mfxU16      PitchHigh;   /*!< Distance in bytes between the start of two consecutive rows in a frame. */
286 
287     mfxU64      TimeStamp;   /*!< Time stamp of the video frame in units of 90KHz. Divide TimeStamp by 90,000 (90 KHz) to obtain the time in seconds.
288                                   A value of MFX_TIMESTAMP_UNKNOWN indicates that there is no time stamp. */
289     mfxU32      FrameOrder;  /*!< Current frame counter for the top field of the current frame. An invalid value of MFX_FRAMEORDER_UNKNOWN indicates that
290                             API functions that generate the frame output do not use this frame. */
291     mfxU16      Locked;      /*!< Counter flag for the application. If Locked is greater than zero then the application locks the frame or field pair.
292                                   Do not move, alter or delete the frame. */
293     union{
294         mfxU16  Pitch;
295         mfxU16  PitchLow;    /*!< Distance in bytes between the start of two consecutive rows in a frame. */
296     };
297     /*! @} */
298 
299     /*!
300         @name Color Planes
301         Data pointers to corresponding color channels (planes). The frame buffer pointers must be 16-byte aligned. The application has to specify pointers to
302         all color channels even for packed formats. For example, for YUY2 format the application must specify Y, U, and V pointers.
303         For RGB32 format, the application must specify R, G, B, and A pointers.
304     */
305     /*! @{ */
306     union {
307         mfxU8   *Y; /*!< Y channel. */
308         mfxU16  *Y16; /*!< Y16 channel. */
309         mfxU8   *R; /*!< R channel. */
310     };
311     union {
312         mfxU8   *UV;    /*!< UV channel for UV merged formats. */
313         mfxU8   *VU;    /*!< YU channel for VU merged formats. */
314         mfxU8   *CbCr;  /*!< CbCr channel for CbCr merged formats. */
315         mfxU8   *CrCb;  /*!< CrCb channel for CrCb merged formats. */
316         mfxU8   *Cb;    /*!< Cb channel. */
317         mfxU8   *U;     /*!< U channel. */
318         mfxU16  *U16;   /*!< U16 channel. */
319         mfxU8   *G;     /*!< G channel. */
320         mfxY410 *Y410;  /*!< T410 channel for Y410 format (merged AVYU). */
321         mfxY416 *Y416;  /*!< This format is a packed 16-bit representation that includes 16 bits of alpha. */
322     };
323     union {
324         mfxU8   *Cr;    /*!< Cr channel. */
325         mfxU8   *V;     /*!< V channel. */
326         mfxU16  *V16;   /*!< V16 channel. */
327         mfxU8   *B;     /*!< B channel. */
328         mfxA2RGB10 *A2RGB10; /*!< A2RGB10 channel for A2RGB10 format (merged ARGB). */
329     };
330     mfxU8       *A;     /*!< A channel. */
331     mfxMemId    MemId;  /*!< Memory ID of the data buffers. Ignored if any of the preceding data pointers is non-zero. */
332     /*! @} */
333 
334     /*!
335         @name Additional Flags
336     */
337     /*! @{ */
338     mfxU16  Corrupted; /*!< Some part of the frame or field pair is corrupted. See the Corruption enumerator for details. */
339     mfxU16  DataFlag;  /*!< Additional flags to indicate frame data properties. See the FrameDataFlag enumerator for details. */
340     /*! @} */
341 } mfxFrameData;
342 MFX_PACK_END()
343 
344 /*! The mfxHandleType enumerator itemizes system handle types that implementations might use. */
345 typedef enum {
346     MFX_HANDLE_DIRECT3D_DEVICE_MANAGER9         =1,      /*!< Pointer to the IDirect3DDeviceManager9 interface. See Working with Microsoft* DirectX* Applications for more details on how to use this handle. */
347     MFX_HANDLE_D3D9_DEVICE_MANAGER              = MFX_HANDLE_DIRECT3D_DEVICE_MANAGER9, /*!< Pointer to the IDirect3DDeviceManager9 interface. See Working with Microsoft* DirectX* Applications for more details on how to use this handle. */
348     MFX_HANDLE_RESERVED1                        = 2, /* Reserved.  */
349     MFX_HANDLE_D3D11_DEVICE                     = 3, /*!< Pointer to the ID3D11Device interface. See Working with Microsoft* DirectX* Applications for more details on how to use this handle. */
350     MFX_HANDLE_VA_DISPLAY                       = 4, /*!< Pointer to VADisplay interface. See Working with VA-API Applications for more details on how to use this handle. */
351     MFX_HANDLE_RESERVED3                        = 5, /* Reserved.  */
352     MFX_HANDLE_VA_CONFIG_ID                     = 6, /*!< Pointer to VAConfigID interface. It represents external VA config for Common Encryption usage model. */
353     MFX_HANDLE_VA_CONTEXT_ID                    = 7, /*!< Pointer to VAContextID interface. It represents external VA context for Common Encryption usage model. */
354     MFX_HANDLE_CM_DEVICE                        = 8,  /*!< Pointer to CmDevice interface ( Intel(r) C for Metal Runtime ). */
355     MFX_HANDLE_HDDLUNITE_WORKLOADCONTEXT        = 9,  /*!< Pointer to HddlUnite::WorkloadContext interface. */
356 #ifdef ONEVPL_EXPERIMENTAL
357     MFX_HANDLE_PXP_CONTEXT                      = 10, /*!< Pointer to PXP context for protected content support. */
358 #endif
359 } mfxHandleType;
360 
361 /*! The mfxMemoryFlags enumerator specifies memory access mode. */
362 typedef enum
363 {
364     MFX_MAP_READ  = 0x1, /*!< The surface is mapped for reading. */
365     MFX_MAP_WRITE = 0x2, /*!< The surface is mapped for writing. */
366     MFX_MAP_READ_WRITE = MFX_MAP_READ|MFX_MAP_WRITE, /*!< The surface is mapped for reading and writing.  */
367     /*!
368      * The mapping would be done immediately without any implicit synchronizations.
369      * \attention This flag is optional.
370      */
371     MFX_MAP_NOWAIT = 0x10
372 } mfxMemoryFlags;
373 
374 #define MFX_FRAMESURFACE1_VERSION MFX_STRUCT_VERSION(1, 1)
375 
376 /* Frame Surface */
377 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
378 /*! Defines the uncompressed frames surface information and data buffers.
379     The frame surface is in the frame or complementary field pairs of pixels up to four color-channels, in two parts:
380     mfxFrameInfo and mfxFrameData.
381 */
382 typedef struct {
383     union
384     {
385         struct mfxFrameSurfaceInterface*  FrameInterface;       /*!< Specifies interface to work with surface. */
386         mfxU32  reserved[2];
387     };
388     mfxStructVersion Version; /* Specifies version of mfxFrameSurface1 structure. */
389     mfxU16          reserved1[3];
390     mfxFrameInfo    Info; /*!< Specifies surface properties. */
391     mfxFrameData    Data; /*!< Describes the actual frame buffer. */
392 } mfxFrameSurface1;
393 MFX_PACK_END()
394 
395 
396 #define MFX_FRAMESURFACEINTERFACE_VERSION MFX_STRUCT_VERSION(1, 0)
397 
398 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
399 /* Specifies frame surface interface. */
400 typedef struct mfxFrameSurfaceInterface {
401     mfxHDL              Context; /*!< The context of the memory interface. User should not touch (change, set, null) this pointer. */
402     mfxStructVersion    Version; /*!< The version of the structure. */
403     mfxU16              reserved1[3];
404     /*! @brief
405     Increments the internal reference counter of the surface. The surface is not destroyed until the surface is released using the mfxFrameSurfaceInterface::Release function.
406     mfxFrameSurfaceInterface::AddRef should be used each time a new link to the surface is created (for example, copy structure) for proper surface management.
407 
408     @param[in]  surface  Valid surface.
409 
410     @return
411      MFX_ERR_NONE              If no error. \n
412      MFX_ERR_NULL_PTR          If surface is NULL. \n
413      MFX_ERR_INVALID_HANDLE    If mfxFrameSurfaceInterface->Context is invalid (for example NULL). \n
414      MFX_ERR_UNKNOWN           Any internal error.
415 
416     */
417     mfxStatus           (MFX_CDECL *AddRef)(mfxFrameSurface1* surface);
418     /*! @brief
419     Decrements the internal reference counter of the surface. mfxFrameSurfaceInterface::Release should be called after using the
420     mfxFrameSurfaceInterface::AddRef function to add a surface or when allocation logic requires it. For example, call
421     mfxFrameSurfaceInterface::Release to release a surface obtained with the GetSurfaceForXXX function.
422 
423     @param[in]  surface  Valid surface.
424 
425     @return
426      MFX_ERR_NONE               If no error. \n
427      MFX_ERR_NULL_PTR           If surface is NULL. \n
428      MFX_ERR_INVALID_HANDLE     If mfxFrameSurfaceInterface->Context is invalid (for example NULL). \n
429      MFX_ERR_UNDEFINED_BEHAVIOR If Reference Counter of surface is zero before call. \n
430      MFX_ERR_UNKNOWN            Any internal error.
431     */
432     mfxStatus           (MFX_CDECL *Release)(mfxFrameSurface1* surface);
433 
434     /*! @brief
435     Returns current reference counter of mfxFrameSurface1 structure.
436 
437     @param[in]   surface  Valid surface.
438     @param[out]  counter  Sets counter to the current reference counter value.
439 
440     @return
441      MFX_ERR_NONE               If no error. \n
442      MFX_ERR_NULL_PTR           If surface or counter is NULL. \n
443      MFX_ERR_INVALID_HANDLE     If mfxFrameSurfaceInterface->Context is invalid (for example NULL). \n
444      MFX_ERR_UNKNOWN            Any internal error.
445     */
446     mfxStatus           (MFX_CDECL *GetRefCounter)(mfxFrameSurface1* surface, mfxU32* counter);
447 
448     /*! @brief
449     Sets pointers of surface->Info.Data to actual pixel data, providing read-write access.
450 
451     In case of video memory, the surface with data in video memory becomes mapped to system memory.
452     An application can map a surface for read access with any value of mfxFrameSurface1::Data::Locked, but can map a surface for write access only when mfxFrameSurface1::Data::Locked equals to 0.
453 
454     Note: A surface allows shared read access, but exclusive write access. Consider the following cases:
455     @li Map with Write or Read|Write flags. A request during active another read or write access returns MFX_ERR_LOCK_MEMORY error immediately, without waiting.
456     MFX_MAP_NOWAIT does not impact behavior. This type of request does not lead to any implicit synchronizations.
457     @li Map with Read flag. A request during active write access will wait for resource to become free,
458     or exits immediately with error if MFX_MAP_NOWAIT flag was set. This request may lead to the implicit synchronization (with same logic as Synchronize call)
459     waiting for surface to become ready to use (all dependencies should be resolved and upstream components finished writing to this surface).
460 
461     It is guaranteed that read access will be acquired right after synchronization without allowing another thread to acquire this surface for writing.
462 
463     If MFX_MAP_NOWAIT was set and the surface is not ready yet (for example the surface has unresolved data dependencies or active processing), the read access request exits immediately with error.
464 
465     Read-write access with MFX_MAP_READ_WRITE provides exclusive simultaneous reading and writing access.
466 
467     @note Bitwise copying of mfxFrameSurface1 object between map / unmap calls may result in having dangling data pointers in copies.
468 
469     @param[in]   surface  Valid surface.
470     @param[out]  flags  Specify mapping mode.
471     @param[out]  surface->Info.Data Pointers set to actual pixel data.
472 
473     @return
474      MFX_ERR_NONE               If no error. \n
475      MFX_ERR_NULL_PTR           If surface is NULL. \n
476      MFX_ERR_INVALID_HANDLE     If mfxFrameSurfaceInterface->Context is invalid (for example NULL). \n
477      MFX_ERR_UNSUPPORTED        If flags are invalid. \n
478      MFX_ERR_LOCK_MEMORY        If user wants to map the surface for write and surface->Data.Locked does not equal to 0. \n
479      MFX_ERR_UNKNOWN            Any internal error.
480     */
481     mfxStatus           (MFX_CDECL *Map)(mfxFrameSurface1* surface, mfxU32 flags);
482 
483     /*! @brief
484     Invalidates pointers of surface->Info.Data and sets them to NULL.
485     In case of video memory, the underlying texture becomes unmapped after last reader or writer unmap.
486 
487 
488     @param[in]   surface  Valid surface.
489     @param[out]  surface->Info.Data  Pointers set to NULL.
490 
491     @return
492      MFX_ERR_NONE               If no error. \n
493      MFX_ERR_NULL_PTR           If surface is NULL. \n
494      MFX_ERR_INVALID_HANDLE     If mfxFrameSurfaceInterface->Context is invalid (for example NULL). \n
495      MFX_ERR_UNSUPPORTED        If surface is already unmapped. \n
496      MFX_ERR_UNKNOWN            Any internal error.
497     */
498     mfxStatus           (MFX_CDECL *Unmap)(mfxFrameSurface1* surface);
499 
500     /*! @brief
501     Returns a native resource's handle and type. The handle is returned *as-is*, meaning that the reference counter of base resources is not incremented.
502     The native resource is not detached from surface and the library still owns the resource. User must not destroy
503     the native resource or assume that the resource will be alive after mfxFrameSurfaceInterface::Release.
504 
505 
506 
507     @param[in]   surface  Valid surface.
508     @param[out]  resource Pointer is set to the native handle of the resource.
509     @param[out]  resource_type Type of native resource. See mfxResourceType enumeration).
510 
511 
512     @return
513      MFX_ERR_NONE               If no error. \n
514      MFX_ERR_NULL_PTR           If any of surface, resource or resource_type is NULL. \n
515      MFX_ERR_INVALID_HANDLE     If any of surface, resource or resource_type is not valid object (no native resource was allocated). \n
516      MFX_ERR_UNSUPPORTED        If surface is in system memory. \n
517      MFX_ERR_UNKNOWN            Any internal error.
518     */
519     mfxStatus           (MFX_CDECL *GetNativeHandle)(mfxFrameSurface1* surface, mfxHDL* resource, mfxResourceType* resource_type);
520 
521     /*! @brief
522     Returns a device abstraction that was used to create that resource.
523     The handle is returned *as-is*, meaning that the reference counter for the device abstraction is not incremented.
524     The native resource is not detached from the surface and the library still has a reference to the resource.
525     User must not destroy the device or assume that the device will be alive after mfxFrameSurfaceInterface::Release.
526 
527 
528     @param[in]   surface  Valid surface.
529     @param[out]  device_handle Pointer is set to the device which created the resource
530     @param[out]  device_type Type of device (see mfxHandleType enumeration).
531 
532 
533     @return
534      MFX_ERR_NONE               If no error. \n
535      MFX_ERR_NULL_PTR           If any of surface, device_handle or device_type is NULL. \n
536      MFX_ERR_INVALID_HANDLE     If any of surface, resource or resource_type is not valid object (no native resource was allocated). \n
537      MFX_ERR_UNSUPPORTED        If surface is in system memory. \n
538      MFX_ERR_UNKNOWN            Any internal error.
539     */
540     mfxStatus           (MFX_CDECL *GetDeviceHandle)(mfxFrameSurface1* surface, mfxHDL* device_handle, mfxHandleType* device_type);
541 
542     /*! @brief
543     Guarantees readiness of both the data (pixels) and any frame's meta information (for example corruption flags) after a function completes.
544 
545     Instead of MFXVideoCORE_SyncOperation, users may directly call the mfxFrameSurfaceInterface::Synchronize function after the corresponding
546     Decode or VPP function calls (MFXVideoDECODE_DecodeFrameAsync or MFXVideoVPP_RunFrameVPPAsync).
547     The prerequisites to call the functions are:
548 
549     @li The main processing functions return MFX_ERR_NONE.
550     @li A valid mfxFrameSurface1 object.
551 
552 
553 
554     @param[in]   surface  Valid surface.
555     @param[out]  wait  Wait time in milliseconds.
556 
557 
558     @return
559      MFX_ERR_NONE               If no error. \n
560      MFX_ERR_NULL_PTR           If surface is NULL. \n
561      MFX_ERR_INVALID_HANDLE     If any of surface is not valid object . \n
562      MFX_WRN_IN_EXECUTION       If the given timeout is expired and the surface is not ready. \n
563      MFX_ERR_ABORTED            If the specified asynchronous function aborted due to data dependency on a previous asynchronous function that did not complete. \n
564      MFX_ERR_UNKNOWN            Any internal error.
565     */
566     mfxStatus           (MFX_CDECL *Synchronize)(mfxFrameSurface1* surface, mfxU32 wait);
567 
568     /*! @brief
569     The library calls the function after complete of associated video operation
570     notifying the application that frame surface is ready.
571 
572     @attention This is callback function and intended to be called by
573                the library only.
574 
575     It is expected that the function is low-intrusive designed otherwise it may
576     impact performance.
577 
578     @param[in] sts  The status of completed operation.
579 
580     */
581     void               (MFX_CDECL *OnComplete)(mfxStatus sts);
582 
583    /*! @brief
584     Returns an interface defined by the GUID. If the returned interface is a reference
585     counted object the caller should release the obtained interface to avoid memory leaks.
586 
587     @param[in]  surface   Valid surface.
588     @param[in]  guid      GUID of the requested interface.
589     @param[out] iface     Interface.
590 
591 
592     @return
593      MFX_ERR_NONE               If no error. \n
594      MFX_ERR_NULL_PTR           If interface or surface is NULL. \n
595      MFX_ERR_UNSUPPORTED        If requested interface is not supported. \n
596      MFX_ERR_NOT_IMPLEMENTED    If requested interface is not implemented. \n
597      MFX_ERR_NOT_INITIALIZED    If requested interface is not available (not created or already deleted). \n
598      MFX_ERR_UNKNOWN            Any internal error.
599     */
600     mfxStatus           (MFX_CDECL *QueryInterface)(mfxFrameSurface1* surface, mfxGUID guid, mfxHDL* iface);
601 
602     mfxHDL              reserved2[2];
603 } mfxFrameSurfaceInterface;
604 MFX_PACK_END()
605 
606 /*! The TimeStampCalc enumerator itemizes time-stamp calculation methods. */
607 enum {
608     /*! The time stamp calculation is based on the input frame rate if time stamp is not explicitly specified. */
609     MFX_TIMESTAMPCALC_UNKNOWN = 0,
610     /*! Adjust time stamp to 29.97fps on 24fps progressively encoded sequences if telecine attributes are available in the bitstream and
611     time stamp is not explicitly specified. The input frame rate must be specified. */
612     MFX_TIMESTAMPCALC_TELECINE = 1,
613 };
614 
615 /* Transcoding Info */
616 MFX_PACK_BEGIN_USUAL_STRUCT()
617 /*! Specifies configurations for decoding, encoding, and transcoding processes.
618     A zero value in any of these fields indicates that the field is not explicitly specified. */
619 typedef struct {
620     mfxU32  reserved[7]; /*!< Reserved for future use. */
621 
622     /*! Hint to enable low power consumption mode for encoders. See the CodingOptionValue enumerator for values
623         of this option. Use the Query API function to check if this feature is supported. */
624     mfxU16  LowPower;
625     /*! Specifies a multiplier for bitrate control parameters. Affects the following variables: InitialDelayInKB, BufferSizeInKB,
626         TargetKbps, MaxKbps. If this value is not equal to zero, the encoder calculates BRC parameters as ``value * BRCParamMultiplier``. */
627     mfxU16  BRCParamMultiplier;
628 
629     mfxFrameInfo    FrameInfo; /*!< mfxFrameInfo structure that specifies frame parameters. */
630     mfxU32  CodecId;           /*!< Specifies the codec format identifier in the FourCC code; see the CodecFormatFourCC enumerator for details.
631                                     This is a mandated input parameter for the QueryIOSurf and Init API functions. */
632     mfxU16  CodecProfile;      /*!< Specifies the codec profile; see the CodecProfile enumerator for details. Specify the codec profile explicitly or the API functions will determine
633                                     the correct profile from other sources, such as resolution and bitrate. */
634     mfxU16  CodecLevel;        /*!< Codec level; see the CodecLevel enumerator for details. Specify the codec level explicitly or the functions will determine the correct level from other sources,
635                                     such as resolution and bitrate. */
636     mfxU16  NumThread;
637 
638     union {
639         struct {   /* Encoding Options */
640             mfxU16  TargetUsage; /*!< Target usage model that guides the encoding process; see the TargetUsage enumerator for details. */
641 
642             /*! Number of pictures within the current GOP (Group of Pictures); if GopPicSize = 0, then the GOP size is unspecified. If GopPicSize = 1, only I-frames are used.
643                 The following pseudo-code that shows how the library uses this parameter:
644                 @code
645                    mfxU16 get_gop_sequence (...) {
646                       pos=display_frame_order;
647                       if (pos == 0)
648                           return MFX_FRAMETYPE_I | MFX_FRAMETYPE_IDR | MFX_FRAMETYPE_REF;
649 
650                       If (GopPicSize == 1) // Only I-frames
651                           return MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF;
652 
653                       if (GopPicSize == 0)
654                                   frameInGOP = pos;    //Unlimited GOP
655                               else
656                                   frameInGOP = pos%GopPicSize;
657 
658                       if (frameInGOP == 0)
659                           return MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF;
660 
661                       if (GopRefDist == 1 || GopRefDist == 0)    // Only I,P frames
662                                   return MFX_FRAMETYPE_P | MFX_FRAMETYPE_REF;
663 
664                       frameInPattern = (frameInGOP-1)%GopRefDist;
665                       if (frameInPattern == GopRefDist - 1)
666                           return MFX_FRAMETYPE_P | MFX_FRAMETYPE_REF;
667 
668                       return MFX_FRAMETYPE_B;
669                     }
670                 @endcode */
671             mfxU16  GopPicSize;
672             /*! Distance between I- or P (or GPB) - key frames; if it is zero, the GOP structure is unspecified. Note: If GopRefDist = 1,
673                 there are no regular B-frames used (only P or GPB); if mfxExtCodingOption3::GPB is ON, GPB frames (B without backward
674                 references) are used instead of P. */
675             mfxU16  GopRefDist;
676             /*! ORs of the GopOptFlag enumerator indicate the additional flags for the GOP specification. */
677             mfxU16  GopOptFlag;
678             /*! For H.264, specifies IDR-frame interval in terms of I-frames.
679                 For example:
680                 @li If IdrInterval = 0, then every I-frame is an IDR-frame.
681                 @li If IdrInterval = 1, then every other I-frame is an IDR-frame.
682 
683                 For HEVC, if IdrInterval = 0, then only first I-frame is an IDR-frame. For example:
684                 @li If IdrInterval = 1, then every I-frame is an IDR-frame.
685                 @li If IdrInterval = 2, then every other I-frame is an IDR-frame.
686 
687                 For MPEG2, IdrInterval defines sequence header interval in terms of I-frames. For example:
688                 @li If IdrInterval = 0 (default), then the sequence header is inserted once at the beginning of the stream.
689                 @li If IdrInterval = N, then the sequence header is inserted before every Nth I-frame.
690 
691 
692                 If GopPicSize or GopRefDist is zero, IdrInterval is undefined. */
693             mfxU16  IdrInterval;
694 
695             mfxU16  RateControlMethod; /*! Rate control method; see the RateControlMethod enumerator for details. */
696             union {
697                 /*! Initial size of the Video Buffering Verifier (VBV) buffer.
698                     @note In this context, KB is 1000 bytes and Kbps is 1000 bps. */
699                 mfxU16  InitialDelayInKB;
700                 /*! Quantization Parameter (QP) for I-frames for constant QP mode (CQP). Zero QP is not valid and means that the default value is assigned by the library.
701                     Non-zero QPI might be clipped to supported QPI range.
702                     @note Default QPI value is implementation dependent and subject to change without additional notice in this document. */
703                 mfxU16  QPI;
704                 mfxU16  Accuracy; /*!< Specifies accuracy range in the unit of tenth of percent. */
705             };
706             mfxU16  BufferSizeInKB; /*!< Represents the maximum possible size of any compressed frames. */
707             union {
708                 /*! Constant bitrate TargetKbps. Used to estimate the targeted frame size by dividing the frame rate by the bitrate. */
709                 mfxU16  TargetKbps;
710                 /*! Quantization Parameter (QP) for P-frames for constant QP mode (CQP). Zero QP is not valid and means that the default value is assigned by the library.
711                     Non-zero QPP might be clipped to supported QPI range.
712                     @note Default QPP value is implementation dependent and subject to change without additional notice in this document. */
713                 mfxU16  QPP;
714                 mfxU16  ICQQuality; /*!< Used by the Intelligent Constant Quality (ICQ) bitrate control algorithm. Values are in the 1 to 51 range, where 1 corresponds the best quality. */
715             };
716             union {
717                 /*! The maximum bitrate at which the encoded data enters the Video Buffering Verifier (VBV) buffer. */
718                 mfxU16  MaxKbps;
719                 /*! Quantization Parameter (QP) for B-frames for constant QP mode (CQP). Zero QP is not valid and means that the default value is assigned by the library.
720                     Non-zero QPI might be clipped to supported QPB range.
721                     @note Default QPB value is implementation dependent and subject to change without additional notice in this document. */
722                 mfxU16  QPB;
723                 mfxU16  Convergence; /*!< Convergence period in the unit of 100 frames. */
724             };
725 
726             /*! Number of slices in each video frame. Each slice contains one or more macro-block rows. If NumSlice equals zero, the encoder may choose any slice partitioning
727                 allowed by the codec standard. See also mfxExtCodingOption2::NumMbPerSlice. */
728             mfxU16  NumSlice;
729             /*! Max number of all available reference frames (for AVC/HEVC, NumRefFrame defines DPB size). If NumRefFrame = 0, this parameter is not specified.
730                 See also NumRefActiveP, NumRefActiveBL0, and NumRefActiveBL1 in the mfxExtCodingOption3 structure, which set a number of active references. */
731             mfxU16  NumRefFrame;
732             /*! If not zero, specifies that ENCODE takes the input surfaces in the encoded order and uses explicit frame type control.
733                 The application must still provide GopRefDist and mfxExtCodingOption2::BRefType so the library can pack headers and build reference
734                 lists correctly. */
735             mfxU16  EncodedOrder;
736         };
737         struct {   /* Decoding Options */
738             /*! For AVC and HEVC, used to instruct the decoder to return output frames in the decoded order. Must be zero for all other decoders.
739                 When enabled, correctness of mfxFrameData::TimeStamp and FrameOrder for output surface is not guaranteed, the application should ignore them. */
740             mfxU16  DecodedOrder;
741             /*! Instructs DECODE to output extended picture structure values for additional display attributes. See the PicStruct description for details. */
742             mfxU16  ExtendedPicStruct;
743             /*! Time stamp calculation method. See the TimeStampCalc description for details. */
744             mfxU16  TimeStampCalc;
745             /*! Nonzero value indicates that slice groups are present in the bitstream. Used only by AVC decoder. */
746             mfxU16  SliceGroupsPresent;
747             /*! Nonzero value specifies the maximum required size of the decoded picture buffer in frames for AVC and HEVC decoders. */
748             mfxU16  MaxDecFrameBuffering;
749             /*! For decoders supporting dynamic resolution change (VP9), set this option to ON to allow MFXVideoDECODE_DecodeFrameAsync
750                 return MFX_ERR_REALLOC_SURFACE. See the CodingOptionValue enumerator for values of this option. Use the Query API
751                 function to check if this feature is supported. */
752             mfxU16  EnableReallocRequest;
753             /*! Special parameter for AV1 decoder. Indicates presence/absence of film grain parameters in bitstream.
754                 Also controls decoding behavior for streams with film grain parameters. MFXVideoDECODE_DecodeHeader returns nonzero FilmGrain
755                 for streams with film grain parameters and zero for streams w/o them. Decoding with film grain requires additional output surfaces.
756                 If FilmGrain` is non-zero then MFXVideoDECODE_QueryIOSurf will request more surfaces in case of external allocated video memory at decoder output.
757                 FilmGrain is passed to MFXVideoDECODE_Init function to control decoding operation for AV1 streams with film grain parameters.
758                 If FilmGrain is nonzero decoding of each frame require two output surfaces (one for reconstructed frame and one for output frame with film grain applied).
759                 The decoder returns MFX_ERR_MORE_SURFACE from MFXVideoDECODE_DecodeFrameAsync if it has insufficient output surfaces to decode frame.
760                 Application can forcibly disable the feature passing zero value of `FilmGrain` to `MFXVideoDECODE_Init`.
761                 In this case the decoder will output reconstructed frames w/o film grain applied.
762                 Application can retrieve film grain parameters for a frame by attaching extended buffer mfxExtAV1FilmGrainParam to mfxFrameSurface1.
763                 If stream has no film grain parameters `FilmGrain` passed to `MFXVideoDECODE_Init` is ignored by the decoder. */
764             mfxU16  FilmGrain;
765             /*! If not zero, it forces SDK to attempt to decode bitstream even if a decoder may not support all features associated with given CodecLevel. Decoder may produce visual artifacts. Only AVC decoder supports this field. */
766             mfxU16  IgnoreLevelConstrain;
767             /*! This flag is used to disable output of main decoding channel. When it's ON SkipOutput = MFX_CODINGOPTION_ON decoder outputs only video processed channels. For pure decode this flag should be always disabled. */
768             mfxU16  SkipOutput;
769             mfxU16  reserved2[4];
770         };
771         struct {   /* JPEG Decoding Options */
772             /*! Specify the chroma sampling format that has been used to encode a JPEG picture. See the ChromaFormat enumerator for details. */
773             mfxU16  JPEGChromaFormat;
774             /*! Rotation option of the output JPEG picture. See the Rotation enumerator for details. */
775             mfxU16  Rotation;
776             /*! Specify the color format that has been used to encode a JPEG picture. See the JPEGColorFormat enumerator for details. */
777             mfxU16  JPEGColorFormat;
778             /*! Specify JPEG scan type for decoder. See the JPEGScanType enumerator for details. */
779             mfxU16  InterleavedDec;
780             mfxU8   SamplingFactorH[4]; /*!< Horizontal sampling factor. */
781             mfxU8   SamplingFactorV[4]; /*!< Vertical sampling factor. */
782             mfxU16  reserved3[5];
783         };
784         struct {   /* JPEG Encoding Options */
785             /*! Specify interleaved or non-interleaved scans. If it is equal to MFX_SCANTYPE_INTERLEAVED then the image is encoded as interleaved,
786                 all components are encoded in one scan. See the JPEG Scan Type enumerator for details. */
787             mfxU16  Interleaved;
788             /*! Specifies the image quality if the application does not specified quantization table.
789                 The value is from 1 to 100 inclusive. “100” is the best quality. */
790             mfxU16  Quality;
791             /*! Specifies the number of MCU in the restart interval. “0” means no restart interval. */
792             mfxU16  RestartInterval;
793             mfxU16  reserved5[10];
794         };
795     };
796 } mfxInfoMFX;
797 MFX_PACK_END()
798 
799 MFX_PACK_BEGIN_USUAL_STRUCT()
800 /*! Specifies configurations for video processing. A zero value in any of the fields indicates
801    that the corresponding field is not explicitly specified. */
802 typedef struct {
803     mfxU32  reserved[8];
804     mfxFrameInfo    In;  /*!< Input format for video processing. */
805     mfxFrameInfo    Out; /*!< Output format for video processing. */
806 } mfxInfoVPP;
807 MFX_PACK_END()
808 
809 MFX_PACK_BEGIN_STRUCT_W_PTR()
810 /*! Configuration parameters for encoding, decoding, transcoding, and video processing. */
811 typedef struct {
812     /*! Unique component ID that will be passed by the library to mfxFrameAllocRequest. Useful in pipelines where several
813         components of the same type share the same allocator. */
814     mfxU32  AllocId;
815     mfxU32  reserved[2];
816     mfxU16  reserved3;
817     /*! Specifies how many asynchronous operations an application performs before the application explicitly synchronizes the result.
818         If zero, the value is not specified. */
819     mfxU16  AsyncDepth;
820 
821     union {
822         mfxInfoMFX  mfx; /*!< Configurations related to encoding, decoding, and transcoding. See the definition of the mfxInfoMFX structure for details. */
823         mfxInfoVPP  vpp; /*!< Configurations related to video processing. See the definition of the mfxInfoVPP structure for details. */
824     };
825     /*! Specifies the content protection mechanism. See the Protected enumerator for a list of supported protection schemes. */
826     mfxU16  Protected;
827     /*! Input and output memory access types for functions. See the enumerator IOPattern for details.
828         The Query API functions return the natively supported IOPattern if the Query input argument is NULL.
829         This parameter is a mandated input for QueryIOSurf and Init API functions. The output pattern must be specified for DECODE.
830         The input pattern must be specified for ENCODE. Both input and output pattern must be specified for VPP. */
831     mfxU16  IOPattern;
832     mfxExtBuffer** ExtParam; /*!< The number of extra configuration structures attached to this structure. */
833     mfxU16  NumExtParam;     /*!< Points to an array of pointers to the extra configuration structures. See the ExtendedBufferID enumerator
834                                   for a list of extended configurations.
835                                   The list of extended buffers should not contain duplicated entries, such as entries of the same type.
836                                   If the  mfxVideoParam structure is used to query library capability, then the list of extended buffers attached to the input
837                                   and output mfxVideoParam structure should be equal, that is, it should contain the same number of extended
838                                   buffers of the same type. */
839     mfxU16  reserved2;
840 } mfxVideoParam;
841 MFX_PACK_END()
842 
843 /*! The IOPattern enumerator itemizes memory access patterns for API functions. Use bit-ORed values to specify an input access
844     pattern and an output access pattern. */
845 enum {
846     MFX_IOPATTERN_IN_VIDEO_MEMORY   = 0x01, /*!< Input to functions is a video memory surface. */
847     MFX_IOPATTERN_IN_SYSTEM_MEMORY  = 0x02, /*!< Input to functions is a linear buffer directly in system memory or in system memory through an external allocator. */
848     MFX_IOPATTERN_OUT_VIDEO_MEMORY  = 0x10, /*!< Output to functions is a video memory surface.  */
849     MFX_IOPATTERN_OUT_SYSTEM_MEMORY = 0x20 /*!< Output to functions is a linear buffer directly in system memory or in system memory through an external allocator.  */
850 };
851 
852 /*! The CodecFormatFourCC enumerator itemizes codecs in the FourCC format. */
853 enum {
854     MFX_CODEC_AVC         =MFX_MAKEFOURCC('A','V','C',' '), /*!< AVC, H.264, or MPEG-4, part 10 codec. */
855     MFX_CODEC_HEVC        =MFX_MAKEFOURCC('H','E','V','C'), /*!< HEVC codec. */
856     MFX_CODEC_MPEG2       =MFX_MAKEFOURCC('M','P','G','2'), /*!< MPEG-2 codec. */
857     MFX_CODEC_VC1         =MFX_MAKEFOURCC('V','C','1',' '), /*!< VC-1 codec. */
858     MFX_CODEC_CAPTURE     =MFX_MAKEFOURCC('C','A','P','T'), /*!<  */
859     MFX_CODEC_VP9         =MFX_MAKEFOURCC('V','P','9',' '), /*!< VP9 codec. */
860     MFX_CODEC_AV1         =MFX_MAKEFOURCC('A','V','1',' ')  /*!< AV1 codec. */
861 };
862 
863 /*!
864 The CodecProfile enumerator itemizes codec profiles for all codecs.
865 CodecLevel
866 */
867 enum {
868     MFX_PROFILE_UNKNOWN                     =0, /*!< Unspecified profile. */
869     MFX_LEVEL_UNKNOWN                       =0, /*!< Unspecified level. */
870 
871     /*! @{ */
872     /* Combined with H.264 profile these flags impose additional constrains. See H.264 specification for the list of constrains. */
873     MFX_PROFILE_AVC_CONSTRAINT_SET0     = (0x100 << 0),
874     MFX_PROFILE_AVC_CONSTRAINT_SET1     = (0x100 << 1),
875     MFX_PROFILE_AVC_CONSTRAINT_SET2     = (0x100 << 2),
876     MFX_PROFILE_AVC_CONSTRAINT_SET3     = (0x100 << 3),
877     MFX_PROFILE_AVC_CONSTRAINT_SET4     = (0x100 << 4),
878     MFX_PROFILE_AVC_CONSTRAINT_SET5     = (0x100 << 5),
879     /*! @} */
880 
881     /*! @{ */
882     /* H.264 Profiles. */
883     MFX_PROFILE_AVC_BASELINE                =66,
884     MFX_PROFILE_AVC_MAIN                    =77,
885     MFX_PROFILE_AVC_EXTENDED                =88,
886     MFX_PROFILE_AVC_HIGH                    =100,
887     MFX_PROFILE_AVC_HIGH10                  =110,
888     MFX_PROFILE_AVC_HIGH_422                =122,
889     MFX_PROFILE_AVC_CONSTRAINED_BASELINE    =MFX_PROFILE_AVC_BASELINE + MFX_PROFILE_AVC_CONSTRAINT_SET1,
890     MFX_PROFILE_AVC_CONSTRAINED_HIGH        =MFX_PROFILE_AVC_HIGH     + MFX_PROFILE_AVC_CONSTRAINT_SET4
891                                                                       + MFX_PROFILE_AVC_CONSTRAINT_SET5,
892     MFX_PROFILE_AVC_PROGRESSIVE_HIGH        =MFX_PROFILE_AVC_HIGH     + MFX_PROFILE_AVC_CONSTRAINT_SET4,
893     /*! @} */
894 
895     /*! @{ */
896     /* H.264 level 1-1.3 */
897     MFX_LEVEL_AVC_1                         =10,
898     MFX_LEVEL_AVC_1b                        =9,
899     MFX_LEVEL_AVC_11                        =11,
900     MFX_LEVEL_AVC_12                        =12,
901     MFX_LEVEL_AVC_13                        =13,
902     /*! @} */
903     /*! @{ */
904     /* H.264 level 2-2.2 */
905     MFX_LEVEL_AVC_2                         =20,
906     MFX_LEVEL_AVC_21                        =21,
907     MFX_LEVEL_AVC_22                        =22,
908     /*! @} */
909     /*! @{ */
910     /* H.264 level 3-3.2 */
911     MFX_LEVEL_AVC_3                         =30,
912     MFX_LEVEL_AVC_31                        =31,
913     MFX_LEVEL_AVC_32                        =32,
914     /*! @} */
915     /*! @{ */
916     /* H.264 level 4-4.2 */
917     MFX_LEVEL_AVC_4                         =40,
918     MFX_LEVEL_AVC_41                        =41,
919     MFX_LEVEL_AVC_42                        =42,
920     /*! @} */
921     /*! @{ */
922     /* H.264 level 5-5.2 */
923     MFX_LEVEL_AVC_5                         =50,
924     MFX_LEVEL_AVC_51                        =51,
925     MFX_LEVEL_AVC_52                        =52,
926     /*! @} */
927     /*! @{ */
928     /* H.264 level 6-6.2 */
929     MFX_LEVEL_AVC_6                         =60,
930     MFX_LEVEL_AVC_61                        =61,
931     MFX_LEVEL_AVC_62                        =62,
932     /*! @} */
933 
934     /*! @{ */
935     /* MPEG2 Profiles. */
936     MFX_PROFILE_MPEG2_SIMPLE                =0x50,
937     MFX_PROFILE_MPEG2_MAIN                  =0x40,
938     MFX_PROFILE_MPEG2_HIGH                  =0x10,
939     /*! @} */
940 
941     /*! @{ */
942     /* MPEG2 Levels. */
943     MFX_LEVEL_MPEG2_LOW                     =0xA,
944     MFX_LEVEL_MPEG2_MAIN                    =0x8,
945     MFX_LEVEL_MPEG2_HIGH                    =0x4,
946     MFX_LEVEL_MPEG2_HIGH1440                =0x6,
947     /*! @} */
948 
949     /*! @{ */
950     /* VC-1 Profiles. */
951     MFX_PROFILE_VC1_SIMPLE                  =(0+1),
952     MFX_PROFILE_VC1_MAIN                    =(4+1),
953     MFX_PROFILE_VC1_ADVANCED                =(12+1),
954     /*! @} */
955 
956     /*! @{ */
957     /* VC-1 Level Low (simple & main profiles) */
958     MFX_LEVEL_VC1_LOW                       =(0+1),
959     MFX_LEVEL_VC1_MEDIAN                    =(2+1),
960     MFX_LEVEL_VC1_HIGH                      =(4+1),
961     /*! @} */
962 
963     /*! @{ */
964     /* VC-1 advanced profile levels */
965     MFX_LEVEL_VC1_0                         =(0x00+1),
966     MFX_LEVEL_VC1_1                         =(0x01+1),
967     MFX_LEVEL_VC1_2                         =(0x02+1),
968     MFX_LEVEL_VC1_3                         =(0x03+1),
969     MFX_LEVEL_VC1_4                         =(0x04+1),
970     /*! @} */
971 
972     /*! @{ */
973     /* HEVC profiles */
974     MFX_PROFILE_HEVC_MAIN             =1,
975     MFX_PROFILE_HEVC_MAIN10           =2,
976     MFX_PROFILE_HEVC_MAINSP           =3,
977     MFX_PROFILE_HEVC_REXT             =4,
978     MFX_PROFILE_HEVC_SCC              =9,
979     /*! @} */
980 
981     /*! @{ */
982     /* HEVC levels */
983     MFX_LEVEL_HEVC_1   = 10,
984     MFX_LEVEL_HEVC_2   = 20,
985     MFX_LEVEL_HEVC_21  = 21,
986     MFX_LEVEL_HEVC_3   = 30,
987     MFX_LEVEL_HEVC_31  = 31,
988     MFX_LEVEL_HEVC_4   = 40,
989     MFX_LEVEL_HEVC_41  = 41,
990     MFX_LEVEL_HEVC_5   = 50,
991     MFX_LEVEL_HEVC_51  = 51,
992     MFX_LEVEL_HEVC_52  = 52,
993     MFX_LEVEL_HEVC_6   = 60,
994     MFX_LEVEL_HEVC_61  = 61,
995     MFX_LEVEL_HEVC_62  = 62,
996     /*! @} */
997 
998     /*! @{ */
999     /* HEVC tiers */
1000     MFX_TIER_HEVC_MAIN  = 0,
1001     MFX_TIER_HEVC_HIGH  = 0x100,
1002     /*! @} */
1003 
1004     /*! @{ */
1005     /* VP9 Profiles */
1006     MFX_PROFILE_VP9_0                       = 1,
1007     MFX_PROFILE_VP9_1                       = 2,
1008     MFX_PROFILE_VP9_2                       = 3,
1009     MFX_PROFILE_VP9_3                       = 4,
1010     /*! @} */
1011 
1012     /*! @{ */
1013     /* AV1 Profiles */
1014     MFX_PROFILE_AV1_MAIN                    = 1,
1015     MFX_PROFILE_AV1_HIGH                    = 2,
1016     MFX_PROFILE_AV1_PRO                     = 3,
1017     /*! @} */
1018 
1019     /*! @{ */
1020     /* AV1 Levels */
1021     MFX_LEVEL_AV1_2                         = 20,
1022     MFX_LEVEL_AV1_21                        = 21,
1023     MFX_LEVEL_AV1_22                        = 22,
1024     MFX_LEVEL_AV1_23                        = 23,
1025     MFX_LEVEL_AV1_3                         = 30,
1026     MFX_LEVEL_AV1_31                        = 31,
1027     MFX_LEVEL_AV1_32                        = 32,
1028     MFX_LEVEL_AV1_33                        = 33,
1029     MFX_LEVEL_AV1_4                         = 40,
1030     MFX_LEVEL_AV1_41                        = 41,
1031     MFX_LEVEL_AV1_42                        = 42,
1032     MFX_LEVEL_AV1_43                        = 43,
1033     MFX_LEVEL_AV1_5                         = 50,
1034     MFX_LEVEL_AV1_51                        = 51,
1035     MFX_LEVEL_AV1_52                        = 52,
1036     MFX_LEVEL_AV1_53                        = 53,
1037     MFX_LEVEL_AV1_6                         = 60,
1038     MFX_LEVEL_AV1_61                        = 61,
1039     MFX_LEVEL_AV1_62                        = 62,
1040     MFX_LEVEL_AV1_63                        = 63,
1041     MFX_LEVEL_AV1_7                         = 70,
1042     MFX_LEVEL_AV1_71                        = 71,
1043     MFX_LEVEL_AV1_72                        = 72,
1044     MFX_LEVEL_AV1_73                        = 73,
1045     /*! @} */
1046 };
1047 
1048 /*! The GopOptFlag enumerator itemizes special properties in the GOP (Group of Pictures) sequence. */
1049 enum {
1050     /*!
1051        The encoder generates closed GOP if this flag is set. Frames in this GOP do not use frames in previous GOP as reference.
1052 
1053        The encoder generates open GOP if this flag is not set. In this GOP frames prior to the first frame of GOP in display order may use
1054        frames from previous GOP as reference. Frames subsequent to the first frame of GOP in display order do not use frames from previous
1055        GOP as reference.
1056 
1057        The AVC encoder ignores this flag if IdrInterval in mfxInfoMFX structure is set to 0, i.e. if every GOP starts from IDR frame.
1058        In this case, GOP is encoded as closed.
1059 
1060        This flag does not affect long-term reference frames.
1061     */
1062     MFX_GOP_CLOSED          =1,
1063     /*!
1064        The encoder must strictly follow the given GOP structure as defined by parameter GopPicSize, GopRefDist etc in the mfxVideoParam structure.
1065        Otherwise, the encoder can adapt the GOP structure for better efficiency, whose range is constrained by parameter GopPicSize and
1066        GopRefDist etc. See also description of AdaptiveI and AdaptiveB fields in the mfxExtCodingOption2 structure.
1067     */
1068     MFX_GOP_STRICT          =2
1069 };
1070 
1071 /*! The TargetUsage enumerator itemizes a range of numbers from MFX_TARGETUSAGE_1, best quality, to MFX_TARGETUSAGE_7, best speed.
1072     It indicates trade-offs between quality and speed. The application can use any number in the range. The actual number of supported
1073     target usages depends on implementation. If specified target usage is not supported, the encoder will use the closest supported value. */
1074 enum {
1075     MFX_TARGETUSAGE_1    =1, /*!< Best quality */
1076     MFX_TARGETUSAGE_2    =2,
1077     MFX_TARGETUSAGE_3    =3,
1078     MFX_TARGETUSAGE_4    =4, /*!< Balanced quality and speed. */
1079     MFX_TARGETUSAGE_5    =5,
1080     MFX_TARGETUSAGE_6    =6,
1081     MFX_TARGETUSAGE_7    =7, /*!< Best speed */
1082 
1083     MFX_TARGETUSAGE_UNKNOWN         =0, /*!< Unspecified target usage. */
1084     MFX_TARGETUSAGE_BEST_QUALITY    =MFX_TARGETUSAGE_1, /*!< Best quality. */
1085     MFX_TARGETUSAGE_BALANCED        =MFX_TARGETUSAGE_4, /*!< Balanced quality and speed. */
1086     MFX_TARGETUSAGE_BEST_SPEED      =MFX_TARGETUSAGE_7  /*!< Best speed. */
1087 };
1088 
1089 /*! The RateControlMethod enumerator itemizes bitrate control methods. */
1090 enum {
1091     MFX_RATECONTROL_CBR       =1, /*!< Use the constant bitrate control algorithm. */
1092     MFX_RATECONTROL_VBR       =2, /*!< Use the variable bitrate control algorithm. */
1093     MFX_RATECONTROL_CQP       =3, /*!< Use the constant quantization parameter algorithm. */
1094     MFX_RATECONTROL_AVBR      =4, /*!< Use the average variable bitrate control algorithm. */
1095     MFX_RATECONTROL_RESERVED1 =5,
1096     MFX_RATECONTROL_RESERVED2 =6,
1097     MFX_RATECONTROL_RESERVED3 =100,
1098     MFX_RATECONTROL_RESERVED4 =7,
1099     /*!
1100        Use the VBR algorithm with look ahead. It is a special bitrate control mode in the AVC encoder that has been designed
1101        to improve encoding quality. It works by performing extensive analysis of several dozen frames before the actual encoding and as a side
1102        effect significantly increases encoding delay and memory consumption.
1103 
1104        The only available rate control parameter in this mode is mfxInfoMFX::TargetKbps. Two other parameters, MaxKbps and InitialDelayInKB,
1105        are ignored. To control LA depth the application can use mfxExtCodingOption2::LookAheadDepth parameter.
1106 
1107        This method is not HRD compliant.
1108     */
1109     MFX_RATECONTROL_LA        =8,
1110     /*!
1111        Use the Intelligent Constant Quality algorithm. This algorithm improves subjective video quality of encoded stream. Depending on content,
1112        it may or may not decrease objective video quality. Only one control parameter is used - quality factor, specified by mfxInfoMFX::ICQQuality.
1113     */
1114     MFX_RATECONTROL_ICQ       =9,
1115     /*!
1116        Use the Video Conferencing Mode algorithm. This algorithm is similar to the VBR and uses the same set of parameters mfxInfoMFX::InitialDelayInKB,
1117        TargetKbpsandMaxKbps. It is tuned for IPPP GOP pattern and streams with strong temporal correlation between frames.
1118        It produces better objective and subjective video quality in these conditions than other bitrate control algorithms.
1119        It does not support interlaced content, B-frames and produced stream is not HRD compliant.
1120     */
1121     MFX_RATECONTROL_VCM       =10,
1122     /*!
1123        Use Intelligent Constant Quality algorithm with look ahead. Quality factor is specified by mfxInfoMFX::ICQQuality.
1124        To control LA depth the application can use mfxExtCodingOption2::LookAheadDepth parameter.
1125 
1126        This method is not HRD compliant.
1127     */
1128     MFX_RATECONTROL_LA_ICQ    =11,
1129     /*!
1130        MFX_RATECONTROL_LA_EXT has been removed
1131     */
1132 
1133     /*! Use HRD compliant look ahead rate control algorithm. */
1134     MFX_RATECONTROL_LA_HRD    =13,
1135     /*!
1136        Use the variable bitrate control algorithm with constant quality. This algorithm trying to achieve the target subjective quality with
1137        the minimum number of bits, while the bitrate constraint and HRD compliance are satisfied. It uses the same set of parameters
1138        as VBR and quality factor specified by mfxExtCodingOption3::QVBRQuality.
1139     */
1140     MFX_RATECONTROL_QVBR      =14,
1141 };
1142 
1143 /*!
1144    The TrellisControl enumerator is used to control trellis quantization in AVC encoder. The application can turn it on
1145    or off for any combination of I-, P- and B-frames by combining different enumerator values. For example, MFX_TRELLIS_I | MFX_TRELLIS_B
1146    turns it on for I- and B-frames.
1147 
1148    @note Due to performance reason on some target usages trellis quantization is always turned off and this control is ignored by the encoder.
1149 */
1150 enum {
1151     MFX_TRELLIS_UNKNOWN =0,    /*!< Default value, it is up to the encoder to turn trellis quantization on or off. */
1152     MFX_TRELLIS_OFF     =0x01, /*!< Turn trellis quantization off for all frame types. */
1153     MFX_TRELLIS_I       =0x02, /*!< Turn trellis quantization on for I-frames. */
1154     MFX_TRELLIS_P       =0x04, /*!< Turn trellis quantization on for P-frames. */
1155     MFX_TRELLIS_B       =0x08  /*!< Turn trellis quantization on for B-frames. */
1156 };
1157 
1158 MFX_PACK_BEGIN_USUAL_STRUCT()
1159 /*!
1160    Specifies additional options for encoding.
1161 
1162    The application can attach this extended buffer to the mfxVideoParam structure to configure initialization.
1163 */
1164 typedef struct {
1165     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_CODING_OPTION. */
1166 
1167     mfxU16      reserved1;
1168     mfxU16      RateDistortionOpt;      /*!< Set this flag if rate distortion optimization is needed. See the CodingOptionValue enumerator for values of this option. */
1169     mfxU16      MECostType;             /*!< Motion estimation cost type. This value is reserved and must be zero. */
1170     mfxU16      MESearchType;           /*!< Motion estimation search algorithm. This value is reserved and must be zero. */
1171     mfxI16Pair  MVSearchWindow;         /*!< Rectangular size of the search window for motion estimation. This parameter is reserved and must be (0, 0). */
1172     MFX_DEPRECATED mfxU16      EndOfSequence;          /* Deprecated */
1173     mfxU16      FramePicture;           /*!< Set this flag to encode interlaced fields as interlaced frames. This flag does not affect progressive input frames. See the CodingOptionValue enumerator for values of this option. */
1174 
1175     mfxU16      CAVLC;                  /*!< If set, CAVLC is used; if unset, CABAC is used for encoding. See the CodingOptionValue enumerator for values of this option. */
1176     mfxU16      reserved2[2];
1177     /*!
1178        Set this flag to insert the recovery point SEI message at the beginning of every intra refresh cycle. See the description of
1179        IntRefType in mfxExtCodingOption2 structure for details on how to enable and configure intra refresh.
1180 
1181        If intra refresh is not enabled then this flag is ignored.
1182 
1183        See the CodingOptionValue enumerator for values of this option.
1184     */
1185     mfxU16      RecoveryPointSEI;
1186     /*!
1187        Set this flag to instruct the MVC encoder to output each view in separate bitstream buffer. See the CodingOptionValue enumerator
1188        for values of this option and the Multi-View Video Coding section for more details about usage of this flag.
1189     */
1190     mfxU16      ViewOutput;
1191     /*!
1192        If this option is turned ON, then AVC encoder produces an HRD conformant bitstream. If it is turned OFF, then the AVC encoder may (but not necessarily) violate HRD conformance. That is, this option can force the encoder to produce an HRD conformant stream, but
1193        cannot force it to produce a non-conformant stream.
1194 
1195        See the CodingOptionValue enumerator for values of this option.
1196     */
1197     mfxU16      NalHrdConformance;
1198     /*!
1199        If set, encoder puts all SEI messages in the singe NAL unit. It includes messages provided by application and created
1200        by encoder. It is a three-states option. See CodingOptionValue enumerator for values of this option. The three states are:
1201 
1202        @li UNKNOWN Put each SEI in its own NAL unit.
1203 
1204        @li ON Put all SEI messages in the same NAL unit.
1205 
1206        @li OFF The same as unknown.
1207     */
1208     mfxU16      SingleSeiNalUnit;
1209     /*!
1210        If set and VBR rate control method is used, then VCL HRD parameters are written in bitstream with values identical to the values of the NAL HRD parameters.
1211        See the CodingOptionValue enumerator for values of this option.
1212     */
1213     mfxU16      VuiVclHrdParameters;
1214 
1215     mfxU16      RefPicListReordering;   /*!< Set this flag to activate reference picture list reordering. This value is reserved and must be zero. */
1216     mfxU16      ResetRefList;           /*!< Set this flag to reset the reference list to non-IDR I-frames of a GOP sequence. See the CodingOptionValue enumerator for values of this option. */
1217     /*!
1218        Set this flag to write the reference picture marking repetition SEI message into the output bitstream.
1219        See the CodingOptionValue enumerator for values of this option.
1220     */
1221     mfxU16      RefPicMarkRep;
1222     /*!
1223        Set this flag to instruct the AVC encoder to output bitstreams immediately after the encoder encodes a field,
1224        in the field-encoding mode. See the CodingOptionValue enumerator for values of this option.
1225     */
1226     mfxU16      FieldOutput;
1227 
1228     mfxU16      IntraPredBlockSize;   /*!< Minimum block size of intra-prediction. This value is reserved and must be zero. */
1229     mfxU16      InterPredBlockSize;   /*!< Minimum block size of inter-prediction. This value is reserved and must be zero. */
1230     mfxU16      MVPrecision;          /*!< Specify the motion estimation precision. This parameter is reserved and must be zero. */
1231     mfxU16      MaxDecFrameBuffering; /*!< Specifies the maximum number of frames buffered in a DPB. A value of zero means unspecified. */
1232 
1233     mfxU16      AUDelimiter;            /*!< Set this flag to insert the Access Unit Delimiter NAL. See the CodingOptionValue enumerator for values of this option. */
1234     MFX_DEPRECATED mfxU16      EndOfStream;            /* Deprecated */
1235     /*!
1236        Set this flag to insert the picture timing SEI with pic_struct syntax element. See sub-clauses D.1.2 and D.2.2 of the ISO/IEC 14496-10
1237        specification for the definition of this syntax element. See the CodingOptionValue enumerator for values of this option.
1238        The default value is ON.
1239     */
1240     mfxU16      PicTimingSEI;
1241     mfxU16      VuiNalHrdParameters;  /*!< Set this flag to insert NAL HRD parameters in the VUI header. See the CodingOptionValue enumerator for values of this option. */
1242 } mfxExtCodingOption;
1243 MFX_PACK_END()
1244 
1245 /*! The BRefControl enumerator is used to control usage of B-frames as reference in AVC encoder. */
1246 enum {
1247     MFX_B_REF_UNKNOWN = 0, /*!< Default value, it is up to the encoder to use B-frames as reference. */
1248     MFX_B_REF_OFF     = 1, /*!< Do not use B-frames as reference. */
1249     MFX_B_REF_PYRAMID = 2  /*!< Arrange B-frames in so-called “B pyramid” reference structure. */
1250 };
1251 
1252 /*! The LookAheadDownSampling enumerator is used to control down sampling in look ahead bitrate control mode in AVC encoder. */
1253 enum {
1254     MFX_LOOKAHEAD_DS_UNKNOWN = 0, /*!< Default value, it is up to the encoder what down sampling value to use. */
1255     MFX_LOOKAHEAD_DS_OFF     = 1, /*!< Do not use down sampling, perform estimation on original size frames. This is the slowest setting that produces the best quality. */
1256     MFX_LOOKAHEAD_DS_2x      = 2, /*!< Down sample frames two times before estimation. */
1257     MFX_LOOKAHEAD_DS_4x      = 3  /*!< Down sample frames four times before estimation. This option may significantly degrade quality. */
1258 };
1259 
1260 /*! The BPSEIControl enumerator is used to control insertion of buffering period SEI in the encoded bitstream. */
1261 enum {
1262     MFX_BPSEI_DEFAULT = 0x00, /*!< encoder decides when to insert BP SEI. */
1263     MFX_BPSEI_IFRAME  = 0x01  /*!< BP SEI should be inserted with every I-frame */
1264 };
1265 
1266 /*! The SkipFrame enumerator is used to define usage of mfxEncodeCtrl::SkipFrame parameter. */
1267 enum {
1268     MFX_SKIPFRAME_NO_SKIP         = 0, /*!< Frame skipping is disabled, mfxEncodeCtrl::SkipFrame is ignored. */
1269     MFX_SKIPFRAME_INSERT_DUMMY    = 1, /*!< Skipping is allowed, when mfxEncodeCtrl::SkipFrame is set encoder inserts into bitstream frame
1270                                             where all macroblocks are encoded as skipped. Only non-reference P- and B-frames can be skipped.
1271                                             If GopRefDist = 1 and mfxEncodeCtrl::SkipFrame is set for reference P-frame, it will be encoded
1272                                             as non-reference. */
1273     MFX_SKIPFRAME_INSERT_NOTHING  = 2, /*!< Similar to MFX_SKIPFRAME_INSERT_DUMMY, but when mfxEncodeCtrl::SkipFrame is set encoder inserts nothing into bitstream. */
1274     MFX_SKIPFRAME_BRC_ONLY        = 3, /*!< mfxEncodeCtrl::SkipFrame indicates number of missed frames before the current frame. Affects only BRC, current frame will be encoded as usual. */
1275 };
1276 
1277 /*! The IntraRefreshTypes enumerator itemizes types of intra refresh. */
1278 enum {
1279         MFX_REFRESH_NO             = 0, /*!< Encode without refresh. */
1280         MFX_REFRESH_VERTICAL       = 1, /*!< Vertical refresh, by column of MBs. */
1281         MFX_REFRESH_HORIZONTAL     = 2, /*!< Horizontal refresh, by rows of MBs. */
1282         MFX_REFRESH_SLICE          = 3  /*!< Horizontal refresh by slices without overlapping. */
1283 };
1284 
1285 MFX_PACK_BEGIN_USUAL_STRUCT()
1286 /*!
1287    Used with the mfxExtCodingOption structure to specify additional options for encoding.
1288 
1289    The application can attach this extended buffer to the mfxVideoParam structure to configure initialization and to the mfxEncodeCtrl during runtime.
1290 */
1291 typedef struct {
1292     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_CODING_OPTION2. */
1293 
1294     /*!
1295        Specifies intra refresh type. See the IntraRefreshTypes. The major goal of intra refresh is improvement of error resilience without
1296        significant impact on encoded bitstream size caused by I-frames. The  encoder achieves this by encoding part of each frame in the refresh
1297        cycle using intra MBs.
1298 
1299        This parameter is valid during initialization and
1300        runtime. When used with temporal scalability, intra refresh applied only to base layer.
1301 
1302        MFX_REFRESH_NO No refresh.
1303 
1304        MFX_REFRESH_VERTICAL Vertical refresh, by column of MBs.
1305 
1306        MFX_REFRESH_HORIZONTAL Horizontal refresh, by rows of MBs.
1307 
1308        MFX_REFRESH_SLICE Horizontal refresh by slices without overlapping.
1309 
1310        MFX_REFRESH_SLICE Library ignores IntRefCycleSize (size of refresh cycle equals number slices).
1311     */
1312     mfxU16      IntRefType;
1313     /*!
1314        Specifies number of pictures within refresh cycle starting from 2. 0 and 1 are invalid values. This parameter is valid only during initialization.
1315     */
1316     mfxU16      IntRefCycleSize;
1317     /*!
1318        Specifies QP difference for inserted intra MBs. Signed values are in the -51 to 51 range. This parameter is valid during initialization and runtime.
1319     */
1320     mfxI16      IntRefQPDelta;
1321 
1322     /*!
1323        Specify maximum encoded frame size in byte. This parameter is used in VBR based bitrate control modes and ignored in others.
1324        The encoder tries to keep frame size below specified limit but minor overshoots are possible to preserve visual quality.
1325        This parameter is valid during initialization and runtime. It is recommended to set MaxFrameSize to 5x-10x target frame size
1326        ((TargetKbps*1000)/(8* FrameRateExtN/FrameRateExtD)) for I-frames and 2x-4x target frame size for P- and B-frames.
1327     */
1328     mfxU32      MaxFrameSize;
1329     /*!
1330        Specify maximum slice size in bytes. If this parameter is specified other controls over number of slices are ignored.
1331 
1332        @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported.
1333     */
1334     mfxU32      MaxSliceSize;
1335 
1336     /*!
1337        Modifies bitrate to be in the range imposed by the encoder. The default value is ON, that is, bitrate is limited. Setting this flag to OFF may lead to violation of HRD conformance.Specifying bitrate below the encoder range might significantly affect quality.
1338 
1339        If set to ON, this option takes effect in non CQP modes:
1340        if TargetKbps is not in the range imposed by the encoder, it will be changed to be in the range.
1341 
1342        This parameter is valid only during initialization. Flag works with MFX_CODEC_AVC only, it is ignored with other codecs.
1343        See the CodingOptionValue
1344        enumerator for values of this option.
1345     */
1346     mfxU16      BitrateLimit;
1347     /*!
1348        Setting this flag enables macroblock level bitrate control that generally improves subjective visual quality. Enabling this flag may
1349        have negative impact on performance and objective visual quality metric. See the CodingOptionValue enumerator for values of this option.
1350        The default value depends on target usage settings.
1351     */
1352     mfxU16      MBBRC;
1353     /*!
1354        Set this option to ON to enable external BRC. See the CodingOptionValue enumerator for values of this option.
1355        Use the Query API function to check if this feature is supported.
1356     */
1357     mfxU16      ExtBRC;
1358     /*!
1359        Specifies the depth of the look ahead rate control algorithm. The depth value is the number of frames that the encoder analyzes before encoding. Values are in the 10 to 100 range, inclusive.
1360        To instruct the encoder to use the default value the application should zero this field.
1361     */
1362     mfxU16      LookAheadDepth;
1363     /*!
1364        Used to control trellis quantization in AVC encoder. See TrellisControl enumerator for values of this option.
1365        This parameter is valid only during initialization.
1366     */
1367     mfxU16      Trellis;
1368     /*!
1369        Controls picture parameter set repetition in AVC encoder. Set this flag to ON to repeat PPS with each frame.
1370        See the CodingOptionValue enumerator for values of this option. The default value is ON. This parameter is valid only during initialization.
1371     */
1372     mfxU16      RepeatPPS;
1373     /*!
1374        Controls usage of B-frames as reference. See BRefControl enumerator for values of this option.
1375        This parameter is valid only during initialization.
1376     */
1377     mfxU16      BRefType;
1378     /*!
1379        Controls insertion of I-frames by the encoder. Set this flag to ON to allow changing of frame type from P and B to I.
1380        This option is ignored if GopOptFlag in mfxInfoMFX structure is equal to MFX_GOP_STRICT. See the CodingOptionValue enumerator
1381        for values of this option. This parameter is valid only during initialization.
1382     */
1383     mfxU16      AdaptiveI;
1384     /*!
1385        Controls changing of frame type from B to P. Set this flag to ON enable changing of frame type from B to P. This option is ignored if
1386        GopOptFlag in mfxInfoMFX structure is equal to MFX_GOP_STRICT. See the CodingOptionValue enumerator for values of this option.
1387        This parameter is valid only during initialization.
1388     */
1389     mfxU16      AdaptiveB;
1390     /*!
1391        Controls down sampling in look ahead bitrate control mode. See LookAheadDownSampling enumerator for values
1392        of this option. This parameter is valid only during initialization.
1393     */
1394     mfxU16      LookAheadDS;
1395     /*!
1396        Specifies suggested slice size in number of macroblocks. The library can adjust this number based on platform capability.
1397        If this option is specified, that is, if it is not equal to zero, the library ignores mfxInfoMFX::NumSlice parameter.
1398     */
1399     mfxU16      NumMbPerSlice;
1400     /*!
1401        Enables usage of mfxEncodeCtrl::SkipFrameparameter. See the SkipFrame enumerator for values of this option.
1402        @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported.
1403     */
1404     mfxU16      SkipFrame;
1405     mfxU8       MinQPI; /*!< Minimum allowed QP value for I-frame types. Valid range is 1 to 51 inclusive. Zero means default value, that is, no limitations on QP.
1406                              @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported. */
1407     mfxU8       MaxQPI; /*!< Maximum allowed QP value for I-frame types. Valid range is 1 to 51 inclusive. Zero means default value, that is, no limitations on QP.
1408                              @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported. */
1409     mfxU8       MinQPP; /*!< Minimum allowed QP value for P-frame types. Valid range is 1 to 51 inclusive. Zero means default value, that is, no limitations on QP.
1410                              @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported. */
1411     mfxU8       MaxQPP; /*!< Maximum allowed QP value for P-frame types. Valid range is 1 to 51 inclusive. Zero means default value, that is, no limitations on QP.
1412                              @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported. */
1413     mfxU8       MinQPB; /*!< Minimum allowed QP value for B-frame types. Valid range is 1 to 51 inclusive. Zero means default value, that is, no limitations on QP.
1414                              @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported. */
1415     mfxU8       MaxQPB; /*!< Maximum allowed QP value for B-frame types. Valid range is 1 to 51 inclusive. Zero means default value, that is, no limitations on QP.
1416                              @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported. */
1417     /*!
1418        Sets fixed_frame_rate_flag in VUI.
1419        @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported.
1420     */
1421     mfxU16      FixedFrameRate;
1422     /*! Disables deblocking.
1423         @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported.
1424     */
1425     mfxU16      DisableDeblockingIdc;
1426     /*!
1427        Completely disables VUI in the output bitstream.
1428        @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported.
1429     */
1430     mfxU16      DisableVUI;
1431     /*!
1432        Controls insertion of buffering period SEI in the encoded bitstream. It should be one of the following values:
1433 
1434        MFX_BPSEI_DEFAULT   Encoder decides when to insert BP SEI,
1435 
1436        MFX_BPSEI_IFRAME    BP SEI should be inserted with every I-frame.
1437     */
1438     mfxU16      BufferingPeriodSEI;
1439     /*!
1440        Set this flag to ON to enable per-frame reporting of Mean Absolute Difference. This parameter is valid only during initialization.
1441     */
1442     mfxU16      EnableMAD;
1443     /*!
1444        Set this flag to ON to use raw frames for reference instead of reconstructed frames. This parameter is valid during
1445        initialization and runtime (only if was turned ON during initialization).
1446        @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported.
1447     */
1448     mfxU16      UseRawRef;
1449 } mfxExtCodingOption2;
1450 MFX_PACK_END()
1451 
1452 /*! The WeightedPred enumerator itemizes weighted prediction modes. */
1453 enum {
1454     MFX_WEIGHTED_PRED_UNKNOWN  = 0, /*!< Allow encoder to decide. */
1455     MFX_WEIGHTED_PRED_DEFAULT  = 1, /*!< Use default weighted prediction. */
1456     MFX_WEIGHTED_PRED_EXPLICIT = 2, /*!< Use explicit weighted prediction. */
1457     MFX_WEIGHTED_PRED_IMPLICIT = 3  /*!< Use implicit weighted prediction (for B-frames only). */
1458 };
1459 
1460 /*! The ScenarioInfo enumerator itemizes scenarios for the encoding session. */
1461 enum {
1462     MFX_SCENARIO_UNKNOWN             = 0,
1463     MFX_SCENARIO_DISPLAY_REMOTING    = 1,
1464     MFX_SCENARIO_VIDEO_CONFERENCE    = 2,
1465     MFX_SCENARIO_ARCHIVE             = 3,
1466     MFX_SCENARIO_LIVE_STREAMING      = 4,
1467     MFX_SCENARIO_CAMERA_CAPTURE      = 5,
1468     MFX_SCENARIO_VIDEO_SURVEILLANCE  = 6,
1469     MFX_SCENARIO_GAME_STREAMING      = 7,
1470     MFX_SCENARIO_REMOTE_GAMING       = 8
1471 };
1472 
1473 /*! The ContentInfo enumerator itemizes content types for the encoding session. */
1474 enum {
1475     MFX_CONTENT_UNKNOWN              = 0,
1476     MFX_CONTENT_FULL_SCREEN_VIDEO    = 1,
1477     MFX_CONTENT_NON_VIDEO_SCREEN     = 2
1478 };
1479 
1480 /*! The PRefType enumerator itemizes models of reference list construction and DPB management when GopRefDist=1. */
1481 enum {
1482     MFX_P_REF_DEFAULT = 0, /*!< Allow encoder to decide. */
1483     MFX_P_REF_SIMPLE  = 1, /*!< Regular sliding window used for DPB removal process. */
1484     MFX_P_REF_PYRAMID = 2  /*!< Let N be the max reference list’s size. Encoder treats each N’s frame as a 'strong'
1485                                 reference and the others as 'weak' references. The encoder uses a 'weak' reference only for
1486                                 prediction of the next frame and removes it from DPB immediately after use. 'Strong' references are removed from
1487                                 DPB by a sliding window. */
1488 };
1489 
1490 MFX_PACK_BEGIN_USUAL_STRUCT()
1491 /*!
1492    Used with mfxExtCodingOption and mfxExtCodingOption2 structures to specify additional options for encoding.
1493    The application can attach this extended buffer to the mfxVideoParam structure to configure initialization and to the mfxEncodeCtrl during runtime.
1494 */
1495 typedef struct {
1496     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_CODING_OPTION3. */
1497 
1498     mfxU16      NumSliceI; /*!< The number of slices for I-frames.
1499                                 @note Not all codecs and implementations support these values. Use the Query API function to check if this feature is supported */
1500     mfxU16      NumSliceP; /*!< The number of slices for P-frames.
1501                                 @note Not all codecs and implementations support these values. Use the Query API function to check if this feature is supported */
1502     mfxU16      NumSliceB; /*!< The number of slices for B-frames.
1503                                 @note Not all codecs and implementations support these values. Use the Query API function to check if this feature is supported */
1504 
1505     /*!
1506        When rate control method is MFX_RATECONTROL_VBR, MFX_RATECONTROL_LA, MFX_RATECONTROL_LA_HRD, or MFX_RATECONTROL_QVBR this parameter
1507        specifies the maximum bitrate averaged over a sliding window specified by WinBRCSize. For MFX_RATECONTROL_CBR this parameter is ignored and
1508        equals TargetKbps.
1509     */
1510     mfxU16      WinBRCMaxAvgKbps;
1511     /*!
1512        When rate control method is MFX_RATECONTROL_CBR, MFX_RATECONTROL_VBR, MFX_RATECONTROL_LA, MFX_RATECONTROL_LA_HRD, or MFX_RATECONTROL_QVBR
1513        this parameter specifies sliding window size in frames. Set this parameter to zero to disable sliding window.
1514     */
1515     mfxU16      WinBRCSize;
1516 
1517     /*! When rate control method is MFX_RATECONTROL_QVBR, this parameter specifies quality factor.
1518         Values are in the 1 to 51 range, where 1 corresponds to the best quality.
1519     */
1520     mfxU16      QVBRQuality;
1521     /*!
1522        Set this flag to ON to enable per-macroblock QP control. Rate control method must be MFX_RATECONTROL_CQP. See the CodingOptionValue
1523        enumerator for values of this option. This parameter is valid only during initialization.
1524     */
1525     mfxU16      EnableMBQP;
1526     /*!
1527        Distance between the beginnings of the intra-refresh cycles in frames. Zero means no distance between cycles.
1528     */
1529     mfxU16      IntRefCycleDist;
1530     /*!
1531        Set this flag to ON to enable the ENC mode decision algorithm to bias to fewer B Direct/Skip types. Applies only to B-frames,
1532        all other frames will ignore this setting. See the CodingOptionValue enumerator for values of this option.
1533     */
1534     mfxU16      DirectBiasAdjustment;
1535     /*!
1536        Enables global motion bias. See the CodingOptionValue enumerator for values of this option.
1537     */
1538     mfxU16      GlobalMotionBiasAdjustment;
1539     /*!
1540        Values are:
1541 
1542        @li 0: Set MV cost to be 0.
1543 
1544        @li 1: Scale MV cost to be 1/2 of the default value.
1545 
1546        @li 2: Scale MV cost to be 1/4 of the default value.
1547 
1548        @li 3: Scale MV cost to be 1/8 of the default value.
1549     */
1550     mfxU16      MVCostScalingFactor;
1551     /*!
1552        Set this flag to ON to enable usage of mfxExtMBDisableSkipMap. See the CodingOptionValue enumerator for values of this option.
1553        This parameter is valid only during initialization.
1554     */
1555     mfxU16      MBDisableSkipMap;
1556 
1557     mfxU16      WeightedPred;   /*!< Weighted prediction mode. See the WeightedPred enumerator for values of these options. */
1558     mfxU16      WeightedBiPred; /*!< Weighted prediction mode. See the WeightedPred enumerator for values of these options. */
1559 
1560     /*!
1561        Instructs encoder whether aspect ratio info should present in VUI parameters. See the CodingOptionValue enumerator for values of this option.
1562     */
1563     mfxU16      AspectRatioInfoPresent;
1564     /*!
1565        Instructs encoder whether overscan info should present in VUI parameters. See the CodingOptionValue enumerator for values of this option.
1566     */
1567     mfxU16      OverscanInfoPresent;
1568     /*!
1569        ON indicates that the cropped decoded pictures output are suitable for display using overscan. OFF indicates that the cropped decoded
1570        pictures output contain visually important information in the entire region out to the edges of the cropping rectangle of the picture.
1571        See the CodingOptionValue enumerator for values of this option.
1572     */
1573     mfxU16      OverscanAppropriate;
1574     /*!
1575        Instructs encoder whether frame rate info should present in VUI parameters. See the CodingOptionValue enumerator for values of this option.
1576     */
1577     mfxU16      TimingInfoPresent;
1578     /*!
1579        Instructs encoder whether bitstream restriction info should present in VUI parameters. See the CodingOptionValue enumerator for values of this option.
1580     */
1581     mfxU16      BitstreamRestriction;
1582     /*!
1583        Corresponds to AVC syntax element low_delay_hrd_flag (VUI). See the CodingOptionValue enumerator for values of this option.
1584     */
1585     mfxU16      LowDelayHrd;
1586     /*!
1587        When set to OFF, no sample outside the picture boundaries and no sample at a fractional sample position for which the sample value
1588        is derived using one or more samples outside the picture boundaries is used for inter prediction of any sample.
1589 
1590        When set to ON, one or more samples outside picture boundaries may be used in inter prediction.
1591 
1592        See the CodingOptionValue enumerator for values of this option.
1593     */
1594     mfxU16      MotionVectorsOverPicBoundaries;
1595     mfxU16      reserved1[2];
1596 
1597     mfxU16      ScenarioInfo; /*!< Provides a hint to encoder about the scenario for the encoding session. See the ScenarioInfo enumerator for values of this option. */
1598     mfxU16      ContentInfo;  /*!< Provides a hint to encoder about the content for the encoding session. See the ContentInfo enumerator for values of this option. */
1599 
1600     mfxU16      PRefType;     /*!< When GopRefDist=1, specifies the model of reference list construction and DPB management. See the PRefType enumerator for values of this option. */
1601     /*!
1602        Instructs encoder whether internal fade detection algorithm should be used for calculation of weigh/offset values for pred_weight_table
1603        unless application provided mfxExtPredWeightTable for this frame. See the CodingOptionValue enumerator for values of this option.
1604     */
1605     mfxU16      FadeDetection;
1606     mfxU16      reserved2[2];
1607     /*!
1608        Set this flag to OFF to make HEVC encoder use regular P-frames instead of GPB. See the CodingOptionValue enumerator for values of this option.
1609     */
1610     mfxU16      GPB;
1611 
1612     /*!
1613        Same as mfxExtCodingOption2::MaxFrameSize but affects only I-frames. MaxFrameSizeI must be set if MaxFrameSizeP is set.
1614        If MaxFrameSizeI is not specified or greater than spec limitation, spec limitation will be applied to the sizes of I-frames.
1615     */
1616     mfxU32      MaxFrameSizeI;
1617     /*!
1618        Same as mfxExtCodingOption2::MaxFrameSize but affects only P/B-frames. If MaxFrameSizeP equals 0, the library sets MaxFrameSizeP
1619        equal to MaxFrameSizeI. If MaxFrameSizeP is not specified or greater than spec limitation, spec limitation will be applied to the
1620        sizes of P/B-frames.
1621     */
1622     mfxU32      MaxFrameSizeP;
1623     mfxU32      reserved3[3];
1624 
1625     /*!
1626        Enables QPOffset control. See the CodingOptionValue enumerator for values of this option.
1627     */
1628     mfxU16      EnableQPOffset;
1629     /*!
1630        Specifies QP offset per pyramid layer when EnableQPOffset is set to ON and RateControlMethod is CQP.
1631 
1632        For B-pyramid, B-frame QP = QPB + QPOffset[layer].
1633 
1634        For P-pyramid, P-frame QP = QPP + QPOffset[layer].
1635     */
1636     mfxI16      QPOffset[8];              /* FrameQP = QPX + QPOffset[pyramid_layer]; QPX = QPB for B-pyramid, QPP for P-pyramid */
1637 
1638 
1639     mfxU16      NumRefActiveP[8];   /*!< Max number of active references for P-frames. Array index is pyramid layer. */
1640     mfxU16      NumRefActiveBL0[8]; /*!< Max number of active references for B-frames in reference picture list 0. Array index is pyramid layer. */
1641     mfxU16      NumRefActiveBL1[8]; /*!< Max number of active references for B-frames in reference picture list 1. Array index is pyramid layer. */
1642 
1643     mfxU16      reserved6;
1644     /*!
1645        For HEVC if this option is turned ON, the transform_skip_enabled_flag will be set to 1 in PPS. OFF specifies that transform_skip_enabled_flag will be set to 0.
1646     */
1647     mfxU16      TransformSkip;
1648     /*!
1649        Minus 1 specifies target encoding chroma format (see ChromaFormatIdc enumerator). May differ from the source format.
1650        TargetChromaFormatPlus1 = 0 specifies the default target chroma format which is equal to source (mfxVideoParam::mfx::FrameInfo::ChromaFormat + 1),
1651        except RGB4 source format. In case of RGB4 source format default target , chroma format is 4:2:0 (instead of 4:4:4)
1652        for the purpose of backward compatibility.
1653     */
1654     mfxU16      TargetChromaFormatPlus1;
1655     /*!
1656        Target encoding bit-depth for luma samples. May differ from source bit-depth. 0 specifies a default target bit-depth that is equal to
1657        source (mfxVideoParam::mfx::FrameInfo::BitDepthLuma).
1658     */
1659     mfxU16      TargetBitDepthLuma;
1660     /*!
1661        Target encoding bit-depth for chroma samples. May differ from source bit-depth. 0 specifies a default target bit-depth that is equal to
1662        source (mfxVideoParam::mfx::FrameInfo::BitDepthChroma).
1663     */
1664     mfxU16      TargetBitDepthChroma;
1665     mfxU16      BRCPanicMode; /*!< Controls panic mode in AVC and MPEG2 encoders. */
1666 
1667     /*!
1668        When rate control method is MFX_RATECONTROL_VBR, MFX_RATECONTROL_QVBR or MFX_RATECONTROL_VCM this parameter specifies frame size
1669        tolerance. Set this parameter to MFX_CODINGOPTION_ON to allow strictly obey average frame size set by MaxKbps, for example cases when
1670        MaxFrameSize == (MaxKbps*1000)/(8* FrameRateExtN/FrameRateExtD). Also MaxFrameSizeI and MaxFrameSizeP can be set separately.
1671     */
1672     mfxU16      LowDelayBRC;
1673     /*!
1674        Set this flag to ON to enable usage of mfxExtMBForceIntra for AVC encoder. See the CodingOptionValue enumerator
1675        for values of this option. This parameter is valid only during initialization.
1676     */
1677     mfxU16      EnableMBForceIntra;
1678     /*!
1679        If this flag is set to ON, BRC may decide a larger P- or B-frame size than what MaxFrameSizeP dictates when the scene change is detected.
1680        It may benefit the video quality. AdaptiveMaxFrameSize feature is not supported with LowPower ON or if the value of MaxFrameSizeP = 0.
1681     */
1682     mfxU16      AdaptiveMaxFrameSize;
1683 
1684     /*!
1685        Controls AVC encoder attempts to predict from small partitions. Default value allows encoder to choose preferred mode.
1686        MFX_CODINGOPTION_ON forces encoder to favor quality and MFX_CODINGOPTION_OFF forces encoder to favor performance.
1687     */
1688     mfxU16      RepartitionCheckEnable;
1689     mfxU16      reserved5[3];
1690     mfxU16      EncodedUnitsInfo;          /*!< Set this flag to ON to make encoded units info available in mfxExtEncodedUnitsInfo. */
1691     /*!
1692        If this flag is set to ON, the HEVC encoder uses the NAL unit type provided by the application in the mfxEncodeCtrl::MfxNalUnitType field.
1693        This parameter is valid only during initialization.
1694        @note Not all codecs and implementations support this value. Use the Query API function to check if this feature is supported.
1695     */
1696     mfxU16      EnableNalUnitType;
1697 
1698     union {
1699         MFX_DEPRECATED mfxU16      ExtBrcAdaptiveLTR; /* Deprecated */
1700 
1701         /*!
1702             If this flag is set to ON, encoder will mark, modify, or remove LTR frames based on encoding parameters and content
1703             properties. Turn OFF to prevent Adaptive marking of Long Term Reference Frames.
1704         */
1705         mfxU16      AdaptiveLTR;
1706     };
1707     /*!
1708        If this flag is set to ON, encoder adaptively selects one of implementation-defined quantization matrices for each frame.
1709        Non-default quantization matrices aim to improve subjective visual quality under certain conditions.
1710        Their number and definitions are API implementation specific.
1711        If this flag is set to OFF, default quantization matrix is used for all frames.
1712        This parameter is valid only during initialization.
1713     */
1714     mfxU16      AdaptiveCQM;
1715     /*!
1716        If this flag is set to ON, encoder adaptively selects list of reference frames to imrove encoding quality.
1717        Enabling of the flag can increase computation complexity and introduce additional delay.
1718        If this flag is set to OFF, regular reference frames are used for encoding.
1719     */
1720     mfxU16      AdaptiveRef;
1721 
1722 #ifdef ONEVPL_EXPERIMENTAL
1723     /*!
1724        The tri-state option specifies hint for the library to execute encoding tools processing on CPU.
1725        It may give better encoding quality, but leads to higher CPU utilization.
1726        The library can ignore MFX_CODINGOPTION_ON if processing on CPU is not supported.
1727     */
1728     mfxU16      CPUEncToolsProcessing;
1729     mfxU16      reserved[160];
1730 #else
1731     mfxU16      reserved[161];
1732 #endif
1733 
1734 } mfxExtCodingOption3;
1735 MFX_PACK_END()
1736 
1737 /*! IntraPredBlockSize/InterPredBlockSize specifies the minimum block size of inter-prediction. */
1738 enum {
1739     MFX_BLOCKSIZE_UNKNOWN   = 0, /*!< Unspecified. */
1740     MFX_BLOCKSIZE_MIN_16X16 = 1, /*!< 16x16 minimum block size.              */
1741     MFX_BLOCKSIZE_MIN_8X8   = 2, /*!< 8x8 minimum block size. May be 16x16 or 8x8.         */
1742     MFX_BLOCKSIZE_MIN_4X4   = 3  /*!< 4x4 minimum block size. May be 16x16, 8x8, or 4x4.    */
1743 };
1744 
1745 /*! The MVPrecision enumerator specifies the motion estimation precision. */
1746 enum {
1747     MFX_MVPRECISION_UNKNOWN    = 0,
1748     MFX_MVPRECISION_INTEGER    = (1 << 0),
1749     MFX_MVPRECISION_HALFPEL    = (1 << 1),
1750     MFX_MVPRECISION_QUARTERPEL = (1 << 2)
1751 };
1752 
1753 /*! The CodingOptionValue enumerator defines a three-state coding option setting. */
1754 enum {
1755     MFX_CODINGOPTION_UNKNOWN    =0,    /*!< Unspecified. */
1756     MFX_CODINGOPTION_ON         =0x10, /*!< Coding option set. */
1757     MFX_CODINGOPTION_OFF        =0x20, /*!< Coding option not set. */
1758     MFX_CODINGOPTION_ADAPTIVE   =0x30  /*!< Reserved. */
1759 };
1760 
1761 /*! The BitstreamDataFlag enumerator uses bit-ORed values to itemize additional information about the bitstream buffer. */
1762 enum {
1763     MFX_BITSTREAM_NO_FLAG           = 0x0000, /*!< The bitstream doesn't contain any flags. */
1764     /*!
1765        The bitstream buffer contains a complete frame or complementary field pair of data for the bitstream. For decoding, this means
1766        that the decoder can proceed with this buffer without waiting for the start of the next frame, which effectively reduces decoding latency.
1767        If this flag is set, but the bitstream buffer contains incomplete frame or pair of field, then decoder will produce corrupted output.
1768     */
1769     MFX_BITSTREAM_COMPLETE_FRAME    = 0x0001,
1770     /*!
1771        The bitstream buffer contains the end of the stream. For decoding,
1772        this means that the application does not have any additional bitstream data to send to decoder.
1773     */
1774     MFX_BITSTREAM_EOS               = 0x0002
1775 };
1776 /*! The ExtendedBufferID enumerator itemizes and defines identifiers (BufferId) for extended buffers or video processing algorithm identifiers. */
1777 enum {
1778     /*!
1779        This extended buffer defines additional encoding controls. See the mfxExtCodingOption structure for details.
1780        The application can attach this buffer to the structure for encoding initialization.
1781     */
1782     MFX_EXTBUFF_CODING_OPTION                   = MFX_MAKEFOURCC('C','D','O','P'),
1783     /*!
1784        This extended buffer defines sequence header and picture header for encoders and decoders. See the mfxExtCodingOptionSPSPPS
1785        structure for details. The application can attach this buffer to the mfxVideoParam structure for encoding initialization,
1786        and for obtaining raw headers from the decoders and encoders.
1787     */
1788     MFX_EXTBUFF_CODING_OPTION_SPSPPS            = MFX_MAKEFOURCC('C','O','S','P'),
1789     /*!
1790        This extended buffer defines a list of VPP algorithms that applications should not use. See the mfxExtVPPDoNotUse structure
1791        for details. The application can attach this buffer to the mfxVideoParam structure for video processing initialization.
1792     */
1793     MFX_EXTBUFF_VPP_DONOTUSE                    = MFX_MAKEFOURCC('N','U','S','E'),
1794     /*!
1795        This extended buffer defines auxiliary information at the VPP output. See the mfxExtVppAuxData structure for details. The application
1796        can attach this buffer to the mfxEncodeCtrl structure for per-frame encoding control.
1797     */
1798     MFX_EXTBUFF_VPP_AUXDATA                     = MFX_MAKEFOURCC('A','U','X','D'),
1799     /*!
1800        The extended buffer defines control parameters for the VPP denoise filter algorithm. See the mfxExtVPPDenoise2 structure for details.
1801        The application can attach this buffer to the mfxVideoParam structure for video processing initialization.
1802     */
1803     MFX_EXTBUFF_VPP_DENOISE2                    = MFX_MAKEFOURCC('D','N','I','2'),
1804     MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_EXTBUFF_VPP_DENOISE)                     = MFX_MAKEFOURCC('D','N','I','S'), /*!< Deprecated in 2.2 API version.*/
1805     MFX_EXTBUFF_VPP_SCENE_ANALYSIS              = MFX_MAKEFOURCC('S','C','L','Y'), /*!< Reserved for future use. */
1806     MFX_DEPRECATED_ENUM_FIELD_INSIDE(MFX_EXTBUFF_VPP_SCENE_CHANGE)                = MFX_EXTBUFF_VPP_SCENE_ANALYSIS, /* Deprecated. */
1807     /*!
1808        The extended buffer defines control parameters for the VPP ProcAmp filter algorithm. See the mfxExtVPPProcAmp structure for details.
1809        The application can attach this buffer to the mfxVideoParam structure for video processing initialization or to the mfxFrameData
1810        structure in the mfxFrameSurface1 structure of output surface for per-frame processing configuration.
1811     */
1812     MFX_EXTBUFF_VPP_PROCAMP                     = MFX_MAKEFOURCC('P','A','M','P'),
1813     /*!
1814        The extended buffer defines control parameters for the VPP detail filter algorithm. See the mfxExtVPPDetail structure for details.
1815        The application can attach this buffer to the structure for video processing initialization.
1816     */
1817     MFX_EXTBUFF_VPP_DETAIL                      = MFX_MAKEFOURCC('D','E','T',' '),
1818     /*!
1819        This extended buffer defines video signal type. See the mfxExtVideoSignalInfo structure for details. The application can attach this
1820        buffer to the mfxVideoParam structure for encoding initialization, and for retrieving such information from the decoders. If video
1821        signal info changes per frame, the application can attach this buffer to the mfxFrameData structure for video processing.
1822     */
1823     MFX_EXTBUFF_VIDEO_SIGNAL_INFO               = MFX_MAKEFOURCC('V','S','I','N'),
1824     /*!
1825        This extended buffer defines video signal type. See the mfxExtVideoSignalInfo structure for details. The application can attach this
1826        buffer to the mfxVideoParam structure for the input of video processing if the input video signal information changes in sequence
1827        base.
1828     */
1829     MFX_EXTBUFF_VIDEO_SIGNAL_INFO_IN            = MFX_MAKEFOURCC('V','S','I','I'),
1830     /*!
1831        This extended buffer defines video signal type. See the mfxExtVideoSignalInfo structure for details. The application can attach this
1832        buffer to the mfxVideoParam structure for the output of video processing if the output video signal information changes in sequence
1833        base.
1834     */
1835     MFX_EXTBUFF_VIDEO_SIGNAL_INFO_OUT           = MFX_MAKEFOURCC('V','S','I','O'),
1836     /*!
1837        This extended buffer defines a list of VPP algorithms that applications should use. See the mfxExtVPPDoUse structure for details.
1838        The application can attach this buffer to the structure for video processing initialization.
1839     */
1840     MFX_EXTBUFF_VPP_DOUSE                       = MFX_MAKEFOURCC('D','U','S','E'),
1841     /*!
1842        This extended buffer defines additional encoding controls for reference list. See the mfxExtAVCRefListCtrl structure for details.
1843        The application can attach this buffer to the mfxVideoParam structure for encoding & decoding initialization, or the mfxEncodeCtrl
1844        structure for per-frame encoding configuration.
1845     */
1846     MFX_EXTBUFF_AVC_REFLIST_CTRL                = MFX_MAKEFOURCC('R','L','S','T'),
1847     /*!
1848        This extended buffer defines control parameters for the VPP frame rate conversion algorithm. See the mfxExtVPPFrameRateConversion structure
1849        for details. The application can attach this buffer to the mfxVideoParam structure for video processing initialization.
1850     */
1851     MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION       = MFX_MAKEFOURCC('F','R','C',' '),
1852     /*!
1853        This extended buffer configures the H.264 picture timing SEI message. See the mfxExtPictureTimingSEI structure for details.
1854        The application can attach this buffer to the mfxVideoParam structure for encoding initialization, or the mfxEncodeCtrl structure
1855        for per-frame encoding configuration.
1856     */
1857     MFX_EXTBUFF_PICTURE_TIMING_SEI              = MFX_MAKEFOURCC('P','T','S','E'),
1858     /*!
1859        This extended buffer configures the structure of temporal layers inside the encoded H.264 bitstream. See the mfxExtAvcTemporalLayers
1860        structure for details. The application can attach this buffer to the mfxVideoParam structure for encoding initialization.
1861     */
1862     MFX_EXTBUFF_AVC_TEMPORAL_LAYERS             = MFX_MAKEFOURCC('A','T','M','L'),
1863     /*!
1864        This extended buffer defines additional encoding controls. See the mfxExtCodingOption2 structure for details.
1865        The application can attach this buffer to the structure for encoding initialization.
1866     */
1867     MFX_EXTBUFF_CODING_OPTION2                  = MFX_MAKEFOURCC('C','D','O','2'),
1868     /*!
1869        This extended buffer defines control parameters for the VPP image stabilization filter algorithm. See the mfxExtVPPImageStab structure
1870        for details. The application can attach this buffer to the mfxVideoParam structure for video processing initialization.
1871     */
1872     MFX_EXTBUFF_VPP_IMAGE_STABILIZATION         = MFX_MAKEFOURCC('I','S','T','B'),
1873     /*!
1874        This extended buffer is used to retrieve encoder capability. See the mfxExtEncoderCapability structure for details.
1875        The application can attach this buffer to the mfxVideoParam structure before calling MFXVideoENCODE_Query function.
1876     */
1877     MFX_EXTBUFF_ENCODER_CAPABILITY              = MFX_MAKEFOURCC('E','N','C','P'),
1878     /*!
1879        This extended buffer is used to control encoder reset behavior and also to query possible encoder reset outcome.
1880        See the mfxExtEncoderResetOption structure for details. The application can attach this buffer to the mfxVideoParam structure
1881        before calling MFXVideoENCODE_Query or MFXVideoENCODE_Reset functions.
1882     */
1883     MFX_EXTBUFF_ENCODER_RESET_OPTION            = MFX_MAKEFOURCC('E','N','R','O'),
1884     /*!
1885        This extended buffer is used by the encoder to report additional information about encoded picture.
1886        See the mfxExtAVCEncodedFrameInfo structure for details. The application can attach this buffer to the mfxBitstream structure
1887        before calling MFXVideoENCODE_EncodeFrameAsync function.
1888     */
1889     MFX_EXTBUFF_ENCODED_FRAME_INFO              = MFX_MAKEFOURCC('E','N','F','I'),
1890     /*!
1891        This extended buffer is used to control composition of several input surfaces in the one output. In this mode,
1892        the VPP skips any other filters. The VPP returns error if any mandatory filter is specified and filter skipped warning
1893        for optional filter. The only supported filters are deinterlacing and interlaced scaling.
1894     */
1895     MFX_EXTBUFF_VPP_COMPOSITE                   = MFX_MAKEFOURCC('V','C','M','P'),
1896     /*!
1897        This extended buffer is used to control transfer matrix and nominal range of YUV frames.
1898        The application should provide it during initialization.
1899     */
1900     MFX_EXTBUFF_VPP_VIDEO_SIGNAL_INFO           = MFX_MAKEFOURCC('V','V','S','I'),
1901     /*!
1902        This extended buffer is used by the application to specify different Region Of Interests during encoding.
1903        The application should provide it at initialization or at runtime.
1904     */
1905     MFX_EXTBUFF_ENCODER_ROI                     = MFX_MAKEFOURCC('E','R','O','I'),
1906     /*!
1907        This extended buffer is used by the application to specify different deinterlacing algorithms.
1908     */
1909     MFX_EXTBUFF_VPP_DEINTERLACING               = MFX_MAKEFOURCC('V','P','D','I'),
1910     /*!
1911        This extended buffer specifies reference lists for the encoder.
1912     */
1913     MFX_EXTBUFF_AVC_REFLISTS                    = MFX_MAKEFOURCC('R','L','T','S'),
1914     /*!
1915        See the mfxExtDecVideoProcessing structure for details.
1916     */
1917     MFX_EXTBUFF_DEC_VIDEO_PROCESSING            = MFX_MAKEFOURCC('D','E','C','V'),
1918     /*!
1919        The extended buffer defines control parameters for the VPP field-processing algorithm. See the mfxExtVPPFieldProcessing
1920        structure for details. The application can attach this buffer to the mfxVideoParam structure for video processing initialization
1921        or to the mfxFrameData structure during runtime.
1922     */
1923     MFX_EXTBUFF_VPP_FIELD_PROCESSING            = MFX_MAKEFOURCC('F','P','R','O'),
1924     /*!
1925        This extended buffer defines additional encoding controls. See the mfxExtCodingOption3 structure for details.
1926        The application can attach this buffer to the structure for encoding initialization.
1927     */
1928     MFX_EXTBUFF_CODING_OPTION3                  = MFX_MAKEFOURCC('C','D','O','3'),
1929     /*!
1930        This extended buffer defines chroma samples location information. See the mfxExtChromaLocInfo structure for details.
1931        The application can attach this buffer to the mfxVideoParam structure for encoding initialization.
1932     */
1933     MFX_EXTBUFF_CHROMA_LOC_INFO                 = MFX_MAKEFOURCC('C','L','I','N'),
1934     /*!
1935        This extended buffer defines per-macroblock QP. See the mfxExtMBQP structure for details.
1936        The application can attach this buffer to the mfxEncodeCtrl structure for per-frame encoding configuration.
1937     */
1938     MFX_EXTBUFF_MBQP                            = MFX_MAKEFOURCC('M','B','Q','P'),
1939     /*!
1940        This extended buffer defines per-macroblock force intra flag. See the mfxExtMBForceIntra structure for details.
1941        The application can attach this buffer to the mfxEncodeCtrl structure for per-frame encoding configuration.
1942     */
1943     MFX_EXTBUFF_MB_FORCE_INTRA                  = MFX_MAKEFOURCC('M','B','F','I'),
1944     /*!
1945        This extended buffer defines additional encoding controls for HEVC tiles. See the mfxExtHEVCTiles structure for details.
1946        The application can attach this buffer to the mfxVideoParam structure for encoding initialization.
1947     */
1948     MFX_EXTBUFF_HEVC_TILES                      = MFX_MAKEFOURCC('2','6','5','T'),
1949     /*!
1950        This extended buffer defines macroblock map for current frame which forces specified macroblocks to be non skip. See the
1951        mfxExtMBDisableSkipMap structure for details. The application can attach this buffer to the mfxEncodeCtrl structure for
1952        per-frame encoding configuration.
1953     */
1954     MFX_EXTBUFF_MB_DISABLE_SKIP_MAP             = MFX_MAKEFOURCC('M','D','S','M'),
1955     /*!
1956        See the mfxExtHEVCParam structure for details.
1957     */
1958     MFX_EXTBUFF_HEVC_PARAM                      = MFX_MAKEFOURCC('2','6','5','P'),
1959     /*!
1960        This extended buffer is used by decoders to report additional information about decoded frame. See the
1961        mfxExtDecodedFrameInfo structure for more details.
1962     */
1963     MFX_EXTBUFF_DECODED_FRAME_INFO              = MFX_MAKEFOURCC('D','E','F','I'),
1964     /*!
1965        See the mfxExtTimeCode structure for more details.
1966     */
1967     MFX_EXTBUFF_TIME_CODE                       = MFX_MAKEFOURCC('T','M','C','D'),
1968     /*!
1969        This extended buffer specifies the region to encode. The application can attach this buffer to the
1970        mfxVideoParam structure during HEVC encoder initialization.
1971     */
1972     MFX_EXTBUFF_HEVC_REGION                     = MFX_MAKEFOURCC('2','6','5','R'),
1973     /*!
1974        See the mfxExtPredWeightTable structure for details.
1975     */
1976     MFX_EXTBUFF_PRED_WEIGHT_TABLE               = MFX_MAKEFOURCC('E','P','W','T'),
1977     /*!
1978        See the mfxExtDitrtyRect structure for details.
1979     */
1980     MFX_EXTBUFF_DIRTY_RECTANGLES                = MFX_MAKEFOURCC('D','R','O','I'),
1981     /*!
1982        See the mfxExtMoveRect structure for details.
1983     */
1984     MFX_EXTBUFF_MOVING_RECTANGLES               = MFX_MAKEFOURCC('M','R','O','I'),
1985     /*!
1986        See the mfxExtCodingOptionVPS structure for details.
1987     */
1988     MFX_EXTBUFF_CODING_OPTION_VPS               = MFX_MAKEFOURCC('C','O','V','P'),
1989     /*!
1990        See the mfxExtVPPRotation structure for details.
1991     */
1992     MFX_EXTBUFF_VPP_ROTATION                    = MFX_MAKEFOURCC('R','O','T',' '),
1993     /*!
1994        See the mfxExtEncodedSlicesInfo structure for details.
1995     */
1996     MFX_EXTBUFF_ENCODED_SLICES_INFO             = MFX_MAKEFOURCC('E','N','S','I'),
1997     /*!
1998        See the mfxExtVPPScaling structure for details.
1999     */
2000     MFX_EXTBUFF_VPP_SCALING                     = MFX_MAKEFOURCC('V','S','C','L'),
2001     /*!
2002        This extended buffer defines additional encoding controls for reference list. See the mfxExtAVCRefListCtrl structure for details.
2003        The application can attach this buffer to the mfxVideoParam structure for encoding & decoding initialization, or
2004        the mfxEncodeCtrl structure for per-frame encoding configuration.
2005     */
2006     MFX_EXTBUFF_HEVC_REFLIST_CTRL               = MFX_EXTBUFF_AVC_REFLIST_CTRL,
2007     /*!
2008        This extended buffer specifies reference lists for the encoder.
2009     */
2010     MFX_EXTBUFF_HEVC_REFLISTS                   = MFX_EXTBUFF_AVC_REFLISTS,
2011     /*!
2012        This extended buffer configures the structure of temporal layers inside the encoded H.264 bitstream. See the mfxExtAvcTemporalLayers
2013        structure for details. The application can attach this buffer to the mfxVideoParam structure for encoding initialization.
2014     */
2015     MFX_EXTBUFF_HEVC_TEMPORAL_LAYERS            = MFX_EXTBUFF_AVC_TEMPORAL_LAYERS,
2016     /*!
2017        See the mfxExtVPPMirroring structure for details.
2018     */
2019     MFX_EXTBUFF_VPP_MIRRORING                   = MFX_MAKEFOURCC('M','I','R','R'),
2020     /*!
2021        See the mfxExtMVOverPicBoundaries structure for details.
2022     */
2023     MFX_EXTBUFF_MV_OVER_PIC_BOUNDARIES          = MFX_MAKEFOURCC('M','V','P','B'),
2024     /*!
2025        See the mfxExtVPPColorFill structure for details.
2026     */
2027     MFX_EXTBUFF_VPP_COLORFILL                   = MFX_MAKEFOURCC('V','C','L','F'),
2028     /*!
2029        This extended buffer is used by decoders to report error information before frames get decoded.
2030        See the mfxExtDecodeErrorReport structure for more details.
2031     */
2032     MFX_EXTBUFF_DECODE_ERROR_REPORT             = MFX_MAKEFOURCC('D', 'E', 'R', 'R'),
2033     /*!
2034        See the mfxExtColorConversion structure for details.
2035     */
2036     MFX_EXTBUFF_VPP_COLOR_CONVERSION            = MFX_MAKEFOURCC('V', 'C', 'S', 'C'),
2037     /*!
2038        This extended buffer configures HDR SEI message. See the mfxExtContentLightLevelInfo structure for details.
2039     */
2040     MFX_EXTBUFF_CONTENT_LIGHT_LEVEL_INFO        = MFX_MAKEFOURCC('L', 'L', 'I', 'S'),
2041     /*!
2042        This extended buffer configures HDR SEI message. See the mfxExtMasteringDisplayColourVolume structure for details. If colour volume changes
2043        per frame, the application can attach this buffer to the mfxFrameData structure for video processing.
2044     */
2045     MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME = MFX_MAKEFOURCC('D', 'C', 'V', 'S'),
2046     /*!
2047        This extended buffer configures HDR SEI message. See the mfxExtMasteringDisplayColourVolume structure for details. The application can
2048        attach this buffer to the mfxVideoParam structure for the input of video processing if the mastering display colour volume changes per
2049        sequence. In this case, this buffer should be together with MFX_EXTBUFF_CONTENT_LIGHT_LEVEL_INFO to indicate the light level and mastering
2050        colour volume of the input of video processing. If colour Volume changes per frame instead of per sequence, the application can attach
2051        MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME to mfxFrameData for frame based processing.
2052     */
2053     MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME_IN         = MFX_MAKEFOURCC('D', 'C', 'V', 'I'),
2054     /*!
2055        This extended buffer configures HDR SEI message. See the mfxExtMasteringDisplayColourVolume structure for details. The application can
2056        attach this buffer to the mfxVideoParam structure for the output of video processing if the mastering display colour volume changes per
2057        sequence. If colour volume changes per frame instead of per sequence, the application can attach the buffer with MFX_EXTBUFF_MASTERING_
2058        DISPLAY_COLOUR_VOLUME to mfxFrameData for frame based processing.
2059     */
2060     MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME_OUT        = MFX_MAKEFOURCC('D', 'C', 'V', 'O'),
2061     /*!
2062        See the mfxExtEncodedUnitsInfo structure for details.
2063     */
2064     MFX_EXTBUFF_ENCODED_UNITS_INFO              = MFX_MAKEFOURCC('E', 'N', 'U', 'I'),
2065     /*!
2066        This video processing algorithm identifier is used to enable MCTF via mfxExtVPPDoUse and together with mfxExtVppMctf
2067     */
2068     MFX_EXTBUFF_VPP_MCTF                        = MFX_MAKEFOURCC('M', 'C', 'T', 'F'),
2069     /*!
2070        Extends mfxVideoParam structure with VP9 segmentation parameters. See the mfxExtVP9Segmentation structure for details.
2071     */
2072     MFX_EXTBUFF_VP9_SEGMENTATION                = MFX_MAKEFOURCC('9', 'S', 'E', 'G'),
2073     /*!
2074        Extends mfxVideoParam structure with parameters for VP9 temporal scalability. See the mfxExtVP9TemporalLayers structure for details.
2075     */
2076     MFX_EXTBUFF_VP9_TEMPORAL_LAYERS             = MFX_MAKEFOURCC('9', 'T', 'M', 'L'),
2077     /*!
2078        Extends mfxVideoParam structure with VP9-specific parameters. See the mfxExtVP9Param structure for details.
2079     */
2080     MFX_EXTBUFF_VP9_PARAM                       = MFX_MAKEFOURCC('9', 'P', 'A', 'R'),
2081     /*!
2082        See the mfxExtAVCRoundingOffset structure for details.
2083     */
2084     MFX_EXTBUFF_AVC_ROUNDING_OFFSET             = MFX_MAKEFOURCC('R','N','D','O'),
2085     /*!
2086        See the mfxExtPartialBitstreamParam structure for details.
2087     */
2088     MFX_EXTBUFF_PARTIAL_BITSTREAM_PARAM         = MFX_MAKEFOURCC('P','B','O','P'),
2089 
2090     /*!
2091        See the mfxExtEncoderIPCMArea structure for details.
2092     */
2093     MFX_EXTBUFF_ENCODER_IPCM_AREA  = MFX_MAKEFOURCC('P', 'C', 'M', 'R'),
2094     /*!
2095        See the mfxExtInsertHeaders structure for details.
2096     */
2097     MFX_EXTBUFF_INSERT_HEADERS  = MFX_MAKEFOURCC('S', 'P', 'R', 'E'),
2098 
2099     /*!
2100        See the mfxExtDeviceAffinityMask structure for details.
2101     */
2102     MFX_EXTBUFF_DEVICE_AFFINITY_MASK = MFX_MAKEFOURCC('D', 'A', 'F', 'M'),
2103 
2104     /*!
2105        See the mfxExtInCrops structure for details.
2106     */
2107     MFX_EXTBUFF_CROPS = MFX_MAKEFOURCC('C', 'R', 'O', 'P'),
2108 
2109     /*!
2110         See the mfxExtAV1BitstreamParam structure for more details.
2111     */
2112     MFX_EXTBUFF_AV1_BITSTREAM_PARAM             = MFX_MAKEFOURCC('A', '1', 'B', 'S'),
2113 
2114     /*!
2115         See the mfxExtAV1ResolutionParam structure for more details.
2116     */
2117     MFX_EXTBUFF_AV1_RESOLUTION_PARAM            = MFX_MAKEFOURCC('A', '1', 'R', 'S'),
2118 
2119     /*!
2120         See the mfxExtAV1TileParam structure for more details.
2121     */
2122     MFX_EXTBUFF_AV1_TILE_PARAM                  = MFX_MAKEFOURCC('A', '1', 'T', 'L'),
2123 
2124     /*!
2125         See the mfxExtAV1Segmentation structure for more details.
2126     */
2127     MFX_EXTBUFF_AV1_SEGMENTATION                = MFX_MAKEFOURCC('1', 'S', 'E', 'G'),
2128 
2129     /*!
2130        See the mfxExtAV1FilmGrainParam structure for more details.
2131     */
2132     MFX_EXTBUFF_AV1_FILM_GRAIN_PARAM = MFX_MAKEFOURCC('A','1','F','G'),
2133 
2134     /*!
2135        See the mfxExtHyperModeParam structure for more details.
2136     */
2137     MFX_EXTBUFF_HYPER_MODE_PARAM = MFX_MAKEFOURCC('H', 'Y', 'P', 'M'),
2138     /*!
2139        See the mfxExtTemporalLayers structure for more details.
2140     */
2141     MFX_EXTBUFF_UNIVERSAL_TEMPORAL_LAYERS = MFX_MAKEFOURCC('U', 'T', 'M', 'P'),
2142 #ifdef ONEVPL_EXPERIMENTAL
2143     /*!
2144        This extended buffer defines additional encoding controls for reference list. See the mfxExtRefListCtrl structure for details.
2145        The application can attach this buffer to the mfxVideoParam structure for encoding & decoding initialization, or
2146        the mfxEncodeCtrl structure for per-frame encoding configuration.
2147     */
2148     MFX_EXTBUFF_UNIVERSAL_REFLIST_CTRL = MFX_EXTBUFF_AVC_REFLIST_CTRL,
2149 #endif
2150     /*!
2151        See the mfxExtVPP3DLut structure for more details.
2152     */
2153     MFX_EXTBUFF_VPP_3DLUT = MFX_MAKEFOURCC('T','D','L','T'),
2154 
2155     /*!
2156        See the mfxExtAllocationHints structure for more details.
2157     */
2158     MFX_EXTBUFF_ALLOCATION_HINTS = MFX_MAKEFOURCC('A','L','C','H'),
2159 };
2160 
2161 /* VPP Conf: Do not use certain algorithms  */
2162 MFX_PACK_BEGIN_STRUCT_W_PTR()
2163 /*!
2164    Tells the VPP not to use certain filters in pipeline. See “Configurable VPP filters” table for complete
2165    list of configurable filters. The user can attach this structure to the mfxVideoParam structure when initializing video processing.
2166 */
2167 typedef struct {
2168     mfxExtBuffer    Header;  /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_DONOTUSE. */
2169     mfxU32          NumAlg;  /*!< Number of filters (algorithms) not to use */
2170     mfxU32*         AlgList; /*!< Pointer to a list of filters (algorithms) not to use */
2171 } mfxExtVPPDoNotUse;
2172 MFX_PACK_END()
2173 
2174 MFX_PACK_BEGIN_USUAL_STRUCT()
2175 /*!
2176    A hint structure that configures the VPP denoise filter algorithm.
2177    @deprecated Deprecated in API version 2.5. Use mfxExtVPPDenoise2 instead.
2178 */
2179 MFX_DEPRECATED typedef struct {
2180     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_DENOISE. */
2181     mfxU16  DenoiseFactor;  /*!< Indicates the level of noise to remove. Value range of 0 to 100 (inclusive).  */
2182 } mfxExtVPPDenoise;
2183 MFX_PACK_END()
2184 
2185 /*! The mfxDenoiseMode enumerator specifies the mode of denoise. */
2186 typedef enum {
2187     MFX_DENOISE_MODE_DEFAULT    = 0,     /*!< Default denoise mode. The library selects the most appropriate denoise mode. */
2188     MFX_DENOISE_MODE_VENDOR     = 1000,  /*!< The enumeration to separate common denoise mode above and vendor specific. */
2189 
2190     MFX_DENOISE_MODE_INTEL_HVS_AUTO_BDRATE     = MFX_DENOISE_MODE_VENDOR + 1,  /*!< Indicates auto BD rate improvement in pre-processing before video encoding,
2191                                                                                     ignore Strength.*/
2192     MFX_DENOISE_MODE_INTEL_HVS_AUTO_SUBJECTIVE = MFX_DENOISE_MODE_VENDOR + 2,  /*!< Indicates auto subjective quality improvement in pre-processing before video encoding,
2193                                                                                     ignore Strength.*/
2194     MFX_DENOISE_MODE_INTEL_HVS_AUTO_ADJUST     = MFX_DENOISE_MODE_VENDOR + 3,  /*!< Indicates auto adjust subjective quality in post-processing (after decoding) for video playback,
2195                                                                                     ignore Strength.*/
2196     MFX_DENOISE_MODE_INTEL_HVS_PRE_MANUAL      = MFX_DENOISE_MODE_VENDOR + 4,  /*!< Indicates manual mode for pre-processing before video encoding,
2197                                                                                     allow to adjust the denoise strength manually.*/
2198     MFX_DENOISE_MODE_INTEL_HVS_POST_MANUAL     = MFX_DENOISE_MODE_VENDOR + 5,  /*!< Indicates manual mode for post-processing for video playback,
2199                                                                                     allow to adjust the denoise strength manually.*/
2200 } mfxDenoiseMode;
2201 
2202 MFX_PACK_BEGIN_USUAL_STRUCT()
2203 /*!
2204    A hint structure that configures the VPP denoise filter algorithm.
2205 */
2206 typedef struct {
2207     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_DENOISE2. */
2208     mfxDenoiseMode  Mode;   /*!< Indicates the mode of denoise. mfxDenoiseMode enumerator.  */
2209     mfxU16  Strength;       /*!< Denoise strength in manaul mode. Value of 0-100 (inclusive) indicates the strength of denoise.
2210                                  The strength of denoise controls degree of possible changes of pixel values; the bigger the strength
2211                                  the larger the change is.  */
2212     mfxU16  reserved[15];
2213 } mfxExtVPPDenoise2;
2214 MFX_PACK_END()
2215 
2216 /*! The mfx3DLutChannelMapping enumerator specifies the channel mapping of 3DLUT. */
2217 typedef enum {
2218     MFX_3DLUT_CHANNEL_MAPPING_DEFAULT            = 0,   /*!< Default 3DLUT channel mapping. The library selects the most appropriate 3DLUT channel mapping. */
2219     MFX_3DLUT_CHANNEL_MAPPING_RGB_RGB            = 1,   /*!< 3DLUT RGB channels map to RGB channels. */
2220     MFX_3DLUT_CHANNEL_MAPPING_YUV_RGB            = 2,   /*!< 3DLUT YUV channels map to RGB channels. */
2221     MFX_3DLUT_CHANNEL_MAPPING_VUY_RGB            = 3,   /*!< 3DLUT VUY channels map to RGB channels. */
2222 } mfx3DLutChannelMapping;
2223 
2224 /*! The mfx3DLutMemoryLayout enumerator specifies the memory layout of 3DLUT. */
2225 typedef enum {
2226     MFX_3DLUT_MEMORY_LAYOUT_DEFAULT                        = 0,          /*!< Default 3DLUT memory layout. The library selects the most appropriate 3DLUT memory layout.*/
2227 
2228     MFX_3DLUT_MEMORY_LAYOUT_VENDOR                         = 0x1000,     /*!< The enumeration to separate default above and vendor specific.*/
2229     /*!
2230        Intel specific memory layout. The enumerator indicates the attributes and memory layout of 3DLUT.
2231        3DLUT size is 17(the number of elements per dimension), 4 channels(3 valid channels, 1 channel is reserved), every channel must be 16-bit unsigned integer.
2232        3DLUT contains 17x17x32 entries with holes that are not filled. Take RGB as example, the nodes RxGx17 to RxGx31 are not filled, are "don't care" bits, and not accessed for the 17x17x17 nodes.
2233     */
2234     MFX_3DLUT_MEMORY_LAYOUT_INTEL_17LUT                    = MFX_3DLUT_MEMORY_LAYOUT_VENDOR + 1,
2235     /*!
2236        Intel specific memory layout. The enumerator indicates the attributes and memory layout of 3DLUT.
2237        3DLUT size is 33(the number of elements per dimension), 4 channels(3 valid channels, 1 channel is reserved), every channel must be 16-bit unsigned integer.
2238        3DLUT contains 33x33x64 entries with holes that are not filled. Take RGB as example, the nodes RxGx33 to RxGx63 are not filled, are "don't care" bits, and not accessed for the 33x33x33 nodes.
2239     */
2240     MFX_3DLUT_MEMORY_LAYOUT_INTEL_33LUT                    = MFX_3DLUT_MEMORY_LAYOUT_VENDOR + 2,
2241     /*!
2242        Intel specific memory layout. The enumerator indicates the attributes and memory layout of 3DLUT.
2243        3DLUT size is 65(the number of elements per dimension), 4 channels(3 valid channels, 1 channel is reserved), every channel must be 16-bit unsigned integer.
2244        3DLUT contains 65x65x128 entries with holes that are not filled. Take RGB as example, the nodes RxGx65 to RxGx127 are not filled, are "don't care" bits, and not accessed for the 65x65x65 nodes.
2245     */
2246     MFX_3DLUT_MEMORY_LAYOUT_INTEL_65LUT                    = MFX_3DLUT_MEMORY_LAYOUT_VENDOR + 3,
2247 } mfx3DLutMemoryLayout;
2248 
2249 MFX_PACK_BEGIN_STRUCT_W_PTR()
2250 /*!
2251     A hint structure that configures the data channel.
2252 */
2253 typedef struct {
2254     mfxDataType  DataType;                /*!< Data type, mfxDataType enumerator.*/
2255     mfxU32       Size;                    /*!< Size of Look up table, the number of elements per dimension.*/
2256     union
2257     {
2258         mfxU8*     Data;                  /*!< The pointer to 3DLUT data, 8 bit unsigned integer.*/
2259         mfxU16*    Data16;                /*!< The pointer to 3DLUT data, 16 bit unsigned integer.*/
2260     };
2261     mfxU32       reserved[4];             /*!< Reserved for future extension.*/
2262 } mfxChannel;
2263 MFX_PACK_END()
2264 
2265 MFX_PACK_BEGIN_USUAL_STRUCT()
2266 /*!
2267     A hint structure that configures 3DLUT system buffer.
2268 */
2269 typedef struct {
2270     mfxChannel           Channel[3];        /*!< 3 Channels, can be RGB or YUV, mfxChannel structure.*/
2271     mfxU32               reserved[8];       /*!< Reserved for future extension.*/
2272 } mfx3DLutSystemBuffer;
2273 MFX_PACK_END()
2274 
2275 MFX_PACK_BEGIN_USUAL_STRUCT()
2276 /*!
2277     A hint structure that configures 3DLUT video buffer.
2278 */
2279 typedef struct {
2280     mfxDataType                DataType;       /*!< Data type, mfxDataType enumerator.*/
2281     mfx3DLutMemoryLayout       MemLayout;      /*!< Indicates 3DLUT memory layout. mfx3DLutMemoryLayout enumerator.*/
2282     mfxMemId                   MemId;          /*!< Memory ID for holding the lookup table data. One MemID is dedicated for one instance of VPP.*/
2283     mfxU32                     reserved[8];    /*!< Reserved for future extension.*/
2284 } mfx3DLutVideoBuffer;
2285 MFX_PACK_END()
2286 
2287 MFX_PACK_BEGIN_USUAL_STRUCT()
2288 /*!
2289     A hint structure that configures 3DLUT filter.
2290 */
2291 typedef struct {
2292     mfxExtBuffer             Header;           /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_3DLUT..*/
2293     mfx3DLutChannelMapping   ChannelMapping;   /*!< Indicates 3DLUT channel mapping. mfx3DLutChannelMapping enumerator.*/
2294     mfxResourceType          BufferType;       /*!< Indicates 3DLUT buffer type. mfxResourceType enumerator, can be system memory, VA surface, DX11 texture/buffer etc.*/
2295     union
2296     {
2297         mfx3DLutSystemBuffer SystemBuffer;     /*!< The 3DLUT system buffer. mfx3DLutSystemBuffer structure describes the details of the buffer.*/
2298         mfx3DLutVideoBuffer  VideoBuffer;      /*!< The 3DLUT video buffer. mfx3DLutVideoBuffer describes the details of 3DLUT video buffer.*/
2299     };
2300     mfxU32                   reserved[4];      /*!< Reserved for future extension.*/
2301 } mfxExtVPP3DLut;
2302 MFX_PACK_END()
2303 
2304 MFX_PACK_BEGIN_USUAL_STRUCT()
2305 /*!
2306    A hint structure that configures the VPP detail/edge enhancement filter algorithm.
2307 */
2308 typedef struct {
2309     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_DETAIL. */
2310     mfxU16  DetailFactor;   /*!< Indicates the level of details to be enhanced. Value range of 0 to 100 (inclusive).  */
2311 } mfxExtVPPDetail;
2312 MFX_PACK_END()
2313 
2314 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
2315 /*!
2316    A hint structure that configures the VPP ProcAmp filter algorithm.
2317    The structure parameters will be clipped to their corresponding range and rounded by their corresponding increment.
2318    @note There are no default values for fields in this structure, all settings must be explicitly specified every time this
2319          buffer is submitted for processing.
2320 */
2321 typedef struct {
2322     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_PROCAMP. */
2323     mfxF64   Brightness;    /*!< The brightness parameter is in the range of -100.0F to 100.0F, in increments of 0.1F.
2324                                  Setting this field to 0.0F will disable brightness adjustment. */
2325     mfxF64   Contrast;      /*!< The contrast parameter in the range of 0.0F to 10.0F, in increments of 0.01F, is used for manual
2326                                  contrast adjustment. Setting this field to 1.0F will disable contrast adjustment. If the parameter
2327                                  is negative, contrast will be adjusted automatically. */
2328     mfxF64   Hue;           /*!< The hue parameter is in the range of -180F to 180F, in increments of 0.1F. Setting this field to 0.0F
2329                                  will disable hue adjustment. */
2330     mfxF64   Saturation;    /*!< The saturation parameter is in the range of 0.0F to 10.0F, in increments of 0.01F.
2331                                  Setting this field to 1.0F will disable saturation adjustment. */
2332 } mfxExtVPPProcAmp;
2333 MFX_PACK_END()
2334 
2335 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
2336 /*!
2337    Returns statistics collected during encoding.
2338 */
2339 typedef struct {
2340     mfxU32  reserved[16];
2341     mfxU32  NumFrame;       /*!< Number of encoded frames. */
2342     mfxU64  NumBit;         /*!< Number of bits for all encoded frames. */
2343     mfxU32  NumCachedFrame; /*!< Number of internally cached frames. */
2344 } mfxEncodeStat;
2345 MFX_PACK_END()
2346 
2347 MFX_PACK_BEGIN_USUAL_STRUCT()
2348 /*!
2349    Returns statistics collected during decoding.
2350 */
2351 typedef struct {
2352     mfxU32  reserved[16];
2353     mfxU32  NumFrame;        /*!< Number of total decoded frames. */
2354     mfxU32  NumSkippedFrame; /*!< Number of skipped frames. */
2355     mfxU32  NumError;        /*!< Number of errors recovered. */
2356     mfxU32  NumCachedFrame;  /*!< Number of internally cached frames. */
2357 } mfxDecodeStat;
2358 MFX_PACK_END()
2359 
2360 MFX_PACK_BEGIN_USUAL_STRUCT()
2361 /*!
2362    Returns statistics collected during video processing.
2363 */
2364 typedef struct {
2365     mfxU32  reserved[16];
2366     mfxU32  NumFrame;       /*!< Total number of frames processed. */
2367     mfxU32  NumCachedFrame; /*!< Number of internally cached frames. */
2368 } mfxVPPStat;
2369 MFX_PACK_END()
2370 
2371 MFX_PACK_BEGIN_USUAL_STRUCT()
2372 /*!
2373    Returns auxiliary data generated by the video processing pipeline.
2374    The encoding process may use the auxiliary data by attaching this structure to the mfxEncodeCtrl structure.
2375 */
2376 typedef struct {
2377     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_AUXDATA. */
2378 
2379     union{
2380         struct{
2381             MFX_DEPRECATED mfxU32  SpatialComplexity; /* Deprecated */
2382             MFX_DEPRECATED mfxU32  TemporalComplexity; /* Deprecated */
2383         };
2384         struct{
2385             /*!
2386                Detected picture structure - top field first, bottom field first, progressive or unknown if video processor cannot
2387                detect picture structure. See the PicStruct enumerator for definition of these values.
2388 
2389             */
2390             mfxU16  PicStruct;
2391             mfxU16  reserved[3];
2392         };
2393     };
2394     MFX_DEPRECATED  mfxU16          SceneChangeRate; /* Deprecated */
2395     MFX_DEPRECATED  mfxU16          RepeatedFrame;   /* Deprecated */
2396 } mfxExtVppAuxData;
2397 MFX_PACK_END()
2398 
2399 /*! The PayloadCtrlFlags enumerator itemizes additional payload properties. */
2400 enum {
2401     MFX_PAYLOAD_CTRL_SUFFIX = 0x00000001 /*!< Insert this payload into HEVC Suffix SEI NAL-unit. */
2402 };
2403 
2404 MFX_PACK_BEGIN_STRUCT_W_PTR()
2405 /*!
2406    Describes user data payload in MPEG-2 or SEI message payload in H.264.
2407 
2408    For encoding, these payloads can be
2409    inserted into the bitstream. The payload buffer must contain a valid formatted payload.
2410 
2411    For H.264, this is the sei_message() as
2412    specified in the section 7.3.2.3.1 'Supplemental enhancement information message syntax' of the ISO/IEC 14496-10 specification.
2413 
2414    For MPEG-2,
2415    this is the section 6.2.2.2.2 'User data' of the ISO/IEC 13818-2 specification, excluding the user data start_code.
2416 
2417    For decoding,
2418    these payloads can be retrieved as the decoder parses the bitstream and caches them in an internal buffer.
2419 
2420    @internal
2421    +-----------+-------------------------------------------+
2422    | **Codec** | **Supported Types**                       |
2423    +===========+===========================================+
2424    | MPEG2     | 0x01B2 //User Data                        |
2425    +-----------+-------------------------------------------+
2426    | AVC       | 02 //pan_scan_rect                        |
2427    |           | 03 //filler_payload                       |
2428    |           | 04 //user_data_registered_itu_t_t35       |
2429    |           | 05 //user_data_unregistered               |
2430    |           | 06 //recovery_point                       |
2431    |           | 09 //scene_info                           |
2432    |           | 13 //full_frame_freeze                    |
2433    |           | 14 //full_frame_freeze_release            |
2434    |           | 15 //full_frame_snapshot                  |
2435    |           | 16 //progressive_refinement_segment_start |
2436    |           | 17 //progressive_refinement_segment_end   |
2437    |           | 19 //film_grain_characteristics           |
2438    |           | 20 //deblocking_filter_display_preference |
2439    |           | 21 //stereo_video_info                    |
2440    |           | 45 //frame_packing_arrangement            |
2441    +-----------+-------------------------------------------+
2442    | HEVC      | All                                       |
2443    +-----------+-------------------------------------------+
2444    @endinternal
2445 
2446 */
2447 typedef struct {
2448     mfxU32      CtrlFlags;  /*!< Additional payload properties. See the PayloadCtrlFlags enumerator for details. */
2449     mfxU32      reserved[3];
2450     mfxU8       *Data;      /*!< Pointer to the actual payload data buffer. */
2451     mfxU32      NumBit;     /*!< Number of bits in the payload data */
2452     mfxU16      Type;       /*!< MPEG-2 user data start code or H.264 SEI message type. */
2453     mfxU16      BufSize;    /*!< Payload buffer size in bytes. */
2454 } mfxPayload;
2455 MFX_PACK_END()
2456 
2457 MFX_PACK_BEGIN_STRUCT_W_PTR()
2458 /*!
2459    Contains parameters for per-frame based encoding control.
2460 */
2461 typedef struct {
2462     mfxExtBuffer    Header; /*!< This extension buffer doesn't have assigned buffer ID. Ignored. */
2463     mfxU32  reserved[4];
2464     mfxU16  reserved1;
2465     /*!
2466        Type of NAL unit that contains encoding frame. All supported values are defined by MfxNalUnitType enumerator. Other values
2467        defined in ITU-T H.265 specification are not supported.
2468 
2469        The encoder uses this field only if application sets mfxExtCodingOption3::EnableNalUnitType option to ON during encoder initialization.
2470 
2471        @note Only encoded order is supported. If application specifies this value in display order or uses value inappropriate for current frame or
2472              invalid value, then the encoder silently ignores it.
2473     */
2474     mfxU16  MfxNalUnitType;
2475     mfxU16  SkipFrame; /*!< Indicates that current frame should be skipped or the number of missed frames before the current frame. See mfxExtCodingOption2::SkipFrame for details. */
2476 
2477     mfxU16  QP;        /*!< If nonzero, this value overwrites the global QP value for the current frame in the constant QP mode. */
2478 
2479     /*!
2480        Encoding frame type. See the FrameType enumerator for details. If the encoder works in the encoded order, the application must
2481        specify the frame type. If the encoder works in the display order, only key frames are enforceable.
2482     */
2483     mfxU16  FrameType;
2484     mfxU16  NumExtParam; /*!< Number of extra control buffers. */
2485     mfxU16  NumPayload;  /*!< Number of payload records to insert into the bitstream. */
2486     mfxU16  reserved2;
2487 
2488     /*!
2489        Pointer to an array of pointers to external buffers that provide additional information or control to the encoder for this
2490        frame or field pair. A typical use is to pass the VPP auxiliary data generated by the video processing pipeline to the encoder.
2491        See the ExtendedBufferID for the list of extended buffers.
2492     */
2493     mfxExtBuffer    **ExtParam;
2494     /*!
2495        Pointer to an array of pointers to user data (MPEG-2) or SEI messages (H.264) for insertion into the bitstream. For field pictures,
2496        odd payloads are associated with the first field and even payloads are associated with the second field. See the mfxPayload structure
2497        for payload definitions.
2498     */
2499     mfxPayload      **Payload;
2500 } mfxEncodeCtrl;
2501 MFX_PACK_END()
2502 
2503 /*! The ExtMemBufferType enumerator specifies the buffer type. It is a bit-ORed value of the following. */
2504 enum {
2505     MFX_MEMTYPE_PERSISTENT_MEMORY   =0x0002 /*!< Memory page for persistent use. */
2506 };
2507 
2508 /* Frame Memory Types */
2509 #define MFX_MEMTYPE_BASE(x) (0x90ff & (x))
2510 
2511 /*!
2512    The ExtMemFrameType enumerator specifies the memory type of frame. It is a bit-ORed value of the following.
2513     \verbatim embed:rst
2514     For information on working with video memory surfaces, see the :ref:`Working with Hardware Acceleration section<hw-acceleration>`.
2515     \endverbatim
2516 */
2517 enum {
2518     MFX_MEMTYPE_DXVA2_DECODER_TARGET       =0x0010, /*!< Frames are in video memory and belong to video decoder render targets. */
2519     MFX_MEMTYPE_DXVA2_PROCESSOR_TARGET     =0x0020, /*!< Frames are in video memory and belong to video processor render targets. */
2520     MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET   = MFX_MEMTYPE_DXVA2_DECODER_TARGET,  /*!< Frames are in video memory and belong to video decoder render targets. */
2521     MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET = MFX_MEMTYPE_DXVA2_PROCESSOR_TARGET,/*!< Frames are in video memory and belong to video processor render targets. */
2522     MFX_MEMTYPE_SYSTEM_MEMORY              =0x0040, /*!< The frames are in system memory. */
2523     MFX_MEMTYPE_RESERVED1                  =0x0080, /*!<  */
2524 
2525     MFX_MEMTYPE_FROM_ENCODE     = 0x0100, /*!< Allocation request comes from an ENCODE function */
2526     MFX_MEMTYPE_FROM_DECODE     = 0x0200, /*!< Allocation request comes from a DECODE function */
2527     MFX_MEMTYPE_FROM_VPPIN      = 0x0400, /*!< Allocation request comes from a VPP function for input frame allocation */
2528     MFX_MEMTYPE_FROM_VPPOUT     = 0x0800, /*!< Allocation request comes from a VPP function for output frame allocation */
2529     MFX_MEMTYPE_FROM_ENC        = 0x2000, /*!< Allocation request comes from an ENC function */
2530     MFX_MEMTYPE_FROM_PAK        = 0x4000, /* Reserved */
2531 
2532     MFX_MEMTYPE_INTERNAL_FRAME  = 0x0001, /*!< Allocation request for internal frames */
2533     MFX_MEMTYPE_EXTERNAL_FRAME  = 0x0002, /*!< Allocation request for I/O frames */
2534     MFX_MEMTYPE_EXPORT_FRAME    = 0x0008, /*!< Application requests frame handle export to some associated object. For Linux frame handle can be
2535                                                considered to be exported to DRM Prime FD, DRM FLink or DRM FrameBuffer Handle. Specifics of export
2536                                                types and export procedure depends on external frame allocator implementation */
2537     MFX_MEMTYPE_SHARED_RESOURCE = MFX_MEMTYPE_EXPORT_FRAME, /*!< For DX11 allocation use shared resource bind flag. */
2538     MFX_MEMTYPE_VIDEO_MEMORY_ENCODER_TARGET = 0x1000 /*!< Frames are in video memory and belong to video encoder render targets. */
2539 };
2540 
2541 MFX_PACK_BEGIN_USUAL_STRUCT()
2542 /*!
2543    Describes multiple frame allocations when initializing encoders, decoders, and video preprocessors.
2544    A range specifies the number of video frames. Applications are free to allocate additional frames. In all cases, the minimum number of
2545    frames must be at least NumFrameMin or the called API function will return an error.
2546 */
2547 typedef struct {
2548     union {
2549         mfxU32  AllocId;       /*!< Unique (within the session) ID of component requested the allocation. */
2550         mfxU32  reserved[1];
2551     };
2552     mfxU32  reserved3[3];
2553     mfxFrameInfo    Info;      /*!< Describes the properties of allocated frames. */
2554     mfxU16  Type;              /*!< Allocated memory type. See the ExtMemFrameType enumerator for details. */
2555     mfxU16  NumFrameMin;       /*!< Minimum number of allocated frames. */
2556     mfxU16  NumFrameSuggested; /*!< Suggested number of allocated frames. */
2557     mfxU16  reserved2;
2558 } mfxFrameAllocRequest;
2559 MFX_PACK_END()
2560 
2561 MFX_PACK_BEGIN_STRUCT_W_PTR()
2562 /*!
2563    Describes the response to multiple frame allocations. The calling API function returns the number of
2564    video frames actually allocated and pointers to their memory IDs.
2565 */
2566 typedef struct {
2567     mfxU32      AllocId;        /*!< Unique (within the session) ID of component requested the allocation. */
2568     mfxU32      reserved[3];
2569     mfxMemId    *mids;          /*!< Pointer to the array of the returned memory IDs. The application allocates or frees this array. */
2570     mfxU16      NumFrameActual; /*!< Number of frames actually allocated. */
2571     mfxU16      reserved2;
2572 } mfxFrameAllocResponse;
2573 MFX_PACK_END()
2574 
2575 /*! The FrameType enumerator itemizes frame types. Use bit-ORed values to specify all that apply. */
2576 enum {
2577     MFX_FRAMETYPE_UNKNOWN       =0x0000, /*!< Frame type is unspecified. */
2578 
2579     MFX_FRAMETYPE_I             =0x0001, /*!< This frame or the first field is encoded as an I-frame/field. */
2580     MFX_FRAMETYPE_P             =0x0002, /*!< This frame or the first field is encoded as an P-frame/field. */
2581     MFX_FRAMETYPE_B             =0x0004, /*!< This frame or the first field is encoded as an B-frame/field. */
2582     MFX_FRAMETYPE_S             =0x0008, /*!< This frame or the first field is either an SI- or SP-frame/field. */
2583 
2584     MFX_FRAMETYPE_REF           =0x0040, /*!< This frame or the first field is encoded as a reference. */
2585     MFX_FRAMETYPE_IDR           =0x0080, /*!< This frame or the first field is encoded as an IDR. */
2586 
2587     MFX_FRAMETYPE_xI            =0x0100, /*!< The second field is encoded as an I-field. */
2588     MFX_FRAMETYPE_xP            =0x0200, /*!< The second field is encoded as an P-field. */
2589     MFX_FRAMETYPE_xB            =0x0400, /*!< The second field is encoded as an S-field. */
2590     MFX_FRAMETYPE_xS            =0x0800, /*!< The second field is an SI- or SP-field. */
2591 
2592     MFX_FRAMETYPE_xREF          =0x4000, /*!< The second field is encoded as a reference. */
2593     MFX_FRAMETYPE_xIDR          =0x8000  /*!< The second field is encoded as an IDR. */
2594 };
2595 
2596 /*!
2597    The MfxNalUnitType enumerator specifies NAL unit types supported by the HEVC encoder.
2598 */
2599 enum {
2600     MFX_HEVC_NALU_TYPE_UNKNOWN    =      0, /*!< The encoder will decide what NAL unit type to use. */
2601     MFX_HEVC_NALU_TYPE_TRAIL_N    = ( 0+1), /*!< See Table 7-1 of the ITU-T H.265 specification for the definition of these type. */
2602     MFX_HEVC_NALU_TYPE_TRAIL_R    = ( 1+1), /*!< See Table 7-1 of the ITU-T H.265 specification for the definition of these type. */
2603     MFX_HEVC_NALU_TYPE_RADL_N     = ( 6+1), /*!< See Table 7-1 of the ITU-T H.265 specification for the definition of these type. */
2604     MFX_HEVC_NALU_TYPE_RADL_R     = ( 7+1), /*!< See Table 7-1 of the ITU-T H.265 specification for the definition of these type. */
2605     MFX_HEVC_NALU_TYPE_RASL_N     = ( 8+1), /*!< See Table 7-1 of the ITU-T H.265 specification for the definition of these type. */
2606     MFX_HEVC_NALU_TYPE_RASL_R     = ( 9+1), /*!< See Table 7-1 of the ITU-T H.265 specification for the definition of these type. */
2607     MFX_HEVC_NALU_TYPE_IDR_W_RADL = (19+1), /*!< See Table 7-1 of the ITU-T H.265 specification for the definition of these type. */
2608     MFX_HEVC_NALU_TYPE_IDR_N_LP   = (20+1), /*!< See Table 7-1 of the ITU-T H.265 specification for the definition of these type. */
2609     MFX_HEVC_NALU_TYPE_CRA_NUT    = (21+1)  /*!< See Table 7-1 of the ITU-T H.265 specification for the definition of these type. */
2610 };
2611 
2612 /*! The mfxSkipMode enumerator describes the decoder skip-mode options. */
2613 typedef enum {
2614     MFX_SKIPMODE_NOSKIP=0, /*! Do not skip any frames. */
2615     MFX_SKIPMODE_MORE=1,   /*! Skip more frames. */
2616     MFX_SKIPMODE_LESS=2    /*! Skip less frames. */
2617 } mfxSkipMode;
2618 
2619 MFX_PACK_BEGIN_STRUCT_W_PTR()
2620 /*!
2621    Attach this structure as part of the extended buffers to configure the encoder during MFXVideoENCODE_Init. The sequence or picture
2622    parameters specified by this structure overwrite any parameters specified by the structure or any other attached extended buffers attached.
2623 
2624    For H.264, SPSBuffer and PPSBuffer must point to valid bitstreams that contain the sequence parameter set and picture parameter set,
2625    respectively.
2626 
2627    For MPEG-2, SPSBuffer must point to valid bitstreams that contain the sequence header followed by any sequence header extension. The PPSBuffer pointer is ignored.
2628 
2629    The encoder imports parameters from these buffers. If the encoder does not support the specified parameters,
2630    the encoder does not initialize and returns the status code MFX_ERR_INCOMPATIBLE_VIDEO_PARAM.
2631 
2632    Check with the MFXVideoENCODE_Query function for the support of this multiple segment encoding feature. If this feature is not supported,
2633    the query returns MFX_ERR_UNSUPPORTED.
2634 */
2635 typedef struct {
2636     mfxExtBuffer    Header;     /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_CODING_OPTION_SPSPPS. */
2637     mfxU8           *SPSBuffer; /*!< Pointer to a valid bitstream that contains the SPS (sequence parameter set for H.264 or sequence header
2638                                      followed by any sequence header extension for MPEG-2) buffer. Can be NULL to skip specifying the SPS. */
2639     mfxU8           *PPSBuffer; /*!< Pointer to a valid bitstream that contains the PPS (picture parameter set for H.264 or picture header
2640                                      followed by any picture header extension for MPEG-2) buffer. Can be NULL to skip specifying the PPS. */
2641     mfxU16          SPSBufSize; /*!< Size of the SPS in bytes. */
2642     mfxU16          PPSBufSize; /*!< Size of the PPS in bytes. */
2643     mfxU16          SPSId;      /*!< SPS identifier. The value is reserved and must be zero. */
2644     mfxU16          PPSId;      /*!< PPS identifier. The value is reserved and must be zero. */
2645 } mfxExtCodingOptionSPSPPS;
2646 MFX_PACK_END()
2647 
2648 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
2649 /*!
2650    Attach this structure as part of the extended buffers to configure the encoder during MFXVideoENCODE_Init. The sequence or picture
2651    parameters specified by this structure overwrite any parameters specified by the structure or any other attached extended buffers attached.
2652 
2653    If the encoder does not support the specified parameters, the encoder does not initialize and returns the status code
2654    MFX_ERR_INCOMPATIBLE_VIDEO_PARAM.
2655 
2656    Check with the MFXVideoENCODE_Query function for the support of this multiple segment encoding feature. If this feature is not supported,
2657    the query returns MFX_ERR_UNSUPPORTED.
2658 */
2659 typedef struct {
2660     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_CODING_OPTION_VPS. */
2661 
2662     union {
2663         mfxU8       *VPSBuffer; /*!< Pointer to a valid bitstream that contains the VPS (video parameter set for HEVC) buffer. */
2664         mfxU64      reserved1;
2665     };
2666     mfxU16          VPSBufSize; /*!< Size of the VPS in bytes. */
2667     mfxU16          VPSId;      /*!< VPS identifier; the value is reserved and must be zero. */
2668 
2669     mfxU16          reserved[6];
2670 } mfxExtCodingOptionVPS;
2671 MFX_PACK_END()
2672 
2673 MFX_PACK_BEGIN_USUAL_STRUCT()
2674 /*!
2675    Defines the video signal information.
2676 
2677    For H.264, see Annex E of the ISO/IEC 14496-10 specification for the definition of these parameters.
2678 
2679    For MPEG-2, see section 6.3.6 of the ITU* H.262 specification for the definition of these parameters. The field VideoFullRange is ignored.
2680 
2681    For VC-1, see section 6.1.14.5 of the SMPTE* 421M specification. The fields VideoFormat and VideoFullRange are ignored.
2682 
2683    @note If ColourDescriptionPresent is zero, the color description information (including ColourPrimaries, TransferCharacteristics,
2684          and MatrixCoefficients) does not present in the bitstream.
2685 */
2686 typedef struct {
2687     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VIDEO_SIGNAL_INFO. */
2688     mfxU16          VideoFormat;
2689     mfxU16          VideoFullRange;
2690     mfxU16          ColourDescriptionPresent;
2691     mfxU16          ColourPrimaries;
2692     mfxU16          TransferCharacteristics;
2693     mfxU16          MatrixCoefficients;
2694 } mfxExtVideoSignalInfo;
2695 MFX_PACK_END()
2696 
2697 MFX_PACK_BEGIN_STRUCT_W_PTR()
2698 /*!
2699    Tells the VPP to include certain filters in the pipeline.
2700 
2701    Each filter may be included in the pipeline in one of two different ways:
2702 
2703    @li Adding a filter ID to this structure. In this method,
2704    the default filter parameters are used.
2705 
2706    @li Attaching a filter configuration structure directly to the mfxVideoParam structure.
2707    In this method, adding filter ID to the mfxExtVPPDoUse structure is optional.
2708 
2709    See Table “Configurable VPP filters” for complete list of
2710    configurable filters, their IDs, and configuration structures.
2711 
2712    The user can attach this structure to the mfxVideoParam structure when initializing video processing.
2713 
2714    @note MFX_EXTBUFF_VPP_COMPOSITE cannot be enabled using mfxExtVPPDoUse because default parameters are undefined for this filter.
2715          The application must attach the appropriate filter configuration structure directly to the mfxVideoParam structure to enable it.
2716 */
2717 typedef struct {
2718     mfxExtBuffer    Header;   /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_DOUSE. */
2719     mfxU32          NumAlg;   /*!< Number of filters (algorithms) to use */
2720     mfxU32          *AlgList; /*!< Pointer to a list of filters (algorithms) to use */
2721 } mfxExtVPPDoUse;
2722 MFX_PACK_END()
2723 
2724 MFX_PACK_BEGIN_USUAL_STRUCT()
2725 /*!
2726    Configures reference frame options for the H.264 encoder.
2727     \verbatim embed:rst
2728     See the :ref:`Reference List Selection <sec_reference_list_selection>` and :ref:`Long Term Reference Frame <sec_long_term_reference_frame>` sections for more details.
2729     \endverbatim
2730 
2731 
2732    @note Not all implementations of the encoder support LongTermIdx and ApplyLongTermIdx fields in this structure. The application must use
2733          query mode 1 to determine if such functionality is supported. To do this, the application must attach this extended buffer to the
2734          mfxVideoParam structure and call the MFXVideoENCODE_Query function. If the function returns MFX_ERR_NONE and these fields were set to one,
2735          then the functionality is supported. If the function fails or sets fields to zero, then the functionality is not supported.
2736 
2737 */
2738 typedef struct {
2739     mfxExtBuffer    Header;            /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_AVC_REFLIST_CTRL. */
2740     mfxU16          NumRefIdxL0Active; /*!< Specify the number of reference frames in the active reference list L0. This number should be less or equal to the NumRefFrame parameter from encoding initialization. */
2741     mfxU16          NumRefIdxL1Active; /*!< Specify the number of reference frames in the active reference list L1. This number should be less or equal to the NumRefFrame parameter from encoding initialization. */
2742 
2743     struct {
2744         /*! @{
2745         @name Reference Lists
2746         The following structure members are used by the reference lists contained in the parent structure. */
2747         mfxU32      FrameOrder;  /*!< Together FrameOrder and PicStruct fields are used to identify reference picture. Use FrameOrder = MFX_FRAMEORDER_UNKNOWN to mark unused entry. */
2748         mfxU16      PicStruct;   /*!< Together FrameOrder and PicStruct fields are used to identify reference picture. Use FrameOrder = MFX_FRAMEORDER_UNKNOWN to mark unused entry. */
2749         mfxU16      ViewId;      /*!< Reserved and must be zero. */
2750         mfxU16      LongTermIdx; /*!< Index that should be used by the encoder to mark long-term reference frame. */
2751         mfxU16      reserved[3]; /*!< Reserved */
2752         /*! @} */
2753     } PreferredRefList[32], /*!< Reference list that specifies the list of frames that should be used to predict the current frame. */
2754     RejectedRefList[16], /*!< Reference list that specifies the list of frames that should not be used for prediction. */
2755     LongTermRefList[16]; /*!< Reference list that specifies the list of frames that should be marked as long-term reference frame. */
2756 
2757     mfxU16      ApplyLongTermIdx;/*!< If it is equal to zero, the encoder assigns long-term index according to internal algorithm.
2758                                       If it is equal to one, the encoder uses LongTermIdx value as long-term index. */
2759     mfxU16      reserved[15];
2760 } mfxExtAVCRefListCtrl;
2761 MFX_PACK_END()
2762 
2763 /*! The FrcAlgm enumerator itemizes frame rate conversion algorithms. See description of mfxExtVPPFrameRateConversion structure for more details. */
2764 enum {
2765     MFX_FRCALGM_PRESERVE_TIMESTAMP    = 0x0001, /*!< Frame dropping/repetition based frame rate conversion algorithm with preserved original
2766                                                      time stamps. Any inserted frames will carry MFX_TIMESTAMP_UNKNOWN. */
2767     MFX_FRCALGM_DISTRIBUTED_TIMESTAMP = 0x0002, /*!< Frame dropping/repetition based frame rate conversion algorithm with distributed time stamps.
2768                                                      The algorithm distributes output time stamps evenly according to the output frame rate. */
2769     MFX_FRCALGM_FRAME_INTERPOLATION   = 0x0004  /*!< Frame rate conversion algorithm based on frame interpolation. This flag may be combined with
2770                                                      MFX_FRCALGM_PRESERVE_TIMESTAMP or MFX_FRCALGM_DISTRIBUTED_TIMESTAMP flags. */
2771 };
2772 
2773 MFX_PACK_BEGIN_USUAL_STRUCT()
2774 /*!
2775    Configures the VPP frame rate conversion filter. The user can attach this structure to the
2776    mfxVideoParam structure when initializing, resetting, or querying capability of video processing.
2777 
2778    On some platforms the advanced frame rate conversion algorithm (the algorithm based on frame interpolation) is not supported. To query its support,
2779    the application should add the MFX_FRCALGM_FRAME_INTERPOLATION flag to the Algorithm value in the mfxExtVPPFrameRateConversion structure, attach it to the
2780    structure, and call the MFXVideoVPP_Query function. If the filter is supported, the function returns a MFX_ERR_NONE status and copies the content of the
2781    input structure to the output structure. If an advanced filter is not supported, then a simple filter will be used and the function returns
2782    MFX_WRN_INCOMPATIBLE_VIDEO_PARAM, copies content of the input structure to the output structure, and corrects the Algorithm value.
2783 
2784    If advanced FRC algorithm is not supported, both MFXVideoVPP_Init and MFXVideoVPP_Reset functions return the MFX_WRN_INCOMPATIBLE_VIDEO_PARAM status.
2785 */
2786 typedef struct {
2787     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION. */
2788     mfxU16      Algorithm;  /*!< See the FrcAlgm enumerator for a list of frame rate conversion algorithms. */
2789     mfxU16      reserved;
2790     mfxU32      reserved2[15];
2791 } mfxExtVPPFrameRateConversion;
2792 MFX_PACK_END()
2793 
2794 /*! The ImageStabMode enumerator itemizes image stabilization modes. See description of mfxExtVPPImageStab structure for more details. */
2795 enum {
2796     MFX_IMAGESTAB_MODE_UPSCALE = 0x0001, /*!< Upscale mode. */
2797     MFX_IMAGESTAB_MODE_BOXING  = 0x0002  /*!< Boxing mode. */
2798 };
2799 
2800 MFX_PACK_BEGIN_USUAL_STRUCT()
2801 /*!
2802    A hint structure that configures the VPP image stabilization filter.
2803 
2804    On some platforms this filter is not supported. To query its support, the application should use the same approach that it uses
2805    to configure VPP filters: adding the filter ID to the mfxExtVPPDoUse structure or by attaching the mfxExtVPPImageStab structure
2806    directly to the mfxVideoParam structure and calling the MFXVideoVPP_Query function.
2807 
2808    If this filter is supported, the function returns a MFX_ERR_NONE
2809    status and copies the content of the input structure to the output structure. If the filter is not supported, the function returns MFX_WRN_FILTER_SKIPPED, removes the
2810    filter from the mfxExtVPPDoUse structure, and zeroes the mfxExtVPPImageStab structure.
2811 
2812    If the image stabilization filter is not supported, both MFXVideoVPP_Init and MFXVideoVPP_Reset functions return a MFX_WRN_FILTER_SKIPPED status.
2813 
2814    The application can retrieve the list of active filters by attaching the mfxExtVPPDoUse structure to the mfxVideoParam structure and calling the
2815    MFXVideoVPP_GetVideoParam function. The application must allocate enough memory for the filter list.
2816 */
2817 typedef struct {
2818     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_IMAGE_STABILIZATION. */
2819     mfxU16  Mode;           /*!< Image stabilization mode. See ImageStabMode enumerator for values. */
2820     mfxU16  reserved[11];
2821 } mfxExtVPPImageStab;
2822 MFX_PACK_END()
2823 
2824 
2825 /*! The InsertHDRPayload enumerator itemizes HDR payloads insertion rules. */
2826 enum {
2827     MFX_PAYLOAD_OFF = 0, /*!< Do not insert payload. */
2828     MFX_PAYLOAD_IDR = 1  /*!< Insert payload on IDR frames. */
2829 };
2830 
2831 MFX_PACK_BEGIN_USUAL_STRUCT()
2832 /*!
2833    Configures the HDR SEI message.
2834 
2835    If the application attaches this structure to the mfxEncodeCtrl structure
2836    at runtime, the encoder inserts the HDR SEI message for the current frame and ignores InsertPayloadToggle.
2837 
2838    If the application attaches this
2839    structure to the mfxVideoParam structure during initialization or reset, the encoder inserts the HDR SEI message based on InsertPayloadToggle.
2840 
2841    If the application attaches this structure for video processing, InsertPayloadToggle will be ignored.
2842 
2843    Field semantics are defined in ITU-T* H.265 Annex D.
2844 */
2845 typedef struct {
2846     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME. */
2847     mfxU16      reserved[15];
2848 
2849     mfxU16 InsertPayloadToggle;  /*!< InsertHDRPayload enumerator value. */
2850     mfxU16 DisplayPrimariesX[3]; /*!< Color primaries for a video source in increments of 0.00002. Consist of RGB x coordinates and
2851                                        define how to convert colors from RGB color space to CIE XYZ color space. Fields range is
2852                                        0 to 50000. */
2853     mfxU16 DisplayPrimariesY[3]; /*!< Color primaries for a video source in increments of 0.00002. Consists of RGB y coordinates and
2854                                        defines how to convert colors from RGB color space to CIE XYZ color space. Field range is
2855                                        0 to 50000. */
2856     mfxU16 WhitePointX;          /*!< White point X coordinate. */
2857     mfxU16 WhitePointY;          /*!< White point Y coordinate. */
2858     mfxU32 MaxDisplayMasteringLuminance; /*!< Specify maximum luminance of the display on which the content was authored in units of 0.00001
2859                                               candelas per square meter. Field range is 1 to 65535. */
2860     mfxU32 MinDisplayMasteringLuminance; /*!< Specify minimum luminance of the display on which the content was authored in units of 0.00001
2861                                               candelas per square meter. Field range is 1 to 65535. */
2862 } mfxExtMasteringDisplayColourVolume;
2863 MFX_PACK_END()
2864 
2865 MFX_PACK_BEGIN_USUAL_STRUCT()
2866 /*!
2867    Configures the HDR SEI message.
2868 
2869    If the application attaches this structure to the mfxEncodeCtrl
2870    structure at runtime, the encoder inserts the HDR SEI message for the current frame and ignores InsertPayloadToggle.
2871 
2872    If the application
2873    attaches this structure to the mfxVideoParam structure during initialization or reset, the encoder inserts the HDR SEI message based on
2874    InsertPayloadToggle.
2875 
2876    If the application attaches this structure for video processing, InsertPayloadToggle will be ignored.
2877 
2878    Field semantics are defined in ITU-T* H.265 Annex D.
2879 */
2880 typedef struct {
2881     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to EXTBUFF_CONTENT_LIGHT_LEVEL_INFO. */
2882     mfxU16      reserved[9];
2883 
2884     mfxU16 InsertPayloadToggle;     /*!< InsertHDRPayload enumerator value. */
2885     mfxU16 MaxContentLightLevel;    /*!< Maximum luminance level of the content. Field range is 1 to 65535. */
2886     mfxU16 MaxPicAverageLightLevel; /*!< Maximum average per-frame luminance level of the content. Field range is 1 to 65535. */
2887 } mfxExtContentLightLevelInfo;
2888 MFX_PACK_END()
2889 
2890 MFX_PACK_BEGIN_USUAL_STRUCT()
2891 /*!
2892    Configures the H.264 picture timing SEI message. The encoder ignores it if HRD information in
2893    the stream is absent and the PicTimingSEI option in the mfxExtCodingOption structure is turned off. See mfxExtCodingOption for details.
2894 
2895    If the application attaches this structure to the mfxVideoParam structure during initialization, the encoder inserts the picture timing
2896    SEI message based on provided template in every access unit of coded bitstream.
2897 
2898    If application attaches this structure to the mfxEncodeCtrl structure at runtime, the encoder inserts the picture timing SEI message
2899    based on provided template in access unit that represents current frame.
2900 
2901    These parameters define the picture timing information. An invalid value of 0xFFFF indicates that application does not set the value and
2902    encoder must calculate it.
2903 
2904    See Annex D of the ISO*\/IEC* 14496-10 specification for the definition of these parameters.
2905 */
2906 typedef struct {
2907   mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_PICTURE_TIMING_SEI. */
2908   mfxU32      reserved[14];
2909 
2910   struct {
2911       mfxU16    ClockTimestampFlag;
2912       mfxU16    CtType;
2913       mfxU16    NuitFieldBasedFlag;
2914       mfxU16    CountingType;
2915       mfxU16    FullTimestampFlag;
2916       mfxU16    DiscontinuityFlag;
2917       mfxU16    CntDroppedFlag;
2918       mfxU16    NFrames;
2919       mfxU16    SecondsFlag;
2920       mfxU16    MinutesFlag;
2921       mfxU16    HoursFlag;
2922       mfxU16    SecondsValue;
2923       mfxU16    MinutesValue;
2924       mfxU16    HoursValue;
2925       mfxU32    TimeOffset;
2926   } TimeStamp[3];
2927 } mfxExtPictureTimingSEI;
2928 MFX_PACK_END()
2929 
2930 MFX_PACK_BEGIN_USUAL_STRUCT()
2931 /*!
2932    Configures the H.264 temporal layers hierarchy.
2933 
2934    If the application attaches it to the mfxVideoParam
2935    structure during initialization, the encoder generates the temporal layers and inserts the prefix NAL unit before each slice to
2936    indicate the temporal and priority IDs of the layer.
2937 
2938    This structure can be used with the display-order encoding mode only.
2939 */
2940 typedef struct {
2941     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_AVC_TEMPORAL_LAYERS. */
2942     mfxU32          reserved1[4];
2943     mfxU16          reserved2;
2944     mfxU16          BaseLayerPID; /*!< The priority ID of the base layer. The encoder increases the ID for each temporal layer and writes to the prefix NAL unit. */
2945 
2946     struct {
2947         mfxU16 Scale;       /*!< The ratio between the frame rates of the current temporal layer and the base layer. */
2948         mfxU16 reserved[3];
2949     }Layer[8];
2950 } mfxExtAvcTemporalLayers;  /*!< The array of temporal layers; Use Scale=0 to specify absent layers. */
2951 MFX_PACK_END()
2952 
2953 MFX_PACK_BEGIN_USUAL_STRUCT()
2954 /*!
2955    Used to retrieve encoder capability. See the description of mode 4 of the MFXVideoENCODE_Query function
2956    for details on how to use this structure.
2957 
2958    @note Not all implementations of the encoder support this extended buffer. The application must use query mode 1 to determine
2959          if the functionality is supported. To do this, the application must attach this extended buffer to the mfxVideoParam structure and
2960          call the MFXVideoENCODE_Query function. If the function returns MFX_ERR_NONE then the  functionality is supported.
2961 */
2962 typedef struct {
2963     mfxExtBuffer Header;  /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_ENCODER_CAPABILITY. */
2964 
2965     mfxU32      MBPerSec; /*!< Specify the maximum processing rate in macro blocks per second. */
2966     mfxU16      reserved[58];
2967 } mfxExtEncoderCapability;
2968 MFX_PACK_END()
2969 
2970 MFX_PACK_BEGIN_USUAL_STRUCT()
2971 /*!
2972    Used to control the encoder behavior during reset. By using this structure, the application
2973    instructs the encoder to start a new coded sequence after reset or to continue encoding of the current sequence.
2974 
2975    This structure is also used in mode 3 of the MFXVideoENCODE_Query function to check for reset outcome before actual reset. The application
2976    should set StartNewSequence to the required behavior and call the query function. If the query fails (see status codes below), then reset is not
2977    possible in current encoder state. If the application sets StartNewSequence to MFX_CODINGOPTION_UNKNOWN, then the query function replaces the coding option with the
2978    actual reset type: MFX_CODINGOPTION_ON if the encoder will begin a new sequence after reset or MFX_CODINGOPTION_OFF if the encoder will continue the current sequence.
2979 
2980    Using this structure may cause one of the following status codes from the MFXVideoENCODE_Reset and MFXVideoENCODE_Queryfunctions:
2981 
2982    @li MFX_ERR_INVALID_VIDEO_PARAM If a reset is not possible. For example, the application sets StartNewSequence to off and requests resolution change.
2983 
2984    @li MFX_ERR_INCOMPATIBLE_VIDEO_PARAM If the application requests change that leads to memory allocation. For example, the application sets StartNewSequence to on and
2985                                         requests resolution change to greater than the initialization value.
2986 
2987    @li MFX_ERR_NONE If reset is possible.
2988 
2989    The following limited list of parameters can be changed without starting a new coded sequence:
2990 
2991    @li The bitrate parameters, TargetKbps and MaxKbps, in the mfxInfoMFX structure.
2992 
2993    @li The number of slices, NumSlice, in the mfxInfoMFX structure. Number of slices should be equal to or less than the number of slices during initialization.
2994 
2995    @li The number of temporal layers in the mfxExtAvcTemporalLayers structure. Reset should be called immediately before encoding of frame from base layer and
2996      number of reference frames should be large enough for the new temporal layers structure.
2997 
2998    @li The quantization parameters, QPI, QPP and QPB, in the mfxInfoMFX structure.
2999 
3000    The application should retrieve all cached frames before calling reset. When the Query API function
3001    checks for reset outcome, it expects that this requirement be satisfied. If it is not true and there are some cached frames inside the
3002  encoder, then the query result may differ from the reset result, because the encoder may insert an IDR frame to produce valid coded sequence.
3003    \verbatim embed:rst
3004    See the :ref:`Configuration Change <config-change>` section for more information.
3005    \endverbatim
3006 
3007    @note Not all implementations of the encoder support this extended buffer. The application must use query mode 1 to determine if the
3008          functionality is supported. To do this, the application must attach this extended buffer to the mfxVideoParam structure and call the
3009          MFXVideoENCODE_Query function. If the function returns MFX_ERR_NONE, then the functionality is supported.
3010 
3011    \verbatim embed:rst
3012    See the :ref:`Streaming and Video Conferencing Features <stream_vid_conf_features>` section for more information.
3013    \endverbatim
3014 
3015 */
3016 typedef struct {
3017     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_ENCODER_RESET_OPTION. */
3018 
3019     /*!
3020        Instructs encoder to start new sequence after reset. Use one of the CodingOptionValue options:
3021 
3022        @li MFX_CODINGOPTION_ON The encoder completely reset internal state and begins new coded sequence after reset, including
3023                              insertion of IDR frame, sequence, and picture headers.
3024 
3025        @li MFX_CODINGOPTION_OFF The encoder continues encoding of current coded sequence after reset, without insertion of IDR frame.
3026 
3027        @li MFX_CODINGOPTION_UNKNOWN Depending on the current encoder state and changes in configuration parameters, the encoder may or may not
3028                                   start new coded sequence. This value is also used to query reset outcome.
3029     */
3030     mfxU16      StartNewSequence;
3031     mfxU16      reserved[11];
3032 } mfxExtEncoderResetOption;
3033 MFX_PACK_END()
3034 
3035 /*! The LongTermIdx specifies long term index of picture control. */
3036 enum {
3037     MFX_LONGTERM_IDX_NO_IDX = 0xFFFF /*!< Long term index of picture is undefined. */
3038 };
3039 
3040 MFX_PACK_BEGIN_USUAL_STRUCT()
3041 /*!
3042    Used by the encoder to report additional information about the encoded picture. The application can attach
3043    this buffer to the mfxBitstream structure before calling MFXVideoENCODE_EncodeFrameAsync function. For interlaced content the encoder
3044    requires two such structures. They correspond to fields in encoded order.
3045 
3046    @note Not all implementations of the encoder support this extended buffer. The application must use query mode 1 to determine if
3047          the functionality is supported. To do this, the application must attach this extended buffer to the mfxVideoParam structure and
3048          call the MFXVideoENCODE_Query function. If the function returns MFX_ERR_NONE then the functionality is supported.
3049 */
3050 typedef struct {
3051     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_ENCODED_FRAME_INFO. */
3052 
3053     mfxU32          FrameOrder;        /*!< Frame order of encoded picture. */
3054     mfxU16          PicStruct;         /*!< Picture structure of encoded picture. */
3055     mfxU16          LongTermIdx;       /*!< Long term index of encoded picture if applicable. */
3056     mfxU32          MAD;               /*!< Mean Absolute Difference between original pixels of the frame and motion compensated (for inter macroblocks) or
3057                                             spatially predicted (for intra macroblocks) pixels. Only luma component, Y plane, is used in calculation. */
3058     mfxU16          BRCPanicMode;      /*!< Bitrate control was not able to allocate enough bits for this frame. Frame quality may be unacceptably low. */
3059     mfxU16          QP;                /*!< Luma QP. */
3060     mfxU32          SecondFieldOffset; /*!< Offset to second field. Second field starts at mfxBitstream::Data + mfxBitstream::DataOffset + mfxExtAVCEncodedFrameInfo::SecondFieldOffset. */
3061     mfxU16          reserved[2];
3062 
3063     struct {
3064         /*! @{
3065         @name Reference Lists
3066         The following structure members are used by the reference lists contained in the parent structure. */
3067         mfxU32      FrameOrder;        /*!< Frame order of reference picture. */
3068         mfxU16      PicStruct;         /*!< Picture structure of reference picture. */
3069         mfxU16      LongTermIdx;       /*!< Long term index of reference picture if applicable. */
3070         mfxU16      reserved[4];
3071         /*! @} */
3072     } UsedRefListL0[32], /*!< Reference list that has been used to encode picture. */
3073     UsedRefListL1[32]; /*!< Reference list that has been used to encode picture. */
3074 } mfxExtAVCEncodedFrameInfo;
3075 MFX_PACK_END()
3076 
3077 MFX_PACK_BEGIN_USUAL_STRUCT()
3078 /*!
3079    Used to specify input stream details for composition of several input surfaces in the one output.
3080 */
3081 typedef struct mfxVPPCompInputStream {
3082     mfxU32  DstX; /*!< X coordinate of location of input stream in output surface. */
3083     mfxU32  DstY; /*!< Y coordinate of location of input stream in output surface. */
3084     mfxU32  DstW; /*!< Width of of location of input stream in output surface.*/
3085     mfxU32  DstH; /*!< Height of of location of input stream in output surface.*/
3086 
3087     mfxU16  LumaKeyEnable; /*!< Non-zero value enables luma keying for the input stream. Luma keying is used to mark some of the areas
3088                                 of the frame with specified luma values as transparent. It may, for example, be used for closed captioning. */
3089     mfxU16  LumaKeyMin;    /*!< Minimum value of luma key, inclusive. Pixels whose luma values fit in this range are rendered transparent. */
3090     mfxU16  LumaKeyMax;    /*!< Maximum value of luma key, inclusive. Pixels whose luma values fit in this range are rendered transparent. */
3091 
3092     mfxU16  GlobalAlphaEnable; /*!< Non-zero value enables global alpha blending for this input stream. */
3093     mfxU16  GlobalAlpha;       /*!< Alpha value for this stream. Should be in the range of 0 to 255, where 0 is transparent and 255 is opaque. */
3094     mfxU16  PixelAlphaEnable;  /*!< Non-zero value enables per pixel alpha blending for this input stream. The stream should have RGB color format. */
3095 
3096     mfxU16  TileId;        /*!< Specify the tile this video stream is assigned to. Should be in the range of 0 to NumTiles. Valid only if NumTiles > 0. */
3097 
3098     mfxU16  reserved2[17];
3099 } mfxVPPCompInputStream;
3100 MFX_PACK_END()
3101 
3102 MFX_PACK_BEGIN_STRUCT_W_PTR()
3103 /*!
3104    Used to control composition of several input surfaces in one output. In this mode, the VPP skips
3105    any other filters. The VPP returns an error if any mandatory filter is specified and returns the filter skipped warning if an optional filter is specified. The only
3106    supported filters are deinterlacing and interlaced scaling. The only supported combinations of input and output color formats are:
3107 
3108    - RGB to RGB,
3109 
3110    - NV12 to NV12,
3111 
3112    - RGB and NV12 to NV12, for per the pixel alpha blending use case.
3113 
3114    The VPP returns MFX_ERR_MORE_DATA for additional input until an output is ready. When the output is ready, the VPP returns MFX_ERR_NONE.
3115    The application must process the output frame after synchronization.
3116 
3117    The composition process is controlled by:
3118 
3119    - mfxFrameInfo::CropXYWH in the input surface defines the location of the picture in the input frame.
3120 
3121    - InputStream[i].DstXYWH defines the location of the cropped input picture in the output frame.
3122 
3123    - mfxFrameInfo::CropXYWH in the output surface defines the actual part of the output frame. All pixels in the output frame outside this region will be filled by the specified color.
3124 
3125    If the application uses the composition process on video streams with different frame sizes, the application should provide maximum frame size in the
3126    mfxVideoParam structure during the initialization, reset, or query operations.
3127 
3128    If the application uses the composition process, the MFXVideoVPP_QueryIOSurf function returns the cumulative number of input surfaces, that is, the number
3129    required to process all input video streams. The function sets the frame size in the mfxFrameAllocRequest equal to the size provided by the
3130    application in the mfxVideoParam structure.
3131 
3132    The composition process supports all types of surfaces.
3133 
3134    All input surfaces should have the same type and color format, except for the per pixel alpha blending case, where it is allowable to mix NV12 and RGB
3135    surfaces.
3136 
3137    There are three different blending use cases:
3138 
3139    - <b>Luma keying.</b> All input surfaces should have the NV12 color format specified during VPP initialization. Part of each surface, including the
3140      first one, may be rendered transparent by using LumaKeyEnable, LumaKeyMin, and LumaKeyMax values.
3141 
3142    - <b>Global alpha blending.</b> All input surfaces should have the same color format, NV12 or RGB, specified during VPP initialization. Each input surface, including the first one, can be blended with underlying surfaces by using GlobalAlphaEnable and
3143      GlobalAlpha values.
3144 
3145    - <b>Per-pixel alpha blending.</b> It is allowed to mix NV12 and RGB input surfaces. Each RGB input surface, including the first one,
3146      can be blended with underlying surfaces by using PixelAlphaEnable value.
3147 
3148    It is not allowed to mix different blending use cases in the same function call.
3149 
3150    In the special case where the destination region of the output surface defined by output crops is fully covered with destination sub-regions of the
3151    surfaces, the fast compositing mode can be enabled. The main use case for this mode is a video-wall scenario with a fixed destination surface
3152    partition into sub-regions of potentially different size.
3153 
3154    In order to trigger this mode, the application must cluster input surfaces into tiles, defining at least one tile by setting the NumTiles
3155    field to be greater than 0, and assigning surfaces to the corresponding tiles by setting the TileId field to the value within the 0 to NumTiles range per
3156    input surface. Tiles should also satisfy the following additional constraints:
3157 
3158    - Each tile should not have more than 8 surfaces assigned to it.
3159 
3160    - Tile bounding boxes, as defined by the enclosing rectangles of a union of a surfaces assigned to this tile, should not intersect.
3161 
3162    Background color may be changed dynamically through Reset. There is no default value. YUV black is (0;128;128) or (16;128;128) depending
3163    on the sample range. The library uses a YUV or RGB triple depending on output color format.
3164 */
3165 typedef struct {
3166     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_COMPOSITE. */
3167 
3168     /* background color*/
3169     union {
3170         mfxU16   Y; /*!< Y value of the background color. */
3171         mfxU16   R; /*!< R value of the background color. */
3172     };
3173     union {
3174         mfxU16   U; /*!< U value of the background color. */
3175         mfxU16   G; /*!< G value of the background color. */
3176     };
3177     union {
3178         mfxU16   V; /*!< V value of the background color. */
3179         mfxU16   B; /*!< B value of the background color. */
3180     };
3181     mfxU16       NumTiles;              /*!< Number of input surface clusters grouped together to enable fast compositing. May be changed dynamically
3182                                              at runtime through Reset. */
3183     mfxU16       reserved1[23];
3184 
3185     mfxU16       NumInputStream;        /*!< Number of input surfaces to compose one output. May be changed dynamically at runtime through Reset. Number of surfaces
3186                                              can be decreased or increased, but should not exceed the number specified during initialization. Query mode 2 should be used
3187                                              to find the maximum supported number. */
3188     mfxVPPCompInputStream *InputStream; /*!< An array of mfxVPPCompInputStream structures that describe composition of input video streams. It should consist of exactly NumInputStream elements. */
3189 } mfxExtVPPComposite;
3190 MFX_PACK_END()
3191 
3192 /*! The TransferMatrix enumerator itemizes color transfer matrices. */
3193 enum {
3194     MFX_TRANSFERMATRIX_UNKNOWN = 0, /*!< Transfer matrix is not specified */
3195     MFX_TRANSFERMATRIX_BT709   = 1, /*!< Transfer matrix from ITU-R BT.709 standard. */
3196     MFX_TRANSFERMATRIX_BT601   = 2  /*!< Transfer matrix from ITU-R BT.601 standard. */
3197 };
3198 
3199 /* The NominalRange enumerator itemizes pixel's value nominal range. */
3200 enum {
3201     MFX_NOMINALRANGE_UNKNOWN   = 0, /*!< Range is not defined. */
3202     MFX_NOMINALRANGE_0_255     = 1, /*!< Range is from  0 to 255. */
3203     MFX_NOMINALRANGE_16_235    = 2  /*!< Range is from 16 to 235. */
3204 };
3205 
3206 MFX_PACK_BEGIN_USUAL_STRUCT()
3207 /*!
3208    Used to control transfer matrix and nominal range of YUV frames. The application
3209    should provide this during initialization. Supported for multiple conversions, for example YUV to YUV, YUV to RGB, and RGB to YUV.
3210 
3211    @note This structure is used by VPP only and is not compatible with mfxExtVideoSignalInfo.
3212 */
3213 typedef struct {
3214     mfxExtBuffer    Header;   /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_VIDEO_SIGNAL_INFO. */
3215     mfxU16          reserved1[4];
3216 
3217     union {
3218         struct { // Init
3219             struct  {
3220                 mfxU16  TransferMatrix; /*!< Transfer matrix. */
3221                 mfxU16  NominalRange;   /*!< Nominal range. */
3222                 mfxU16  reserved2[6];
3223             } In, Out;
3224         };
3225         struct { // Runtime<
3226             mfxU16  TransferMatrix; /*!< Transfer matrix. */
3227             mfxU16  NominalRange;   /*!< Nominal range. */
3228             mfxU16  reserved3[14];
3229         };
3230     };
3231 } mfxExtVPPVideoSignalInfo;
3232 MFX_PACK_END()
3233 
3234 /*! The ROImode enumerator itemizes QP adjustment mode for ROIs. */
3235 enum {
3236     MFX_ROI_MODE_PRIORITY =  0, /*!< Priority mode. */
3237     MFX_ROI_MODE_QP_DELTA =  1,  /*!< QP mode */
3238     MFX_ROI_MODE_QP_VALUE =  2 /*!< Absolute QP */
3239 };
3240 
3241 MFX_PACK_BEGIN_USUAL_STRUCT()
3242 /*!
3243    Used by the application to specify different Region Of Interests during encoding. It may be used at
3244    initialization or at runtime.
3245 */
3246 typedef struct {
3247     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_ENCODER_ROI. */
3248 
3249     mfxU16  NumROI;  /*!< Number of ROI descriptions in array. The Query API function mode 2 returns maximum supported value (set it to 256 and
3250                          query will update it to maximum supported value). */
3251     mfxU16  ROIMode; /*!< QP adjustment mode for ROIs. Defines if Priority or DeltaQP is used during encoding. */
3252     mfxU16  reserved1[10];
3253 
3254     struct  {
3255         /*! @{
3256         @name ROI location rectangle
3257         The ROI rectangle definition uses end-point exclusive notation. In other words, the pixel with (Right, Bottom)
3258         coordinates lies immediately outside of the ROI. Left, Top, Right, Bottom should be aligned by codec-specific block boundaries
3259         (should be dividable by 16 for AVC, or by 32 for HEVC). Every ROI with unaligned coordinates will be expanded by the library to minimal-area
3260         block-aligned ROI, enclosing the original one. For example (5, 5, 15, 31) ROI will be expanded to (0, 0, 16, 32) for AVC encoder,
3261         or to (0, 0, 32, 32) for HEVC.
3262          */
3263         mfxU32  Left;   /*!< Left ROI's coordinate. */
3264         mfxU32  Top;    /*!< Top ROI's coordinate. */
3265         mfxU32  Right;  /*!< Right ROI's coordinate. */
3266         mfxU32  Bottom; /*!< Bottom ROI's coordinate. */
3267         union {
3268             /*! Priority of ROI. Used if ROIMode = MFX_ROI_MODE_PRIORITY.This is an absolute value in the range of -3 to 3,
3269                                   which will be added to the MB QP. Priority is deprecated mode and is used only for backward compatibility.
3270                                   Bigger value produces better quality. */
3271             mfxI16  Priority;
3272             /*! Delta QP of ROI. Used if ROIMode = MFX_ROI_MODE_QP_DELTA. This is an absolute value in the range of -51 to 51,
3273                                   which will be added to the MB QP. Lesser value produces better quality. */
3274             mfxI16  DeltaQP;
3275         };
3276         mfxU16  reserved2[7];
3277         /*! @} */
3278     } ROI[256]; /*!< Array of ROIs. Different ROI may overlap each other. If macroblock belongs to several ROI,
3279                      Priority from ROI with lowest index is used. */
3280 } mfxExtEncoderROI;
3281 MFX_PACK_END()
3282 
3283 /*! The DeinterlacingMode enumerator itemizes VPP deinterlacing modes. */
3284 enum {
3285     MFX_DEINTERLACING_BOB                    =  1, /*!< BOB deinterlacing mode. */
3286     MFX_DEINTERLACING_ADVANCED               =  2, /*!< Advanced deinterlacing mode. */
3287     MFX_DEINTERLACING_AUTO_DOUBLE            =  3, /*!< Auto mode with deinterlacing double frame rate output. */
3288     MFX_DEINTERLACING_AUTO_SINGLE            =  4, /*!< Auto mode with deinterlacing single frame rate output. */
3289     MFX_DEINTERLACING_FULL_FR_OUT            =  5, /*!< Deinterlace only mode with full frame rate output. */
3290     MFX_DEINTERLACING_HALF_FR_OUT            =  6, /*!< Deinterlace only Mode with half frame rate output. */
3291     MFX_DEINTERLACING_24FPS_OUT              =  7, /*!< 24 fps fixed output mode. */
3292     MFX_DEINTERLACING_FIXED_TELECINE_PATTERN =  8, /*!< Fixed telecine pattern removal mode. */
3293     MFX_DEINTERLACING_30FPS_OUT              =  9, /*!< 30 fps fixed output mode. */
3294     MFX_DEINTERLACING_DETECT_INTERLACE       = 10, /*!< Only interlace detection. */
3295     MFX_DEINTERLACING_ADVANCED_NOREF         = 11, /*!< Advanced deinterlacing mode without using of reference frames. */
3296     MFX_DEINTERLACING_ADVANCED_SCD           = 12, /*!< Advanced deinterlacing mode with scene change detection. */
3297     MFX_DEINTERLACING_FIELD_WEAVING          = 13  /*!< Field weaving. */
3298 };
3299 
3300 /*! The TelecinePattern enumerator itemizes telecine patterns. */
3301 enum {
3302     MFX_TELECINE_PATTERN_32           = 0, /*!< 3:2 telecine. */
3303     MFX_TELECINE_PATTERN_2332         = 1, /*!< 2:3:3:2 telecine. */
3304     MFX_TELECINE_PATTERN_FRAME_REPEAT = 2, /*!< One frame repeat telecine. */
3305     MFX_TELECINE_PATTERN_41           = 3, /*!< 4:1 telecine. */
3306     MFX_TELECINE_POSITION_PROVIDED    = 4  /*!< User must provide position inside a sequence of 5 frames where the artifacts start. */
3307 };
3308 
3309 MFX_PACK_BEGIN_USUAL_STRUCT()
3310 /*!
3311    Used by the application to specify different deinterlacing algorithms.
3312 */
3313 typedef struct {
3314     mfxExtBuffer    Header;   /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_DEINTERLACING. */
3315     mfxU16  Mode;             /*!< Deinterlacing algorithm. See the DeinterlacingMode enumerator for details. */
3316     mfxU16  TelecinePattern;  /*!< Specifies telecine pattern when Mode = MFX_DEINTERLACING_FIXED_TELECINE_PATTERN. See the TelecinePattern enumerator for details.*/
3317     mfxU16  TelecineLocation; /*!< Specifies position inside a sequence of 5 frames where the artifacts start when TelecinePattern = MFX_TELECINE_POSITION_PROVIDED*/
3318     mfxU16  reserved[9];      /*!< Reserved for future use. */
3319 } mfxExtVPPDeinterlacing;
3320 MFX_PACK_END()
3321 
3322 MFX_PACK_BEGIN_USUAL_STRUCT()
3323 /*!
3324    Specifies reference lists for the encoder. It may be used together with the mfxExtAVCRefListCtrl
3325    structure to create customized reference lists. If both structures are used together, then the encoder takes reference lists from the
3326    mfxExtAVCRefLists structure and modifies them according to the mfxExtAVCRefListCtrl instructions. In case of interlaced coding,
3327    the first mfxExtAVCRefLists structure affects TOP field and the second – BOTTOM field.
3328 
3329    @note Not all implementations of the encoder support this structure. The application must use the Query API function to determine if it is supported.
3330 */
3331 typedef struct {
3332     mfxExtBuffer    Header;            /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_AVC_REFLISTS. */
3333     mfxU16          NumRefIdxL0Active; /*!< Specify the number of reference frames in the active reference list L0. This number should be less than or
3334                                             equal to the NumRefFrame parameter from encoding initialization. */
3335     mfxU16          NumRefIdxL1Active; /*!< Specify the number of reference frames in the active reference list L1. This number should be less than or
3336                                             equal to the NumRefFrame parameter from encoding initialization. */
3337     mfxU16          reserved[2];
3338 
3339     /*! Used by the reference lists contained in the parent structure. Together these fields are used to identify reference picture. */
3340     struct mfxRefPic{
3341         mfxU32      FrameOrder; /*!< Use FrameOrder = MFX_FRAMEORDER_UNKNOWN to mark
3342                                      unused entry. */
3343         mfxU16      PicStruct;  /*!< Use PicStruct = MFX_PICSTRUCT_FIELD_TFF for TOP field, PicStruct = MFX_PICSTRUCT_FIELD_BFF for
3344                                      BOTTOM field. */
3345         mfxU16      reserved[5];
3346     } RefPicList0[32], /*!< Specify L0 reference list. */
3347       RefPicList1[32]; /*!< Specify L1 reference list. */
3348 
3349 }mfxExtAVCRefLists;
3350 MFX_PACK_END()
3351 
3352 /*! The VPPFieldProcessingMode enumerator is used to control VPP field processing algorithm. */
3353 enum {
3354     MFX_VPP_COPY_FRAME      =0x01, /*!< Copy the whole frame. */
3355     MFX_VPP_COPY_FIELD      =0x02, /*!< Copy only one field. */
3356     MFX_VPP_SWAP_FIELDS     =0x03  /*!< Swap top and bottom fields. */
3357 };
3358 
3359 /*! The PicType enumerator itemizes picture type. */
3360 enum {
3361     MFX_PICTYPE_UNKNOWN     =0x00, /*!< Picture type is unknown. */
3362     MFX_PICTYPE_FRAME       =0x01, /*!< Picture is a frame. */
3363     MFX_PICTYPE_TOPFIELD    =0x02, /*!< Picture is a top field. */
3364     MFX_PICTYPE_BOTTOMFIELD =0x04  /*!< Picture is a bottom field. */
3365 };
3366 
3367 MFX_PACK_BEGIN_USUAL_STRUCT()
3368 /*!
3369    Configures the VPP field processing algorithm. The application can attach this extended buffer to
3370    the mfxVideoParam structure to configure initialization and/or to the mfxFrameData during runtime. Runtime configuration has priority
3371    over initialization configuration. If the field processing algorithm was activated via the mfxExtVPPDoUse structure and the mfxExtVPPFieldProcessing
3372    extended buffer was not provided during initialization, this buffer must be attached to the mfxFrameData structure of each input surface.
3373 */
3374 typedef struct {
3375     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_FIELD_PROCESSING. */
3376 
3377     mfxU16          Mode;     /*!< Specifies the mode of the field processing algorithm. See the VPPFieldProcessingMode enumerator for values of this option. */
3378     mfxU16          InField;  /*!< When Mode is MFX_VPP_COPY_FIELD, specifies input field. See the PicType enumerator for values of this parameter. */
3379     mfxU16          OutField; /*!< When Mode is MFX_VPP_COPY_FIELD, specifies output field. See the PicType enumerator for values of this parameter. */
3380     mfxU16          reserved[25];
3381 } mfxExtVPPFieldProcessing;
3382 MFX_PACK_END()
3383 
3384 MFX_PACK_BEGIN_USUAL_STRUCT()
3385 /*!
3386    If attached to the mfxVideoParam structure during the Init stage, this buffer will instruct the decoder to resize output frames via the
3387    fixed function resize engine (if supported by hardware), utilizing direct pipe connection and bypassing intermediate memory operations.
3388    The main benefits of this mode of pipeline operation are offloading resize operation to a dedicated engine, thus reducing power
3389    consumption and memory traffic.
3390 */
3391 typedef struct {
3392     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_DEC_VIDEO_PROCESSING. */
3393 
3394     /*! Input surface description. */
3395     struct mfxIn{
3396         mfxU16  CropX; /*!< X coordinate of region of interest of the input surface. */
3397         mfxU16  CropY; /*!< Y coordinate of region of interest of the input surface. */
3398         mfxU16  CropW; /*!< Width coordinate of region of interest of the input surface. */
3399         mfxU16  CropH; /*!< Height coordinate of region of interest of the input surface. */
3400         mfxU16  reserved[12];
3401     }In; /*!< Input surface description. */
3402 
3403     /*! Output surface description. */
3404     struct mfxOut{
3405         mfxU32  FourCC;       /*!< FourCC of output surface Note: Should be MFX_FOURCC_NV12. */
3406         mfxU16  ChromaFormat; /*!< Chroma Format of output surface.
3407                                    @note Should be MFX_CHROMAFORMAT_YUV420 */
3408         mfxU16  reserved1;
3409 
3410         mfxU16  Width;        /*!< Width of output surface. */
3411         mfxU16  Height;       /*!< Height of output surface. */
3412 
3413         mfxU16  CropX; /*!< X coordinate of region of interest of the output surface. */
3414         mfxU16  CropY; /*!< Y coordinate of region of interest of the output surface. */
3415         mfxU16  CropW; /*!< Width coordinate of region of interest of the output surface. */
3416         mfxU16  CropH; /*!< Height coordinate of region of interest of the output surface. */
3417         mfxU16  reserved[22];
3418     }Out; /*!< Output surface description. */
3419 
3420     mfxU16  reserved[13];
3421 } mfxExtDecVideoProcessing;
3422 MFX_PACK_END()
3423 
3424 MFX_PACK_BEGIN_USUAL_STRUCT()
3425 /*!
3426    Members of this structure define the location of chroma samples information.
3427 
3428    See Annex E of the ISO*\/IEC* 14496-10 specification for the definition of these parameters.
3429 */
3430 typedef struct {
3431     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_CHROMA_LOC_INFO. */
3432 
3433     mfxU16       ChromaLocInfoPresentFlag;
3434     mfxU16       ChromaSampleLocTypeTopField;
3435     mfxU16       ChromaSampleLocTypeBottomField;
3436     mfxU16       reserved[9];
3437 } mfxExtChromaLocInfo;
3438 MFX_PACK_END()
3439 
3440 /*! The MBQPMode enumerator itemizes QP update modes. */
3441 enum {
3442     MFX_MBQP_MODE_QP_VALUE = 0, /*!< QP array contains QP values. */
3443     MFX_MBQP_MODE_QP_DELTA = 1,  /*!< QP array contains deltas for QP. */
3444     MFX_MBQP_MODE_QP_ADAPTIVE = 2 /*!< QP array contains deltas for QP or absolute QP values. */
3445 };
3446 
3447 MFX_PACK_BEGIN_USUAL_STRUCT()
3448 /*!
3449    Specifies per-MB or per-CU mode and QP or deltaQP value depending on the mode type.
3450  */
3451 typedef struct{
3452     union {
3453           /*!
3454            QP for MB or CU. Valid when Mode = MFX_MBQP_MODE_QP_VALUE.
3455 
3456            For AVC, the valid range is 1 to 51.
3457 
3458            For HEVC, the valid range is 1 to 51. The application's provided QP values should be valid, otherwise invalid QP values may cause undefined behavior.
3459 
3460            MBQP map should be aligned for 16x16 block size. The align rule is: (width +15 /16) && (height +15 /16).
3461 
3462            For MPEG2, the valid range is 1 to 112. QP corresponds to quantizer_scale of the ISO*\/IEC* 13818-2 specification.
3463            */
3464         mfxU8 QP;
3465             /*!
3466              Per-macroblock QP delta. Valid when Mode = MFX_MBQP_MODE_QP_DELTA.
3467              */
3468         mfxI8 DeltaQP;
3469     };
3470     mfxU16 Mode; /*!< Defines QP update mode. Can be equal to MFX_MBQP_MODE_QP_VALUE or MFX_MBQP_MODE_QP_DELTA. */
3471 } mfxQPandMode;
3472 MFX_PACK_END()
3473 
3474 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
3475 /*!
3476    Specifies per-macroblock QP for current frame if mfxExtCodingOption3::EnableMBQP was turned ON during
3477    encoder initialization. The application can attach this extended buffer to the mfxEncodeCtrl structure during runtime.
3478 */
3479 typedef struct {
3480     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_MBQP. */
3481 
3482     mfxU32 reserved[10];
3483     mfxU16 Mode;        /*!< Defines QP update mode. See MBQPMode enumerator for more details. */
3484     mfxU16 BlockSize;   /*!< QP block size, valid for HEVC only during Init and Runtime. */
3485     mfxU32 NumQPAlloc;  /*!< Size of allocated by application QP or DeltaQP array. */
3486     union {
3487         /*!
3488            Pointer to a list of per-macroblock QP in raster scan order. In case of interlaced encoding the first half of QP array affects the top
3489            field and the second half of QP array affects the bottom field. Valid when Mode = MFX_MBQP_MODE_QP_VALUE.
3490 
3491            For AVC, the valid range is 1 to 51.
3492 
3493            For HEVC, the valid range is 1 to 51. Application’s provided QP values should be valid. Otherwise invalid QP values may cause undefined behavior.
3494            MBQP map should be aligned for 16x16 block size. The alignment rule is (width +15 /16) && (height +15 /16).
3495 
3496            For MPEG2, QP corresponds to quantizer_scale of the ISO*\/IEC* 13818-2 specification and has a valid range of 1 to 112.
3497         */
3498         mfxU8  *QP;
3499         mfxI8  *DeltaQP;    /*!< Pointer to a list of per-macroblock QP deltas in raster scan order.
3500                                  For block i: QP[i] = BrcQP[i] + DeltaQP[i]. Valid when Mode = MFX_MBQP_MODE_QP_DELTA. */
3501         mfxQPandMode *QPmode; /*!< Block-granularity modes when MFX_MBQP_MODE_QP_ADAPTIVE is set. */
3502 
3503         mfxU64 reserved2;
3504     };
3505 } mfxExtMBQP;
3506 MFX_PACK_END()
3507 
3508 MFX_PACK_BEGIN_USUAL_STRUCT()
3509 /*!
3510    Runtime ctrl buffer for SPS/PPS insertion with current encoding frame.
3511 */
3512 typedef struct {
3513     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_INSERT_HEADERS. */
3514     mfxU16          SPS;      /*!< Tri-state option to insert SPS. */
3515     mfxU16          PPS;      /*!< Tri-state option to insert PPS. */
3516     mfxU16          reserved[8];
3517 } mfxExtInsertHeaders;
3518 MFX_PACK_END()
3519 
3520 MFX_PACK_BEGIN_STRUCT_W_PTR()
3521 /*!
3522   Specifies rectangle areas for IPCM coding mode.
3523 */
3524 typedef struct {
3525     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_ENCODER_IPCM_AREA. */
3526     mfxU16          reserve1[10];
3527 
3528     mfxU16          NumArea;  /*! Number of areas */
3529     struct area {
3530 
3531         mfxU32      Left; /*!< Left area coordinate. */
3532         mfxU32      Top;  /*!< Top area coordinate. */
3533         mfxU32      Right; /*!< Right area coordinate. */
3534         mfxU32      Bottom; /*!< Bottom area coordinate. */
3535 
3536         mfxU16      reserved2[8];
3537 
3538     } * Areas; /*!< Array of areas. */
3539 } mfxExtEncoderIPCMArea;
3540 MFX_PACK_END()
3541 
3542 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
3543 /*!
3544    Specifies macroblock map for current frame which forces specified macroblocks to be encoded as intra
3545    if mfxExtCodingOption3::EnableMBForceIntra was turned ON during encoder initialization. The application can attach this extended
3546    buffer to the mfxEncodeCtrl structure during runtime.
3547 */
3548 typedef struct {
3549     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_MB_FORCE_INTRA. */
3550 
3551     mfxU32 reserved[11];
3552     mfxU32 MapSize;  /*!< Macroblock map size. */
3553     union {
3554         mfxU8  *Map; /*!< Pointer to a list of force intra macroblock flags in raster scan order. Each flag is one byte in map. Set flag to 1
3555                           to force corresponding macroblock to be encoded as intra. In case of interlaced encoding, the first half of map
3556                           affects top field and the second half of map affects the bottom field. */
3557         mfxU64  reserved2;
3558     };
3559 } mfxExtMBForceIntra;
3560 MFX_PACK_END()
3561 
3562 MFX_PACK_BEGIN_USUAL_STRUCT()
3563 /*!
3564    Configures tiles options for the HEVC encoder. The application can attach this extended buffer to the
3565    mfxVideoParam structure to configure initialization.
3566 */
3567 typedef struct {
3568     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_HEVC_TILES. */
3569 
3570     mfxU16 NumTileRows;    /*!< Number of tile rows. */
3571     mfxU16 NumTileColumns; /*!< Number of tile columns. */
3572     mfxU16 reserved[74];
3573 }mfxExtHEVCTiles;
3574 MFX_PACK_END()
3575 
3576 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
3577 /*!
3578    Specifies macroblock map for current frame which forces specified macroblocks to be non-skip if
3579    mfxExtCodingOption3::MBDisableSkipMap was turned ON during encoder initialization. The application can attach this
3580    extended buffer to the mfxEncodeCtrl structure during runtime.
3581 */
3582 typedef struct {
3583     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_MB_DISABLE_SKIP_MAP. */
3584 
3585     mfxU32 reserved[11];
3586     mfxU32 MapSize;  /*!< Macroblock map size. */
3587     union {
3588         mfxU8  *Map; /*!< Pointer to a list of non-skip macroblock flags in raster scan order. Each flag is one byte in map. Set flag to 1 to force
3589                           corresponding macroblock to be non-skip. In case of interlaced encoding, the first half of map affects
3590                           the top field and the second half of map affects the bottom field. */
3591         mfxU64  reserved2;
3592     };
3593 } mfxExtMBDisableSkipMap;
3594 MFX_PACK_END()
3595 
3596 /*! The GeneralConstraintFlags enumerator uses bit-ORed values to itemize HEVC bitstream indications for specific profiles. Each value
3597     indicates for format range extensions profiles.
3598     To specify HEVC Main 10 Still Picture profile applications have to set mfxInfoMFX::CodecProfile == MFX_PROFILE_HEVC_MAIN10 and
3599     mfxExtHEVCParam::GeneralConstraintFlags == MFX_HEVC_CONSTR_REXT_ONE_PICTURE_ONLY. */
3600 enum {
3601     /* REXT Profile constraint flags*/
3602     MFX_HEVC_CONSTR_REXT_MAX_12BIT          = (1 << 0),
3603     MFX_HEVC_CONSTR_REXT_MAX_10BIT          = (1 << 1),
3604     MFX_HEVC_CONSTR_REXT_MAX_8BIT           = (1 << 2),
3605     MFX_HEVC_CONSTR_REXT_MAX_422CHROMA      = (1 << 3),
3606     MFX_HEVC_CONSTR_REXT_MAX_420CHROMA      = (1 << 4),
3607     MFX_HEVC_CONSTR_REXT_MAX_MONOCHROME     = (1 << 5),
3608     MFX_HEVC_CONSTR_REXT_INTRA              = (1 << 6),
3609     MFX_HEVC_CONSTR_REXT_ONE_PICTURE_ONLY   = (1 << 7),
3610     MFX_HEVC_CONSTR_REXT_LOWER_BIT_RATE     = (1 << 8)
3611 };
3612 
3613 
3614 /*! The SampleAdaptiveOffset enumerator uses bit-ORed values to itemize corresponding HEVC encoding feature. */
3615 enum {
3616     MFX_SAO_UNKNOWN       = 0x00, /*!< Use default value for platform/TargetUsage. */
3617     MFX_SAO_DISABLE       = 0x01, /*!< Disable SAO. If set during Init leads to SPS sample_adaptive_offset_enabled_flag = 0.
3618                                        If set during Runtime, leads to to slice_sao_luma_flag = 0 and slice_sao_chroma_flag = 0
3619                                        for current frame. */
3620     MFX_SAO_ENABLE_LUMA   = 0x02, /*!< Enable SAO for luma (slice_sao_luma_flag = 1). */
3621     MFX_SAO_ENABLE_CHROMA = 0x04  /*!< Enable SAO for chroma (slice_sao_chroma_flag = 1). */
3622 };
3623 
3624 
3625 /* This struct has 4-byte alignment for binary compatibility with previously released versions of API */
3626 MFX_PACK_BEGIN_USUAL_STRUCT()
3627 typedef struct {
3628     mfxExtBuffer    Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_HEVC_PARAM. */
3629 
3630     mfxU16          PicWidthInLumaSamples;  /*!< Specifies the width of each coded picture in units of luma samples. */
3631     mfxU16          PicHeightInLumaSamples; /*!< Specifies the height of each coded picture in units of luma samples. */
3632     mfxU64          GeneralConstraintFlags; /*!< Additional flags to specify exact profile and constraints. See the GeneralConstraintFlags enumerator for values of this field. */
3633     mfxU16          SampleAdaptiveOffset;   /*!< Controls SampleAdaptiveOffset encoding feature. See the SampleAdaptiveOffset enumerator for supported values
3634                                                  (bit-ORed). Valid during encoder Init and Runtime. */
3635     mfxU16          LCUSize;                /*!< Specifies largest coding unit size (max luma coding block). Valid during encoder Init. */
3636     mfxU16          reserved[116];
3637 } mfxExtHEVCParam;
3638 MFX_PACK_END()
3639 
3640 /*! The ErrorTypes enumerator uses bit-ORed values to itemize bitstream error types. */
3641 enum {
3642     MFX_ERROR_NO                  =        0,  /*!< No error in bitstream. */
3643     MFX_ERROR_PPS                 = (1 << 0),  /*!< Invalid/corrupted PPS. */
3644     MFX_ERROR_SPS                 = (1 << 1),  /*!< Invalid/corrupted SPS. */
3645     MFX_ERROR_SLICEHEADER         = (1 << 2),  /*!< Invalid/corrupted slice header. */
3646     MFX_ERROR_SLICEDATA           = (1 << 3),  /*!< Invalid/corrupted slice data. */
3647     MFX_ERROR_FRAME_GAP           = (1 << 4),  /*!< Missed frames. */
3648 #ifdef ONEVPL_EXPERIMENTAL
3649     MFX_ERROR_JPEG_APP0_MARKER    = (1 << 5),  /*!< Invalid/corrupted APP0 marker. */
3650     MFX_ERROR_JPEG_APP1_MARKER    = (1 << 6),  /*!< Invalid/corrupted APP1 marker. */
3651     MFX_ERROR_JPEG_APP2_MARKER    = (1 << 7),  /*!< Invalid/corrupted APP2 marker. */
3652     MFX_ERROR_JPEG_APP3_MARKER    = (1 << 8),  /*!< Invalid/corrupted APP3 marker. */
3653     MFX_ERROR_JPEG_APP4_MARKER    = (1 << 9),  /*!< Invalid/corrupted APP4 marker. */
3654     MFX_ERROR_JPEG_APP5_MARKER    = (1 << 10), /*!< Invalid/corrupted APP5 marker. */
3655     MFX_ERROR_JPEG_APP6_MARKER    = (1 << 11), /*!< Invalid/corrupted APP6 marker. */
3656     MFX_ERROR_JPEG_APP7_MARKER    = (1 << 12), /*!< Invalid/corrupted APP7 marker. */
3657     MFX_ERROR_JPEG_APP8_MARKER    = (1 << 13), /*!< Invalid/corrupted APP8 marker. */
3658     MFX_ERROR_JPEG_APP9_MARKER    = (1 << 14), /*!< Invalid/corrupted APP9 marker. */
3659     MFX_ERROR_JPEG_APP10_MARKER   = (1 << 15), /*!< Invalid/corrupted APP10 marker. */
3660     MFX_ERROR_JPEG_APP11_MARKER   = (1 << 16), /*!< Invalid/corrupted APP11 marker. */
3661     MFX_ERROR_JPEG_APP12_MARKER   = (1 << 17), /*!< Invalid/corrupted APP12 marker. */
3662     MFX_ERROR_JPEG_APP13_MARKER   = (1 << 18), /*!< Invalid/corrupted APP13 marker. */
3663     MFX_ERROR_JPEG_APP14_MARKER   = (1 << 19), /*!< Invalid/corrupted APP14 marker. */
3664     MFX_ERROR_JPEG_DQT_MARKER     = (1 << 20), /*!< Invalid/corrupted DQT marker. */
3665     MFX_ERROR_JPEG_SOF0_MARKER    = (1 << 21), /*!< Invalid/corrupted SOF0 marker. */
3666     MFX_ERROR_JPEG_DHT_MARKER     = (1 << 22), /*!< Invalid/corrupted DHT marker. */
3667     MFX_ERROR_JPEG_DRI_MARKER     = (1 << 23), /*!< Invalid/corrupted DRI marker. */
3668     MFX_ERROR_JPEG_SOS_MARKER     = (1 << 24), /*!< Invalid/corrupted SOS marker. */
3669     MFX_ERROR_JPEG_UNKNOWN_MARKER = (1 << 25), /*!< Unknown Marker. */
3670 #endif
3671 };
3672 
3673 
3674 MFX_PACK_BEGIN_USUAL_STRUCT()
3675 /*!
3676    Used by the decoders to report bitstream error information right after DecodeHeader or DecodeFrameAsync.
3677    The application can attach this extended buffer to the mfxBitstream structure at runtime.
3678 */
3679 typedef struct {
3680     mfxExtBuffer    Header;     /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_DECODE_ERROR_REPORT. */
3681 
3682     mfxU32          ErrorTypes; /*!< Bitstream error types (bit-ORed values). See ErrorTypes enumerator for the list of types. */
3683     mfxU16          reserved[10];
3684 } mfxExtDecodeErrorReport;
3685 MFX_PACK_END()
3686 
3687 MFX_PACK_BEGIN_USUAL_STRUCT()
3688 /*!
3689    Used by the decoders to report additional information about a decoded frame. The application can attach this
3690    extended buffer to the mfxFrameSurface1::mfxFrameData structure at runtime.
3691 */
3692 typedef struct {
3693     mfxExtBuffer Header;    /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_DECODED_FRAME_INFO. */
3694 
3695     mfxU16       FrameType; /*!< Frame type. See FrameType enumerator for the list of types. */
3696     mfxU16       reserved[59];
3697 } mfxExtDecodedFrameInfo;
3698 MFX_PACK_END()
3699 
3700 MFX_PACK_BEGIN_USUAL_STRUCT()
3701 /*!
3702    Used by the library to pass MPEG 2 specific timing information.
3703 
3704    See ISO/IEC 13818-2 and ITU-T H.262, MPEG-2 Part 2 for the definition of these parameters.
3705 */
3706 typedef struct {
3707     mfxExtBuffer Header;           /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_TIME_CODE. */
3708 
3709     mfxU16       DropFrameFlag;    /*!< Indicated dropped frame. */
3710     mfxU16       TimeCodeHours;    /*!< Hours. */
3711     mfxU16       TimeCodeMinutes;  /*!< Minutes. */
3712     mfxU16       TimeCodeSeconds;  /*!< Seconds. */
3713     mfxU16       TimeCodePictures; /*!< Pictures. */
3714     mfxU16       reserved[7];
3715 } mfxExtTimeCode;
3716 MFX_PACK_END()
3717 
3718 /*! The HEVCRegionType enumerator itemizes type of HEVC region. */
3719 enum {
3720     MFX_HEVC_REGION_SLICE = 0 /*!< Slice type. */
3721 };
3722 
3723 /*! The HEVCRegionEncoding enumerator itemizes HEVC region's encoding. */
3724 enum {
3725     MFX_HEVC_REGION_ENCODING_ON  = 0,
3726     MFX_HEVC_REGION_ENCODING_OFF = 1
3727 };
3728 
3729 MFX_PACK_BEGIN_USUAL_STRUCT()
3730 /*!
3731    Attached to the mfxVideoParam structure during HEVC encoder initialization. Specifies the region to encode.
3732 */
3733 typedef struct {
3734     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_HEVC_REGION. */
3735 
3736     mfxU32       RegionId;       /*!< ID of region. */
3737     mfxU16       RegionType;     /*!< Type of region. See HEVCRegionType enumerator for the list of types. */
3738     mfxU16       RegionEncoding; /*!< Set to MFX_HEVC_REGION_ENCODING_ON to encode only specified region. */
3739     mfxU16       reserved[24];
3740 } mfxExtHEVCRegion;
3741 MFX_PACK_END()
3742 
3743 MFX_PACK_BEGIN_USUAL_STRUCT()
3744 /*!
3745    Specifies weighted prediction table for current frame when all of the following conditions are met:
3746 
3747    @li mfxExtCodingOption3::WeightedPred was set to explicit during encoder Init or Reset .
3748 
3749    @li The current frame is P-frame or mfxExtCodingOption3::WeightedBiPred was set to explicit during encoder Init or Reset.
3750 
3751    @li The current frame is B-frame and is attached to the mfxEncodeCtrl structure.
3752 */
3753 typedef struct {
3754     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_PRED_WEIGHT_TABLE. */
3755 
3756     mfxU16       LumaLog2WeightDenom;     /*!< Base 2 logarithm of the denominator for all luma weighting factors. Value must be in the range of 0 to 7, inclusive. */
3757     mfxU16       ChromaLog2WeightDenom;   /*!< Base 2 logarithm of the denominator for all chroma weighting factors. Value must be in the range of 0 to 7, inclusive. */
3758     mfxU16       LumaWeightFlag[2][32];   /*!< LumaWeightFlag[L][R] equal to 1 specifies that the weighting factors for the luma component are specified for R’s entry of RefPicList L. */
3759     mfxU16       ChromaWeightFlag[2][32]; /*!< ChromaWeightFlag[L][R] equal to 1 specifies that the weighting factors for the chroma component are specified for R’s entry of RefPicList L. */
3760     mfxI16       Weights[2][32][3][2];    /*!< The values of the weights and offsets used in the encoding processing. The value of Weights[i][j][k][m] is
3761                                                interpreted as: i refers to reference picture list 0 or 1; j refers to reference list entry 0-31;
3762                                                k refers to data for the luma component when it is 0, the Cb chroma component when it is 1 and
3763                                                the Cr chroma component when it is 2; m refers to weight when it is 0 and offset when it is 1 */
3764     mfxU16       reserved[58];
3765 } mfxExtPredWeightTable;
3766 MFX_PACK_END()
3767 
3768 MFX_PACK_BEGIN_USUAL_STRUCT()
3769 /*!
3770    Used by encoders to set rounding offset parameters for quantization. It is per-frame based encoding control,
3771    and can be attached to some frames and skipped for others. When the extension buffer is set the application can attach it to the mfxEncodeCtrl
3772    during runtime.
3773 */
3774 typedef struct {
3775     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_AVC_ROUNDING_OFFSET. */
3776 
3777     mfxU16       EnableRoundingIntra; /*!< Enable rounding offset for intra blocks. See the CodingOptionValue enumerator for values of this option. */
3778     mfxU16       RoundingOffsetIntra; /*!< Intra rounding offset. Value must be in the range of 0 to 7, inclusive. */
3779     mfxU16       EnableRoundingInter; /*!< Enable rounding offset for inter blocks. See the CodingOptionValue enumerator for values of this option. */
3780     mfxU16       RoundingOffsetInter; /*!< Inter rounding offset. Value must be in the range of 0 to 7, inclusive. */
3781 
3782     mfxU16       reserved[24];
3783 } mfxExtAVCRoundingOffset;
3784 MFX_PACK_END()
3785 
3786 MFX_PACK_BEGIN_USUAL_STRUCT()
3787 /*!
3788    Used by the application to specify dirty regions within a frame during encoding. It may be used at initialization or at runtime.
3789 
3790    Dirty rectangle definition is using end-point exclusive notation. In other words, the pixel with (Right, Bottom) coordinates lies
3791    immediately outside of the dirty rectangle. Left, Top, Right, Bottom should be aligned by codec-specific block boundaries (should be
3792    dividable by 16 for AVC, or by block size (8, 16, 32 or 64, depends on platform) for HEVC).
3793 
3794    Every dirty rectangle with unaligned
3795    coordinates will be expanded to a minimal-area block-aligned dirty rectangle, enclosing the original one.
3796    For example, a (5, 5, 15, 31) dirty rectangle will be expanded to (0, 0, 16, 32) for AVC encoder, or to (0, 0, 32, 32) for HEVC,
3797    if block size is 32.
3798 
3799    Dirty rectangle (0, 0, 0, 0) is a valid dirty rectangle and means that the frame is not changed.
3800 */
3801 typedef struct {
3802     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_DIRTY_RECTANGLES. */
3803 
3804     mfxU16  NumRect;    /*!< Number of dirty rectangles. */
3805     mfxU16  reserved1[11];
3806 
3807     struct {
3808         /*! @{
3809         @name Dirty rectangle coordinates
3810         The following structure members are used by the Rect array contained in the parent structure.
3811 
3812          */
3813         mfxU32  Left;   /*!< Dirty region left coordinate. */
3814         mfxU32  Top;    /*!< Dirty region top coordinate. */
3815         mfxU32  Right;  /*!< Dirty region right coordinate. */
3816         mfxU32  Bottom; /*!< Dirty region bottom coordinate. */
3817 
3818         mfxU16  reserved2[8];
3819         /*! @} */
3820     } Rect[256];        /*!< Array of dirty rectangles. */
3821 } mfxExtDirtyRect;
3822 MFX_PACK_END()
3823 
3824 MFX_PACK_BEGIN_USUAL_STRUCT()
3825 /*!
3826    Used by the application to specify moving regions within a frame during encoding.
3827 
3828    Destination rectangle location should be aligned to MB boundaries (should be dividable by 16). If not, the encoder
3829    truncates it to MB boundaries, for example, both 17 and 31 will be truncated to 16.
3830 */
3831 typedef struct {
3832     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_MOVING_RECTANGLE. */
3833 
3834     mfxU16  NumRect;        /*!< Number of moving rectangles. */
3835     mfxU16  reserved1[11];
3836 
3837     struct {
3838         /*! @{
3839         @name Destination and source rectangle location
3840         The following structure members are used by the Rect array contained in the parent structure.
3841          */
3842         mfxU32  DestLeft;   /*!< Destination rectangle location. */
3843         mfxU32  DestTop;    /*!< Destination rectangle location. */
3844         mfxU32  DestRight;  /*!< Destination rectangle location. */
3845         mfxU32  DestBottom; /*!< Destination rectangle location. */
3846 
3847         mfxU32  SourceLeft; /*!< Source rectangle location. */
3848         mfxU32  SourceTop;  /*!< Source rectangle location. */
3849         mfxU16  reserved2[4];
3850         /*! @} */
3851     } Rect[256];            /*!< Array of moving rectangles. */
3852 } mfxExtMoveRect;
3853 MFX_PACK_END()
3854 
3855 /*! The Angle enumerator itemizes valid rotation angles. */
3856 enum {
3857     MFX_ANGLE_0     =   0, /*!< 0 degrees. */
3858     MFX_ANGLE_90    =  90, /*!< 90 degrees. */
3859     MFX_ANGLE_180   = 180, /*!< 180 degrees. */
3860     MFX_ANGLE_270   = 270  /*!< 270 degrees. */
3861 };
3862 
3863 MFX_PACK_BEGIN_USUAL_STRUCT()
3864 /*!
3865    Configures the VPP Rotation filter algorithm.
3866 */
3867 typedef struct {
3868     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_ROTATION. */
3869 
3870     mfxU16 Angle;        /*!< Rotation angle. See Angle enumerator for supported values. */
3871     mfxU16 reserved[11];
3872 } mfxExtVPPRotation;
3873 MFX_PACK_END()
3874 
3875 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
3876 /*!
3877    Used by the encoder to report additional information about encoded slices. The application can attach this
3878    buffer to the mfxBitstream structure before calling the MFXVideoENCODE_EncodeFrameAsync function.
3879 
3880    @note Not all implementations of the encoder support this extended buffer. The application must use query mode 1 to determine if the
3881          functionality is supported. To do this, the application must attach this extended buffer to the mfxVideoParam structure and call the
3882          MFXVideoENCODE_Query function. If the function returns MFX_ERR_NONE, then the functionality is supported.
3883 */
3884 typedef struct {
3885     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_ENCODED_SLICES_INFO. */
3886 
3887     mfxU16  SliceSizeOverflow;   /*!< When mfxExtCodingOption2::MaxSliceSize is used, indicates the requested slice size was not met for one or more generated slices. */
3888     mfxU16  NumSliceNonCopliant; /*!< When mfxExtCodingOption2::MaxSliceSize is used, indicates the number of generated slices exceeds specification limits. */
3889     mfxU16  NumEncodedSlice;     /*!< Number of encoded slices. */
3890     mfxU16  NumSliceSizeAlloc;   /*!< SliceSize array allocation size. Must be specified by application. */
3891     union {
3892         mfxU16  *SliceSize;      /*!< Slice size in bytes. Array must be allocated by application. */
3893         mfxU64  reserved1;
3894     };
3895 
3896     mfxU16 reserved[20];
3897 } mfxExtEncodedSlicesInfo;
3898 MFX_PACK_END()
3899 
3900 /*! The ScalingMode enumerator itemizes variants of scaling filter implementation. */
3901 enum {
3902     MFX_SCALING_MODE_DEFAULT    = 0, /*!< Default scaling mode. The library selects the most appropriate scaling method. */
3903     MFX_SCALING_MODE_LOWPOWER   = 1, /*!< Low power scaling mode which is applicable for library implementations.
3904                                          The exact scaling algorithm is defined by the library. */
3905     MFX_SCALING_MODE_QUALITY    = 2, /*!< The best quality scaling mode. */
3906     MFX_SCALING_MODE_VENDOR = 1000, /*!< The enumeration to separate common scaling controls above and vendor specific. */
3907     MFX_SCALING_MODE_INTEL_GEN_COMPUTE  = MFX_SCALING_MODE_VENDOR + 1, /*! The mode to run scaling operation on Execution Units (EUs). */
3908     MFX_SCALING_MODE_INTEL_GEN_VDBOX = MFX_SCALING_MODE_VENDOR + 2, /*! The special optimization mode where scaling operation running on SFC (Scaler & Format Converter) is coupled with VDBOX (also known as Multi-Format Codec fixed-function engine). This mode is applicable for DECODE_VPP domain functions. */
3909     MFX_SCALING_MODE_INTEL_GEN_VEBOX = MFX_SCALING_MODE_VENDOR + 3 /*! The special optimization mode where scaling operation running on SFC is coupled with VEBOX (HW video processing pipe). */
3910 };
3911 
3912 /*! The InterpolationMode enumerator specifies type of interpolation method used by VPP scaling filter. */
3913 enum {
3914     MFX_INTERPOLATION_DEFAULT                = 0, /*!< Default interpolation mode for scaling. Library selects the most appropriate
3915                                                     scaling method. */
3916     MFX_INTERPOLATION_NEAREST_NEIGHBOR       = 1, /*!< Nearest neighbor interpolation method. */
3917     MFX_INTERPOLATION_BILINEAR               = 2, /*!< Bilinear interpolation method. */
3918     MFX_INTERPOLATION_ADVANCED               = 3  /*!< Advanced interpolation method is defined by each implementation and usually gives best                                                          quality. */
3919 };
3920 
3921 MFX_PACK_BEGIN_USUAL_STRUCT()
3922 /*!
3923    Configures the VPP Scaling filter algorithm.
3924    Not all combinations of ScalingMode and InterpolationMethod are supported in the library. The application must use the Query API function to determine if a combination is supported.
3925 */
3926 typedef struct {
3927     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_SCALING. */
3928 
3929     mfxU16 ScalingMode;  /*!< Scaling mode. See ScalingMode for values. */
3930     mfxU16 InterpolationMethod; /*!< Interpolation mode for scaling algorithm. See InterpolationMode for values. */
3931     mfxU16 reserved[10];
3932 } mfxExtVPPScaling;
3933 MFX_PACK_END()
3934 
3935 typedef mfxExtAVCRefListCtrl mfxExtHEVCRefListCtrl;
3936 typedef mfxExtAVCRefLists mfxExtHEVCRefLists;
3937 typedef mfxExtAvcTemporalLayers mfxExtHEVCTemporalLayers;
3938 
3939 #ifdef ONEVPL_EXPERIMENTAL
3940 typedef mfxExtAVCRefListCtrl mfxExtRefListCtrl;
3941 #endif
3942 
3943 /* The MirroringType enumerator itemizes mirroring types. */
3944 enum
3945 {
3946     MFX_MIRRORING_DISABLED   = 0,
3947     MFX_MIRRORING_HORIZONTAL = 1,
3948     MFX_MIRRORING_VERTICAL   = 2
3949 };
3950 
3951 MFX_PACK_BEGIN_USUAL_STRUCT()
3952 /*!
3953    Configures the VPP Mirroring filter algorithm.
3954 */
3955 typedef struct {
3956     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_MIRRORING. */
3957 
3958     mfxU16 Type;         /*!< Mirroring type. See MirroringType for values. */
3959     mfxU16 reserved[11];
3960 } mfxExtVPPMirroring;
3961 MFX_PACK_END()
3962 
3963 MFX_PACK_BEGIN_USUAL_STRUCT()
3964 /*!
3965    Instructs encoder to use or not use samples over specified picture border for inter prediction. Attached to the mfxVideoParam structure.
3966 */
3967 typedef struct {
3968     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_MV_OVER_PIC_BOUNDARIES. */
3969 
3970     mfxU16 StickTop;     /*!< When set to OFF, one or more samples outside corresponding picture boundary may be used in inter prediction.
3971                               See the CodingOptionValue enumerator for values of this option. */
3972     mfxU16 StickBottom;  /*!< When set to OFF, one or more samples outside corresponding picture boundary may be used in inter prediction.
3973                               See the CodingOptionValue enumerator for values of this option. */
3974     mfxU16 StickLeft;    /*!< When set to OFF, one or more samples outside corresponding picture boundary may be used in inter prediction.
3975                               See the CodingOptionValue enumerator for values of this option. */
3976     mfxU16 StickRight;   /*!< When set to OFF, one or more samples outside corresponding picture boundary may be used in inter prediction.
3977                               See the CodingOptionValue enumerator for values of this option. */
3978     mfxU16 reserved[8];
3979 } mfxExtMVOverPicBoundaries;
3980 MFX_PACK_END()
3981 
3982 MFX_PACK_BEGIN_USUAL_STRUCT()
3983 /*!
3984    Configures the VPP ColorFill filter algorithm.
3985 */
3986 typedef struct {
3987     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_COLORFILL. */
3988 
3989     mfxU16 Enable;       /*!< Set to ON makes VPP fill the area between Width/Height and Crop borders.
3990                               See the CodingOptionValue enumerator for values of this option. */
3991     mfxU16 reserved[11];
3992 } mfxExtVPPColorFill;
3993 MFX_PACK_END()
3994 
3995 
3996 /*! The ChromaSiting enumerator defines chroma location. Use bit-OR’ed values to specify the desired location. */
3997 enum {
3998     MFX_CHROMA_SITING_UNKNOWN             = 0x0000, /*!< Unspecified. */
3999     MFX_CHROMA_SITING_VERTICAL_TOP        = 0x0001, /*!< Chroma samples are co-sited vertically on the top with the luma samples. */
4000     MFX_CHROMA_SITING_VERTICAL_CENTER     = 0x0002, /*!< Chroma samples are not co-sited vertically with the luma samples. */
4001     MFX_CHROMA_SITING_VERTICAL_BOTTOM     = 0x0004, /*!< Chroma samples are co-sited vertically on the bottom with the luma samples. */
4002     MFX_CHROMA_SITING_HORIZONTAL_LEFT     = 0x0010, /*!< Chroma samples are co-sited horizontally on the left with the luma samples. */
4003     MFX_CHROMA_SITING_HORIZONTAL_CENTER   = 0x0020  /*!< Chroma samples are not co-sited horizontally with the luma samples. */
4004 };
4005 
4006 MFX_PACK_BEGIN_USUAL_STRUCT()
4007 /*!
4008    A hint structure that tunes the VPP Color Conversion algorithm when
4009    attached to the mfxVideoParam structure during VPP Init.
4010 */
4011 typedef struct {
4012     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_COLOR_CONVERSION. */
4013 
4014     mfxU16 ChromaSiting; /*!< See ChromaSiting enumerator for details. */
4015     mfxU16 reserved[27];
4016 } mfxExtColorConversion;
4017 MFX_PACK_END()
4018 
4019 
4020 /*! The VP9ReferenceFrame enumerator itemizes reference frame type by mfxVP9SegmentParam::ReferenceFrame parameter.  */
4021 enum {
4022     MFX_VP9_REF_INTRA   = 0, /*!< Intra. */
4023     MFX_VP9_REF_LAST    = 1, /*!< Last. */
4024     MFX_VP9_REF_GOLDEN  = 2, /*!< Golden. */
4025     MFX_VP9_REF_ALTREF  = 3  /*!< Alternative reference. */
4026 };
4027 
4028 /*!
4029    The SegmentIdBlockSize enumerator indicates the block size represented by each segment_id in segmentation map.
4030    These values are used with the mfxExtVP9Segmentation::SegmentIdBlockSize parameter.
4031 */
4032 enum {
4033     MFX_VP9_SEGMENT_ID_BLOCK_SIZE_UNKNOWN =  0, /*!< Unspecified block size. */
4034     MFX_VP9_SEGMENT_ID_BLOCK_SIZE_8x8     =  8, /*!<  8x8  block size. */
4035     MFX_VP9_SEGMENT_ID_BLOCK_SIZE_16x16   = 16, /*!< 16x16 block size. */
4036     MFX_VP9_SEGMENT_ID_BLOCK_SIZE_32x32   = 32, /*!< 32x32 block size. */
4037     MFX_VP9_SEGMENT_ID_BLOCK_SIZE_64x64   = 64, /*!< 64x64 block size. */
4038 };
4039 
4040 /*!
4041    The SegmentFeature enumerator indicates features enabled for the segment.
4042    These values are used with the mfxVP9SegmentParam::FeatureEnabled parameter.
4043 */
4044 enum {
4045     MFX_VP9_SEGMENT_FEATURE_QINDEX      = 0x0001, /*!< Quantization index delta. */
4046     MFX_VP9_SEGMENT_FEATURE_LOOP_FILTER = 0x0002, /*!< Loop filter level delta. */
4047     MFX_VP9_SEGMENT_FEATURE_REFERENCE   = 0x0004, /*!< Reference frame. */
4048     MFX_VP9_SEGMENT_FEATURE_SKIP        = 0x0008  /*!< Skip. */
4049 };
4050 
4051 MFX_PACK_BEGIN_USUAL_STRUCT()
4052 /*!
4053    Contains features and parameters for the segment.
4054 */
4055 typedef struct {
4056     mfxU16  FeatureEnabled;       /*!< Indicates which features are enabled for the segment. See the SegmentFeature enumerator for values for this
4057                                        option. Values from the enumerator can be bit-OR’ed. Support of a particular feature depends on underlying
4058                                        hardware platform. Application can check which features are supported by calling Query. */
4059     mfxI16  QIndexDelta;          /*!< Quantization index delta for the segment. Ignored if MFX_VP9_SEGMENT_FEATURE_QINDEX isn’t set in FeatureEnabled.
4060                                        Valid range for this parameter is [-255, 255]. If QIndexDelta is out of this range, it will be ignored.
4061                                        If QIndexDelta is within valid range, but sum of base quantization index and QIndexDelta is out of [0, 255],
4062                                        QIndexDelta will be clamped. */
4063     mfxI16  LoopFilterLevelDelta; /*!< Loop filter level delta for the segment. Ignored if MFX_VP9_SEGMENT_FEATURE_LOOP_FILTER is not set in
4064                                        FeatureEnabled. Valid range for this parameter is [-63, 63]. If LoopFilterLevelDelta is out of this range,
4065                                        it will be ignored. If LoopFilterLevelDelta is within valid range, but sum of base loop filter level and
4066                                        LoopFilterLevelDelta is out of [0, 63], LoopFilterLevelDelta will be clamped. */
4067     mfxU16  ReferenceFrame;       /*!< Reference frame for the segment. See VP9ReferenceFrame enumerator for values for this option. Ignored
4068                                        if MFX_VP9_SEGMENT_FEATURE_REFERENCE isn’t set in FeatureEnabled. */
4069     mfxU16  reserved[12];
4070 } mfxVP9SegmentParam;
4071 MFX_PACK_END()
4072 
4073 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
4074 /*!
4075    In the VP9 encoder it is possible to divide a frame into up to 8 segments and apply particular features (like delta for quantization index or for
4076    loop filter level) on a per-segment basis. “Uncompressed header” of every frame indicates if segmentation is enabled for the current frame,
4077    and (if segmentation enabled) contains full information about features applied to every segment. Every “Mode info block” of a coded
4078    frame has segment_id in the range of 0 to 7.
4079 
4080    To enable Segmentation, the mfxExtVP9Segmentation structure with correct settings should be passed to the encoder. It can be attached to the
4081    mfxVideoParam structure during initialization or the MFXVideoENCODE_Reset call (static configuration). If the mfxExtVP9Segmentation buffer isn’t
4082    attached during initialization, segmentation is disabled for static configuration. If the buffer isn’t attached for the Reset call, the encoder
4083    continues to use static configuration for segmentation which was the default before this Reset call. If the mfxExtVP9Segmentation buffer with
4084    NumSegments=0 is provided during initialization or Reset call, segmentation becomes disabled for static configuration.
4085 
4086    The buffer can be attached to the mfxEncodeCtrl structure during runtime (dynamic configuration). Dynamic configuration is applied to the
4087    current frame only. After encoding of the current frame, the encoder will switch to the next dynamic configuration or to static configuration if dynamic configuration
4088    is not provided for next frame).
4089 
4090    The SegmentIdBlockSize, NumSegmentIdAlloc, and SegmentId parameters represent a segmentation map. Here, the segmentation map is an array of segment_ids (one
4091    byte per segment_id) for blocks of size NxN in raster scan order. The size NxN is specified by the application and is constant for the whole frame.
4092    If mfxExtVP9Segmentation is attached during initialization and/or during runtime, all three parameters should be set to proper values that do not
4093    conflict with each other and with NumSegments. If any of the parameters are not set or any conflict or error in these parameters is detected by the library, the segmentation
4094    map will be discarded.
4095 */
4096 typedef struct {
4097     mfxExtBuffer        Header;             /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VP9_SEGMENTATION. */
4098     mfxU16              NumSegments;        /*!< Number of segments for frame. Value 0 means that segmentation is disabled. Sending 0 for a
4099                                                  particular frame will disable segmentation for this frame only. Sending 0 to the Reset API function will
4100                                                  disable segmentation permanently. Segmentation can be enabled again by a subsequent Reset call. */
4101     mfxVP9SegmentParam  Segment[8];         /*!< Array of mfxVP9SegmentParam structures containing features and parameters for every segment.
4102                                                  Entries with indexes bigger than NumSegments-1 are ignored. See the mfxVP9SegmentParam structure for
4103                                                  definitions of segment features and their parameters. */
4104     mfxU16              SegmentIdBlockSize; /*!< Size of block (NxN) for segmentation map. See SegmentIdBlockSize enumerator for values for this
4105                                                  option. An encoded block that is bigger than SegmentIdBlockSize uses segment_id taken from it’s
4106                                                  top-left sub-block from the segmentation map. The application can check if a particular block size is
4107                                                  supported by calling Query. */
4108     mfxU32              NumSegmentIdAlloc;  /*!< Size of buffer allocated for segmentation map (in bytes). Application must assure that
4109                                                  NumSegmentIdAlloc is large enough to cover frame resolution with blocks of size SegmentIdBlockSize.
4110                                                  Otherwise the segmentation map will be discarded. */
4111     union {
4112         mfxU8           *SegmentId;         /*!< Pointer to the segmentation map buffer which holds the array of segment_ids in raster scan order. The application
4113                                                  is responsible for allocation and release of this memory. The buffer pointed to by SegmentId, provided during
4114                                                  initialization or Reset call should be considered in use until another SegmentId is provided via Reset
4115                                                  call (if any), or until MFXVideoENCODE_Close is called. The buffer pointed to by SegmentId provided with
4116                                                  mfxEncodeCtrl should be considered in use while the input surface is locked by the library. Every segment_id in the
4117                                                  map should be in the range of 0 to NumSegments-1. If some segment_id is out of valid range, the
4118                                                  segmentation map cannot be applied. If the mfxExtVP9Segmentation buffer is attached to the mfxEncodeCtrl structure in
4119                                                  runtime, SegmentId can be zero. In this case, the segmentation map from static configuration will be used. */
4120         mfxU64          reserved1;
4121     };
4122     mfxU16  reserved[52];
4123 } mfxExtVP9Segmentation;
4124 MFX_PACK_END()
4125 
4126 MFX_PACK_BEGIN_USUAL_STRUCT()
4127 /*!
4128    Specifies temporal layer.
4129 */
4130 typedef struct {
4131     mfxU16 FrameRateScale;  /*!< The ratio between the frame rates of the current temporal layer and the base layer. The library treats a particular
4132                                  temporal layer as “defined” if it has FrameRateScale > 0. If the base layer is defined, it must have FrameRateScale = 1. FrameRateScale of each subsequent layer (if defined) must be a multiple of and greater than the
4133                                  FrameRateScale value of previous layer. */
4134     mfxU16 TargetKbps;      /*!< Target bitrate for the current temporal layer. Ignored if RateControlMethod is CQP. If RateControlMethod is not CQP, the
4135                                  application must provide TargetKbps for every defined temporal layer. TargetKbps of each subsequent layer (if defined)
4136                                  must be greater than the TargetKbps value of the previous layer. */
4137     mfxU16 reserved[14];
4138 } mfxVP9TemporalLayer;
4139 MFX_PACK_END()
4140 
4141 MFX_PACK_BEGIN_USUAL_STRUCT()
4142 /*!
4143    API allows the encoding of VP9 bitstreams that contain several subset bitstreams that differ in frame rates, also called “temporal layers”.
4144 
4145    When decoding, each temporal layer can be extracted from the coded stream and decoded separately. The mfxExtVP9TemporalLayers structure
4146    configures the temporal layers for the VP9 encoder. It can be attached to the mfxVideoParam structure during initialization or the
4147    MFXVideoENCODE_Reset call. If the mfxExtVP9TemporalLayers buffer isn’t attached during initialization, temporal scalability is disabled. If the buffer isn’t attached for the Reset call, the encoder continues to use the temporal scalability configuration that was defined before the Reset call.
4148 
4149    In the API, temporal layers are ordered by their frame rates in ascending order. Temporal layer 0 (having the lowest frame rate) is called the base layer.
4150    Each subsequent temporal layer includes all previous layers.
4151 
4152    The temporal scalability feature requires a minimum number of allocated reference
4153    frames (controlled by the NumRefFrame parameter). If the NumRefFrame value set by the application isn’t enough to build the reference structure for the requested
4154    number of temporal layers, the library corrects the NumRefFrame value. The temporal layer structure is reset (re-started) after key-frames.
4155 */
4156 typedef struct {
4157     mfxExtBuffer        Header;   /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VP9_TEMPORAL_LAYERS. */
4158     /*!
4159        The array of temporal layers. Layer[0] specifies the base layer.
4160 
4161        The library reads layers from the array when they are defined (FrameRateScale > 0).
4162        All layers starting from first layer with FrameRateScale = 0 are ignored. The last layer that is not ignored is considered the “highest layer”.
4163 
4164        The frame rate of the highest layer is specified in the mfxVideoParam structure. Frame rates of lower layers are calculated using their FrameRateScale.
4165 
4166        TargetKbps of the highest layer should be equal to the TargetKbps value specified in the mfxVideoParam structure. If it is not true, TargetKbps of highest temporal layers has priority.
4167 
4168        If there are no defined layers in the Layer array, the temporal scalability feature is disabled. For example, to disable temporal scalability in runtime, the application should
4169        pass mfxExtVP9TemporalLayers buffer to Reset with all FrameRateScales set to 0.
4170     */
4171     mfxVP9TemporalLayer Layer[8];
4172     mfxU16              reserved[60];
4173 } mfxExtVP9TemporalLayers;
4174 MFX_PACK_END()
4175 
4176 MFX_PACK_BEGIN_USUAL_STRUCT()
4177 /*!
4178    Structure attached to the mfxVideoParam structure. Extends the mfxVideoParam structure with VP9-specific parameters. Used by both decoder and encoder.
4179 */
4180 typedef struct {
4181     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VP9_PARAM. */
4182 
4183     mfxU16  FrameWidth;      /*!< Width of the coded frame in pixels. */
4184     mfxU16  FrameHeight;     /*!< Height of the coded frame in pixels. */
4185 
4186     mfxU16  WriteIVFHeaders; /*!< Set this option to ON to make the encoder insert IVF container headers to the output stream. The NumFrame field of the IVF
4187                                   sequence header will be zero. It is the responsibility of the application to update the NumFrame field  with the correct value. See the
4188                                   CodingOptionValue enumerator for values of this option. */
4189 
4190     mfxI16  reserved1[6];
4191     mfxI16  QIndexDeltaLumaDC;   /*!< Specifies an offset for a particular quantization parameter. */
4192     mfxI16  QIndexDeltaChromaAC; /*!< Specifies an offset for a particular quantization parameter. */
4193     mfxI16  QIndexDeltaChromaDC; /*!< Specifies an offset for a particular quantization parameter. */
4194     /*!
4195        Number of tile rows. Should be power of two. The maximum number of tile rows is 4, per the VP9 specification. In addition, the maximum supported number
4196        of tile rows may depend on the underlying library implementation.
4197 
4198        Use the Query API function to check if a particular pair of values (NumTileRows, NumTileColumns)
4199        is supported. In VP9, tile rows have dependencies and cannot be encoded or decoded in parallel. Therefore, tile rows are always encoded by the library in
4200        serial mode (one-by-one).
4201     */
4202     mfxU16  NumTileRows;
4203     /*!
4204        Number of tile columns. Should be power of two. Restricted with maximum and minimum tile width in luma pixels, as defined in the VP9
4205        specification (4096 and 256 respectively). In addition, the maximum supported number of tile columns may depend on the underlying library
4206        implementation.
4207 
4208        Use the Query API function to check if a particular pair of values (NumTileRows, NumTileColumns) is supported. In VP9,  tile columns do not have
4209        dependencies and can be encoded/decoded in parallel. Therefore, tile columns can be encoded by the library in both parallel and serial modes.
4210 
4211        Parallel mode is automatically utilized by the library when NumTileColumns exceeds 1 and does not exceed the number of tile coding engines on the
4212        platform. In other cases, serial mode is used. Parallel mode is capable of encoding more than 1 tile row (within limitations provided by VP9
4213        specification and particular platform). Serial mode supports only tile grids 1xN and Nx1.
4214     */
4215     mfxU16  NumTileColumns;
4216     mfxU16  reserved[110];
4217 } mfxExtVP9Param;
4218 MFX_PACK_END()
4219 
4220 
4221 MFX_PACK_BEGIN_USUAL_STRUCT()
4222 /*!
4223    Used to report encoded unit information.
4224 */
4225 typedef struct {
4226     mfxU16 Type;      /*!< Codec-dependent coding unit type (NALU type for AVC/HEVC, start_code for MPEG2 etc). */
4227     mfxU16 reserved1;
4228     mfxU32 Offset;    /*!< Offset relative to the associated mfxBitstream::DataOffset. */
4229     mfxU32 Size;      /*!< Unit size, including delimiter. */
4230     mfxU32 reserved[5];
4231 } mfxEncodedUnitInfo;
4232 MFX_PACK_END()
4233 
4234 MFX_PACK_BEGIN_STRUCT_W_L_TYPE()
4235 /*!
4236    If mfxExtCodingOption3::EncodedUnitsInfo was set to MFX_CODINGOPTION_ON during encoder initialization, the mfxExtEncodedUnitsInfo structure is
4237    attached to the mfxBitstream structure during encoding. It is used to report information about coding units in the resulting bitstream.
4238 
4239    The number of filled items in UnitInfo is min(NumUnitsEncoded, NumUnitsAlloc).
4240 
4241    For counting a minimal amount of encoded units you can use the following algorithm:
4242    @code
4243       nSEI = amountOfApplicationDefinedSEI;
4244       if (CodingOption3.NumSlice[IPB] != 0 || mfxVideoParam.mfx.NumSlice != 0)
4245         ExpectedAmount = 10 + nSEI + Max(CodingOption3.NumSlice[IPB], mfxVideoParam.mfx.NumSlice);
4246       else if (CodingOption2.NumMBPerSlice != 0)
4247         ExpectedAmount = 10 + nSEI + (FrameWidth * FrameHeight) / (256 * CodingOption2.NumMBPerSlice);
4248       else if (CodingOption2.MaxSliceSize != 0)
4249         ExpectedAmount = 10 + nSEI + Round(MaxBitrate / (FrameRate*CodingOption2.MaxSliceSize));
4250       else
4251         ExpectedAmount = 10 + nSEI;
4252 
4253       if (mfxFrameInfo.PictStruct != MFX_PICSTRUCT_PROGRESSIVE)
4254         ExpectedAmount = ExpectedAmount * 2;
4255 
4256       if (temporalScaleabilityEnabled)
4257         ExpectedAmount = ExpectedAmount * 2;
4258     @endcode
4259     @note Only supported by the AVC encoder.
4260 */
4261 typedef struct {
4262     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_ENCODED_UNITS_INFO. */
4263 
4264     union {
4265         mfxEncodedUnitInfo *UnitInfo; /*!< Pointer to an array of mfxEncodedUnitsInfo structures whose size is equal to or greater than NumUnitsAlloc. */
4266         mfxU64  reserved1;
4267     };
4268     mfxU16 NumUnitsAlloc;             /*!< UnitInfo array size. */
4269     mfxU16 NumUnitsEncoded;           /*!< Output field. Number of coding units to report. If NumUnitsEncoded is greater than NumUnitsAlloc, the UnitInfo
4270                                            array will contain information only for the first NumUnitsAlloc units. User may consider reallocating the
4271                                            UnitInfo array to avoid this for subsequent frames. */
4272 
4273     mfxU16 reserved[22];
4274 } mfxExtEncodedUnitsInfo;
4275 MFX_PACK_END()
4276 
4277 
4278 MFX_PACK_BEGIN_USUAL_STRUCT()
4279 /*!
4280    Provides setup for the Motion-Compensated Temporal Filter (MCTF) during the VPP initialization and for control
4281    parameters at runtime. By default, MCTF is off. An application may enable it by adding MFX_EXTBUFF_VPP_MCTF to the mfxExtVPPDoUse buffer or by
4282    attaching mfxExtVppMctf to the mfxVideoParam structure during initialization or reset.
4283 */
4284 typedef struct {
4285     mfxExtBuffer Header;         /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_VPP_MCTF. */
4286     mfxU16       FilterStrength; /*!< Value in range of 0 to 20 (inclusive) to indicate the filter strength of MCTF.
4287 
4288                                     The strength of the MCTF process controls the degree of possible change of pixel values eligible for MCTF - the greater the strength value, the larger the change. It is a dimensionless quantity - values in the range of 1 to 20 inclusively imply strength; value 0 stands for AUTO mode and is
4289                                       valid during initialization or reset only
4290 
4291                                     If an invalid value is given, it is fixed to the default value of 0.
4292                                       If the field value is in the range of 1 to 20 inclusive, MCTF operates in fixed-strength mode with the given strength of MCTF process.
4293 
4294                                       At runtime, values of 0 and greater than 20 are ignored. */
4295     mfxU16       reserved[27];
4296 } mfxExtVppMctf;
4297 MFX_PACK_END()
4298 
4299 /*! Describes type of workload passed to MFXQueryAdapters. */
4300 typedef enum
4301 {
4302     MFX_COMPONENT_ENCODE = 1, /*!< Encode workload. */
4303     MFX_COMPONENT_DECODE = 2, /*!< Decode workload. */
4304     MFX_COMPONENT_VPP    = 3  /*!< VPP workload. */
4305 } mfxComponentType;
4306 
4307 MFX_PACK_BEGIN_STRUCT_W_PTR()
4308 /*!
4309    Contains workload description, which is accepted by MFXQueryAdapters function.
4310 */
4311 typedef struct
4312 {
4313     mfxComponentType Type;         /*!< Type of workload: Encode, Decode, VPP. See mfxComponentType enumerator for values. */
4314     mfxVideoParam    Requirements; /*!< Detailed description of workload. See mfxVideoParam for details. */
4315 
4316     mfxU16           reserved[4];
4317 } mfxComponentInfo;
4318 MFX_PACK_END()
4319 
4320 /* Adapter description */
4321 MFX_PACK_BEGIN_USUAL_STRUCT()
4322 /*!
4323    Contains a description of the graphics adapter for the Legacy mode.
4324 */
4325 typedef struct
4326 {
4327     mfxPlatform Platform; /*!< Platform type description. See mfxPlatform for details. */
4328     mfxU32      Number;   /*!< Value which uniquely characterizes media adapter. On Windows* this number can be used for initialization through
4329                                DXVA interface (see <a href="https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgifactory1-enumadapters1">example</a>). */
4330 
4331     mfxU16      reserved[14];
4332 } mfxAdapterInfo;
4333 MFX_PACK_END()
4334 
4335 MFX_PACK_BEGIN_STRUCT_W_PTR()
4336 /*!
4337    Contains description of all graphics adapters available on the current system.
4338 */
4339 typedef struct
4340 {
4341     mfxAdapterInfo * Adapters;  /*!< Pointer to array of mfxAdapterInfo structs allocated by user. */
4342     mfxU32           NumAlloc;  /*!< Length of Adapters array. */
4343     mfxU32           NumActual; /*!< Number of Adapters entries filled by MFXQueryAdapters. */
4344 
4345     mfxU16           reserved[4];
4346 } mfxAdaptersInfo;
4347 MFX_PACK_END()
4348 
4349 
4350 /*! The PartialBitstreamOutput enumerator indicates flags of partial bitstream output type. */
4351 enum {
4352     MFX_PARTIAL_BITSTREAM_NONE    = 0, /*!< Do not use partial output */
4353     MFX_PARTIAL_BITSTREAM_SLICE   = 1, /*!< Partial bitstream output will be aligned to slice granularity */
4354     MFX_PARTIAL_BITSTREAM_BLOCK   = 2, /*!< Partial bitstream output will be aligned to user-defined block size granularity */
4355     MFX_PARTIAL_BITSTREAM_ANY     = 3  /*!< Partial bitstream output will be return any coded data available at the end of SyncOperation timeout */
4356 };
4357 
4358 MFX_PACK_BEGIN_USUAL_STRUCT()
4359 /*!
4360    Used by an encoder to output parts of the bitstream as soon as they are ready. The application can attach this extended buffer to the
4361    mfxVideoParam structure at initialization. If this option is turned ON (Granularity != MFX_PARTIAL_BITSTREAM_NONE), then the encoder can output
4362    bitstream by part based on the required granularity.
4363 
4364    This parameter is valid only during initialization and reset. Absence of this buffer means default or previously configured bitstream output
4365    behavior.
4366 
4367    @note Not all codecs and implementations support this feature. Use the Query API function to check if this feature is supported.
4368 */
4369 typedef struct {
4370     mfxExtBuffer    Header;      /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_PARTIAL_BITSTREAM_PARAM. */
4371     mfxU32          BlockSize;   /*!< Output block granularity for PartialBitstreamGranularity. Valid only for MFX_PARTIAL_BITSTREAM_BLOCK. */
4372     mfxU16          Granularity; /*!< Granularity of the partial bitstream: slice/block/any, all types of granularity state in PartialBitstreamOutput enum. */
4373     mfxU16          reserved[8];
4374 } mfxExtPartialBitstreamParam;
4375 MFX_PACK_END()
4376 
4377 MFX_PACK_BEGIN_STRUCT_W_PTR()
4378 /*!
4379    The mfxExtDeviceAffinityMask structure is used by the application to specify
4380    affinity mask for the device with given device ID. See mfxDeviceDescription
4381    for the device ID definition and sub device indexes. If the implementation
4382    manages CPU threads for some purpose, the user can set the CPU thread affinity
4383    mask by using this structure with DeviceID set to "CPU".
4384 */
4385 typedef struct {
4386     /*! Extension buffer header. Header.BufferId must be equal to
4387         MFX_EXTBUFF_DEVICE_AFFINITY_MASK. */
4388     mfxExtBuffer    Header;
4389     /*! Null terminated string with device ID. In case of CPU affinity mask
4390         it must be equal to "CPU". */
4391     mfxChar         DeviceID[MFX_STRFIELD_LEN];
4392     /*! Number of sub devices or threads in case of CPU in the mask. */
4393     mfxU32          NumSubDevices;
4394     /*! Mask array. Every bit represents sub-device (or thread for CPU).
4395         "1" means execution is allowed. "0" means that execution is prohibited on
4396         this sub-device (or thread). Length of the array is equal to the:
4397         "max_subdevices / 8" and rounded to the closest (from the right) integer.
4398         Bits order within each entry of the mask array is LSB: bit 0 holds data
4399         for sub device with index 0 and bit 8 for sub device with index 8.
4400         Index of sub device is defined by the mfxDeviceDescription structure. */
4401     mfxU8           *Mask;
4402     mfxU32           reserved[4]; /*! Reserved for future use. */
4403 } mfxExtDeviceAffinityMask;
4404 MFX_PACK_END()
4405 
4406 MFX_PACK_BEGIN_USUAL_STRUCT()
4407 /*! The structure is used by AV1 encoder with more parameter control to encode frame. */
4408 typedef struct {
4409     mfxExtBuffer Header;   /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_AV1_BITSTREAM_PARAM. */
4410 
4411     mfxU16 WriteIVFHeaders; /*!< Tri-state option to control IVF headers insertion, default is ON.
4412                                 Writing IVF headers is enabled in the encoder when mfxExtAV1BitstreamParam is attached and its value is ON or zero.
4413                                 Writing IVF headers is disabled by default in the encoder when mfxExtAV1BitstreamParam is not attached. */
4414 
4415     mfxU16 reserved[31];
4416 } mfxExtAV1BitstreamParam;
4417 MFX_PACK_END()
4418 
4419 MFX_PACK_BEGIN_USUAL_STRUCT()
4420 /*! The structure is used by AV1 encoder with more parameter control to encode frame. */
4421 typedef struct {
4422     mfxExtBuffer Header; /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_AV1_RESOLUTION_PARAM. */
4423 
4424     mfxU32 FrameWidth;   /*!< Width of the coded frame in pixels, default value is from mfxFrameInfo. */
4425     mfxU32 FrameHeight;  /*!< Height of the coded frame in pixels, default value is from mfxFrameInfo. */
4426 
4427     mfxU32 reserved[6];
4428 } mfxExtAV1ResolutionParam;
4429 MFX_PACK_END()
4430 
4431 MFX_PACK_BEGIN_USUAL_STRUCT()
4432   /*! The structure is used by AV1 encoder with more parameter control to encode frame. */
4433 typedef struct {
4434     mfxExtBuffer Header;   /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_AV1_TILE_PARAM. */
4435 
4436     mfxU16 NumTileRows;    /*!< Number of tile rows, default value is 1. */
4437     mfxU16 NumTileColumns; /*!< Number of tile columns, default value is 1. */
4438     mfxU16 NumTileGroups;  /*!< Number of tile groups, it will be ingored if the tile groups num is invalid, default value is 1. */
4439 
4440     mfxU16 reserved[5];
4441 } mfxExtAV1TileParam;
4442 MFX_PACK_END()
4443 
4444 /*!
4445     The AV1 SegmentIdBlockSize enumerator indicates the block size represented by each segment_id in segmentation map.
4446     These values are used with the mfxExtAV1Segmentation::SegmentIdBlockSize parameter.
4447 */
4448 typedef enum {
4449     MFX_AV1_SEGMENT_ID_BLOCK_SIZE_UNSPECIFIED = 0,  /*!< Unspecified block size. */
4450     MFX_AV1_SEGMENT_ID_BLOCK_SIZE_4x4         = 4,  /*!< block size 4x4 */
4451     MFX_AV1_SEGMENT_ID_BLOCK_SIZE_8x8         = 8,  /*!< block size 8x8 */
4452     MFX_AV1_SEGMENT_ID_BLOCK_SIZE_16x16       = 16, /*!< block size 16x16 */
4453     MFX_AV1_SEGMENT_ID_BLOCK_SIZE_32x32       = 32, /*!< block size 32x32 */
4454     MFX_AV1_SEGMENT_ID_BLOCK_SIZE_64x64       = 64, /*!< block size 64x64 */
4455     MFX_AV1_SEGMENT_ID_BLOCK_SIZE_128x128     = 128 /*!< block size 128x128 */
4456 } mfxAV1SegmentIdBlockSize;
4457 
4458 /*!
4459     The AV1 SegmentFeature enumerator indicates features enabled for the segment.
4460     These values are used with the mfxAV1SegmentParam::FeatureEnabled parameter.
4461 */
4462 enum {
4463     MFX_AV1_SEGMENT_FEATURE_ALT_QINDEX    = 0x0001, /*!< use alternate Quantizer. */
4464     MFX_AV1_SEGMENT_FEATURE_ALT_LF_Y_VERT = 0x0002, /*!< use alternate loop filter value on y plane vertical. */
4465     MFX_AV1_SEGMENT_FEATURE_ALT_LF_Y_HORZ = 0x0004, /*!< use alternate loop filter value on y plane horizontal. */
4466     MFX_AV1_SEGMENT_FEATURE_ALT_LF_U      = 0x0008, /*!< use alternate loop filter value on u plane. */
4467     MFX_AV1_SEGMENT_FEATURE_ALT_LF_V      = 0x0010, /*!< use alternate loop filter value on v plane. */
4468     MFX_AV1_SEGMENT_FEATURE_REFERENCE     = 0x0020, /*!< use segment reference frame. */
4469     MFX_AV1_SEGMENT_FEATURE_SKIP          = 0x0040, /*!< use segment (0,0) + skip mode. */
4470     MFX_AV1_SEGMENT_FEATURE_GLOBALMV      = 0x0080  /*!< use global motion vector. */
4471 };
4472 
4473 MFX_PACK_BEGIN_USUAL_STRUCT()
4474 /*!
4475     Contains features and parameters for the segment.
4476 */
4477 typedef struct {
4478     mfxU16 FeatureEnabled;  /*!< Indicates which features are enabled for the segment. See the AV1 SegmentFeature enumerator for values for
4479                                 this option. Values from the enumerator can be bit-OR’ed. Support of a particular feature depends on underlying
4480                                 hardware platform. Application can check which features are supported by calling Query. */
4481     mfxI16 AltQIndex;       /*!< Quantization index delta for the segment. Ignored if MFX_AV1_SEGMENT_FEATURE_ALT_QINDEX isn’t set in FeatureEnabled.
4482                                 Valid range for this parameter is [-255, 255]. If AltQIndex is out of this range, it will be ignored. If AltQIndex
4483                                 is within valid range, but sum of base quantization index and AltQIndex is out of [0, 255], AltQIndex will be clamped. */
4484     mfxU16 reserved[30];
4485 } mfxAV1SegmentParam;
4486 MFX_PACK_END()
4487 
4488 MFX_PACK_BEGIN_STRUCT_W_PTR()
4489 /*!
4490     In the AV1 encoder it is possible to divide a frame into up to 8 segments and apply particular features (like delta for quantization index or for
4491     loop filter level) on a per-segment basis. “Uncompressed header” of every frame indicates if segmentation is enabled for the current frame,
4492     and (if segmentation enabled) contains full information about features applied to every segment. Every “Mode info block” of a coded
4493     frame has segment_id in the range of 0 to 7.
4494     To enable Segmentation, the mfxExtAV1Segmentation structure with correct settings should be passed to the encoder. It can be attached to the
4495     mfxVideoParam structure during initialization or the MFXVideoENCODE_Reset call (static configuration). If the mfxExtAV1Segmentation buffer isn’t
4496     attached during initialization, segmentation is disabled for static configuration. If the buffer isn’t attached for the Reset call, the encoder
4497     continues to use static configuration for segmentation which was the default before this Reset call. If the mfxExtAV1Segmentation buffer with
4498     NumSegments=0 is provided during initialization or Reset call, segmentation becomes disabled for static configuration.
4499     The buffer can be attached to the mfxEncodeCtrl structure during runtime (dynamic configuration). Dynamic configuration is applied to the
4500     current frame only. After encoding of the current frame, the encoder will switch to the next dynamic configuration or to static configuration if
4501     dynamic configuration is not provided for next frame).
4502     The SegmentIdBlockSize, NumSegmentIdAlloc, and SegmentId parameters represent a segmentation map. Here, the segmentation map is an array of
4503     segment_ids (one byte per segment_id) for blocks of size NxN in raster scan order. The size NxN is specified by the application and is constant
4504     for the whole frame.
4505     If mfxExtAV1Segmentation is attached during initialization and/or during runtime, all three parameters should be set to proper values that do not
4506     conflict with each other and with NumSegments. If any of the parameters are not set or any conflict or error in these parameters is detected by
4507     the library, the segmentation map will be discarded.
4508 */
4509 typedef struct {
4510     mfxExtBuffer       Header;            /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_AV1_SEGMENTATION. */
4511     mfxU8              NumSegments;       /*!< Number of segments for frame. Value 0 means that segmentation is disabled. Sending 0 for a
4512                                                 particular frame will disable segmentation for this frame only. Sending 0 to the Reset API function will
4513                                                 disable segmentation permanently. Segmentation can be enabled again by a subsequent Reset call. */
4514     mfxU8              reserved1[3];
4515     mfxAV1SegmentParam Segment[8];        /*!< Array of mfxAV1SegmentParam structures containing features and parameters for every segment.
4516                                                 Entries with indexes bigger than NumSegments-1 are ignored. See the mfxAV1SegmentParam structure for
4517                                                 definitions of segment features and their parameters. */
4518     mfxU16             SegmentIdBlockSize;/*!< Size of block (NxN) for segmentation map. See AV1 SegmentIdBlockSize enumerator for values for this
4519                                                 option. An encoded block that is bigger than AV1 SegmentIdBlockSize uses segment_id taken from it’s
4520                                                 top-left sub-block from the segmentation map. The application can check if a particular block size is
4521                                                 supported by calling Query. */
4522     mfxU16             reserved2;
4523     mfxU32             NumSegmentIdAlloc; /*!< Size of buffer allocated for segmentation map (in bytes). Application must assure that
4524                                                 NumSegmentIdAlloc is large enough to cover frame resolution with blocks of size SegmentIdBlockSize.
4525                                                 Otherwise the segmentation map will be discarded. */
4526     mfxU8 *            SegmentIds;        /*!< Pointer to the segmentation map buffer which holds the array of segment_ids in raster scan order. The application
4527                                                 is responsible for allocation and release of this memory. The buffer pointed to by SegmentId, provided during
4528                                                 initialization or Reset call should be considered in use until another SegmentId is provided via Reset
4529                                                 call (if any), or until MFXVideoENCODE_Close is called. The buffer pointed to by SegmentId provided with
4530                                                 mfxEncodeCtrl should be considered in use while the input surface is locked by the library. Every segment_id in the
4531                                                 map should be in the range of 0 to NumSegments-1. If some segment_id is out of valid range, the
4532                                                 segmentation map cannot be applied. If the mfxExtAV1Segmentation buffer is attached to the mfxEncodeCtrl structure in
4533                                                 runtime, SegmentId can be zero. In this case, the segmentation map from static configuration will be used. */
4534     mfxU16             reserved[36];
4535 } mfxExtAV1Segmentation;
4536 MFX_PACK_END()
4537 
4538 /*! The FilmGrainFlags enumerator itemizes flags in AV1 film grain parameters.
4539     The flags are equivalent to respective syntax elements from film_grain_params() section of uncompressed header. */
4540 enum {
4541     MFX_FILM_GRAIN_NO                       =       0, /*!< Film grain isn't added to this frame. */
4542     MFX_FILM_GRAIN_APPLY                    = (1 << 0), /*!< Film grain is added to this frame. */
4543     MFX_FILM_GRAIN_UPDATE                   = (1 << 1), /*!< New set of film grain parameters is sent for this frame. */
4544     MFX_FILM_GRAIN_CHROMA_SCALING_FROM_LUMA = (1 << 2), /*!< Chroma scaling is inferred from luma scaling. */
4545     MFX_FILM_GRAIN_OVERLAP                  = (1 << 3), /*!< Overlap between film grain blocks is applied. */
4546     MFX_FILM_GRAIN_CLIP_TO_RESTRICTED_RANGE = (1 << 4) /*!< Clipping to the restricted (studio) range is applied after adding the film grain. */
4547 };
4548 
4549 MFX_PACK_BEGIN_USUAL_STRUCT()
4550 /*! Defines film grain point. */
4551 typedef struct {
4552     mfxU8 Value; /*!<  The x coordinate for the i-th point of the piece-wise linear scaling function for luma/Cb/Cr component. */
4553     mfxU8 Scaling; /*!<  The scaling (output) value for the i-th point of the piecewise linear scaling function for luma/Cb/Cr component. */
4554 } mfxAV1FilmGrainPoint;
4555 MFX_PACK_END()
4556 
4557 MFX_PACK_BEGIN_USUAL_STRUCT()
4558 /*! The structure is used by AV-1 decoder to report film grain parameters for decoded frame. */
4559 typedef struct {
4560     mfxExtBuffer Header;    /*!< Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_AV1_FILM_GRAIN_PARAM. */
4561 
4562     mfxU16 FilmGrainFlags;  /*!< Bit map with bit-ORed flags from FilmGrainFlags enum. */
4563     mfxU16 GrainSeed;       /*!< Starting value for pseudo-random numbers used during film grain synthesis. */
4564 
4565     mfxU8  RefIdx;          /*!< Indicate which reference frame contains the film grain parameters to be used for this frame. */
4566     mfxU8  NumYPoints;      /*!< The number of points for the piece-wise linear scaling function of the luma component. */
4567     mfxU8  NumCbPoints;     /*!< The number of points for the piece-wise linear scaling function of the Cb component. */
4568     mfxU8  NumCrPoints;     /*!< The number of points for the piece-wise linear scaling function of the Cr component.*/
4569 
4570     mfxAV1FilmGrainPoint PointY[14]; /*!< The array of points for luma component. */
4571     mfxAV1FilmGrainPoint PointCb[10]; /*!< The array of points for Cb component. */
4572     mfxAV1FilmGrainPoint PointCr[10]; /*!< The array of points for Cr component. */
4573 
4574     mfxU8 GrainScalingMinus8; /*!< The shift – 8 applied to the values of the chroma component. The grain_scaling_minus_8 can take values of 0..3 and
4575                                    determines the range and quantization step of the standard deviation of film grain.*/
4576     mfxU8 ArCoeffLag;         /*!< The number of auto-regressive coefficients for luma and chroma.*/
4577 
4578     mfxU8 ArCoeffsYPlus128[24];  /*!< Auto-regressive coefficients used for the Y plane. */
4579     mfxU8 ArCoeffsCbPlus128[25]; /*!< Auto-regressive coefficients used for the Cb plane. */
4580     mfxU8 ArCoeffsCrPlus128[25]; /*!< The number of points for the piece-wise linear scaling function of the Cr component.*/
4581 
4582     mfxU8 ArCoeffShiftMinus6;  /*!< The range of the auto-regressive coefficients.
4583                                     Values of 0, 1, 2, and 3 correspond to the ranges for auto-regressive coefficients of
4584                                     [-2, 2), [-1, 1), [-0.5, 0.5) and [-0.25, 0.25) respectively.*/
4585     mfxU8 GrainScaleShift;     /*!< Downscaling factor of the grain synthesis process for the Gaussian random numbers .*/
4586 
4587     mfxU8  CbMult;     /*!< The multiplier for the Cb component used in derivation of the input index to the Cb component scaling function.*/
4588     mfxU8  CbLumaMult; /*!< The multiplier for the average luma component used in derivation of the input index to the Cb component scaling function. */
4589     mfxU16 CbOffset;   /*!< The offset used in derivation of the input index to the Cb component scaling function.*/
4590 
4591     mfxU8  CrMult;     /*!< The multiplier for the Cr component used in derivation of the input index to the Cr component scaling function.*/
4592     mfxU8  CrLumaMult; /*!< The multiplier for the average luma component used in derivation of the input index to the Cr component scaling function.*/
4593     mfxU16 CrOffset;   /*!< The offset used in derivation of the input index to the Cr component scaling function.*/
4594 
4595     mfxU16 reserved[43];
4596 } mfxExtAV1FilmGrainParam;
4597 MFX_PACK_END()
4598 
4599 #define MFX_SURFACEARRAY_VERSION MFX_STRUCT_VERSION(1, 0)
4600 
4601 
4602 MFX_PACK_BEGIN_STRUCT_W_PTR()
4603 /*! The structure is reference counted object to return array of surfaces allocated and processed by the library. */
4604 typedef struct mfxSurfaceArray
4605 {
4606     mfxHDL              Context; /*!< The context of the memory interface. User should not touch (change, set, null) this pointer. */
4607     mfxStructVersion    Version; /*!< The version of the structure. */
4608     mfxU16 reserved[3];
4609     /*! @brief
4610     Increments the internal reference counter of the surface. The surface is not destroyed until the surface is released using the mfxSurfaceArray::Release function.
4611     mfxSurfaceArray::AddRef should be used each time a new link to the surface is created (for example, copy structure) for proper surface management.
4612 
4613     @param[in]  surface  Valid mfxSurfaceArray.
4614 
4615     @return
4616      MFX_ERR_NONE              If no error. \n
4617      MFX_ERR_NULL_PTR          If surface is NULL. \n
4618      MFX_ERR_INVALID_HANDLE    If mfxSurfaceArray->Context is invalid (for example NULL). \n
4619      MFX_ERR_UNKNOWN           Any internal error.
4620 
4621     */
4622     mfxStatus (MFX_CDECL *AddRef)(struct mfxSurfaceArray*  surface_array);
4623     /*! @brief
4624     Decrements the internal reference counter of the surface. mfxSurfaceArray::Release should be called after
4625     using the mfxSurfaceArray::AddRef function to add a surface or when allocation logic requires it.
4626 
4627     @param[in]  surface_array  Valid mfxSurfaceArray.
4628 
4629     @return
4630      MFX_ERR_NONE               If no error. \n
4631      MFX_ERR_NULL_PTR           If surface is NULL. \n
4632      MFX_ERR_INVALID_HANDLE     If mfxSurfaceArray->Context is invalid (for example NULL). \n
4633      MFX_ERR_UNDEFINED_BEHAVIOR If Reference Counter of surface is zero before call. \n
4634      MFX_ERR_UNKNOWN            Any internal error.
4635     */
4636     mfxStatus (MFX_CDECL *Release)(struct mfxSurfaceArray*  surface_array);
4637 
4638     /*! @brief
4639     Returns current reference counter of mfxSurfaceArray structure.
4640 
4641     @param[in]   surface  Valid surface_array.
4642     @param[out]  counter  Sets counter to the current reference counter value.
4643 
4644     @return
4645      MFX_ERR_NONE               If no error. \n
4646      MFX_ERR_NULL_PTR           If surface or counter is NULL. \n
4647      MFX_ERR_INVALID_HANDLE     If mfxSurfaceArray->Context is invalid (for example NULL). \n
4648      MFX_ERR_UNKNOWN            Any internal error.
4649     */
4650     mfxStatus (MFX_CDECL *GetRefCounter)(struct mfxSurfaceArray*  surface_array, mfxU32* counter);
4651 
4652     mfxFrameSurface1** Surfaces; /*!< The array of pointers to mfxFrameSurface1. mfxFrameSurface1 surfaces are allocated by the same
4653     agent who allocates mfxSurfaceArray. */
4654     mfxU32 NumSurfaces; /*!<The size of array of pointers to mfxFrameSurface1. */
4655     mfxU32 reserved1;
4656 } mfxSurfaceArray;
4657 MFX_PACK_END()
4658 
4659 MFX_PACK_BEGIN_STRUCT_W_PTR()
4660 /*! The structure is used for VPP channels initializtion in Decode_VPP component.  */
4661 typedef struct {
4662     mfxFrameInfo  VPP; /*!< The configuration parameters of VPP filters per each channel. */
4663     mfxU16  Protected; /*!< Specifies the content protection mechanism. */
4664     mfxU16  IOPattern; /*!< Output memory access types for SDK functions. */
4665     mfxExtBuffer** ExtParam; /*!< Points to an array of pointers to the extra configuration structures; see the ExtendedBufferID enumerator for a list of extended configurations. */
4666     mfxU16  NumExtParam; /*!< The number of extra configuration structures attached to the structure. */
4667     mfxU16  reserved1[7];
4668 } mfxVideoChannelParam;
4669 MFX_PACK_END()
4670 
4671 MFX_PACK_BEGIN_USUAL_STRUCT()
4672 /*! The structure describes rectangle coordinates wat can bse used for ROI or for Cropping. */
4673     typedef struct {
4674         mfxU16  Left;   /*!< X coordinate of region of top-left corner of rectangle. */
4675         mfxU16  Top;    /*!< Y coordinate of region of top-left corner of rectangle. */
4676         mfxU16  Right;  /*!< X coordinate of region of bottom-right corner of rectangle. */
4677         mfxU16  Bottom; /*!< Y coordinate of region of bottom-right corner of rectangle. */
4678     } mfxRect;
4679 MFX_PACK_END()
4680 
4681 MFX_PACK_BEGIN_USUAL_STRUCT()
4682 /*! The structure contains crop parameters which applied by Decode_VPP component to input surfaces before video processing operation.
4683     It is used for letterboxing operations.
4684 */
4685 typedef struct {
4686     mfxExtBuffer     Header; /*! Extension buffer header. BufferId must be equal to MFX_EXTBUFF_CROPS. */
4687     mfxRect          Crops;  /*!< Crops parameters for letterboxing operations. */
4688     mfxU32           reserved[4];
4689 }mfxExtInCrops;
4690 MFX_PACK_END()
4691 
4692 /*! The mfxHyperMode enumerator describes HyperMode implementation behavior. */
4693 typedef enum {
4694     MFX_HYPERMODE_OFF = 0x0,        /*!< Don't use HyperMode implementation. */
4695     MFX_HYPERMODE_ON = 0x1,         /*!< Enable HyperMode implementation and return error if some issue on initialization. */
4696     MFX_HYPERMODE_ADAPTIVE = 0x2,   /*!< Enable HyperMode implementation and switch to single fallback if some issue on initialization. */
4697 } mfxHyperMode;
4698 
4699 MFX_PACK_BEGIN_USUAL_STRUCT()
4700 /*! The structure is used for HyperMode initialization. */
4701 typedef struct {
4702     mfxExtBuffer    Header; /*!< Extension buffer header. BufferId must be equal to MFX_EXTBUFF_HYPER_MODE_PARAM. */
4703     mfxHyperMode    Mode;   /*!< HyperMode implementation behavior. */
4704     mfxU16          reserved[19];
4705 } mfxExtHyperModeParam;
4706 MFX_PACK_END()
4707 
4708 MFX_PACK_BEGIN_USUAL_STRUCT()
4709 /*! The structure is used for universal temporal layer description. */
4710 typedef struct {
4711     mfxU16 FrameRateScale;  /*!< The ratio between the frame rates of the current temporal layer and the base layer. The library treats a particular
4712                                  temporal layer as “defined” if it has FrameRateScale > 0. If the base layer is defined, it must have FrameRateScale = 1.
4713                                  FrameRateScale of each subsequent layer (if defined) must be a multiple of and greater than the
4714                                  FrameRateScale value of previous layer. */
4715     mfxU16  reserved[3]; /*!< Reserved for future use. */
4716 
4717     union {
4718           /*!< Type of bitrate controls is currently the same across all temporal layers and inherits from common parameters. */
4719           struct {
4720             mfxU32  InitialDelayInKB;/*!< Initial size of the Video Buffering Verifier (VBV) buffer for the current temporal layer.
4721                                           @note In this context, KB is 1000 bytes and Kbps is 1000 bps. */
4722             mfxU32  BufferSizeInKB; /*!< Represents the maximum possible size of any compressed frames for the current temporal layer. */
4723             mfxU32  TargetKbps;  /*!< Target bitrate for the current temporal layer. If RateControlMethod is not CQP, the
4724                                       application can provide TargetKbps for every defined temporal layer. If TargetKbps per temporal layer is not set then
4725                                       encoder doesn't apply any special bitrate limitations for the layer.  */
4726             mfxU32  MaxKbps;  /*!< The maximum bitrate at which the encoded data enters the Video Buffering Verifier (VBV) buffer for the current temporal layer. */
4727 
4728             mfxU32  reserved1[16]; /*!< Reserved for future use. */
4729 
4730           };
4731           struct {
4732             mfxI32  QPI;  /*!< Quantization Parameter (QP) for I-frames for constant QP mode (CQP) for the current temporal layer. Zero QP is not valid and means that the default value is assigned by the library.
4733                     Non-zero QPI might be clipped to supported QPI range.
4734                     @note Default QPI value is implementation dependent and subject to change without additional notice in this document. */
4735             mfxI32  QPP;  /*!< Quantization Parameter (QP) for P-frames for constant QP mode (CQP) for the current temporal layer. Zero QP is not valid and means that the default value is assigned by the library.
4736                     Non-zero QPP might be clipped to supported QPI range.
4737                     @note Default QPP value is implementation dependent and subject to change without additional notice in this document. */
4738             mfxI32  QPB; /*!< Quantization Parameter (QP) for B-frames for constant QP mode (CQP) for the current temporal layer. Zero QP is not valid and means that the default value is assigned by the library.
4739                     Non-zero QPI might be clipped to supported QPB range.
4740                     @note Default QPB value is implementation dependent and subject to change without additional notice in this document. */
4741           };
4742     };
4743     mfxU16  reserved2[4]; /*!< Reserved for future use. */
4744 
4745 } mfxTemporalLayer;
4746 MFX_PACK_END()
4747 
4748 MFX_PACK_BEGIN_STRUCT_W_PTR()
4749 /*! The structure is used for universal temporal layers description. */
4750 typedef struct {
4751     mfxExtBuffer     Header;     /*! Extension buffer header. Header.BufferId must be equal to MFX_EXTBUFF_UNIVERSAL_TEMPORAL_LAYERS. */
4752     mfxU16           NumLayers; /*!< The  number of temporal layers. */
4753     mfxU16           BaseLayerPID; /*!< The priority ID of the base layer. The encoder increases the ID for each temporal layer and writes to the prefix NAL unit for AVC and HEVC. */
4754     mfxU16           reserved[2]; /*!< Reserved for future use. */
4755     mfxTemporalLayer *Layers; /*!< The array of temporal layers. */
4756 
4757     mfxU16 reserved1[8]; /*!< Reserved for future use. */
4758 } mfxExtTemporalLayers;
4759 MFX_PACK_END()
4760 
4761 #ifdef __cplusplus
4762 } // extern "C"
4763 #endif
4764 
4765 #endif
4766