• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2018-2021 The Khronos Group Inc.
2//
3// SPDX-License-Identifier: CC-BY-4.0
4
5[[encode-h264]]
6== Encode H.264
7
8This extension adds H.264 codec specific structures/types needed to support
9H.264 encoding.
10Unless otherwise noted, all references to the H.264 specification are to the
112010 edition published by the ITU-T, dated March 2010.
12This specification is available at http://www.itu.int/rec/T-REC-H.264.
13
14
15=== H.264 encode profile
16
17An H.264 encode profile is specified by including the
18slink:VkVideoEncodeH264ProfileEXT structure in the pname:pNext chain of the
19slink:VkVideoProfileKHR structure when
20slink:VkVideoProfileKHR::pname:videoCodecOperation is
21ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_EXT.
22
23[open,refpage='VkVideoEncodeH264ProfileEXT',desc='Structure specifying H.264 encode profile',type='structs']
24--
25The slink:VkVideoEncodeH264ProfileEXT structure is defined as:
26
27include::{generated}/api/structs/VkVideoEncodeH264ProfileEXT.txt[]
28
29  * pname:sType is the type of this structure.
30  * pname:pNext is `NULL` or a pointer to a structure extending this
31    structure.
32  * pname:stdProfileIdc is a code:StdVideoH264ProfileIdc value specifying
33    the H.264 codec profile IDC.
34
35include::{generated}/validity/structs/VkVideoEncodeH264ProfileEXT.txt[]
36--
37
38
39=== Capabilities
40
41[open,refpage='VkVideoEncodeH264CapabilitiesEXT',desc='Structure specifying H.264 encode capabilities',type='structs']
42--
43When flink:vkGetPhysicalDeviceVideoCapabilitiesKHR is called to query the
44capabilities with parameter pname:videoCodecOperation specified as
45ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_EXT, a
46slink:VkVideoEncodeH264CapabilitiesEXT structure can: be chained to
47slink:VkVideoCapabilitiesKHR to retrieve H.264 extension specific
48capabilities.
49
50The slink:VkVideoEncodeH264CapabilitiesEXT structure is defined as:
51
52include::{generated}/api/structs/VkVideoEncodeH264CapabilitiesEXT.txt[]
53
54  * pname:sType is the type of this structure.
55  * pname:pNext is `NULL` or a pointer to a structure extending this
56    structure.
57  * pname:flags is a bitmask of elink:VkVideoEncodeH264CapabilityFlagBitsEXT
58    describing supported encoding tools.
59  * pname:inputModeFlags is a bitmask of
60    elink:VkVideoEncodeH264InputModeFlagBitsEXT describing supported command
61    buffer input granularities/modes.
62  * pname:outputModeFlags is a bitmask of
63    elink:VkVideoEncodeH264OutputModeFlagBitsEXT describing supported output
64    (bitstream size reporting) granularities/modes.
65  * pname:maxPictureSizeInMbs reports the maximum encoded picture width and
66    height in Macroblocks.
67  * pname:minPictureSizeInMbs reports the minimum encoded picture width and
68    height in Macroblocks.
69  * pname:inputImageDataAlignment reports alignment of data that must: be
70    filled in the input image horizontally and vertically in pixels.
71    Max is 16: Data must: be filled up to Macroblock boundary (no
72    extrapolation/filling is supported by implementation).
73    Min is 1: The implementation will take care of all needed
74    extrapolation/filling up to the next Macroblock boundary.
75  * pname:maxNumL0ReferenceForP reports the maximum number of reference
76    pictures the encoder supports as list0 references for P pictures.
77  * pname:maxNumL0ReferenceForB reports the maximum number of reference
78    pictures the encoder supports as list0 references for B pictures.
79    Reports 0 if B pictures are not supported.
80  * pname:maxNumL1Reference reports the maximum number of reference pictures
81    the encoder supports as list1 references if B pictures are supported.
82    Reports 0 if B pictures are not supported.
83  * pname:qualityLevelCount is the number of discrete quality levels
84    supported.
85  * pname:stdExtensionVersion is the specific H.264 extension name and
86    version supported by this implementation.
87
88include::{generated}/validity/structs/VkVideoEncodeH264CapabilitiesEXT.txt[]
89--
90
91[open,refpage='VkVideoEncodeH264CapabilityFlagsEXT',desc='Bitmask of VkVideoEncodeH264CapabilityFlagBitsEXT',type='flags']
92--
93include::{generated}/api/flags/VkVideoEncodeH264CapabilityFlagsEXT.txt[]
94
95tname:VkVideoEncodeH264CapabilityFlagsEXT is a bitmask type for setting a
96mask of zero or more elink:VkVideoEncodeH264CapabilityFlagBitsEXT.
97--
98
99[open,refpage='VkVideoEncodeH264CapabilityFlagBitsEXT',desc='Video encode H.264 capability flags',type='enums']
100--
101Bits which may: be set in
102slink:VkVideoEncodeH264CapabilitiesEXT::pname:flags, indicating the encoding
103tools supported, are:
104
105include::{generated}/api/enums/VkVideoEncodeH264CapabilityFlagBitsEXT.txt[]
106
107  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_CABAC_BIT_EXT reports if CABAC
108    entropy coding is supported.
109  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_CAVLC_BIT_EXT reports if CAVLC
110    entropy coding is supported.
111    An implementation must: support at least one entropy coding mode.
112  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_BI_PRED_IMPLICIT_BIT_EXT
113    reports if using weighted_bipred_idc_flag from StdVideoH264PpsFlags is
114    supported.
115  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_TRANSFORM_8X8_BIT_EXT reports if
116    enabling transform_8x8_mode_flag in StdVideoH264PpsFlags is supported.
117  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_CHROMA_QP_OFFSET_BIT_EXT reports
118    if setting chroma_qp_index_offset in StdVideoH264PictureParameterSet is
119    supported.
120  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_SECOND_CHROMA_QP_OFFSET_BIT_EXT
121    reports if setting second_chroma_qp_index_offset in
122    StdVideoH264PictureParameterSet is supported.
123  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_DISABLED_BIT_EXT
124    reports if using STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_DISABLED
125    from StdVideoH264DisableDeblockingFilterIdc is supported.
126  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_ENABLED_BIT_EXT
127    reports if using STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_ENABLED
128    from StdVideoH264DisableDeblockingFilterIdc is supported.
129  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_PARTIAL_BIT_EXT
130    reports if using STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_PARTIAL
131    from StdVideoH264DisableDeblockingFilterIdc is supported.
132    An implementation must: support at least one deblocking filter mode.
133  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_MULTIPLE_SLICE_PER_FRAME_BIT_EXT
134  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_EVENLY_DISTRIBUTED_SLICE_SIZE_BIT_EXT
135  * ename:VK_VIDEO_ENCODE_H264_CAPABILITY_OPTIONAL_RC_EXTENSION_STRUCT_BIT_EXT
136    indicates that the implementation does not require
137    sname:VkVideoEncodeH264RateControlInfoEXT to be chained to
138    sname:VkVideoEncodeRateControlInfoKHR in the call to
139    flink:vkCmdControlVideoCodingKHR.
140    When implementations do not report this capability,
141    slink:VkVideoEncodeH264RateControlInfoEXT must: be chained to
142    slink:VkVideoEncodeRateControlInfoKHR.
143--
144
145[open,refpage='VkVideoEncodeH264InputModeFlagsEXT',desc='Bitmask of VkVideoEncodeH264InputModeFlagBitsEXT',type='flags']
146--
147include::{generated}/api/flags/VkVideoEncodeH264InputModeFlagsEXT.txt[]
148
149tname:VkVideoEncodeH264InputModeFlagsEXT is a bitmask type for setting a
150mask of zero or more elink:VkVideoEncodeH264InputModeFlagBitsEXT.
151--
152
153[open,refpage='VkVideoEncodeH264InputModeFlagBitsEXT',desc='Video encode H.264 input modes',type='enums']
154--
155The pname:inputModeFlags field reports the various commmand buffer input
156granularities supported by the implementation as follows:
157
158include::{generated}/api/enums/VkVideoEncodeH264InputModeFlagBitsEXT.txt[]
159
160  * ename:VK_VIDEO_ENCODE_H264_INPUT_MODE_FRAME_BIT_EXT indicates that a
161    single command buffer must: at least encode an entire frame.
162    Any non-VCL NALUs must: be encoded using the same command buffer as the
163    frame if ename:VK_VIDEO_ENCODE_H264_INPUT_MODE_NON_VCL_BIT_EXT is not
164    supported.
165  * ename:VK_VIDEO_ENCODE_H264_INPUT_MODE_SLICE_BIT_EXT indicates that a
166    single command buffer must: at least encode a single slice.
167    Any non-VCL NALUs must: be encoded using the same command buffer as the
168    first slice of the frame if
169    ename:VK_VIDEO_ENCODE_H264_INPUT_MODE_NON_VCL_BIT_EXT is not supported.
170  * ename:VK_VIDEO_ENCODE_H264_INPUT_MODE_NON_VCL_BIT_EXT indicates that a
171    single command buffer may: encode a non-VCL NALU by itself.
172
173An implementation must: support at least one of
174ename:VK_VIDEO_ENCODE_H264_INPUT_MODE_FRAME_BIT_EXT or
175ename:VK_VIDEO_ENCODE_H264_INPUT_MODE_SLICE_BIT_EXT.
176--
177
178[open,refpage='VkVideoEncodeH264OutputModeFlagsEXT',desc='Bitmask of VkVideoEncodeH264OutputModeFlagBitsEXT',type='flags']
179--
180include::{generated}/api/flags/VkVideoEncodeH264OutputModeFlagsEXT.txt[]
181
182tname:VkVideoEncodeH264OutputModeFlagsEXT is a bitmask type for setting a
183mask of zero or more elink:VkVideoEncodeH264InputModeFlagBitsEXT.
184--
185
186[open,refpage='VkVideoEncodeH264OutputModeFlagBitsEXT',desc='Video encode H.264 output modes',type='enums']
187--
188Bits which may: be set in
189slink:VkVideoEncodeH264CapabilitiesEXT::pname:outputModeFlags, indicating
190the minimum bitstream generation commands that must: be included between
191each flink:vkCmdBeginVideoCodingKHR and flink:vkCmdEndVideoCodingKHR pair
192(henceforth simply begin/end pair), are:
193
194include::{generated}/api/enums/VkVideoEncodeH264OutputModeFlagBitsEXT.txt[]
195
196  * ename:VK_VIDEO_ENCODE_H264_OUTPUT_MODE_FRAME_BIT_EXT indicates that
197    calls to generate all NALUs of a frame must: be included within a single
198    begin/end pair.
199    Any non-VCL NALUs must: be encoded within the same begin/end pair if
200    ename:VK_VIDEO_ENCODE_H264_OUTPUT_MODE_NON_VCL_BIT_EXT is not supported.
201  * ename:VK_VIDEO_ENCODE_H264_OUTPUT_MODE_SLICE_BIT_EXT indicates that each
202    begin/end pair must: encode at least one slice.
203    Any non-VCL NALUs must: be encoded within the same begin/end pair as the
204    first slice of the frame if
205    ename:VK_VIDEO_ENCODE_H264_OUTPUT_MODE_NON_VCL_BIT_EXT is not supported.
206  * ename:VK_VIDEO_ENCODE_H264_OUTPUT_MODE_NON_VCL_BIT_EXT indicates that
207    each begin/end pair may: encode only a non-VCL NALU by itself.
208    An implementation must: support at least one of
209    ename:VK_VIDEO_ENCODE_H264_OUTPUT_MODE_FRAME_BIT_EXT or
210    ename:VK_VIDEO_ENCODE_H264_OUTPUT_MODE_SLICE_BIT_EXT.
211
212A single begin/end pair must: not encode more than a single frame.
213
214The bitstreams of NALUs generated within a single begin/end pair are written
215continuously into the same bitstream buffer (any padding between the NALUs
216must: be compliant to the H.264 standard).
217
218The supported input modes must: be coarser or equal to the supported output
219modes.
220For example, it is illegal to report slice input is supported but only frame
221output is supported.
222
223An implementation must: report one of the following combinations of
224input/output modes:
225
226  ** Input: Frame, Output: Frame
227  ** Input: Frame, Output: Frame and Non-VCL
228  ** Input: Frame, Output: Slice
229  ** Input: Frame, Output: Slice and Non-VCL
230  ** Input: Slice, Output: Slice
231  ** Input: Slice, Output: Slice and Non-VCL
232  ** Input: Frame and Non-VCL, Output: Frame and Non-VCL
233  ** Input: Frame and Non-VCL, Output: Slice and Non-VCL
234  ** Input: Slice and Non-VCL, Output: Slice and Non-VCL
235--
236
237
238=== Create Information
239
240[open,refpage='VkVideoEncodeH264SessionCreateInfoEXT', desc='Structure specifies H.264 encoder creation parameters', type='structs']
241--
242A slink:VkVideoEncodeH264SessionCreateInfoEXT structure must: be chained to
243slink:VkVideoSessionCreateInfoKHR when the function
244flink:vkCreateVideoSessionKHR is called with pname:videoCodecOperation in
245slink:VkVideoSessionCreateInfoKHR set to
246ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_EXT.
247
248The sname:VkVideoEncodeH264SessionCreateInfoEXT structure is defined as:
249
250include::{generated}/api/structs/VkVideoEncodeH264SessionCreateInfoEXT.txt[]
251
252  * pname:sType is the type of this structure.
253  * pname:pNext is `NULL` or a pointer to a structure extending this
254    structure.
255  * pname:flags is a bitmask of tlink:VkVideoEncodeH264CreateFlagsEXT
256    specifying H.264 encoder creation flags.
257  * pname:maxPictureSizeInMbs specifies the syntax element
258    pic_width_in_mbs_minus1 + 1 and the syntax element
259    pic_height_in_map_units_minus1 + 1.
260  * pname:pStdExtensionVersion is a pointer to a slink:VkExtensionProperties
261    structure specifying H.264 codec extensions.
262
263include::{generated}/validity/structs/VkVideoEncodeH264SessionCreateInfoEXT.txt[]
264--
265
266[open,refpage='VkVideoEncodeH264CreateFlagsEXT',desc='Bitmask specifying the video encode session creation flags',type='flags']
267--
268include::{generated}/api/flags/VkVideoEncodeH264CreateFlagsEXT.txt[]
269
270tlink:VkVideoEncodeH264CreateFlagsEXT is a bitmask type for setting a mask
271of zero or more elink:VkVideoEncodeH264CreateFlagBitsEXT.
272--
273
274[open,refpage='VkVideoEncodeH264CreateFlagBitsEXT',desc='Video encode session creation flags',type='enums']
275--
276Bits which can: be set in
277slink:VkVideoEncodeH264SessionCreateInfoEXT::pname:flags are:
278
279include::{generated}/api/enums/VkVideoEncodeH264CreateFlagBitsEXT.txt[]
280
281  * ename:VK_VIDEO_ENCODE_H264_CREATE_DEFAULT_EXT is 0, and specifies no
282    additional creation flags.
283  * ename:VK_VIDEO_ENCODE_H264_CREATE_RESERVED_0_BIT_EXT The current version
284    of the specification has reserved this value for future use.
285--
286
287
288=== Encoder Parameter Sets
289
290To reduce parameter traffic during encoding, the encoder parameter set
291object supports storing H.264 SPS/PPS parameter sets that may: be later
292referenced during encoding.
293
294[open,refpage='VkVideoEncodeH264SessionParametersCreateInfoEXT',desc='Structure specifies H.264 encoder parameter set information',type='structs']
295--
296A slink:VkVideoEncodeH264SessionParametersCreateInfoEXT structure holding
297one H.264 SPS and at least one H.264 PPS paramater set must: be chained to
298slink:VkVideoSessionParametersCreateInfoKHR when calling
299flink:vkCreateVideoSessionParametersKHR to store these parameter set(s) with
300the encoder parameter set object for later reference.
301The provided H.264 SPS/PPS parameters must: be within the limits specified
302during encoder creation for the encoder specified in
303slink:VkVideoSessionParametersCreateInfoKHR.
304
305The slink:VkVideoEncodeH264SessionParametersCreateInfoEXT structure is
306defined as:
307
308include::{generated}/api/structs/VkVideoEncodeH264SessionParametersCreateInfoEXT.txt[]
309
310  * pname:sType is the type of this structure.
311  * pname:pNext is `NULL` or a pointer to a structure extending this
312    structure.
313  * pname:maxSpsStdCount is the maximum number of SPS parameters that the
314    sname:VkVideoSessionParametersKHR can contain.
315  * pname:maxPpsStdCount is the maximum number of PPS parameters that the
316    sname:VkVideoSessionParametersKHR can contain.
317  * pname:pParametersAddInfo is `NULL` or a pointer to a
318    sname:VkVideoEncodeH264SessionParametersAddInfoEXT structure specifying
319    H.264 parameters to add upon object creation.
320
321include::{generated}/validity/structs/VkVideoEncodeH264SessionParametersCreateInfoEXT.txt[]
322--
323
324[open,refpage='VkVideoEncodeH264SessionParametersAddInfoEXT',desc='Structure specifies H.264 encoder parameter set information',type='structs']
325--
326include::{generated}/api/structs/VkVideoEncodeH264SessionParametersAddInfoEXT.txt[]
327  * pname:sType is the type of this structure.
328  * pname:pNext is `NULL` or a pointer to a structure extending this
329    structure.
330  * pname:spsStdCount is the number of SPS elements in the pname:pSpsStd.
331    Its value must: be less than or equal to the value of
332    pname:maxSpsStdCount.
333  * pname:pSpsStd is a pointer to an array of
334    code:StdVideoH264SequenceParameterSet structures representing H.264
335    sequence parameter sets.
336    Each element of the array must: have a unique H.264 SPS ID.
337  * pname:ppsStdCount is the number of PPS provided in pname:pPpsStd.
338    Its value must: be less than or equal to the value of
339    pname:maxPpsStdCount.
340  * pname:pPpsStd is a pointer to an array of
341    code:StdVideoH264PictureParameterSet structures representing H.264
342    picture parameter sets.
343    Each element of the array must: have a unique H.264 SPS-PPS ID pair.
344
345.Valid Usage
346****
347  * [[VUID-VkVideoEncodeH264SessionParametersAddInfoEXT-spsStdCount-04837]]
348    The values of pname:spsStdCount and pname:ppsStdCount must: be less than
349    or equal to the values of pname:maxSpsStdCount and pname:maxPpsStdCount,
350    respectively
351  * [[VUID-VkVideoEncodeH264SessionParametersAddInfoEXT-maxSpsStdCount-04838]]
352    When the pname:maxSpsStdCount number of parameters of type
353    StdVideoH264SequenceParameterSet in the Video Session Parameters object
354    is reached, no additional parameters of that type can be added to the
355    object.
356    ename:VK_ERROR_TOO_MANY_OBJECTS will be returned if an attempt is made
357    to add additional data to this object at this point
358  * [[VUID-VkVideoEncodeH264SessionParametersAddInfoEXT-maxPpsStdCount-04839]]
359    When the pname:maxPpsStdCount number of parameters of type
360    StdVideoH264PictureParameterSet in the Video Session Parameters object
361    is reached, no additional parameters of that type can be added to the
362    object.
363    ename:VK_ERROR_TOO_MANY_OBJECTS will be returned if an attempt is made
364    to add additional data to this object at this point
365  * [[VUID-VkVideoEncodeH264SessionParametersAddInfoEXT-None-04840]]
366    Each entry to be added must: have a unique, to the rest of the parameter
367    array entries and the existing parameters in the Video Session
368    Parameters Object that is being updated, SPS-PPS IDs
369  * [[VUID-VkVideoEncodeH264SessionParametersAddInfoEXT-None-04841]]
370    Parameter entries that already exist in Video Session Parameters object
371    with a particular SPS-PPS IDs cannot: be replaced nor updated
372  * [[VUID-VkVideoEncodeH264SessionParametersAddInfoEXT-None-04842]]
373    When creating a new object using a Video Session Parameters as a
374    template, the array's parameters with the same SPS-PPS IDs as the ones
375    from the template take precedence
376  * [[VUID-VkVideoEncodeH264SessionParametersAddInfoEXT-None-04843]]
377    SPS/PPS parameters must: comply with the limits specified in
378    slink:VkVideoSessionCreateInfoKHR during Video Session creation
379****
380
381include::{generated}/validity/structs/VkVideoEncodeH264SessionParametersAddInfoEXT.txt[]
382--
383
384
385=== Frame Encoding
386
387In order to encode a frame, add a slink:VkVideoEncodeH264VclFrameInfoEXT
388structure to the pname:pNext chain of the slink:VkVideoEncodeInfoKHR
389structure passed to the flink:vkCmdEncodeVideoKHR command.
390
391[open,refpage='VkVideoEncodeH264VclFrameInfoEXT',desc='Structure specifies H.264 encode frame parameters',type='structs']
392--
393The structure slink:VkVideoEncodeH264VclFrameInfoEXT representing a frame
394encode operation is defined as:
395
396include::{generated}/api/structs/VkVideoEncodeH264VclFrameInfoEXT.txt[]
397
398  * pname:sType is the type of this structure.
399  * pname:pNext is `NULL` or a pointer to a structure extending this
400    structure.
401  * pname:refDefaultFinalList0EntryCount is the default number of reference
402    List0 entries for all slices of this frame.
403    Each slice may: override this by providing its own List0 entries.
404  * pname:pRefDefaultFinalList0Entries is a pointer to an array of
405    slink:VkVideoEncodeH264DpbSlotInfoEXT structures providing information
406    for each reference List0 entry.
407    The entries provided must: be ordered after all reference List0
408    modification operations are applied (i.e. final list order).
409    The entires provided must: not reflect decoded picture marking
410    operations in this frame that are applicable to references; the impact
411    of such operations must: be reflected in future frame encode cmds.
412    The slot index in each entry must: match one of the slot indexes
413    provided in pname:pReferenceSlots of the slink:VkVideoEncodeInfoKHR
414    structure to which this structure is chained.
415  * pname:refDefaultFinalList1EntryCount is the default number of reference
416    List1 entries for all slices of this frame.
417    Each slice may: override this by providing its own List1 entries.
418  * pname:pRefDefaultFinalList1Entries is a pointer to an array of
419    slink:VkVideoEncodeH264DpbSlotInfoEXT structures providing information
420    related to each reference List1 entry.
421    The entries provided must: be ordered after all reference List1
422    modification operations are applied (i.e. final list order).
423    The entires provided must: not reflect decoded picture marking
424    operations in this frame that are applicable to references; the impact
425    of such operations must: be reflected in future frame encode cmds.
426    The slot index in each entry must: match one of the slot indexes
427    provided in pname:pReferenceSlots of the slink:VkVideoEncodeInfoKHR
428    structure to which this structure is chained.
429  * pname:naluSliceEntryCount is the number of NALUs in this frame.
430  * pname:pNaluSliceEntries is a pointer to an array of pname:naluCount
431    slink:VkVideoEncodeH264NaluSliceEXT structures that make up the frame.
432    This is an ordered sequence; the NALUs are generated consecutively in
433    the bitstream buffer (provided in pname:bitstreamBuffer in
434    slink:VkVideoBeginCodingInfoKHR) in the same order as in this array.
435  * pname:pCurrentPictureInfo is a pointer to a
436    slink:VkVideoEncodeH264DpbSlotInfoEXT structure specifying information
437    for the reconstructed picture for this frame.
438    Info provided must: reflect decoded picture marking operations in this
439    frame that are applicable to this frame.
440    The slot index in pCurrentPictureInfo must: match the slot index
441    provided in pname:pSetupReferenceSlot of slink:VkVideoEncodeInfoKHR
442    structure to which this structure is chained to.
443
444include::{generated}/validity/structs/VkVideoEncodeH264VclFrameInfoEXT.txt[]
445--
446
447[open,refpage='VkVideoEncodeH264DpbSlotInfoEXT',desc='Structure specifies H.264 encode DPB picture information',type='structs']
448--
449The slink:VkVideoEncodeH264DpbSlotInfoEXT structure correlates a DPB Slot
450index with codec-specific information and is defined as:
451
452include::{generated}/api/structs/VkVideoEncodeH264DpbSlotInfoEXT.txt[]
453  * pname:sType is the type of this structure.
454  * pname:pNext is `NULL` or a pointer to a structure extending this
455    structure.
456  * pname:slotIndex is the slot index for this picture.
457    pname:slotIndex must: match the pname:slotIndex in
458    pname:pSetupReferenceSlot of slink:VkVideoEncodeInfoKHR in the command
459    used to encode the corresponding picture.
460  * pname:pStdPictureInfo is a pointer to a
461    code:StdVideoEncodeH264PictureInfo structure specifying codec standard
462    specific syntax/information associated with this picture from the H.264
463    specification.
464
465include::{generated}/validity/structs/VkVideoEncodeH264DpbSlotInfoEXT.txt[]
466--
467
468[open,refpage='VkVideoEncodeH264NaluSliceEXT',desc='Structure specifies H.264 encode slice NALU parameters',type='structs']
469--
470The structure slink:VkVideoEncodeH264NaluSliceEXT representing a slice is
471defined as:
472
473include::{generated}/api/structs/VkVideoEncodeH264NaluSliceEXT.txt[]
474  * pname:sType is the type of this structure.
475  * pname:pNext is `NULL` or a pointer to a structure extending this
476    structure.
477  * pname:pSliceHeaderStd is a pointer to a
478    code:StdVideoEncodeH264SliceHeader specifying the standard slice header
479    from the H.264 specification.
480  * pname:mbCount is the number of macroblocks in this slice.
481  * pname:refFinalList0EntryCount is the number of active references in
482    List0.
483    If zero, the default frame List0 provided in the enclosing
484    slink:VkVideoEncodeH264VclFrameInfoEXT is used.
485    If non-zero, it overrides the default frame List0 for this slice.
486  * pname:pRefFinalList0Entries is a pointer to a
487    slink:VkVideoEncodeH264DpbSlotInfoEXT specifying DPB information for the
488    active List0 references.
489    The same restrictions related to order of entries and decoded picture
490    marking operations described for List0 in
491    slink:VkVideoEncodeH264VclFrameInfoEXT apply here.
492  * pname:refFinalList1EntryCount is the number of active references in
493    List1.
494    If zero, the default frame List1 provided in the enclosing
495    slink:VkVideoEncodeH264VclFrameInfoEXT is used.
496    If non-zero, it overrides the default frame List1 for this slice.
497  * pname:pRefFinalList1Entries is a pointer to a
498    slink:VkVideoEncodeH264DpbSlotInfoEXT structure specifying DPB
499    information for the active List1 references.
500    The same restrictions related to order of entries and decoded picture
501    marking operations described for List1 in
502    slink:VkVideoEncodeH264VclFrameInfoEXT apply here.
503
504include::{generated}/validity/structs/VkVideoEncodeH264NaluSliceEXT.txt[]
505--
506
507[open,refpage='VkVideoEncodeH264EmitPictureParametersEXT',desc='Structure specifies H.264 encode SPS NALU insertion parameters',type='structs']
508--
509The structure slink:VkVideoEncodeH264EmitPictureParametersEXT is defined as:
510
511include::{generated}/api/structs/VkVideoEncodeH264EmitPictureParametersEXT.txt[]
512
513  * pname:sType is the type of this structure.
514  * pname:pNext is `NULL` or a pointer to a structure extending this
515    structure.
516  * pname:spsId is the H.264 SPS ID for the H.264 SPS to insert in the
517    bitstream.
518    The SPS ID must: match the SPS provided in pname:spsStd of
519    slink:VkVideoEncodeH264SessionParametersCreateInfoEXT.
520    This is retrieved from the slink:VkVideoSessionParametersKHR object
521    provided in slink:VkVideoBeginCodingInfoKHR.
522  * pname:emitSpsEnable enables the emitting of the SPS structure with id of
523    pname:spsId.
524  * pname:ppsIdEntryCount is the number of entries in the
525    pname:ppsIdEntries.
526    If this parameter is `0` then no pps entries are going to be emitted in
527    the bitstream.
528  * pname:ppsIdEntries is a pointer to an array of H.264 PPS IDs for the
529    H.264 PPS to insert in the bitstream.
530    The PPS IDs must: match one of the IDs of the PPS(s) provided in
531    pname:pPpsStd of slink:VkVideoEncodeH264SessionParametersCreateInfoEXT
532    to identify the PPS parameter set to insert in the bitstream.
533    This is retrieved from the slink:VkVideoSessionParametersKHR object
534    provided in slink:VkVideoBeginCodingInfoKHR.
535
536include::{generated}/validity/structs/VkVideoEncodeH264EmitPictureParametersEXT.txt[]
537--
538
539=== Rate control
540
541[open,refpage='VkVideoEncodeH264RateControlInfoEXT',desc='Structure describing H.264 stream rate control parameters',type='structs']
542--
543
544In order to provide H.264-specific stream rate control parameters, add a
545slink:VkVideoEncodeH264RateControlInfoEXT structure to the pname:pNext chain
546of the slink:VkVideoEncodeRateControlInfoKHR structure in the pname:pNext
547chain of the slink:VkVideoCodingControlInfoKHR structure passed to the
548flink:vkCmdControlVideoCodingKHR command.
549
550The parameters from this structure act as a guidance for implementations to
551apply various rate control heuristics.
552
553The structure sname:VkVideoEncodeH264RateControlInfoEXT is defined as:
554
555include::{generated}/api/structs/VkVideoEncodeH264RateControlInfoEXT.txt[]
556  * pname:sType is the type of this structure.
557  * pname:pNext is `NULL` or a pointer to a structure extending this
558    structure.
559  * pname:gopFrameCount is the number of frames contained within the group
560    of pictures (GOP), starting from an intra frame and until the next intra
561    frame.
562    If it is set to 0, the implementation chooses a suitable value.
563    If it is set to code:UINT32_MAX, the GOP length is treated as infinite.
564    This value is ignored when
565    slink:VkVideoEncodeRateControlInfoKHR::pname:rateControlMode is
566    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR.
567  * pname:idrPeriod is the interval, in terms of number of frames, between
568    two IDR frames.
569    If it is set to 0, the implementation chooses a suitable value.
570    If it is set to code:UINT32_MAX, the IDR period is treated as infinite.
571    This value is ignored when
572    slink:VkVideoEncodeRateControlInfoKHR::pname:rateControlMode is
573    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR.
574  * pname:consecutiveBFrameCount is the number of consecutive B-frames
575    between I- and/or P-frames within the GOP.
576    This value is ignored when
577    slink:VkVideoEncodeRateControlInfoKHR::pname:rateControlMode is
578    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR.
579  * pname:rateControlStructure is a
580    elink:VkVideoEncodeH264RateControlStructureFlagBitsEXT value specifying
581    the expected encode stream reference structure, to aid in rate control
582    calculations.
583
584It is possible to infer the picture type to be used when encoding a frame,
585on the basis of the values provided for pname:consecutiveBFrameCount,
586pname:idrPeriod, and pname:gopFrameCount, but this inferred picture type
587will not be used by implementations to override the picture type provided in
588flink:vkCmdEncodeVideoKHR.
589Additionally, it is not required for the video session to be reset if the
590inferred picture type does not match the actual picture type.
591
592include::{generated}/validity/structs/VkVideoEncodeH264RateControlInfoEXT.txt[]
593--
594
595[open,refpage='VkVideoEncodeH264RateControlStructureFlagBitsEXT',desc='Video encode H.264 rate control structure flags',type='enums']
596--
597
598The pname:rateControlStructure in slink:VkVideoEncodeH264RateControlInfoEXT
599specifies one of the following video stream reference structures as a hint
600for the rate control implementation:
601
602include::{generated}/api/enums/VkVideoEncodeH264RateControlStructureFlagBitsEXT.txt[]
603  * ename:VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_UNKNOWN_EXT is `0`,
604    and specifies a reference structure unknown at the time of stream rate
605    control configuration.
606  * ename:VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_FLAT_BIT_EXT specifies
607    a flat reference structure.
608  * ename:VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_DYADIC_BIT_EXT
609    specifies a dyadic reference structure.
610--
611
612[open,refpage='VkVideoEncodeH264RateControlLayerInfoEXT',desc='Structure describing H.264 per-layer rate control parameters',type='structs']
613--
614
615H.264-specific per-layer rate control parameters must: be specified by
616adding slink:VkVideoEncodeH264RateControlLayerInfoEXT structure to the
617pname:pNext chain of each slink:VkVideoEncodeRateControlLayerInfoKHR
618structure in a call to flink:vkCmdControlVideoCodingKHR command, when the
619command buffer context has an active video encode H.264 session.
620
621The structure sname:VkVideoEncodeH264RateControlLayerInfoEXT is defined as:
622
623include::{generated}/api/structs/VkVideoEncodeH264RateControlLayerInfoEXT.txt[]
624  * pname:sType is the type of this structure.
625  * pname:pNext is `NULL` or a pointer to a structure extending this
626    structure.
627  * pname:temporalLayerId specifies the H.264 temporal layer ID of the video
628    coding layer that settings provided in this structure and its parent
629    slink:VkVideoEncodeRateControlLayerInfoKHR structure apply to.
630  * pname:useInitialRcQp indicates whether the values within
631    pname:initialRcQp should be used by the implementation.
632  * pname:initialRcQp provides the QP values for each picture type, to be
633    used in rate control calculations at the start of video encode
634    operations on a newly-created video session, or immediately after a
635    session reset.
636    These values are ignored when
637    slink:VkVideoEncodeRateControlInfoKHR::pname:rateControlMode is
638    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR.
639  * pname:useMinQp indicates whether the values within pname:minQp should be
640    used by the implementation.
641    When it is set to ename:VK_FALSE, the implementation ignores the values
642    in pname:minQp and chooses suitable values.
643  * pname:minQp provides the lower bound on the QP values for each picture
644    type, to be used in rate control calculations.
645  * pname:useMaxQp indicates whether the values within pname:maxQp should be
646    used by the implementation.
647    When it is set to ename:VK_FALSE, the implementation ignores the values
648    in pname:maxQp and chooses suitable values.
649  * pname:maxQp provides the upper bound on the QP values for each picture
650    type, to be used in rate control calculations.
651  * pname:useMaxFrameSize indicates whether the values within
652    pname:maxFrameSize should be used by the implementation.
653  * pname:maxFrameSize provides the upper bound on the encoded frame size
654    for each picture type.
655    The implementation does not guarantee the encoded frame sizes will be
656    within the specified limits, however these limits may: be used as a
657    guide in rate control calculations.
658    If enabled and not set properly, the pname:maxQp limit may prevent the
659    implementation from respecting the pname:maxFrameSize limit.
660
661
662.Valid Usage
663****
664  * [[VUID-VkVideoEncodeH264RateControlLayerInfoEXT-rateControlMode-06474]]
665    When slink:VkVideoEncodeRateControlInfoKHR::pname:rateControlMode is
666    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR, both
667    pname:useMinQp and pname:useMaxQp must be set to ename:VK_TRUE.
668  * [[VUID-VkVideoEncodeH264RateControlLayerInfoEXT-rateControlMode-06475]]
669    When slink:VkVideoEncodeRateControlInfoKHR::pname:rateControlMode is
670    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR, the values
671    provided in pname:minQP must be identical to those provided in
672    pname:maxQp.
673****
674
675include::{generated}/validity/structs/VkVideoEncodeH264RateControlLayerInfoEXT.txt[]
676--
677
678[open,refpage='VkVideoEncodeH264QpEXT',desc='Structure describing H.264 QP values per picture type',type='structs']
679--
680The structure sname:VkVideoEncodeH264QpEXT is defined as:
681
682include::{generated}/api/structs/VkVideoEncodeH264QpEXT.txt[]
683
684  * pname:qpI is the QP to be used for I-frames.
685  * pname:qpP is the QP to be used for P-frames.
686  * pname:qpB is the QP to be used for B-frames.
687
688include::{generated}/validity/structs/VkVideoEncodeH264QpEXT.txt[]
689--
690
691[open,refpage='VkVideoEncodeH264FrameSizeEXT',desc='Structure describing frame size values per H.264 picture type',type='structs']
692--
693The structure sname:VkVideoEncodeH264FrameSizeEXT is defined as:
694
695include::{generated}/api/structs/VkVideoEncodeH264FrameSizeEXT.txt[]
696
697  * pname:frameISize is the size in bytes to be used for I-frames.
698  * pname:framePSize is the size in bytes to be used for P-frames.
699  * pname:frameBSize is the size in bytes to be used for B-frames.
700
701include::{generated}/validity/structs/VkVideoEncodeH264FrameSizeEXT.txt[]
702--
703
704
705