1e5c31af7Sopenharmony_ci// Copyright 2018-2024 The Khronos Group Inc.
2e5c31af7Sopenharmony_ci//
3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0
4e5c31af7Sopenharmony_ci
5e5c31af7Sopenharmony_ci[[video-encode-operations]]
6e5c31af7Sopenharmony_ci== Video Encode Operations
7e5c31af7Sopenharmony_ci
8e5c31af7Sopenharmony_ci[[encode-input-picture]]
9e5c31af7Sopenharmony_ciVideo encode operations consume an _encode input picture_ and zero or more
10e5c31af7Sopenharmony_cireference pictures, and produce compressed video data to a video bitstream
11e5c31af7Sopenharmony_cibuffer and an optional <<reconstructed-picture,reconstructed picture>>.
12e5c31af7Sopenharmony_ci
13e5c31af7Sopenharmony_ci[NOTE]
14e5c31af7Sopenharmony_ci.Note
15e5c31af7Sopenharmony_ci====
16e5c31af7Sopenharmony_ciSuch encode input pictures can be used
17e5c31af7Sopenharmony_ciifdef::VK_KHR_video_decode_queue[]
18e5c31af7Sopenharmony_cias the <<decode-output-picture,output>> of video decode operations,
19e5c31af7Sopenharmony_ciendif::VK_KHR_video_decode_queue[]
20e5c31af7Sopenharmony_ciwith graphics or compute operations,
21e5c31af7Sopenharmony_ciifdef::VK_KHR_surface[]
22e5c31af7Sopenharmony_cior with <<wsi,Window System Integration>> APIs,
23e5c31af7Sopenharmony_ciendif::VK_KHR_surface[]
24e5c31af7Sopenharmony_cidepending on the capabilities of the implementation.
25e5c31af7Sopenharmony_ci====
26e5c31af7Sopenharmony_ci
27e5c31af7Sopenharmony_ciVideo encode operations may: access the following resources in the
28e5c31af7Sopenharmony_ciename:VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR stage:
29e5c31af7Sopenharmony_ci
30e5c31af7Sopenharmony_ci  * The image subregions corresponding to the source
31e5c31af7Sopenharmony_ci    <<encode-input-picture-info,encode input picture>> and
32e5c31af7Sopenharmony_ci    <<encode-active-reference-picture-info,active reference pictures>> with
33e5c31af7Sopenharmony_ci    access ename:VK_ACCESS_2_VIDEO_ENCODE_READ_BIT_KHR.
34e5c31af7Sopenharmony_ci  * The destination video bitstream buffer range and the optional
35e5c31af7Sopenharmony_ci    <<encode-reconstructed-picture-info,reconstructed picture>> with access
36e5c31af7Sopenharmony_ci    ename:VK_ACCESS_2_VIDEO_ENCODE_WRITE_BIT_KHR.
37e5c31af7Sopenharmony_ci
38e5c31af7Sopenharmony_ciThe image subresource of each <<video-picture-resources,video picture
39e5c31af7Sopenharmony_ciresource>> accessed by the video encode operation is specified using a
40e5c31af7Sopenharmony_cicorresponding slink:VkVideoPictureResourceInfoKHR structure.
41e5c31af7Sopenharmony_ciEach such image subresource must: be in the appropriate image layout as
42e5c31af7Sopenharmony_cifollows:
43e5c31af7Sopenharmony_ci
44e5c31af7Sopenharmony_ci  * If the image subresource is used in the video encode operation as an
45e5c31af7Sopenharmony_ci    <<encode-input-picture,encode input picture>>, then it must: be in the
46e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_VIDEO_ENCODE_SRC_KHR layout.
47e5c31af7Sopenharmony_ci  * If the image subresource is used in the video encode operation as a
48e5c31af7Sopenharmony_ci    <<reconstructed-picture,reconstructed picture>> or <<reference-picture,
49e5c31af7Sopenharmony_ci    reference picture>>, then it must: be in the
50e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_VIDEO_ENCODE_DPB_KHR layout.
51e5c31af7Sopenharmony_ci
52e5c31af7Sopenharmony_ci[[encode-unsuccessful]]
53e5c31af7Sopenharmony_ciA video encode operation may: complete unsuccessfully.
54e5c31af7Sopenharmony_ciIn this case the target video bitstream buffer will have undefined:
55e5c31af7Sopenharmony_cicontents.
56e5c31af7Sopenharmony_ciSimilarly, if <<encode-ref-pic-setup,reference picture setup>> is requested,
57e5c31af7Sopenharmony_cithe <<reconstructed-picture,reconstructed-picture>> will also have
58e5c31af7Sopenharmony_ciundefined: contents, and the activated DPB slot will have an
59e5c31af7Sopenharmony_ci<<dpb-slot-states,invalid picture reference>>.
60e5c31af7Sopenharmony_ci
61e5c31af7Sopenharmony_ciIf a video encode operation completes successfully and the codec-specific
62e5c31af7Sopenharmony_ciparameters provided by the application adhere to the syntactic and semantic
63e5c31af7Sopenharmony_cirequirements defined in the corresponding video compression standard, then
64e5c31af7Sopenharmony_cithe target video bitstream buffer will contain compressed video data after
65e5c31af7Sopenharmony_cithe execution of the video encode operation according to the respective
66e5c31af7Sopenharmony_ci<<encode-codec-specific-semantics,codec-specific semantics>>.
67e5c31af7Sopenharmony_ci
68e5c31af7Sopenharmony_ci
69e5c31af7Sopenharmony_ci[[encode-codec-specific-semantics]]
70e5c31af7Sopenharmony_ci=== Codec-Specific Semantics
71e5c31af7Sopenharmony_ci
72e5c31af7Sopenharmony_ciThe following aspects of video encode operations are codec-specific:
73e5c31af7Sopenharmony_ci
74e5c31af7Sopenharmony_ci  * The compressed video data written to the target video bitstream buffer
75e5c31af7Sopenharmony_ci    range.
76e5c31af7Sopenharmony_ci  * The construction and interpretation of the list of
77e5c31af7Sopenharmony_ci    <<encode-active-reference-picture-info,active reference pictures>> and
78e5c31af7Sopenharmony_ci    the interpretation of the picture data referred to by the corresponding
79e5c31af7Sopenharmony_ci    image subregions.
80e5c31af7Sopenharmony_ci  * The construction and interpretation of information related to the
81e5c31af7Sopenharmony_ci    <<encode-input-picture-info,encode input picture>> and the
82e5c31af7Sopenharmony_ci    interpretation of the picture data referred to by the corresponding
83e5c31af7Sopenharmony_ci    image subregion.
84e5c31af7Sopenharmony_ci  * The decision on <<encode-ref-pic-setup,reference picture setup>>.
85e5c31af7Sopenharmony_ci  * The construction and interpretation of information related to the
86e5c31af7Sopenharmony_ci    optional <<encode-reconstructed-picture-info,reconstructed picture>> and
87e5c31af7Sopenharmony_ci    the generation of picture data to the corresponding image subregion.
88e5c31af7Sopenharmony_ci  * Certain aspects of <<encode-rate-control,rate control>>.
89e5c31af7Sopenharmony_ci
90e5c31af7Sopenharmony_ciThese codec-specific behaviors are defined for each video codec operation
91e5c31af7Sopenharmony_ciseparately.
92e5c31af7Sopenharmony_ci
93e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
94e5c31af7Sopenharmony_ci  * If the used video codec operation is
95e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, then the
96e5c31af7Sopenharmony_ci    codec-specific aspects of the video encoding process are performed as
97e5c31af7Sopenharmony_ci    defined in the <<encode-h264,H.264 Encode Operations>> section.
98e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
99e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
100e5c31af7Sopenharmony_ci  * If the used video codec operation is
101e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then the
102e5c31af7Sopenharmony_ci    codec-specific aspects of the video encoding process are performed as
103e5c31af7Sopenharmony_ci    defined in the <<encode-h265,H.265 Encode Operations>> section.
104e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
105e5c31af7Sopenharmony_ci
106e5c31af7Sopenharmony_ci
107e5c31af7Sopenharmony_ci[[encode-overrides]]
108e5c31af7Sopenharmony_ci==== Video Encode Parameter Overrides
109e5c31af7Sopenharmony_ci
110e5c31af7Sopenharmony_ciImplementations supporting video encode operations for any particular video
111e5c31af7Sopenharmony_cicodec operation often support only a subset of the available encoding tools
112e5c31af7Sopenharmony_cidefined by the corresponding video compression standards.
113e5c31af7Sopenharmony_ciAccordingly, certain implementation-dependent limitations may: apply to
114e5c31af7Sopenharmony_cicodec-specific parameters provided through the structures defined in the
115e5c31af7Sopenharmony_ciVideo Std headers corresponding to the used video codec operation.
116e5c31af7Sopenharmony_ci
117e5c31af7Sopenharmony_ciExposing all of these restrictions on particular codec-specific parameter
118e5c31af7Sopenharmony_civalues or combinations thereof in the form of application-queryable
119e5c31af7Sopenharmony_cicapabilities is impractical, hence this specification allows implementations
120e5c31af7Sopenharmony_cito _override_ the value of any of the codec-specific parameters, unless
121e5c31af7Sopenharmony_ciotherwise specified, as long as all of the following conditions are met:
122e5c31af7Sopenharmony_ci
123e5c31af7Sopenharmony_ci  * If the application-provided codec-specific parameters adhere to the
124e5c31af7Sopenharmony_ci    syntactic and semantic requirements and rules defined by the used video
125e5c31af7Sopenharmony_ci    compression standard, and thus would be usable to produce a video
126e5c31af7Sopenharmony_ci    bitstream compliant with that standard, then the codec-specific
127e5c31af7Sopenharmony_ci    parameters resulting from the process of implementation overrides must:
128e5c31af7Sopenharmony_ci    also adhere to the same requirements and rules, and any video bitstream
129e5c31af7Sopenharmony_ci    produced using the overridden parameters must: also be compliant.
130e5c31af7Sopenharmony_ci  * The overridden codec-specific parameter values must: not have an impact
131e5c31af7Sopenharmony_ci    on the codec-independent behaviors defined for video encode operations.
132e5c31af7Sopenharmony_ci  * The implementation must: not override any codec-specific parameters
133e5c31af7Sopenharmony_ci    specified to a command that may: cause application-provided
134e5c31af7Sopenharmony_ci    codec-specific parameters specified to subsequent commands to no longer
135e5c31af7Sopenharmony_ci    adhere to the semantic requirements and rules defined by the used video
136e5c31af7Sopenharmony_ci    compression standard, unless the implementation also overrides those
137e5c31af7Sopenharmony_ci    parameters to adhere to any such requirements and rules.
138e5c31af7Sopenharmony_ci  * The overridden codec-specific parameter values must: not have an impact
139e5c31af7Sopenharmony_ci    on the codec-specific picture data access semantics.
140e5c31af7Sopenharmony_ci  * The overridden codec-specific parameter values may: change the contents
141e5c31af7Sopenharmony_ci    of the codec-specific bitstream elements produced by video encode
142e5c31af7Sopenharmony_ci    operations or otherwise retrieved by the application (e.g. using the
143e5c31af7Sopenharmony_ci    flink:vkGetEncodedVideoSessionParametersKHR command) but must: still
144e5c31af7Sopenharmony_ci    adhere to the codec-specific semantics defined for that video codec
145e5c31af7Sopenharmony_ci    operation, including, but not limited to, the number, type, and order of
146e5c31af7Sopenharmony_ci    the encoded codec-specific bitstream elements.
147e5c31af7Sopenharmony_ci
148e5c31af7Sopenharmony_ciBesides codec-specific parameter overrides performed for
149e5c31af7Sopenharmony_ciimplementation-dependent reasons, applications can: enable the
150e5c31af7Sopenharmony_ciimplementation to apply additional <<encode-optimizing-overrides,optimizing
151e5c31af7Sopenharmony_cioverrides>> that may: improve the efficiency or performance of video
152e5c31af7Sopenharmony_ciencoding operations.
153e5c31af7Sopenharmony_ciHowever, implementations must: meet the conditions listed above even in case
154e5c31af7Sopenharmony_ciof such optimizing overrides.
155e5c31af7Sopenharmony_ci
156e5c31af7Sopenharmony_ci[NOTE]
157e5c31af7Sopenharmony_ci.Note
158e5c31af7Sopenharmony_ci====
159e5c31af7Sopenharmony_ciUnless the application opts in for optimizing overrides, implementations are
160e5c31af7Sopenharmony_cinot expected to override any of the codec-specific parameters, except when
161e5c31af7Sopenharmony_cisuch overrides are necessary for the correct operation of video encoder
162e5c31af7Sopenharmony_ciimplementation due to limitations to the available encoding tools on that
163e5c31af7Sopenharmony_ciimplementation.
164e5c31af7Sopenharmony_ci====
165e5c31af7Sopenharmony_ci
166e5c31af7Sopenharmony_ci
167e5c31af7Sopenharmony_ci[[encode-operation-steps]]
168e5c31af7Sopenharmony_ci=== Video Encode Operation Steps
169e5c31af7Sopenharmony_ci
170e5c31af7Sopenharmony_ciEach video encode operation performs the following steps in the
171e5c31af7Sopenharmony_ciename:VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR stage:
172e5c31af7Sopenharmony_ci
173e5c31af7Sopenharmony_ci  1. Reads the input picture data from the <<encode-input-picture,encode
174e5c31af7Sopenharmony_ci     input picture>>;
175e5c31af7Sopenharmony_ci  2. Determine derived encoding quality parameters according to the
176e5c31af7Sopenharmony_ci     <<encode-codec-specific-semantics,codec-specific semantics>> and the
177e5c31af7Sopenharmony_ci     current <<encode-rate-control,rate control>> state;
178e5c31af7Sopenharmony_ci  3. Compresses the input picture data according to the
179e5c31af7Sopenharmony_ci     <<encode-codec-specific-semantics,codec-specific semantics>>, applying
180e5c31af7Sopenharmony_ci     any prediction data read from the <<active-reference-pictures,active
181e5c31af7Sopenharmony_ci     reference pictures>> and rate control restrictions in the process;
182e5c31af7Sopenharmony_ci  4. Writes the encoded bitstream data to the destination video bitstream
183e5c31af7Sopenharmony_ci     buffer range;
184e5c31af7Sopenharmony_ci  5. Performs picture reconstruction of the encoded video data according to
185e5c31af7Sopenharmony_ci     the <<encode-codec-specific-semantics,codec-specific semantics>>,
186e5c31af7Sopenharmony_ci     applying any prediction data read from the <<active-reference-pictures,
187e5c31af7Sopenharmony_ci     active reference pictures>> in the process, if a
188e5c31af7Sopenharmony_ci     <<reconstructed-picture,reconstructed picture>> is specified and
189e5c31af7Sopenharmony_ci     <<encode-ref-pic-setup,reference picture setup>> is requested;
190e5c31af7Sopenharmony_ci  6. If <<encode-ref-pic-setup,reference picture setup>> is requested, the
191e5c31af7Sopenharmony_ci     <<dpb-slot,DPB slot index>> specified in the
192e5c31af7Sopenharmony_ci     <<encode-reconstructed-picture-info,reconstructed picture information>>
193e5c31af7Sopenharmony_ci     is <<dpb-slot-states,activated>> with the
194e5c31af7Sopenharmony_ci     <<reconstructed-picture,reconstructed picture>>;
195e5c31af7Sopenharmony_ci  7. Writes the reconstructed picture data to the <<reconstructed-picture,
196e5c31af7Sopenharmony_ci     reconstructed picture>>, if one is specified, according to the
197e5c31af7Sopenharmony_ci     <<encode-codec-specific-semantics,codec-specific semantics>>.
198e5c31af7Sopenharmony_ci
199e5c31af7Sopenharmony_ciWhen <<encode-reconstructed-picture-info,reconstructed picture information>>
200e5c31af7Sopenharmony_ciis provided, the specified <<dpb-slot,DPB slot>> index is associated with
201e5c31af7Sopenharmony_cithe corresponding <<bound-reference-picture-resources,bound reference
202e5c31af7Sopenharmony_cipicture resource>>, indifferent of whether <<encode-ref-pic-setup,reference
203e5c31af7Sopenharmony_cipicture setup>> is requested.
204e5c31af7Sopenharmony_ci
205e5c31af7Sopenharmony_ci=== Capabilities
206e5c31af7Sopenharmony_ci
207e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeCapabilitiesKHR',desc='Structure describing general video encode capabilities for a video profile',type='structs']
208e5c31af7Sopenharmony_ci--
209e5c31af7Sopenharmony_ciWhen calling flink:vkGetPhysicalDeviceVideoCapabilitiesKHR with
210e5c31af7Sopenharmony_cipname:pVideoProfile->videoCodecOperation specifying an encode operation, the
211e5c31af7Sopenharmony_cislink:VkVideoEncodeCapabilitiesKHR structure must: be included in the
212e5c31af7Sopenharmony_cipname:pNext chain of the slink:VkVideoCapabilitiesKHR structure to retrieve
213e5c31af7Sopenharmony_cicapabilities specific to video encoding.
214e5c31af7Sopenharmony_ci
215e5c31af7Sopenharmony_ciThe sname:VkVideoEncodeCapabilitiesKHR structure is defined as:
216e5c31af7Sopenharmony_ci
217e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkVideoEncodeCapabilitiesKHR.adoc[]
218e5c31af7Sopenharmony_ci
219e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
220e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to a structure extending this
221e5c31af7Sopenharmony_ci    structure.
222e5c31af7Sopenharmony_ci  * pname:flags is a bitmask of elink:VkVideoEncodeCapabilityFlagBitsKHR
223e5c31af7Sopenharmony_ci    describing supported encoding features.
224e5c31af7Sopenharmony_ci  * pname:rateControlModes is a bitmask of
225e5c31af7Sopenharmony_ci    elink:VkVideoEncodeRateControlModeFlagBitsKHR indicating supported
226e5c31af7Sopenharmony_ci    <<encode-rate-control-modes,rate control modes>>.
227e5c31af7Sopenharmony_ci  * pname:maxRateControlLayers indicates the maximum number of
228e5c31af7Sopenharmony_ci    <<encode-rate-control-layers,rate control layers>> supported.
229e5c31af7Sopenharmony_ci  * pname:maxBitrate indicates the maximum supported bitrate.
230e5c31af7Sopenharmony_ci  * pname:maxQualityLevels indicates the number of discrete
231e5c31af7Sopenharmony_ci    <<encode-quality-level,video encode quality levels>> supported.
232e5c31af7Sopenharmony_ci    Implementations must: support at least one quality level.
233e5c31af7Sopenharmony_ci  * pname:encodeInputPictureGranularity indicates the granularity at which
234e5c31af7Sopenharmony_ci    <<encode-input-picture,encode input picture>> data is encoded and may:
235e5c31af7Sopenharmony_ci    indicate a texel granularity up to the size of the codec-specific coding
236e5c31af7Sopenharmony_ci    block size.
237e5c31af7Sopenharmony_ci    This capability does not impose any valid usage constraints on the
238e5c31af7Sopenharmony_ci    application, however, depending on the contents of the encode input
239e5c31af7Sopenharmony_ci    picture, it may: have effects on the encoded bitstream, as described in
240e5c31af7Sopenharmony_ci    more detail below.
241e5c31af7Sopenharmony_ci  * pname:supportedEncodeFeedbackFlags is a bitmask of
242e5c31af7Sopenharmony_ci    elink:VkVideoEncodeFeedbackFlagBitsKHR values specifying the supported
243e5c31af7Sopenharmony_ci    flags for <<queries-video-encode-feedback,video encode feedback
244e5c31af7Sopenharmony_ci    queries>>.
245e5c31af7Sopenharmony_ci
246e5c31af7Sopenharmony_ciImplementations must: include support for at least
247e5c31af7Sopenharmony_ciename:VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_BUFFER_OFFSET_BIT_KHR and
248e5c31af7Sopenharmony_ciename:VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_BYTES_WRITTEN_BIT_KHR in
249e5c31af7Sopenharmony_cipname:supportedEncodeFeedbackFlags.
250e5c31af7Sopenharmony_ci
251e5c31af7Sopenharmony_cipname:encodeInputPictureGranularity provides information about the way
252e5c31af7Sopenharmony_ci<<encode-input-picture,encode input picture>> data is used as input to video
253e5c31af7Sopenharmony_ciencode operations.
254e5c31af7Sopenharmony_ciIn particular, some implementations may: not be able to limit the set of
255e5c31af7Sopenharmony_citexels used to encode the output video bitstream to the image subregion
256e5c31af7Sopenharmony_cispecified in the slink:VkVideoPictureResourceInfoKHR structure corresponding
257e5c31af7Sopenharmony_cito the encode input picture (i.e. to the resolution of the image data to
258e5c31af7Sopenharmony_ciencode specified in its pname:codedExtent member).
259e5c31af7Sopenharmony_ci
260e5c31af7Sopenharmony_ci[NOTE]
261e5c31af7Sopenharmony_ci.Note
262e5c31af7Sopenharmony_ci====
263e5c31af7Sopenharmony_ciFor example, the application requests the coded extent to be 1920x1080, but
264e5c31af7Sopenharmony_cithe implementation is only able to source the encode input picture data at
265e5c31af7Sopenharmony_cithe granularity of the codec-specific coding block size which is 16x16
266e5c31af7Sopenharmony_cipixels (or as otherwise indicated in pname:encodeInputPictureGranularity).
267e5c31af7Sopenharmony_ciIn this example, the content is horizontally aligned with the coding block
268e5c31af7Sopenharmony_cisize, but not vertically aligned with it.
269e5c31af7Sopenharmony_ciThus encoding of the last row of coding blocks will be impacted by the
270e5c31af7Sopenharmony_cicontents of the input image at texel rows 1080 to 1087 (the latter being the
271e5c31af7Sopenharmony_cinext row which is vertically aligned with the coding block size, assuming a
272e5c31af7Sopenharmony_cizero-based texel row index).
273e5c31af7Sopenharmony_ci====
274e5c31af7Sopenharmony_ci
275e5c31af7Sopenharmony_ciIf pname:codedExtent rounded up to the next integer multiple of
276e5c31af7Sopenharmony_cipname:encodeInputPictureGranularity is greater than the extent of the image
277e5c31af7Sopenharmony_cisubresource specified for the <<encode-input-picture,encode input picture>>,
278e5c31af7Sopenharmony_cithen the texel values corresponding to texel coordinates outside of the
279e5c31af7Sopenharmony_cibounds of the image subresource may: be undefined:.
280e5c31af7Sopenharmony_ciHowever, implementations should: use well-defined default values for such
281e5c31af7Sopenharmony_citexels in order to maximize the encoding efficiency for the last coding
282e5c31af7Sopenharmony_ciblock row/column, and/or to ensure consistent encoding results across
283e5c31af7Sopenharmony_cirepeated encoding of the same input content.
284e5c31af7Sopenharmony_ciNonetheless, the values used for such texels must: not have an effect on
285e5c31af7Sopenharmony_ciwhether the video encode operation produces a compliant bitstream, and must:
286e5c31af7Sopenharmony_cinot have any other effects on the encoded picture data beyond what may:
287e5c31af7Sopenharmony_ciotherwise result from using these texel values as input to any compression
288e5c31af7Sopenharmony_cialgorithm, as defined in the used video compression standard.
289e5c31af7Sopenharmony_ci
290e5c31af7Sopenharmony_ci[NOTE]
291e5c31af7Sopenharmony_ci.Note
292e5c31af7Sopenharmony_ci====
293e5c31af7Sopenharmony_ciWhile not required, it is generally a good practice for applications to make
294e5c31af7Sopenharmony_cisure that the image subresource used for the encode input picture has an
295e5c31af7Sopenharmony_ciextent that is an integer multiple of the codec-specific coding block size
296e5c31af7Sopenharmony_ci(or at least pname:encodeInputPictureGranularity) and that this padding area
297e5c31af7Sopenharmony_ciis filled with known values in order to improve encoding efficiency,
298e5c31af7Sopenharmony_ciportability, and reproducibility.
299e5c31af7Sopenharmony_ci====
300e5c31af7Sopenharmony_ci
301e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkVideoEncodeCapabilitiesKHR.adoc[]
302e5c31af7Sopenharmony_ci--
303e5c31af7Sopenharmony_ci
304e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeCapabilityFlagBitsKHR',desc='Video encode capability flags',type='enums']
305e5c31af7Sopenharmony_ci--
306e5c31af7Sopenharmony_ciBits which may: be set in slink:VkVideoEncodeCapabilitiesKHR::pname:flags,
307e5c31af7Sopenharmony_ciindicating the encoding tools supported, are:
308e5c31af7Sopenharmony_ci
309e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkVideoEncodeCapabilityFlagBitsKHR.adoc[]
310e5c31af7Sopenharmony_ci
311e5c31af7Sopenharmony_ci  * ename:VK_VIDEO_ENCODE_CAPABILITY_PRECEDING_EXTERNALLY_ENCODED_BYTES_BIT_KHR
312e5c31af7Sopenharmony_ci    indicates that the implementation supports the use of
313e5c31af7Sopenharmony_ci    slink:VkVideoEncodeInfoKHR::pname:precedingExternallyEncodedBytes.
314e5c31af7Sopenharmony_ci  * ename:VK_VIDEO_ENCODE_CAPABILITY_INSUFFICIENT_BITSTREAM_BUFFER_RANGE_DETECTION_BIT_KHR
315e5c31af7Sopenharmony_ci    indicates that the implementation is able to detect and report when the
316e5c31af7Sopenharmony_ci    destination video bitstream buffer range provided by the application is
317e5c31af7Sopenharmony_ci    not sufficiently large to fit the encoded bitstream data produced by a
318e5c31af7Sopenharmony_ci    video encode operation by reporting the
319e5c31af7Sopenharmony_ci    ename:VK_QUERY_RESULT_STATUS_INSUFFICIENT_BITSTREAM_BUFFER_RANGE_KHR
320e5c31af7Sopenharmony_ci    <<query-result-status-codes,query result status code>>.
321e5c31af7Sopenharmony_ci+
322e5c31af7Sopenharmony_ci[NOTE]
323e5c31af7Sopenharmony_ci.Note
324e5c31af7Sopenharmony_ci====
325e5c31af7Sopenharmony_ciSome implementations may: not be able to reliably detect insufficient
326e5c31af7Sopenharmony_cibitstream buffer range conditions in all situations.
327e5c31af7Sopenharmony_ciSuch implementations will not report support for the
328e5c31af7Sopenharmony_ciename:VK_VIDEO_ENCODE_CAPABILITY_INSUFFICIENT_BITSTREAM_BUFFER_RANGE_DETECTION_BIT_KHR
329e5c31af7Sopenharmony_ciencode capability flag for the video profile, but may: still report the
330e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_STATUS_INSUFFICIENT_BITSTREAM_BUFFER_RANGE_KHR query
331e5c31af7Sopenharmony_ciresult status code in certain cases.
332e5c31af7Sopenharmony_ciApplications should: always check for the specific query result status code
333e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_STATUS_INSUFFICIENT_BITSTREAM_BUFFER_RANGE_KHR even
334e5c31af7Sopenharmony_ciwhen this encode capability flag is not supported by the implementation for
335e5c31af7Sopenharmony_cithe video profile in question.
336e5c31af7Sopenharmony_ciHowever, applications must: not assume that a different negative query
337e5c31af7Sopenharmony_ciresult status code indicating an unsuccessful completion of a video encode
338e5c31af7Sopenharmony_cioperation is not the result of an insufficient bitstream buffer condition
339e5c31af7Sopenharmony_ciunless this encode capability flag is supported.
340e5c31af7Sopenharmony_ci====
341e5c31af7Sopenharmony_ci--
342e5c31af7Sopenharmony_ci
343e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeCapabilityFlagsKHR',desc='Bitmask of VkVideoEncodeCapabilityFlagBitsKHR',type='flags']
344e5c31af7Sopenharmony_ci--
345e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkVideoEncodeCapabilityFlagsKHR.adoc[]
346e5c31af7Sopenharmony_ci
347e5c31af7Sopenharmony_citname:VkVideoEncodeCapabilityFlagsKHR is a bitmask type for setting a mask
348e5c31af7Sopenharmony_ciof zero or more elink:VkVideoEncodeCapabilityFlagBitsKHR.
349e5c31af7Sopenharmony_ci--
350e5c31af7Sopenharmony_ci
351e5c31af7Sopenharmony_ci
352e5c31af7Sopenharmony_ci[[encode-quality-level]]
353e5c31af7Sopenharmony_ci=== Video Encode Quality Levels
354e5c31af7Sopenharmony_ci
355e5c31af7Sopenharmony_ciImplementations can: support more than one video encode quality levels for a
356e5c31af7Sopenharmony_civideo encode profile, which control the number and type of
357e5c31af7Sopenharmony_ciimplementation-specific encoding tools and algorithms utilized in the
358e5c31af7Sopenharmony_ciencoding process.
359e5c31af7Sopenharmony_ci
360e5c31af7Sopenharmony_ci[NOTE]
361e5c31af7Sopenharmony_ci.Note
362e5c31af7Sopenharmony_ci====
363e5c31af7Sopenharmony_ciGenerally, using higher video encode quality levels may: produce higher
364e5c31af7Sopenharmony_ciquality video streams at the cost of additional processing time.
365e5c31af7Sopenharmony_ciHowever, as the final quality of an encoded picture depends on the contents
366e5c31af7Sopenharmony_ciof the <<encode-input-picture,encode input picture>>, the contents of the
367e5c31af7Sopenharmony_ci<<active-reference-pictures,active reference pictures>>, the codec-specific
368e5c31af7Sopenharmony_ciencode parameters, and the particular implementation-specific tools used
369e5c31af7Sopenharmony_cicorresponding to the individual video encode quality levels, there are no
370e5c31af7Sopenharmony_ciguarantees that using a higher video encode quality level will always
371e5c31af7Sopenharmony_ciproduce a higher quality encoded picture for any given set of inputs.
372e5c31af7Sopenharmony_ci====
373e5c31af7Sopenharmony_ci
374e5c31af7Sopenharmony_ci[open,refpage='vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR',desc='Query video encode quality level properties',type='protos']
375e5c31af7Sopenharmony_ci--
376e5c31af7Sopenharmony_ciTo query properties for a specific video encode quality level supported by a
377e5c31af7Sopenharmony_civideo encode profile, call:
378e5c31af7Sopenharmony_ci
379e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR.adoc[]
380e5c31af7Sopenharmony_ci
381e5c31af7Sopenharmony_ci  * pname:physicalDevice is the physical device to query the video encode
382e5c31af7Sopenharmony_ci    quality level properties for.
383e5c31af7Sopenharmony_ci  * pname:pQualityLevelInfo is a pointer to a
384e5c31af7Sopenharmony_ci    slink:VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR structure
385e5c31af7Sopenharmony_ci    specifying the video encode profile and quality level to query
386e5c31af7Sopenharmony_ci    properties for.
387e5c31af7Sopenharmony_ci  * pname:pQualityLevelProperties is a pointer to a
388e5c31af7Sopenharmony_ci    slink:VkVideoEncodeQualityLevelPropertiesKHR structure in which the
389e5c31af7Sopenharmony_ci    properties are returned.
390e5c31af7Sopenharmony_ci
391e5c31af7Sopenharmony_ci.Valid Usage
392e5c31af7Sopenharmony_ci****
393e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
394e5c31af7Sopenharmony_ci  * [[VUID-vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR-pQualityLevelInfo-08257]]
395e5c31af7Sopenharmony_ci    If pname:pQualityLevelInfo->pVideoProfile->videoCodecOperation is
396e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, then the pname:pNext
397e5c31af7Sopenharmony_ci    chain of pname:pQualityLevelProperties must: include a
398e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264QualityLevelPropertiesKHR structure
399e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
400e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
401e5c31af7Sopenharmony_ci  * [[VUID-vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR-pQualityLevelInfo-08258]]
402e5c31af7Sopenharmony_ci    If pname:pQualityLevelInfo->pVideoProfile->videoCodecOperation is
403e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then the pname:pNext
404e5c31af7Sopenharmony_ci    chain of pname:pQualityLevelProperties must: include a
405e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265QualityLevelPropertiesKHR structure
406e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
407e5c31af7Sopenharmony_ci****
408e5c31af7Sopenharmony_ci
409e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR.adoc[]
410e5c31af7Sopenharmony_ci--
411e5c31af7Sopenharmony_ci
412e5c31af7Sopenharmony_ci
413e5c31af7Sopenharmony_ci[open,refpage='VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR',desc='Structure describing the video encode profile and quality level to query properties for',type='structs']
414e5c31af7Sopenharmony_ci--
415e5c31af7Sopenharmony_ciThe sname:VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR structure is
416e5c31af7Sopenharmony_cidefined as:
417e5c31af7Sopenharmony_ci
418e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR.adoc[]
419e5c31af7Sopenharmony_ci
420e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
421e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to a structure extending this
422e5c31af7Sopenharmony_ci    structure.
423e5c31af7Sopenharmony_ci  * pname:pVideoProfile is a pointer to a slink:VkVideoProfileInfoKHR
424e5c31af7Sopenharmony_ci    structure specifying the video profile to query the video encode quality
425e5c31af7Sopenharmony_ci    level properties for.
426e5c31af7Sopenharmony_ci  * pname:qualityLevel is the video encode quality level to query properties
427e5c31af7Sopenharmony_ci    for.
428e5c31af7Sopenharmony_ci
429e5c31af7Sopenharmony_ci.Valid Usage
430e5c31af7Sopenharmony_ci****
431e5c31af7Sopenharmony_ci  * [[VUID-VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR-pVideoProfile-08259]]
432e5c31af7Sopenharmony_ci    pname:pVideoProfile must: be a <<video-profile-support, supported video
433e5c31af7Sopenharmony_ci    profile>>
434e5c31af7Sopenharmony_ci  * [[VUID-VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR-pVideoProfile-08260]]
435e5c31af7Sopenharmony_ci    pname:pVideoProfile->videoCodecOperation must: specify an encode
436e5c31af7Sopenharmony_ci    operation
437e5c31af7Sopenharmony_ci  * [[VUID-VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR-qualityLevel-08261]]
438e5c31af7Sopenharmony_ci    pname:qualityLevel must: be less than
439e5c31af7Sopenharmony_ci    slink:VkVideoEncodeCapabilitiesKHR::pname:maxQualityLevels, as returned
440e5c31af7Sopenharmony_ci    by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video profile
441e5c31af7Sopenharmony_ci    specified in pname:pVideoProfile
442e5c31af7Sopenharmony_ci****
443e5c31af7Sopenharmony_ci
444e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR.adoc[]
445e5c31af7Sopenharmony_ci--
446e5c31af7Sopenharmony_ci
447e5c31af7Sopenharmony_ci
448e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeQualityLevelPropertiesKHR',desc='Structure describing the video encode quality level properties',type='structs']
449e5c31af7Sopenharmony_ci--
450e5c31af7Sopenharmony_ciThe sname:VkVideoEncodeQualityLevelPropertiesKHR structure is defined as:
451e5c31af7Sopenharmony_ci
452e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkVideoEncodeQualityLevelPropertiesKHR.adoc[]
453e5c31af7Sopenharmony_ci
454e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
455e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to a structure extending this
456e5c31af7Sopenharmony_ci    structure.
457e5c31af7Sopenharmony_ci  * pname:preferredRateControlMode is a
458e5c31af7Sopenharmony_ci    elink:VkVideoEncodeRateControlModeFlagBitsKHR value indicating the
459e5c31af7Sopenharmony_ci    preferred <<encode-rate-control-modes,rate control mode>> to use with
460e5c31af7Sopenharmony_ci    the video encode quality level.
461e5c31af7Sopenharmony_ci  * pname:preferredRateControlLayerCount indicates the preferred number of
462e5c31af7Sopenharmony_ci    <<encode-rate-control-layers,rate control layers>> to use with the video
463e5c31af7Sopenharmony_ci    encode quality level.
464e5c31af7Sopenharmony_ci
465e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkVideoEncodeQualityLevelPropertiesKHR.adoc[]
466e5c31af7Sopenharmony_ci--
467e5c31af7Sopenharmony_ci
468e5c31af7Sopenharmony_ci
469e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeQualityLevelInfoKHR',desc='Structure specifying used video encode quality level',type='structs']
470e5c31af7Sopenharmony_ci--
471e5c31af7Sopenharmony_ciThe sname:VkVideoEncodeQualityLevelInfoKHR structure is defined as:
472e5c31af7Sopenharmony_ci
473e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkVideoEncodeQualityLevelInfoKHR.adoc[]
474e5c31af7Sopenharmony_ci
475e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
476e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to a structure extending this
477e5c31af7Sopenharmony_ci    structure.
478e5c31af7Sopenharmony_ci  * pname:qualityLevel is the used video encode quality level.
479e5c31af7Sopenharmony_ci
480e5c31af7Sopenharmony_ciThis structure can: be specified in the following places:
481e5c31af7Sopenharmony_ci
482e5c31af7Sopenharmony_ci  * In the pname:pNext chain of slink:VkVideoSessionParametersCreateInfoKHR
483e5c31af7Sopenharmony_ci    to specify the video encode quality level to use for a video session
484e5c31af7Sopenharmony_ci    parameters object created for a video encode session.
485e5c31af7Sopenharmony_ci    If no instance of this structure is included in the pname:pNext chain of
486e5c31af7Sopenharmony_ci    slink:VkVideoSessionParametersCreateInfoKHR, then the video session
487e5c31af7Sopenharmony_ci    parameters object is created with a video encode quality level of zero.
488e5c31af7Sopenharmony_ci  * In the pname:pNext chain of slink:VkVideoCodingControlInfoKHR to change
489e5c31af7Sopenharmony_ci    the video encode quality level state of the bound video session.
490e5c31af7Sopenharmony_ci
491e5c31af7Sopenharmony_ci.Valid Usage
492e5c31af7Sopenharmony_ci****
493e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeQualityLevelInfoKHR-qualityLevel-08311]]
494e5c31af7Sopenharmony_ci    pname:qualityLevel must: be less than
495e5c31af7Sopenharmony_ci    slink:VkVideoEncodeCapabilitiesKHR::pname:maxQualityLevels, as returned
496e5c31af7Sopenharmony_ci    by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the used video
497e5c31af7Sopenharmony_ci    profile
498e5c31af7Sopenharmony_ci****
499e5c31af7Sopenharmony_ci
500e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkVideoEncodeQualityLevelInfoKHR.adoc[]
501e5c31af7Sopenharmony_ci--
502e5c31af7Sopenharmony_ci
503e5c31af7Sopenharmony_ci
504e5c31af7Sopenharmony_ci=== Retrieving Encoded Session Parameters
505e5c31af7Sopenharmony_ci
506e5c31af7Sopenharmony_ciAny codec-specific parameters stored in video session parameters objects
507e5c31af7Sopenharmony_cimay: need to be separately encoded and included in the final video bitstream
508e5c31af7Sopenharmony_cidata, depending on the used video compression standard.
509e5c31af7Sopenharmony_ciIn such cases the application must: call the
510e5c31af7Sopenharmony_ciflink:vkGetEncodedVideoSessionParametersKHR command to retrieve the encoded
511e5c31af7Sopenharmony_ciparameter data from the used video session parameters object in order to be
512e5c31af7Sopenharmony_ciable to produce a compliant video bitstream.
513e5c31af7Sopenharmony_ci
514e5c31af7Sopenharmony_ci[NOTE]
515e5c31af7Sopenharmony_ci.Note
516e5c31af7Sopenharmony_ci====
517e5c31af7Sopenharmony_ciThis is needed because implementations may: have changed some of the
518e5c31af7Sopenharmony_cicodec-specific parameters stored in the video session parameters object, as
519e5c31af7Sopenharmony_cidefined in the <<encode-overrides,Video Encode Parameter Overrides>>
520e5c31af7Sopenharmony_cisection.
521e5c31af7Sopenharmony_ciIn addition, the flink:vkGetEncodedVideoSessionParametersKHR command enables
522e5c31af7Sopenharmony_cithe application to retrieve the encoded parameter data without having to
523e5c31af7Sopenharmony_ciencode these codec-specific parameters manually.
524e5c31af7Sopenharmony_ci====
525e5c31af7Sopenharmony_ci
526e5c31af7Sopenharmony_ci[open,refpage='vkGetEncodedVideoSessionParametersKHR',desc='Get encoded parameter sets from a video session parameters object',type='protos']
527e5c31af7Sopenharmony_ci--
528e5c31af7Sopenharmony_ciEncoded parameter data can: be retrieved from a video session parameters
529e5c31af7Sopenharmony_ciobject created with a video encode operation using the command:
530e5c31af7Sopenharmony_ci
531e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetEncodedVideoSessionParametersKHR.adoc[]
532e5c31af7Sopenharmony_ci
533e5c31af7Sopenharmony_ci  * pname:device is the logical device that owns the video session
534e5c31af7Sopenharmony_ci    parameters object.
535e5c31af7Sopenharmony_ci  * pname:pVideoSessionParametersInfo is a pointer to a
536e5c31af7Sopenharmony_ci    slink:VkVideoEncodeSessionParametersGetInfoKHR structure specifying the
537e5c31af7Sopenharmony_ci    parameters of the encoded parameter data to retrieve.
538e5c31af7Sopenharmony_ci  * pname:pFeedbackInfo is either `NULL` or a pointer to a
539e5c31af7Sopenharmony_ci    slink:VkVideoEncodeSessionParametersFeedbackInfoKHR structure in which
540e5c31af7Sopenharmony_ci    feedback about the requested parameter data is returned.
541e5c31af7Sopenharmony_ci  * pname:pDataSize is a pointer to a code:size_t value related to the
542e5c31af7Sopenharmony_ci    amount of encode parameter data returned, as described below.
543e5c31af7Sopenharmony_ci  * pname:pData is either `NULL` or a pointer to a buffer to write the
544e5c31af7Sopenharmony_ci    encoded parameter data to.
545e5c31af7Sopenharmony_ci
546e5c31af7Sopenharmony_ciIf pname:pData is `NULL`, then the size of the encoded parameter data, in
547e5c31af7Sopenharmony_cibytes, that can: be retrieved is returned in pname:pDataSize.
548e5c31af7Sopenharmony_ciOtherwise, pname:pDataSize must: point to a variable set by the application
549e5c31af7Sopenharmony_cito the size of the buffer, in bytes, pointed to by pname:pData, and on
550e5c31af7Sopenharmony_cireturn the variable is overwritten with the number of bytes actually written
551e5c31af7Sopenharmony_cito pname:pData.
552e5c31af7Sopenharmony_ciIf pname:pDataSize is less than the size of the encoded parameter data that
553e5c31af7Sopenharmony_cican: be retrieved, then no data will be written to pname:pData, zero will be
554e5c31af7Sopenharmony_ciwritten to pname:pDataSize, and ename:VK_INCOMPLETE will be returned instead
555e5c31af7Sopenharmony_ciof ename:VK_SUCCESS, to indicate that no encoded parameter data was
556e5c31af7Sopenharmony_cireturned.
557e5c31af7Sopenharmony_ci
558e5c31af7Sopenharmony_ciIf pname:pFeedbackInfo is not `NULL` then the members of the
559e5c31af7Sopenharmony_cislink:VkVideoEncodeSessionParametersFeedbackInfoKHR structure and any
560e5c31af7Sopenharmony_ciadditional structures included in its pname:pNext chain that are applicable
561e5c31af7Sopenharmony_cito the video session parameters object specified in
562e5c31af7Sopenharmony_cipname:pVideoSessionParametersInfo->videoSessionParameters will be filled
563e5c31af7Sopenharmony_ciwith feedback about the requested parameter data on all successful calls to
564e5c31af7Sopenharmony_cithis command.
565e5c31af7Sopenharmony_ci
566e5c31af7Sopenharmony_ci[NOTE]
567e5c31af7Sopenharmony_ci.Note
568e5c31af7Sopenharmony_ci====
569e5c31af7Sopenharmony_ciThis includes the cases when pname:pData is `NULL` or when
570e5c31af7Sopenharmony_ciename:VK_INCOMPLETE is returned by the command, and enables the application
571e5c31af7Sopenharmony_cito determine whether the implementation <<encode-overrides,overrode>> any of
572e5c31af7Sopenharmony_cithe requested video session parameters without actually needing to retrieve
573e5c31af7Sopenharmony_cithe encoded parameter data itself.
574e5c31af7Sopenharmony_ci====
575e5c31af7Sopenharmony_ci
576e5c31af7Sopenharmony_ci.Valid Usage
577e5c31af7Sopenharmony_ci****
578e5c31af7Sopenharmony_ci  * [[VUID-vkGetEncodedVideoSessionParametersKHR-pVideoSessionParametersInfo-08359]]
579e5c31af7Sopenharmony_ci    pname:pVideoSessionParametersInfo->videoSessionParameters must: have
580e5c31af7Sopenharmony_ci    been created with an encode operation
581e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
582e5c31af7Sopenharmony_ci  * [[VUID-vkGetEncodedVideoSessionParametersKHR-pVideoSessionParametersInfo-08262]]
583e5c31af7Sopenharmony_ci    If pname:pVideoSessionParametersInfo->videoSessionParameters was created
584e5c31af7Sopenharmony_ci    with the video codec operation
585e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, then the pname:pNext
586e5c31af7Sopenharmony_ci    chain of pname:pVideoSessionParametersInfo must: include a
587e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264SessionParametersGetInfoKHR structure
588e5c31af7Sopenharmony_ci  * [[VUID-vkGetEncodedVideoSessionParametersKHR-pVideoSessionParametersInfo-08263]]
589e5c31af7Sopenharmony_ci    If pname:pVideoSessionParametersInfo->videoSessionParameters was created
590e5c31af7Sopenharmony_ci    with the video codec operation
591e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, then for the
592e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264SessionParametersGetInfoKHR structure included in
593e5c31af7Sopenharmony_ci    the pname:pNext chain of pname:pVideoSessionParametersInfo, if its
594e5c31af7Sopenharmony_ci    pname:writeStdSPS member is ename:VK_TRUE, then
595e5c31af7Sopenharmony_ci    pname:pVideoSessionParametersInfo->videoSessionParameters must: contain
596e5c31af7Sopenharmony_ci    a code:StdVideoH264SequenceParameterSet entry with
597e5c31af7Sopenharmony_ci    pname:seq_parameter_set_id matching
598e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264SessionParametersGetInfoKHR::pname:stdSPSId
599e5c31af7Sopenharmony_ci  * [[VUID-vkGetEncodedVideoSessionParametersKHR-pVideoSessionParametersInfo-08264]]
600e5c31af7Sopenharmony_ci    If pname:pVideoSessionParametersInfo->videoSessionParameters was created
601e5c31af7Sopenharmony_ci    with the video codec operation
602e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, then for the
603e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264SessionParametersGetInfoKHR structure included in
604e5c31af7Sopenharmony_ci    the pname:pNext chain of pname:pVideoSessionParametersInfo, if its
605e5c31af7Sopenharmony_ci    pname:writeStdPPS member is ename:VK_TRUE, then
606e5c31af7Sopenharmony_ci    pname:pVideoSessionParametersInfo->videoSessionParameters must: contain
607e5c31af7Sopenharmony_ci    a code:StdVideoH264PictureParameterSet entry with
608e5c31af7Sopenharmony_ci    pname:seq_parameter_set_id and pname:pic_parameter_set_id matching
609e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264SessionParametersGetInfoKHR::pname:stdSPSId and
610e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264SessionParametersGetInfoKHR::pname:stdPPSId,
611e5c31af7Sopenharmony_ci    respectively
612e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
613e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
614e5c31af7Sopenharmony_ci  * [[VUID-vkGetEncodedVideoSessionParametersKHR-pVideoSessionParametersInfo-08265]]
615e5c31af7Sopenharmony_ci    If pname:pVideoSessionParametersInfo->videoSessionParameters was created
616e5c31af7Sopenharmony_ci    with the video codec operation
617e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then the pname:pNext
618e5c31af7Sopenharmony_ci    chain of pname:pVideoSessionParametersInfo must: include a
619e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265SessionParametersGetInfoKHR structure
620e5c31af7Sopenharmony_ci  * [[VUID-vkGetEncodedVideoSessionParametersKHR-pVideoSessionParametersInfo-08266]]
621e5c31af7Sopenharmony_ci    If pname:pVideoSessionParametersInfo->videoSessionParameters was created
622e5c31af7Sopenharmony_ci    with the video codec operation
623e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then for the
624e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265SessionParametersGetInfoKHR structure included in
625e5c31af7Sopenharmony_ci    the pname:pNext chain of pname:pVideoSessionParametersInfo, if its
626e5c31af7Sopenharmony_ci    pname:writeStdVPS member is ename:VK_TRUE, then
627e5c31af7Sopenharmony_ci    pname:pVideoSessionParametersInfo->videoSessionParameters must: contain
628e5c31af7Sopenharmony_ci    a code:StdVideoH265VideoParameterSet entry with
629e5c31af7Sopenharmony_ci    pname:vps_video_parameter_set_id matching
630e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265SessionParametersGetInfoKHR::pname:stdVPSId
631e5c31af7Sopenharmony_ci  * [[VUID-vkGetEncodedVideoSessionParametersKHR-pVideoSessionParametersInfo-08267]]
632e5c31af7Sopenharmony_ci    If pname:pVideoSessionParametersInfo->videoSessionParameters was created
633e5c31af7Sopenharmony_ci    with the video codec operation
634e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then for the
635e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265SessionParametersGetInfoKHR structure included in
636e5c31af7Sopenharmony_ci    the pname:pNext chain of pname:pVideoSessionParametersInfo, if its
637e5c31af7Sopenharmony_ci    pname:writeStdSPS member is ename:VK_TRUE, then
638e5c31af7Sopenharmony_ci    pname:pVideoSessionParametersInfo->videoSessionParameters must: contain
639e5c31af7Sopenharmony_ci    a code:StdVideoH265SequenceParameterSet entry with
640e5c31af7Sopenharmony_ci    pname:sps_video_parameter_set_id and pname:sps_seq_parameter_set_id
641e5c31af7Sopenharmony_ci    matching
642e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265SessionParametersGetInfoKHR::pname:stdVPSId and
643e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265SessionParametersGetInfoKHR::pname:stdSPSId,
644e5c31af7Sopenharmony_ci    respectively
645e5c31af7Sopenharmony_ci  * [[VUID-vkGetEncodedVideoSessionParametersKHR-pVideoSessionParametersInfo-08268]]
646e5c31af7Sopenharmony_ci    If pname:pVideoSessionParametersInfo->videoSessionParameters was created
647e5c31af7Sopenharmony_ci    with the video codec operation
648e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then for the
649e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265SessionParametersGetInfoKHR structure included in
650e5c31af7Sopenharmony_ci    the pname:pNext chain of pname:pVideoSessionParametersInfo, if its
651e5c31af7Sopenharmony_ci    pname:writeStdPPS member is ename:VK_TRUE, then
652e5c31af7Sopenharmony_ci    pname:pVideoSessionParametersInfo->videoSessionParameters must: contain
653e5c31af7Sopenharmony_ci    a code:StdVideoH265PictureParameterSet entry with
654e5c31af7Sopenharmony_ci    pname:sps_video_parameter_set_id, pname:pps_seq_parameter_set_id, and
655e5c31af7Sopenharmony_ci    pname:pps_pic_parameter_set_id matching
656e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265SessionParametersGetInfoKHR::pname:stdVPSId,
657e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265SessionParametersGetInfoKHR::pname:stdSPSId, and
658e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265SessionParametersGetInfoKHR::pname:stdPPSId,
659e5c31af7Sopenharmony_ci    respectively
660e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
661e5c31af7Sopenharmony_ci****
662e5c31af7Sopenharmony_ci
663e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetEncodedVideoSessionParametersKHR.adoc[]
664e5c31af7Sopenharmony_ci--
665e5c31af7Sopenharmony_ci
666e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeSessionParametersGetInfoKHR',desc='Structure specifying parameters for retrieving encoded video session parameter data',type='structs']
667e5c31af7Sopenharmony_ci--
668e5c31af7Sopenharmony_ciThe sname:VkVideoEncodeSessionParametersGetInfoKHR structure is defined as:
669e5c31af7Sopenharmony_ci
670e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkVideoEncodeSessionParametersGetInfoKHR.adoc[]
671e5c31af7Sopenharmony_ci
672e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
673e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to a structure extending this
674e5c31af7Sopenharmony_ci    structure.
675e5c31af7Sopenharmony_ci  * pname:videoSessionParameters is the slink:VkVideoSessionParametersKHR
676e5c31af7Sopenharmony_ci    object to retrieve encoded parameter data from.
677e5c31af7Sopenharmony_ci
678e5c31af7Sopenharmony_ciDepending on the used video encode operation, additional codec-specific
679e5c31af7Sopenharmony_cistructures may: need to be included in the pname:pNext chain of this
680e5c31af7Sopenharmony_cistructure to identify the specific video session parameters to retrieve
681e5c31af7Sopenharmony_ciencoded parameter data for, as described in the corresponding sections.
682e5c31af7Sopenharmony_ci
683e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkVideoEncodeSessionParametersGetInfoKHR.adoc[]
684e5c31af7Sopenharmony_ci--
685e5c31af7Sopenharmony_ci
686e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeSessionParametersFeedbackInfoKHR',desc='Structure providing feedback about the requested video session parameters',type='structs']
687e5c31af7Sopenharmony_ci--
688e5c31af7Sopenharmony_ciThe sname:VkVideoEncodeSessionParametersFeedbackInfoKHR structure is defined
689e5c31af7Sopenharmony_cias:
690e5c31af7Sopenharmony_ci
691e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkVideoEncodeSessionParametersFeedbackInfoKHR.adoc[]
692e5c31af7Sopenharmony_ci
693e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
694e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to a structure extending this
695e5c31af7Sopenharmony_ci    structure.
696e5c31af7Sopenharmony_ci  * pname:hasOverrides indicates whether any of the requested parameter data
697e5c31af7Sopenharmony_ci    were <<encode-overrides,overridden>> by the implementation.
698e5c31af7Sopenharmony_ci
699e5c31af7Sopenharmony_ciDepending on the used video encode operation, additional codec-specific
700e5c31af7Sopenharmony_cistructures can: be be included in the pname:pNext chain of this structure to
701e5c31af7Sopenharmony_cicapture codec-specific feedback information about the requested parameter
702e5c31af7Sopenharmony_cidata, as described in the corresponding sections.
703e5c31af7Sopenharmony_ci
704e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkVideoEncodeSessionParametersFeedbackInfoKHR.adoc[]
705e5c31af7Sopenharmony_ci--
706e5c31af7Sopenharmony_ci
707e5c31af7Sopenharmony_ci
708e5c31af7Sopenharmony_ci[[video-encode-commands]]
709e5c31af7Sopenharmony_ci=== Video Encode Commands
710e5c31af7Sopenharmony_ci
711e5c31af7Sopenharmony_ci[open,refpage='vkCmdEncodeVideoKHR',desc='Launch video encode operations',type='protos']
712e5c31af7Sopenharmony_ci--
713e5c31af7Sopenharmony_ciTo launch video encode operations, call:
714e5c31af7Sopenharmony_ci
715e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdEncodeVideoKHR.adoc[]
716e5c31af7Sopenharmony_ci
717e5c31af7Sopenharmony_ci  * pname:commandBuffer is the command buffer in which to record the
718e5c31af7Sopenharmony_ci    command.
719e5c31af7Sopenharmony_ci  * pname:pEncodeInfo is a pointer to a slink:VkVideoEncodeInfoKHR structure
720e5c31af7Sopenharmony_ci    specifying the parameters of the video encode operations.
721e5c31af7Sopenharmony_ci
722e5c31af7Sopenharmony_ciEach call issues one or more video encode operations.
723e5c31af7Sopenharmony_ciThe implicit parameter pname:opCount corresponds to the number of video
724e5c31af7Sopenharmony_ciencode operations issued by the command.
725e5c31af7Sopenharmony_ciAfter calling this command, the
726e5c31af7Sopenharmony_ci<<queries-operation-active-query-index,active query index>> of each
727e5c31af7Sopenharmony_ci<<queries-operation-active,active>> query is incremented by pname:opCount.
728e5c31af7Sopenharmony_ci
729e5c31af7Sopenharmony_ciCurrently each call to this command results in the issue of a single video
730e5c31af7Sopenharmony_ciencode operation.
731e5c31af7Sopenharmony_ci
732e5c31af7Sopenharmony_ciifdef::VK_KHR_video_maintenance1[]
733e5c31af7Sopenharmony_ciIf the bound video session was created with
734e5c31af7Sopenharmony_ciename:VK_VIDEO_SESSION_CREATE_INLINE_QUERIES_BIT_KHR and the pname:pNext
735e5c31af7Sopenharmony_cichain of pname:pEncodeInfo includes a slink:VkVideoInlineQueryInfoKHR
736e5c31af7Sopenharmony_cistructure with its pname:queryPool member specifying a valid
737e5c31af7Sopenharmony_cisname:VkQueryPool handle, then this command will execute a query for each
738e5c31af7Sopenharmony_civideo encode operation issued by it.
739e5c31af7Sopenharmony_ciendif::VK_KHR_video_maintenance1[]
740e5c31af7Sopenharmony_ci
741e5c31af7Sopenharmony_ci[[encode-active-reference-picture-info]]
742e5c31af7Sopenharmony_ciActive Reference Picture Information::
743e5c31af7Sopenharmony_ci
744e5c31af7Sopenharmony_ciThe list of <<active-reference-pictures,active reference pictures>> used by
745e5c31af7Sopenharmony_cia video encode operation is a list of image subregions used as the source of
746e5c31af7Sopenharmony_ci<<reference-picture,reference picture>> data and related parameters, and is
747e5c31af7Sopenharmony_ciderived from the slink:VkVideoReferenceSlotInfoKHR structures provided as
748e5c31af7Sopenharmony_cithe elements of the pname:pEncodeInfo->pReferenceSlots array.
749e5c31af7Sopenharmony_ciFor each element of pname:pEncodeInfo->pReferenceSlots, one or more elements
750e5c31af7Sopenharmony_ciare added to the active reference picture list, as defined by the
751e5c31af7Sopenharmony_ci<<encode-codec-specific-semantics,codec-specific semantics>>.
752e5c31af7Sopenharmony_ciEach element of this list contains the following information:
753e5c31af7Sopenharmony_ci
754e5c31af7Sopenharmony_ci  * The image subregion within the image subresource
755e5c31af7Sopenharmony_ci    <<video-image-subresource-reference,referred>> to by the
756e5c31af7Sopenharmony_ci    <<video-picture-resources,video picture resource>> used as the reference
757e5c31af7Sopenharmony_ci    picture.
758e5c31af7Sopenharmony_ci  * The <<dpb-slot,DPB slot>> index the reference picture is associated
759e5c31af7Sopenharmony_ci    with.
760e5c31af7Sopenharmony_ci  * The codec-specific reference information related to the reference
761e5c31af7Sopenharmony_ci    picture.
762e5c31af7Sopenharmony_ci
763e5c31af7Sopenharmony_ci[[encode-reconstructed-picture-info]]
764e5c31af7Sopenharmony_ciReconstructed Picture Information::
765e5c31af7Sopenharmony_ci
766e5c31af7Sopenharmony_ciInformation related to the optional <<reconstructed-picture,reconstructed
767e5c31af7Sopenharmony_cipicture>> used by a video encode operation is derived from the
768e5c31af7Sopenharmony_cislink:VkVideoReferenceSlotInfoKHR structure pointed to by
769e5c31af7Sopenharmony_cipname:pEncodeInfo->pSetupReferenceSlot, if not `NULL`, as defined by the
770e5c31af7Sopenharmony_ci<<encode-codec-specific-semantics,codec-specific semantics>>, and consists
771e5c31af7Sopenharmony_ciof the following:
772e5c31af7Sopenharmony_ci
773e5c31af7Sopenharmony_ci  * The image subregion within the image subresource
774e5c31af7Sopenharmony_ci    <<video-image-subresource-reference,referred>> to by the
775e5c31af7Sopenharmony_ci    <<video-picture-resources,video picture resource>> used as the
776e5c31af7Sopenharmony_ci    reconstructed picture.
777e5c31af7Sopenharmony_ci  * The <<dpb-slot,DPB slot>> index to use for picture reconstruction.
778e5c31af7Sopenharmony_ci  * The codec-specific reference information related to the reconstructed
779e5c31af7Sopenharmony_ci    picture.
780e5c31af7Sopenharmony_ci
781e5c31af7Sopenharmony_ci[[encode-ref-pic-setup]]
782e5c31af7Sopenharmony_ciSpecifying a valid slink:VkVideoReferenceSlotInfoKHR structure in
783e5c31af7Sopenharmony_cipname:pEncodeInfo->pSetupReferenceSlot is always required, unless the video
784e5c31af7Sopenharmony_cisession was created with slink:VkVideoSessionCreateInfoKHR::pname:maxDpbSlot
785e5c31af7Sopenharmony_ciequal to zero.
786e5c31af7Sopenharmony_ciHowever, the DPB slot identified by
787e5c31af7Sopenharmony_cipname:pEncodeInfo->pSetupReferenceSlot->slotIndex is only
788e5c31af7Sopenharmony_ci<<dpb-slot-states,activated>> with the <<reconstructed-picture,reconstructed
789e5c31af7Sopenharmony_cipicture>> specified in
790e5c31af7Sopenharmony_cipname:pEncodeInfo->pSetupReferenceSlot->pPictureResource if reference
791e5c31af7Sopenharmony_cipicture setup is requested according to the
792e5c31af7Sopenharmony_ci<<encode-codec-specific-semantics,codec-specific semantics>>.
793e5c31af7Sopenharmony_ci
794e5c31af7Sopenharmony_ciIf reconstructed picture information is specified, but reference picture
795e5c31af7Sopenharmony_cisetup is not requested, according to the codec-specific semantics, the
796e5c31af7Sopenharmony_cicontents of the <<video-picture-resources,video picture resource>>
797e5c31af7Sopenharmony_cicorresponding to the reconstructed picture will be undefined: after the
798e5c31af7Sopenharmony_civideo encode operation.
799e5c31af7Sopenharmony_ci
800e5c31af7Sopenharmony_ci[NOTE]
801e5c31af7Sopenharmony_ci.Note
802e5c31af7Sopenharmony_ci====
803e5c31af7Sopenharmony_ciSome implementations may always output the reconstructed picture or use it
804e5c31af7Sopenharmony_cias temporary storage during the video encode operation even when the
805e5c31af7Sopenharmony_cireconstructed picture is not marked for future reference.
806e5c31af7Sopenharmony_ci====
807e5c31af7Sopenharmony_ci
808e5c31af7Sopenharmony_ci[[encode-input-picture-info]]
809e5c31af7Sopenharmony_ciEncode Input Picture Information::
810e5c31af7Sopenharmony_ci
811e5c31af7Sopenharmony_ciInformation related to the <<encode-input-picture,encode input picture>>
812e5c31af7Sopenharmony_ciused by a video encode operation is derived from
813e5c31af7Sopenharmony_cipname:pEncodeInfo->srcPictureResource and any codec-specific parameters
814e5c31af7Sopenharmony_ciprovided in the pname:pEncodeInfo->pNext chain, as defined by the
815e5c31af7Sopenharmony_ci<<encode-codec-specific-semantics,codec-specific semantics>>, and consists
816e5c31af7Sopenharmony_ciof the following:
817e5c31af7Sopenharmony_ci
818e5c31af7Sopenharmony_ci  * The image subregion within the image subresource
819e5c31af7Sopenharmony_ci    <<video-image-subresource-reference,referred>> to by the
820e5c31af7Sopenharmony_ci    <<video-picture-resources,video picture resource>> used as the encode
821e5c31af7Sopenharmony_ci    input picture.
822e5c31af7Sopenharmony_ci  * The codec-specific picture information related to the encoded picture.
823e5c31af7Sopenharmony_ci
824e5c31af7Sopenharmony_ciSeveral limiting values are defined below that are referenced by the
825e5c31af7Sopenharmony_cirelevant valid usage statements of this command.
826e5c31af7Sopenharmony_ci
827e5c31af7Sopenharmony_ci  * Let `uint32_t activeReferencePictureCount` be the size of the list of
828e5c31af7Sopenharmony_ci    active reference pictures used by the video encode operation.
829e5c31af7Sopenharmony_ci    Unless otherwise defined, pname:activeReferencePictureCount is set to
830e5c31af7Sopenharmony_ci    the value of pname:pEncodeInfo->referenceSlotCount.
831e5c31af7Sopenharmony_ci  * Let `VkOffset2D codedOffsetGranularity` be the minimum alignment
832e5c31af7Sopenharmony_ci    requirement for the coded offset of video picture resources.
833e5c31af7Sopenharmony_ci    Unless otherwise defined, the value of the pname:x and pname:y members
834e5c31af7Sopenharmony_ci    of pname:codedOffsetGranularity are `0`.
835e5c31af7Sopenharmony_ci  * Let `uint32_t dpbFrameUseCount[]` be an array of size pname:maxDpbSlots,
836e5c31af7Sopenharmony_ci    where pname:maxDpbSlots is the
837e5c31af7Sopenharmony_ci    slink:VkVideoSessionCreateInfoKHR::pname:maxDpbSlots the bound video
838e5c31af7Sopenharmony_ci    session was created with, with each element indicating the number of
839e5c31af7Sopenharmony_ci    times a frame associated with the corresponding DPB slot index is
840e5c31af7Sopenharmony_ci    referred to by the video coding operation.
841e5c31af7Sopenharmony_ci    Let the initial value of each element of the array be `0`.
842e5c31af7Sopenharmony_ci  ** If pname:pEncodeInfo->pSetupReferenceSlot is not `NULL`, then
843e5c31af7Sopenharmony_ci     `dpbFrameUseCount[i]` is incremented by one, where pname:i equals
844e5c31af7Sopenharmony_ci     pname:pEncodeInfo->pSetupReferenceSlot->slotIndex.
845e5c31af7Sopenharmony_ci  ** For each element of pname:pEncodeInfo->pReferenceSlots,
846e5c31af7Sopenharmony_ci     `dpbFrameUseCount[i]` is incremented by one, where pname:i equals the
847e5c31af7Sopenharmony_ci     pname:slotIndex member of the corresponding element.
848e5c31af7Sopenharmony_ci  * Let `VkExtent2D maxCodingBlockSize` be the maximum codec-specific coding
849e5c31af7Sopenharmony_ci    block size that may: be used by the video encode operation.
850e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
851e5c31af7Sopenharmony_ci  ** If the bound video session object was created with an
852e5c31af7Sopenharmony_ci     <<encode-h264-profile,H.264 encode profile>>, then let
853e5c31af7Sopenharmony_ci     pname:maxCodingBlockSize be equal to the size of an H.264 macroblock,
854e5c31af7Sopenharmony_ci     i.e. `{16,16}`.
855e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
856e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
857e5c31af7Sopenharmony_ci  ** If the bound video session object was created with an
858e5c31af7Sopenharmony_ci     <<encode-h265-profile,H.265 encode profile>>, then let
859e5c31af7Sopenharmony_ci     pname:maxCodingBlockSize be equal to the maximum H.265 coding block
860e5c31af7Sopenharmony_ci     size that may: be used by the video encode operation derived as the
861e5c31af7Sopenharmony_ci     maximum of the CTB sizes corresponding to the
862e5c31af7Sopenharmony_ci     elink:VkVideoEncodeH265CtbSizeFlagBitsKHR bits set in
863e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH265CapabilitiesKHR::pname:ctbSizes, as returned by
864e5c31af7Sopenharmony_ci     flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video profile the
865e5c31af7Sopenharmony_ci     bound video session was created with.
866e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
867e5c31af7Sopenharmony_ci  ** Otherwise, pname:maxCodingBlockSize is undefined:.
868e5c31af7Sopenharmony_ci  * If pname:maxCodingBlockSize is defined, then let `VkExtent2D
869e5c31af7Sopenharmony_ci    minCodingBlockExtent` be the coded extent of the
870e5c31af7Sopenharmony_ci    <<encode-input-picture,encode input picture>> expressed in terms of
871e5c31af7Sopenharmony_ci    codec-specific coding blocks, assuming the maximum size of such coding
872e5c31af7Sopenharmony_ci    blocks, as defined by pname:maxCodingBlockSize, calculated from the
873e5c31af7Sopenharmony_ci    value of the pname:codedExtent member of
874e5c31af7Sopenharmony_ci    pname:pEncodeInfo->srcPictureResource as follows:
875e5c31af7Sopenharmony_ci  ** [eq]#pname:minCodingBlockExtent.width = (pname:codedExtent.width +
876e5c31af7Sopenharmony_ci     pname:maxCodingBlockSize.width - 1) / pname:maxCodingBlockSize.width#
877e5c31af7Sopenharmony_ci  ** [eq]#pname:minCodingBlockExtent.height = (pname:codedExtent.height +
878e5c31af7Sopenharmony_ci     pname:maxCodingBlockSize.height - 1) / pname:maxCodingBlockSize.height#
879e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
880e5c31af7Sopenharmony_ci  * If the bound video session object was created with an
881e5c31af7Sopenharmony_ci    <<encode-h264-profile,H.264 encode profile>>, then:
882e5c31af7Sopenharmony_ci  ** Let `StdVideoH264PictureType h264PictureType` be the picture type of
883e5c31af7Sopenharmony_ci     the encoded picture set to the value of
884e5c31af7Sopenharmony_ci     pname:pStdPictureInfo->primary_pic_type specified in the
885e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH264PictureInfoKHR structure included in the
886e5c31af7Sopenharmony_ci     pname:pEncodeInfo->pNext chain.
887e5c31af7Sopenharmony_ci  ** Let `StdVideoH264PictureType h264L0PictureTypes[]` and
888e5c31af7Sopenharmony_ci     `StdVideoH264PictureType h264L1PictureTypes[]` be the picture types of
889e5c31af7Sopenharmony_ci     the reference pictures in the L0 and L1 reference lists, respectively.
890e5c31af7Sopenharmony_ci     If pname:pStdPictureInfo->pRefLists specified in the
891e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH264PictureInfoKHR structure included in the
892e5c31af7Sopenharmony_ci     pname:pEncodeInfo->pNext chain is not `NULL`, then for each reference
893e5c31af7Sopenharmony_ci     index specified in the elements of the
894e5c31af7Sopenharmony_ci     pname:pStdPictureInfo->pRefLists->RefPicList0 and
895e5c31af7Sopenharmony_ci     pname:pStdPictureInfo->pRefLists->RefPicList1 arrays, if the reference
896e5c31af7Sopenharmony_ci     index is not code:STD_VIDEO_H264_NO_REFERENCE_PICTURE,
897e5c31af7Sopenharmony_ci     pname:pStdReferenceInfo->primary_pic_type is added to
898e5c31af7Sopenharmony_ci     pname:h264L0PictureTypes or pname:h264L1PictureTypes, respectively,
899e5c31af7Sopenharmony_ci     where pname:pStdReferenceInfo is the member of the
900e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH264DpbSlotInfoKHR structure included in the
901e5c31af7Sopenharmony_ci     pname:pNext chain of the element of pname:pEncodeInfo->pReferenceSlots
902e5c31af7Sopenharmony_ci     for which pname:slotIndex equals the reference index in question.
903e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
904e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
905e5c31af7Sopenharmony_ci  * If the bound video session object was created with an
906e5c31af7Sopenharmony_ci    <<encode-h264-profile,H.265 encode profile>>, then:
907e5c31af7Sopenharmony_ci  ** Let `StdVideoH265PictureType h265PictureType` be the picture type of
908e5c31af7Sopenharmony_ci     the encoded picture set to the value of pname:pStdPictureInfo->pic_type
909e5c31af7Sopenharmony_ci     specified in the slink:VkVideoEncodeH265PictureInfoKHR structure
910e5c31af7Sopenharmony_ci     included in the pname:pEncodeInfo->pNext chain.
911e5c31af7Sopenharmony_ci  ** Let `StdVideoH265PictureType h265L0PictureTypes[]` and
912e5c31af7Sopenharmony_ci     `StdVideoH265PictureType h265L1PictureTypes[]` be the picture types of
913e5c31af7Sopenharmony_ci     the reference pictures in the L0 and L1 reference lists, respectively.
914e5c31af7Sopenharmony_ci     If pname:pStdPictureInfo->pRefLists specified in the
915e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH265PictureInfoKHR structure included in the
916e5c31af7Sopenharmony_ci     pname:pEncodeInfo->pNext chain is not `NULL`, then for each reference
917e5c31af7Sopenharmony_ci     index specified in the elements of the
918e5c31af7Sopenharmony_ci     pname:pStdPictureInfo->pRefLists->RefPicList0 and
919e5c31af7Sopenharmony_ci     pname:pStdPictureInfo->pRefLists->RefPicList1 arrays, if the reference
920e5c31af7Sopenharmony_ci     index is not code:STD_VIDEO_H265_NO_REFERENCE_PICTURE,
921e5c31af7Sopenharmony_ci     pname:pStdReferenceInfo->pic_type is added to pname:h265L0PictureTypes
922e5c31af7Sopenharmony_ci     or pname:h265L1PictureTypes, respectively, where
923e5c31af7Sopenharmony_ci     pname:pStdReferenceInfo is the member of the
924e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH265DpbSlotInfoKHR structure included in the
925e5c31af7Sopenharmony_ci     pname:pNext chain of the element of pname:pEncodeInfo->pReferenceSlots
926e5c31af7Sopenharmony_ci     for which pname:slotIndex equals the reference index in question.
927e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
928e5c31af7Sopenharmony_ci
929e5c31af7Sopenharmony_ci.Valid Usage
930e5c31af7Sopenharmony_ci****
931e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-None-08250]]
932e5c31af7Sopenharmony_ci    The bound video session must: have been created with an encode operation
933e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-None-07012]]
934e5c31af7Sopenharmony_ci    The bound video session must: not be in <<video-session-uninitialized,
935e5c31af7Sopenharmony_ci    uninitialized>> state at the time the command is executed on the device
936e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-None-08318]]
937e5c31af7Sopenharmony_ci    The bound video session parameters object must: have been created with
938e5c31af7Sopenharmony_ci    the currently set <<encode-quality-level,video encode quality level>>
939e5c31af7Sopenharmony_ci    for the bound video session at the time the command is executed on the
940e5c31af7Sopenharmony_ci    device
941e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-opCount-07174]]
942e5c31af7Sopenharmony_ci    For each <<queries-operation-active,active>> query, the
943e5c31af7Sopenharmony_ci    <<queries-operation-active-query-index,active query index>>
944e5c31af7Sopenharmony_ci    corresponding to the query type of that query plus pname:opCount must:
945e5c31af7Sopenharmony_ci    be less than or equal to the
946e5c31af7Sopenharmony_ci    <<queries-operation-last-activatable-query-index,last activatable query
947e5c31af7Sopenharmony_ci    index>> corresponding to the query type of that query plus one
948e5c31af7Sopenharmony_ciifdef::VK_KHR_video_maintenance1[]
949e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08360]]
950e5c31af7Sopenharmony_ci    If the bound video session was created with
951e5c31af7Sopenharmony_ci    ename:VK_VIDEO_SESSION_CREATE_INLINE_QUERIES_BIT_KHR, and the
952e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo includes a
953e5c31af7Sopenharmony_ci    slink:VkVideoInlineQueryInfoKHR structure with its pname:queryPool
954e5c31af7Sopenharmony_ci    member specifying a valid sname:VkQueryPool handle, then
955e5c31af7Sopenharmony_ci    slink:VkVideoInlineQueryInfoKHR::queryCount must: equal ename:opCount
956e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08361]]
957e5c31af7Sopenharmony_ci    If the bound video session was created with
958e5c31af7Sopenharmony_ci    ename:VK_VIDEO_SESSION_CREATE_INLINE_QUERIES_BIT_KHR, and the
959e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo includes a
960e5c31af7Sopenharmony_ci    slink:VkVideoInlineQueryInfoKHR structure with its pname:queryPool
961e5c31af7Sopenharmony_ci    member specifying a valid sname:VkQueryPool handle, then all the queries
962e5c31af7Sopenharmony_ci    used by the command, as specified by the slink:VkVideoInlineQueryInfoKHR
963e5c31af7Sopenharmony_ci    structure, must: be _unavailable_
964e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-queryType-08362]]
965e5c31af7Sopenharmony_ci    If the bound video session was created with
966e5c31af7Sopenharmony_ci    ename:VK_VIDEO_SESSION_CREATE_INLINE_QUERIES_BIT_KHR, then the
967e5c31af7Sopenharmony_ci    pname:queryType used to create the pname:queryPool specified in the
968e5c31af7Sopenharmony_ci    slink:VkVideoInlineQueryInfoKHR structure included in the pname:pNext
969e5c31af7Sopenharmony_ci    chain of pname:pEncodeInfo must: be
970e5c31af7Sopenharmony_ci    ename:VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR or
971e5c31af7Sopenharmony_ci    ename:VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR
972e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-queryPool-08363]]
973e5c31af7Sopenharmony_ci    If the bound video session was created with
974e5c31af7Sopenharmony_ci    ename:VK_VIDEO_SESSION_CREATE_INLINE_QUERIES_BIT_KHR, then the
975e5c31af7Sopenharmony_ci    pname:queryPool specified in the slink:VkVideoInlineQueryInfoKHR
976e5c31af7Sopenharmony_ci    structure included in the pname:pNext chain of pname:pEncodeInfo must:
977e5c31af7Sopenharmony_ci    have been created with a slink:VkVideoProfileInfoKHR structure included
978e5c31af7Sopenharmony_ci    in the pname:pNext chain of slink:VkQueryPoolCreateInfo identical to the
979e5c31af7Sopenharmony_ci    one specified in slink:VkVideoSessionCreateInfoKHR::pname:pVideoProfile
980e5c31af7Sopenharmony_ci    the bound video session was created with
981e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-queryType-08364]]
982e5c31af7Sopenharmony_ci    If the bound video session was created with
983e5c31af7Sopenharmony_ci    ename:VK_VIDEO_SESSION_CREATE_INLINE_QUERIES_BIT_KHR, and the
984e5c31af7Sopenharmony_ci    pname:queryType used to create the pname:queryPool specified in the
985e5c31af7Sopenharmony_ci    slink:VkVideoInlineQueryInfoKHR structure included in the pname:pNext
986e5c31af7Sopenharmony_ci    chain of pname:pEncodeInfo is
987e5c31af7Sopenharmony_ci    ename:VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR, then the sname:VkCommandPool
988e5c31af7Sopenharmony_ci    that pname:commandBuffer was allocated from must: have been created with
989e5c31af7Sopenharmony_ci    a queue family index that supports <<queries-result-status-only,result
990e5c31af7Sopenharmony_ci    status queries>>, as indicated by
991e5c31af7Sopenharmony_ci    slink:VkQueueFamilyQueryResultStatusPropertiesKHR::pname:queryResultStatusSupport
992e5c31af7Sopenharmony_ciendif::VK_KHR_video_maintenance1[]
993e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08201]]
994e5c31af7Sopenharmony_ci    pname:pEncodeInfo->dstBuffer must: be <<video-profile-compatibility,
995e5c31af7Sopenharmony_ci    compatible>> with the video profile the bound video session was created
996e5c31af7Sopenharmony_ci    with
997e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-commandBuffer-08202]]
998e5c31af7Sopenharmony_ci    If pname:commandBuffer is an unprotected command buffer and
999e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
1000e5c31af7Sopenharmony_ci    then pname:pEncodeInfo->dstBuffer must: not be a protected buffer
1001e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-commandBuffer-08203]]
1002e5c31af7Sopenharmony_ci    If pname:commandBuffer is a protected command buffer and
1003e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
1004e5c31af7Sopenharmony_ci    then pname:pEncodeInfo->dstBuffer must: be a protected buffer
1005e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08204]]
1006e5c31af7Sopenharmony_ci    pname:pEncodeInfo->dstBufferOffset must: be an integer multiple of
1007e5c31af7Sopenharmony_ci    slink:VkVideoCapabilitiesKHR::pname:minBitstreamBufferOffsetAlignment,
1008e5c31af7Sopenharmony_ci    as returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the
1009e5c31af7Sopenharmony_ci    video profile the bound video session was created with
1010e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08205]]
1011e5c31af7Sopenharmony_ci    pname:pEncodeInfo->dstBufferRange must: be an integer multiple of
1012e5c31af7Sopenharmony_ci    slink:VkVideoCapabilitiesKHR::pname:minBitstreamBufferSizeAlignment, as
1013e5c31af7Sopenharmony_ci    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video
1014e5c31af7Sopenharmony_ci    profile the bound video session was created with
1015e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08206]]
1016e5c31af7Sopenharmony_ci    pname:pEncodeInfo->srcPictureResource.imageViewBinding must: be
1017e5c31af7Sopenharmony_ci    <<video-profile-compatibility,compatible>> with the video profile the
1018e5c31af7Sopenharmony_ci    bound video session was created with
1019e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08207]]
1020e5c31af7Sopenharmony_ci    The format of pname:pEncodeInfo->srcPictureResource.imageViewBinding
1021e5c31af7Sopenharmony_ci    must: match the slink:VkVideoSessionCreateInfoKHR::pname:pictureFormat
1022e5c31af7Sopenharmony_ci    the bound video session was created with
1023e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08208]]
1024e5c31af7Sopenharmony_ci    pname:pEncodeInfo->srcPictureResource.codedOffset must: be an integer
1025e5c31af7Sopenharmony_ci    multiple of pname:codedOffsetGranularity
1026e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08209]]
1027e5c31af7Sopenharmony_ci    pname:pEncodeInfo->srcPictureResource.codedExtent must: be between
1028e5c31af7Sopenharmony_ci    pname:minCodedExtent and pname:maxCodedExtent, inclusive, the bound
1029e5c31af7Sopenharmony_ci    video session was created with
1030e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08210]]
1031e5c31af7Sopenharmony_ci    pname:pEncodeInfo->srcPictureResource.imageViewBinding must: have been
1032e5c31af7Sopenharmony_ci    created with ename:VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR
1033e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-commandBuffer-08211]]
1034e5c31af7Sopenharmony_ci    If pname:commandBuffer is an unprotected command buffer and
1035e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
1036e5c31af7Sopenharmony_ci    then pname:pEncodeInfo->srcPictureResource.imageViewBinding must: not
1037e5c31af7Sopenharmony_ci    have been created from a protected image
1038e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-commandBuffer-08212]]
1039e5c31af7Sopenharmony_ci    If pname:commandBuffer is a protected command buffer and
1040e5c31af7Sopenharmony_ci    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
1041e5c31af7Sopenharmony_ci    then pname:pEncodeInfo->srcPictureResource.imageViewBinding must: have
1042e5c31af7Sopenharmony_ci    been created from a protected image
1043e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08377]]
1044e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pSetupReferenceSlot must: not be `NULL` unless the
1045e5c31af7Sopenharmony_ci    bound video session was created with
1046e5c31af7Sopenharmony_ci    slink:VkVideoSessionCreateInfoKHR::pname:maxDpbSlots equal to zero
1047e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08213]]
1048e5c31af7Sopenharmony_ci    If pname:pEncodeInfo->pSetupReferenceSlot is not `NULL`, then
1049e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pSetupReferenceSlot->slotIndex must: be less than the
1050e5c31af7Sopenharmony_ci    slink:VkVideoSessionCreateInfoKHR::pname:maxDpbSlots specified when the
1051e5c31af7Sopenharmony_ci    bound video session was created
1052e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08214]]
1053e5c31af7Sopenharmony_ci    If pname:pEncodeInfo->pSetupReferenceSlot is not `NULL`, then
1054e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pSetupReferenceSlot->pPictureResource->codedOffset
1055e5c31af7Sopenharmony_ci    must: be an integer multiple of pname:codedOffsetGranularity
1056e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08215]]
1057e5c31af7Sopenharmony_ci    If pname:pEncodeInfo->pSetupReferenceSlot is not `NULL`, then
1058e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pSetupReferenceSlot->pPictureResource must:
1059e5c31af7Sopenharmony_ci    <<video-picture-resource-matching,match>> one of the
1060e5c31af7Sopenharmony_ci    <<bound-reference-picture-resources,bound reference picture resource>>
1061e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-activeReferencePictureCount-08216]]
1062e5c31af7Sopenharmony_ci    pname:activeReferencePictureCount must: be less than or equal to the
1063e5c31af7Sopenharmony_ci    slink:VkVideoSessionCreateInfoKHR::pname:maxActiveReferencePictures
1064e5c31af7Sopenharmony_ci    specified when the bound video session was created
1065e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-slotIndex-08217]]
1066e5c31af7Sopenharmony_ci    The pname:slotIndex member of each element of
1067e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pReferenceSlots must: be less than the
1068e5c31af7Sopenharmony_ci    slink:VkVideoSessionCreateInfoKHR::pname:maxDpbSlots specified when the
1069e5c31af7Sopenharmony_ci    bound video session was created
1070e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-codedOffset-08218]]
1071e5c31af7Sopenharmony_ci    The pname:codedOffset member of the slink:VkVideoPictureResourceInfoKHR
1072e5c31af7Sopenharmony_ci    structure pointed to by the pname:pPictureResource member of each
1073e5c31af7Sopenharmony_ci    element of pname:pEncodeInfo->pReferenceSlots must: be an integer
1074e5c31af7Sopenharmony_ci    multiple of pname:codedOffsetGranularity
1075e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pPictureResource-08219]]
1076e5c31af7Sopenharmony_ci    The pname:pPictureResource member of each element of
1077e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pReferenceSlots must:
1078e5c31af7Sopenharmony_ci    <<video-picture-resource-matching,match>> one of the
1079e5c31af7Sopenharmony_ci    <<bound-reference-picture-resources,bound reference picture resource>>
1080e5c31af7Sopenharmony_ci    associated with the DPB slot index specified in the pname:slotIndex
1081e5c31af7Sopenharmony_ci    member of that element
1082e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pPictureResource-08220]]
1083e5c31af7Sopenharmony_ci    Each video picture resource corresponding to the pname:pPictureResource
1084e5c31af7Sopenharmony_ci    member specified in the elements of pname:pEncodeInfo->pReferenceSlots
1085e5c31af7Sopenharmony_ci    must: be <<video-picture-resource-uniqueness,unique>> within
1086e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pReferenceSlots
1087e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-dpbFrameUseCount-08221]]
1088e5c31af7Sopenharmony_ci    All elements of pname:dpbFrameUseCount must: be less than or equal to
1089e5c31af7Sopenharmony_ci    `1`
1090e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08222]]
1091e5c31af7Sopenharmony_ci    The image subresource <<video-image-subresource-reference,referred>> to
1092e5c31af7Sopenharmony_ci    by pname:pEncodeInfo->srcPictureResource must: be in the
1093e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_VIDEO_ENCODE_SRC_KHR layout at the time the video
1094e5c31af7Sopenharmony_ci    encode operation is executed on the device
1095e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08223]]
1096e5c31af7Sopenharmony_ci    If pname:pEncodeInfo->pSetupReferenceSlot is not `NULL`, then the image
1097e5c31af7Sopenharmony_ci    subresource <<video-image-subresource-reference,referred>> to by
1098e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pSetupReferenceSlot->pPictureResource must: be in the
1099e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_VIDEO_ENCODE_DPB_KHR layout at the time the video
1100e5c31af7Sopenharmony_ci    encode operation is executed on the device
1101e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pPictureResource-08224]]
1102e5c31af7Sopenharmony_ci    The image subresource <<video-image-subresource-reference,referred>> to
1103e5c31af7Sopenharmony_ci    by the pname:pPictureResource member of each element of
1104e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pReferenceSlots must: be in the
1105e5c31af7Sopenharmony_ci    ename:VK_IMAGE_LAYOUT_VIDEO_ENCODE_DPB_KHR layout at the time the video
1106e5c31af7Sopenharmony_ci    encode operation is executed on the device
1107e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
1108e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08225]]
1109e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1110e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, then the pname:pNext
1111e5c31af7Sopenharmony_ci    chain of pname:pEncodeInfo must: include a
1112e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR structure
1113e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-StdVideoH264SequenceParameterSet-08226]]
1114e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1115e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, then the bound video
1116e5c31af7Sopenharmony_ci    session parameters object must: contain a
1117e5c31af7Sopenharmony_ci    code:StdVideoH264SequenceParameterSet entry with
1118e5c31af7Sopenharmony_ci    pname:seq_parameter_set_id matching
1119e5c31af7Sopenharmony_ci    code:StdVideoEncodeH264PictureInfo::pname:seq_parameter_set_id that is
1120e5c31af7Sopenharmony_ci    provided in the pname:pStdPictureInfo member of the
1121e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR structure included in the
1122e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo
1123e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-StdVideoH264PictureParameterSet-08227]]
1124e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1125e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, then the bound video
1126e5c31af7Sopenharmony_ci    session parameters object must: contain a
1127e5c31af7Sopenharmony_ci    code:StdVideoH264PictureParameterSet entry with
1128e5c31af7Sopenharmony_ci    pname:seq_parameter_set_id and pname:pic_parameter_set_id matching
1129e5c31af7Sopenharmony_ci    code:StdVideoEncodeH264PictureInfo::pname:seq_parameter_set_id and
1130e5c31af7Sopenharmony_ci    code:StdVideoEncodeH264PictureInfo::pname:pic_parameter_set_id,
1131e5c31af7Sopenharmony_ci    respectively, that are provided in the pname:pStdPictureInfo member of
1132e5c31af7Sopenharmony_ci    the slink:VkVideoEncodeH264PictureInfoKHR structure included in the
1133e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo
1134e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08228]]
1135e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1136e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR and
1137e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pSetupReferenceSlot is not `NULL`, then the
1138e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo->pSetupReferenceSlot must:
1139e5c31af7Sopenharmony_ci    include a slink:VkVideoEncodeH264DpbSlotInfoKHR structure
1140e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08229]]
1141e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1142e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, then the pname:pNext
1143e5c31af7Sopenharmony_ci    chain of each element of pname:pEncodeInfo->pReferenceSlots must:
1144e5c31af7Sopenharmony_ci    include a slink:VkVideoEncodeH264DpbSlotInfoKHR structure
1145e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-constantQp-08269]]
1146e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1147e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR and the current
1148e5c31af7Sopenharmony_ci    <<encode-rate-control-modes,rate control mode>> is not
1149e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR, then
1150e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264NaluSliceInfoKHR::pname:constantQp must: be zero
1151e5c31af7Sopenharmony_ci    for each element of the pname:pNaluSliceEntries member of the
1152e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR structure included in the
1153e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo
1154e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-constantQp-08270]]
1155e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1156e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR and the current
1157e5c31af7Sopenharmony_ci    <<encode-rate-control-modes,rate control mode>> is
1158e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR, then
1159e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264NaluSliceInfoKHR::pname:constantQp must: be
1160e5c31af7Sopenharmony_ci    between slink:VkVideoEncodeH264CapabilitiesKHR::pname:minQp and
1161e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264CapabilitiesKHR::pname:maxQp, as returned by
1162e5c31af7Sopenharmony_ci    flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video profile the
1163e5c31af7Sopenharmony_ci    bound video session was created with, for each element of the
1164e5c31af7Sopenharmony_ci    pname:pNaluSliceEntries member of the
1165e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR structure included in the
1166e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo
1167e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-constantQp-08271]]
1168e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1169e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR and
1170e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264CapabilitiesKHR::pname:flags does not include
1171e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_H264_CAPABILITY_PER_SLICE_CONSTANT_QP_BIT_KHR, as
1172e5c31af7Sopenharmony_ci    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video
1173e5c31af7Sopenharmony_ci    profile the bound video session was created with, then
1174e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264NaluSliceInfoKHR::pname:constantQp must: have the
1175e5c31af7Sopenharmony_ci    same value for each element of the pname:pNaluSliceEntries member of the
1176e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR structure included in the
1177e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo
1178e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-naluSliceEntryCount-08302]]
1179e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1180e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, then the
1181e5c31af7Sopenharmony_ci    pname:naluSliceEntryCount member of the
1182e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR structure included in the
1183e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo must: be less than or equal to
1184e5c31af7Sopenharmony_ci    pname:minCodingBlockExtent.width multiplied by
1185e5c31af7Sopenharmony_ci    pname:minCodingBlockExtent.height
1186e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-naluSliceEntryCount-08312]]
1187e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1188e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR and
1189e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264CapabilitiesKHR::pname:flags does not include
1190e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_H264_CAPABILITY_ROW_UNALIGNED_SLICE_BIT_KHR, as
1191e5c31af7Sopenharmony_ci    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video
1192e5c31af7Sopenharmony_ci    profile the bound video session was created with, then the
1193e5c31af7Sopenharmony_ci    pname:naluSliceEntryCount member of the
1194e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR structure included in the
1195e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo must: be less than or equal to
1196e5c31af7Sopenharmony_ci    pname:minCodingBlockExtent.height
1197e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08352]]
1198e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1199e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, the pname:pNext
1200e5c31af7Sopenharmony_ci    chain of pname:pEncodeInfo includes a
1201e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR structure, and
1202e5c31af7Sopenharmony_ci    pname:pEncodeInfo->referenceSlotCount is greater than zero, then
1203e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR::pname:pStdPictureInfo->pRefLists
1204e5c31af7Sopenharmony_ci    must: not be `NULL`
1205e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08339]]
1206e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1207e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, the pname:pNext
1208e5c31af7Sopenharmony_ci    chain of pname:pEncodeInfo includes a
1209e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR structure, and
1210e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR::pname:pStdPictureInfo->pRefLists
1211e5c31af7Sopenharmony_ci    is not `NULL`, then each element of the code:RefPicList0 and
1212e5c31af7Sopenharmony_ci    code:RefPicList1 array members of the
1213e5c31af7Sopenharmony_ci    code:StdVideoEncodeH264ReferenceListsInfo structure pointed to by
1214e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR::pname:pStdPictureInfo->pRefLists
1215e5c31af7Sopenharmony_ci    must: either be code:STD_VIDEO_H264_NO_REFERENCE_PICTURE or must: equal
1216e5c31af7Sopenharmony_ci    the pname:slotIndex member of one of the elements of
1217e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pReferenceSlots
1218e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08353]]
1219e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1220e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, the pname:pNext
1221e5c31af7Sopenharmony_ci    chain of pname:pEncodeInfo includes a
1222e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR structure, and
1223e5c31af7Sopenharmony_ci    pname:pEncodeInfo->referenceSlotCount is greater than zero, then the
1224e5c31af7Sopenharmony_ci    pname:slotIndex member of each element of
1225e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pReferenceSlots must: equal one of the elements of
1226e5c31af7Sopenharmony_ci    the code:RefPicList0 or code:RefPicList1 array members of the
1227e5c31af7Sopenharmony_ci    code:StdVideoEncodeH264ReferenceListsInfo structure pointed to by
1228e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR::pname:pStdPictureInfo->pRefLists
1229e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-maxPPictureL0ReferenceCount-08340]]
1230e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1231e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR and
1232e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264CapabilitiesKHR::pname:maxPPictureL0ReferenceCount
1233e5c31af7Sopenharmony_ci    is zero, as returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR
1234e5c31af7Sopenharmony_ci    for the video profile the bound video session was created with, then
1235e5c31af7Sopenharmony_ci    pname:h264PictureType and each element of pname:h264L0PictureTypes and
1236e5c31af7Sopenharmony_ci    pname:h264L1PictureTypes must: not be code:STD_VIDEO_H264_PICTURE_TYPE_P
1237e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-maxBPictureL0ReferenceCount-08341]]
1238e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1239e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR and
1240e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264CapabilitiesKHR::pname:maxBPictureL0ReferenceCount
1241e5c31af7Sopenharmony_ci    and slink:VkVideoEncodeH264CapabilitiesKHR::pname:maxL1ReferenceCount
1242e5c31af7Sopenharmony_ci    are both zero, as returned by
1243e5c31af7Sopenharmony_ci    flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video profile the
1244e5c31af7Sopenharmony_ci    bound video session was created with, then pname:h264PictureType and
1245e5c31af7Sopenharmony_ci    each element of pname:h264L0PictureTypes and pname:h264L1PictureTypes
1246e5c31af7Sopenharmony_ci    must: not be code:STD_VIDEO_H264_PICTURE_TYPE_B
1247e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-flags-08342]]
1248e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1249e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR and
1250e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264CapabilitiesKHR::pname:flags does not include
1251e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_H264_CAPABILITY_B_FRAME_IN_L0_LIST_BIT_KHR, as
1252e5c31af7Sopenharmony_ci    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video
1253e5c31af7Sopenharmony_ci    profile the bound video session was created with, then each element of
1254e5c31af7Sopenharmony_ci    pname:h264L0PictureTypes must: not be code:STD_VIDEO_H264_PICTURE_TYPE_B
1255e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-flags-08343]]
1256e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1257e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR and
1258e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264CapabilitiesKHR::pname:flags does not include
1259e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_H264_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_KHR, as
1260e5c31af7Sopenharmony_ci    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video
1261e5c31af7Sopenharmony_ci    profile the bound video session was created with, then each element of
1262e5c31af7Sopenharmony_ci    pname:h264L1PictureTypes must: not be code:STD_VIDEO_H264_PICTURE_TYPE_B
1263e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
1264e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
1265e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08230]]
1266e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1267e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then the pname:pNext
1268e5c31af7Sopenharmony_ci    chain of pname:pEncodeInfo must: include a
1269e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR structure
1270e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-StdVideoH265VideoParameterSet-08231]]
1271e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1272e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then the bound video
1273e5c31af7Sopenharmony_ci    session parameters object must: contain a
1274e5c31af7Sopenharmony_ci    code:StdVideoH265VideoParameterSet entry with
1275e5c31af7Sopenharmony_ci    pname:vps_video_parameter_set_id matching
1276e5c31af7Sopenharmony_ci    code:StdVideoEncodeH265PictureInfo::pname:sps_video_parameter_set_id
1277e5c31af7Sopenharmony_ci    that is provided in the pname:pStdPictureInfo member of the
1278e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR structure included in the
1279e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo
1280e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-StdVideoH265SequenceParameterSet-08232]]
1281e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1282e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then the bound video
1283e5c31af7Sopenharmony_ci    session parameters object must: contain a
1284e5c31af7Sopenharmony_ci    code:StdVideoH265SequenceParameterSet entry with
1285e5c31af7Sopenharmony_ci    pname:sps_video_parameter_set_id and pname:sps_seq_parameter_set_id
1286e5c31af7Sopenharmony_ci    matching
1287e5c31af7Sopenharmony_ci    code:StdVideoEncodeH265PictureInfo::pname:sps_video_parameter_set_id and
1288e5c31af7Sopenharmony_ci    code:StdVideoEncodeH265PictureInfo::pname:pps_seq_parameter_set_id,
1289e5c31af7Sopenharmony_ci    respectively, that are provided in the pname:pStdPictureInfo member of
1290e5c31af7Sopenharmony_ci    the slink:VkVideoEncodeH265PictureInfoKHR structure included in the
1291e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo
1292e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-StdVideoH265PictureParameterSet-08233]]
1293e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1294e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then the bound video
1295e5c31af7Sopenharmony_ci    session parameters object must: contain a
1296e5c31af7Sopenharmony_ci    code:StdVideoH265PictureParameterSet entry with
1297e5c31af7Sopenharmony_ci    pname:sps_video_parameter_set_id, pname:pps_seq_parameter_set_id, and
1298e5c31af7Sopenharmony_ci    pname:pps_pic_parameter_set_id matching
1299e5c31af7Sopenharmony_ci    code:StdVideoEncodeH265PictureInfo::pname:sps_video_parameter_set_id,
1300e5c31af7Sopenharmony_ci    code:StdVideoEncodeH265PictureInfo::pname:pps_seq_parameter_set_id, and
1301e5c31af7Sopenharmony_ci    code:StdVideoEncodeH265PictureInfo::pname:pps_pic_parameter_set_id,
1302e5c31af7Sopenharmony_ci    respectively, that are provided in the pname:pStdPictureInfo member of
1303e5c31af7Sopenharmony_ci    the slink:VkVideoEncodeH265PictureInfoKHR structure included in the
1304e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo
1305e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pEncodeInfo-08234]]
1306e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1307e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR and
1308e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pSetupReferenceSlot is not `NULL`, then the
1309e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo->pSetupReferenceSlot must:
1310e5c31af7Sopenharmony_ci    include a slink:VkVideoEncodeH265DpbSlotInfoKHR structure
1311e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08235]]
1312e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1313e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then the pname:pNext
1314e5c31af7Sopenharmony_ci    chain of each element of pname:pEncodeInfo->pReferenceSlots must:
1315e5c31af7Sopenharmony_ci    include a slink:VkVideoEncodeH265DpbSlotInfoKHR structure
1316e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-constantQp-08272]]
1317e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1318e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR and the current
1319e5c31af7Sopenharmony_ci    <<encode-rate-control-modes,rate control mode>> is not
1320e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR, then
1321e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265NaluSliceSegmentInfoKHR::pname:constantQp must:
1322e5c31af7Sopenharmony_ci    be zero for each element of the pname:pNaluSliceSegmentEntries member of
1323e5c31af7Sopenharmony_ci    the slink:VkVideoEncodeH265PictureInfoKHR structure included in the
1324e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo
1325e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-constantQp-08273]]
1326e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1327e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR and the current
1328e5c31af7Sopenharmony_ci    <<encode-rate-control-modes,rate control mode>> is
1329e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR, then
1330e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265NaluSliceSegmentInfoKHR::pname:constantQp must:
1331e5c31af7Sopenharmony_ci    be between slink:VkVideoEncodeH265CapabilitiesKHR::pname:minQp and
1332e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265CapabilitiesKHR::pname:maxQp, as returned by
1333e5c31af7Sopenharmony_ci    flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video profile the
1334e5c31af7Sopenharmony_ci    bound video session was created with, for each element of the
1335e5c31af7Sopenharmony_ci    pname:pNaluSliceSegmentEntries member of the
1336e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR structure included in the
1337e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo
1338e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-constantQp-08274]]
1339e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1340e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR and
1341e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265CapabilitiesKHR::pname:flags does not include
1342e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_H265_CAPABILITY_PER_SLICE_SEGMENT_CONSTANT_QP_BIT_KHR,
1343e5c31af7Sopenharmony_ci    as returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the
1344e5c31af7Sopenharmony_ci    video profile the bound video session was created with, then
1345e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265NaluSliceSegmentInfoKHR::pname:constantQp must:
1346e5c31af7Sopenharmony_ci    have the same value for each element of the
1347e5c31af7Sopenharmony_ci    pname:pNaluSliceSegmentEntries member of the
1348e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264PictureInfoKHR structure included in the
1349e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo
1350e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-naluSliceSegmentEntryCount-08307]]
1351e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1352e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then the
1353e5c31af7Sopenharmony_ci    pname:naluSliceSegmentEntryCount member of the
1354e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR structure included in the
1355e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo must: be less than or equal to
1356e5c31af7Sopenharmony_ci    pname:minCodingBlockExtent.width multiplied by
1357e5c31af7Sopenharmony_ci    pname:minCodingBlockExtent.height
1358e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-naluSliceSegmentEntryCount-08313]]
1359e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1360e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR and
1361e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265CapabilitiesKHR::pname:flags does not include
1362e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_H265_CAPABILITY_ROW_UNALIGNED_SLICE_SEGMENT_BIT_KHR,
1363e5c31af7Sopenharmony_ci    as returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the
1364e5c31af7Sopenharmony_ci    video profile the bound video session was created with, then the
1365e5c31af7Sopenharmony_ci    pname:naluSliceSegmentEntryCount member of the
1366e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR structure included in the
1367e5c31af7Sopenharmony_ci    pname:pNext chain of pname:pEncodeInfo must: be less than or equal to
1368e5c31af7Sopenharmony_ci    pname:minCodingBlockExtent.height
1369e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08354]]
1370e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1371e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, the pname:pNext
1372e5c31af7Sopenharmony_ci    chain of pname:pEncodeInfo includes a
1373e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR structure, and
1374e5c31af7Sopenharmony_ci    pname:pEncodeInfo->referenceSlotCount is greater than zero, then
1375e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR::pname:pStdPictureInfo->pRefLists
1376e5c31af7Sopenharmony_ci    must: not be `NULL`
1377e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08344]]
1378e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1379e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, the pname:pNext
1380e5c31af7Sopenharmony_ci    chain of pname:pEncodeInfo includes a
1381e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR structure, and
1382e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR::pname:pStdPictureInfo->pRefLists
1383e5c31af7Sopenharmony_ci    is not `NULL`, then each element of the code:RefPicList0 and
1384e5c31af7Sopenharmony_ci    code:RefPicList1 array members of the
1385e5c31af7Sopenharmony_ci    code:StdVideoEncodeH265ReferenceListsInfo structure pointed to by
1386e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR::pname:pStdPictureInfo->pRefLists
1387e5c31af7Sopenharmony_ci    must: either be code:STD_VIDEO_H265_NO_REFERENCE_PICTURE or must: equal
1388e5c31af7Sopenharmony_ci    the pname:slotIndex member of one of the elements of
1389e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pReferenceSlots
1390e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-pNext-08355]]
1391e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1392e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, the pname:pNext
1393e5c31af7Sopenharmony_ci    chain of pname:pEncodeInfo includes a
1394e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR structure, and
1395e5c31af7Sopenharmony_ci    pname:pEncodeInfo->referenceSlotCount is greater than zero, then the
1396e5c31af7Sopenharmony_ci    pname:slotIndex member of each element of
1397e5c31af7Sopenharmony_ci    pname:pEncodeInfo->pReferenceSlots must: equal one of the elements of
1398e5c31af7Sopenharmony_ci    the code:RefPicList0 or code:RefPicList1 array members of the
1399e5c31af7Sopenharmony_ci    code:StdVideoEncodeH265ReferenceListsInfo structure pointed to by
1400e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265PictureInfoKHR::pname:pStdPictureInfo->pRefLists
1401e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-maxPPictureL0ReferenceCount-08345]]
1402e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1403e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR and
1404e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265CapabilitiesKHR::pname:maxPPictureL0ReferenceCount
1405e5c31af7Sopenharmony_ci    is zero, as returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR
1406e5c31af7Sopenharmony_ci    for the video profile the bound video session was created with, then
1407e5c31af7Sopenharmony_ci    pname:h265PictureType and each element of pname:h265L0PictureTypes and
1408e5c31af7Sopenharmony_ci    pname:h265L1PictureTypes must: not be code:STD_VIDEO_H265_PICTURE_TYPE_P
1409e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-maxBPictureL0ReferenceCount-08346]]
1410e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1411e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR and
1412e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265CapabilitiesKHR::pname:maxBPictureL0ReferenceCount
1413e5c31af7Sopenharmony_ci    and slink:VkVideoEncodeH265CapabilitiesKHR::pname:maxL1ReferenceCount
1414e5c31af7Sopenharmony_ci    are both zero, as returned by
1415e5c31af7Sopenharmony_ci    flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video profile the
1416e5c31af7Sopenharmony_ci    bound video session was created with, then pname:h265PictureType and
1417e5c31af7Sopenharmony_ci    each element of pname:h265L0PictureTypes and pname:h265L1PictureTypes
1418e5c31af7Sopenharmony_ci    must: not be code:STD_VIDEO_H265_PICTURE_TYPE_B
1419e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-flags-08347]]
1420e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1421e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR and
1422e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265CapabilitiesKHR::pname:flags does not include
1423e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_H265_CAPABILITY_B_FRAME_IN_L0_LIST_BIT_KHR, as
1424e5c31af7Sopenharmony_ci    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video
1425e5c31af7Sopenharmony_ci    profile the bound video session was created with, then each element of
1426e5c31af7Sopenharmony_ci    pname:h265L0PictureTypes must: not be code:STD_VIDEO_H264_PICTURE_TYPE_B
1427e5c31af7Sopenharmony_ci  * [[VUID-vkCmdEncodeVideoKHR-flags-08348]]
1428e5c31af7Sopenharmony_ci    If the bound video session was created with the video codec operation
1429e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR and
1430e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265CapabilitiesKHR::pname:flags does not include
1431e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_H265_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_KHR, as
1432e5c31af7Sopenharmony_ci    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video
1433e5c31af7Sopenharmony_ci    profile the bound video session was created with, then each element of
1434e5c31af7Sopenharmony_ci    pname:h265L1PictureTypes must: not be code:STD_VIDEO_H265_PICTURE_TYPE_B
1435e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
1436e5c31af7Sopenharmony_ci****
1437e5c31af7Sopenharmony_ci
1438e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdEncodeVideoKHR.adoc[]
1439e5c31af7Sopenharmony_ci--
1440e5c31af7Sopenharmony_ci
1441e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeInfoKHR',desc='Structure specifying video encode parameters',type='structs']
1442e5c31af7Sopenharmony_ci--
1443e5c31af7Sopenharmony_ciThe sname:VkVideoEncodeInfoKHR structure is defined as:
1444e5c31af7Sopenharmony_ci
1445e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkVideoEncodeInfoKHR.adoc[]
1446e5c31af7Sopenharmony_ci
1447e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
1448e5c31af7Sopenharmony_ci  * pname:pNext is a pointer to a structure extending this structure.
1449e5c31af7Sopenharmony_ci  * pname:flags is reserved for future use.
1450e5c31af7Sopenharmony_ci  * pname:dstBuffer is the destination video bitstream buffer to write the
1451e5c31af7Sopenharmony_ci    encoded bitstream to.
1452e5c31af7Sopenharmony_ci  * pname:dstBufferOffset is the starting offset in bytes from the start of
1453e5c31af7Sopenharmony_ci    pname:dstBuffer to write the encoded bitstream to.
1454e5c31af7Sopenharmony_ci  * pname:dstBufferRange is the maximum bitstream size in bytes that can: be
1455e5c31af7Sopenharmony_ci    written to pname:dstBuffer, starting from pname:dstBufferOffset.
1456e5c31af7Sopenharmony_ci  * pname:srcPictureResource is the video picture resource to use as the
1457e5c31af7Sopenharmony_ci    <<encode-input-picture,encode input picture>>.
1458e5c31af7Sopenharmony_ci  * pname:pSetupReferenceSlot is `NULL` or a pointer to a
1459e5c31af7Sopenharmony_ci    slink:VkVideoReferenceSlotInfoKHR structure specifying the
1460e5c31af7Sopenharmony_ci    <<encode-reconstructed-picture-info,reconstructed picture information>>.
1461e5c31af7Sopenharmony_ci  * pname:referenceSlotCount is the number of elements in the
1462e5c31af7Sopenharmony_ci    pname:pReferenceSlots array.
1463e5c31af7Sopenharmony_ci  * pname:pReferenceSlots is `NULL` or a pointer to an array of
1464e5c31af7Sopenharmony_ci    slink:VkVideoReferenceSlotInfoKHR structures describing the DPB slots
1465e5c31af7Sopenharmony_ci    and corresponding <<reference-picture,reference picture>> resources to
1466e5c31af7Sopenharmony_ci    use in this video encode operation (the set of
1467e5c31af7Sopenharmony_ci    <<active-reference-pictures, active reference pictures>>).
1468e5c31af7Sopenharmony_ci  * pname:precedingExternallyEncodedBytes is the number of bytes externally
1469e5c31af7Sopenharmony_ci    encoded by the application to the video bitstream and is used to update
1470e5c31af7Sopenharmony_ci    the internal state of the implementation's <<encode-rate-control,rate
1471e5c31af7Sopenharmony_ci    control>> algorithm to account for the bitrate budget consumed by these
1472e5c31af7Sopenharmony_ci    externally encoded bytes.
1473e5c31af7Sopenharmony_ci
1474e5c31af7Sopenharmony_ci.Valid Usage
1475e5c31af7Sopenharmony_ci****
1476e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeInfoKHR-dstBuffer-08236]]
1477e5c31af7Sopenharmony_ci    pname:dstBuffer must: have been created with
1478e5c31af7Sopenharmony_ci    ename:VK_BUFFER_USAGE_VIDEO_ENCODE_DST_BIT_KHR set
1479e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeInfoKHR-dstBufferOffset-08237]]
1480e5c31af7Sopenharmony_ci    pname:dstBufferOffset must: be less than the size of pname:dstBuffer
1481e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeInfoKHR-dstBufferRange-08238]]
1482e5c31af7Sopenharmony_ci    pname:dstBufferRange must: be less than or equal to the size of
1483e5c31af7Sopenharmony_ci    pname:dstBuffer minus pname:dstBufferOffset
1484e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeInfoKHR-pSetupReferenceSlot-08239]]
1485e5c31af7Sopenharmony_ci    If pname:pSetupReferenceSlot is not `NULL`, then its pname:slotIndex
1486e5c31af7Sopenharmony_ci    member must: not be negative
1487e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeInfoKHR-pSetupReferenceSlot-08240]]
1488e5c31af7Sopenharmony_ci    If pname:pSetupReferenceSlot is not `NULL`, then its
1489e5c31af7Sopenharmony_ci    pname:pPictureResource must: not be `NULL`
1490e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeInfoKHR-slotIndex-08241]]
1491e5c31af7Sopenharmony_ci    The pname:slotIndex member of each element of pname:pReferenceSlots
1492e5c31af7Sopenharmony_ci    must: not be negative
1493e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeInfoKHR-pPictureResource-08242]]
1494e5c31af7Sopenharmony_ci    The pname:pPictureResource member of each element of
1495e5c31af7Sopenharmony_ci    pname:pReferenceSlots must: not be `NULL`
1496e5c31af7Sopenharmony_ci****
1497e5c31af7Sopenharmony_ci
1498e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkVideoEncodeInfoKHR.adoc[]
1499e5c31af7Sopenharmony_ci--
1500e5c31af7Sopenharmony_ci
1501e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeFlagsKHR',desc='Reserved for future use',type='flags']
1502e5c31af7Sopenharmony_ci--
1503e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkVideoEncodeFlagsKHR.adoc[]
1504e5c31af7Sopenharmony_ci
1505e5c31af7Sopenharmony_citlink:VkVideoEncodeFlagsKHR is a bitmask type for setting a mask, but is
1506e5c31af7Sopenharmony_cicurrently reserved for future use.
1507e5c31af7Sopenharmony_ci--
1508e5c31af7Sopenharmony_ci
1509e5c31af7Sopenharmony_ci
1510e5c31af7Sopenharmony_ci[[encode-rate-control]]
1511e5c31af7Sopenharmony_ci== Video Encode Rate Control
1512e5c31af7Sopenharmony_ci
1513e5c31af7Sopenharmony_ciThe size of the encoded bitstream data produced by video encode operations
1514e5c31af7Sopenharmony_ciis a function of the following set of constraints:
1515e5c31af7Sopenharmony_ci
1516e5c31af7Sopenharmony_ci  * The capabilities of the compression algorithms defined and employed by
1517e5c31af7Sopenharmony_ci    the used video compression standard;
1518e5c31af7Sopenharmony_ci  * Restrictions imposed by the selected <<video-profiles,video profile>>
1519e5c31af7Sopenharmony_ci    according to the rules defined by the used video compression standard;
1520e5c31af7Sopenharmony_ci  * Further restrictions imposed by the <<video-coding-capabilities,
1521e5c31af7Sopenharmony_ci    capabilities>> supported by the implementation for the selected
1522e5c31af7Sopenharmony_ci    <<video-profiles,video profile>>;
1523e5c31af7Sopenharmony_ci  * The image data in the <<encode-input-picture,encode input picture>> and
1524e5c31af7Sopenharmony_ci    the set of <<active-reference-pictures,active reference pictures>> (as
1525e5c31af7Sopenharmony_ci    these affect the effectiveness of the compression algorithms employed by
1526e5c31af7Sopenharmony_ci    the video encode operations);
1527e5c31af7Sopenharmony_ci  * The set of codec-specific and codec-independent encoding parameters
1528e5c31af7Sopenharmony_ci    provided by the application.
1529e5c31af7Sopenharmony_ci
1530e5c31af7Sopenharmony_ciThese also inherently define the set of decoder capabilities required for
1531e5c31af7Sopenharmony_cireconstructing and processing the picture data in the encoded bitstream.
1532e5c31af7Sopenharmony_ci
1533e5c31af7Sopenharmony_ci[[encode-bitrate]]
1534e5c31af7Sopenharmony_ciVideo coding uses _bitrate_ as the quantitative metric associated with
1535e5c31af7Sopenharmony_ciencoded bitstream data size which expresses the rate at which video
1536e5c31af7Sopenharmony_cibitstream data can: be transferred or processed, measured in number of bits
1537e5c31af7Sopenharmony_ciper second.
1538e5c31af7Sopenharmony_ciThis bitrate is both a function of the encoded bitstream data size of the
1539e5c31af7Sopenharmony_ciencoded pictures as well as the _frame rate_ used by the video sequence.
1540e5c31af7Sopenharmony_ci
1541e5c31af7Sopenharmony_ciRate control algorithms are used by video encode operations to enable
1542e5c31af7Sopenharmony_ciadjusting encoding parameters to achieve a target bitrate, or otherwise
1543e5c31af7Sopenharmony_cidirectly or indirectly control the bitrate of the generated video bitstream
1544e5c31af7Sopenharmony_cidata.
1545e5c31af7Sopenharmony_ciThese algorithms are usually not defined by the used video compression
1546e5c31af7Sopenharmony_cistandard, although some video compression standards do provide non-normative
1547e5c31af7Sopenharmony_ciguidelines for implementations.
1548e5c31af7Sopenharmony_ci
1549e5c31af7Sopenharmony_ciAccordingly, this specification does not mandate implementations to produce
1550e5c31af7Sopenharmony_ciidentical encoded bitstream data outputs in response to video encode
1551e5c31af7Sopenharmony_cioperations, however, it does define a set of codec-independent and
1552e5c31af7Sopenharmony_cicodec-specific parameters that enable the application to control the
1553e5c31af7Sopenharmony_cibehavior of the rate control algorithms supported by the implementation.
1554e5c31af7Sopenharmony_ciSome of these parameters guarantee certain implementation behavior while
1555e5c31af7Sopenharmony_ciothers provide guidance for implementations to apply various rate control
1556e5c31af7Sopenharmony_ciheuristics.
1557e5c31af7Sopenharmony_ci
1558e5c31af7Sopenharmony_ci[NOTE]
1559e5c31af7Sopenharmony_ci.Note
1560e5c31af7Sopenharmony_ci====
1561e5c31af7Sopenharmony_ciApplications need to make sure that they configure rate control parameters
1562e5c31af7Sopenharmony_ciappropriately and that they follow the promises made to the implementation
1563e5c31af7Sopenharmony_cithrough parameters providing guidance for the implementation's rate control
1564e5c31af7Sopenharmony_cialgorithms and heuristics in order to be able to get the desired rate
1565e5c31af7Sopenharmony_cicontrol behavior and to be able to hit the set bitrate targets.
1566e5c31af7Sopenharmony_ciIn addition, the behavior of rate control may also differ across
1567e5c31af7Sopenharmony_ciimplementations even if the capabilities of the used video profile match
1568e5c31af7Sopenharmony_cibetween those implementations.
1569e5c31af7Sopenharmony_ciThis may happen due to implementations applying different rate control
1570e5c31af7Sopenharmony_cialgorithms or heuristics internally, and thus even the same set of guidance
1571e5c31af7Sopenharmony_ciparameter values may have different effects on the rate control behavior
1572e5c31af7Sopenharmony_ciacross implementations.
1573e5c31af7Sopenharmony_ci====
1574e5c31af7Sopenharmony_ci
1575e5c31af7Sopenharmony_ci
1576e5c31af7Sopenharmony_ci[[encode-rate-control-modes]]
1577e5c31af7Sopenharmony_ci=== Rate Control Modes
1578e5c31af7Sopenharmony_ci
1579e5c31af7Sopenharmony_ciAfter a video session is reset to the <<video-session-uninitialized,initial
1580e5c31af7Sopenharmony_cistate>>, the default behavior and parameters of video encode rate control
1581e5c31af7Sopenharmony_ciare entirely implementation-dependent and the application cannot: affect the
1582e5c31af7Sopenharmony_cibitrate or quality parameters of the encoded bitstream data produced by
1583e5c31af7Sopenharmony_civideo encode operations unless the application changes the rate control
1584e5c31af7Sopenharmony_ciconfiguration of the video session, as described in the
1585e5c31af7Sopenharmony_ci<<video-coding-control,Video Coding Control>> section.
1586e5c31af7Sopenharmony_ci
1587e5c31af7Sopenharmony_ciFor each supported <<video-profiles,video profile>>, the implementation may:
1588e5c31af7Sopenharmony_ciexpose a set of _rate control modes_ that are available for use by the
1589e5c31af7Sopenharmony_ciapplication when encoding bitstreams targeting that video profile.
1590e5c31af7Sopenharmony_ciThese modes allow using different rate control algorithms that fall into one
1591e5c31af7Sopenharmony_ciof the following two categories:
1592e5c31af7Sopenharmony_ci
1593e5c31af7Sopenharmony_ci  1. Per-operation rate control
1594e5c31af7Sopenharmony_ci  2. Stream-level rate control
1595e5c31af7Sopenharmony_ci
1596e5c31af7Sopenharmony_ciIn case of _per-operation rate control_, the bitrate of the generated video
1597e5c31af7Sopenharmony_cibitstream data is indirectly controlled by quality, size, or other encoding
1598e5c31af7Sopenharmony_ciparameters specified by the application for each individual video encode
1599e5c31af7Sopenharmony_cioperation.
1600e5c31af7Sopenharmony_ci
1601e5c31af7Sopenharmony_ciIn case of _stream-level rate control_, the application can: directly
1602e5c31af7Sopenharmony_cispecify target bitrates besides other encoding parameters to control the
1603e5c31af7Sopenharmony_cibehavior of the rate control algorithm used by the implementation across
1604e5c31af7Sopenharmony_cimultiple video encode operations.
1605e5c31af7Sopenharmony_ci
1606e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeRateControlModeFlagBitsKHR',desc='Video encode rate control modes',type='enums']
1607e5c31af7Sopenharmony_ci--
1608e5c31af7Sopenharmony_ciThe rate control modes are defined with the following enums:
1609e5c31af7Sopenharmony_ci
1610e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkVideoEncodeRateControlModeFlagBitsKHR.adoc[]
1611e5c31af7Sopenharmony_ci
1612e5c31af7Sopenharmony_ci  * ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DEFAULT_KHR specifies the use of
1613e5c31af7Sopenharmony_ci    implementation-specific rate control.
1614e5c31af7Sopenharmony_ci  * ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR specifies that
1615e5c31af7Sopenharmony_ci    rate control is disabled and the application will specify per-operation
1616e5c31af7Sopenharmony_ci    rate control parameters controlling the encoding quality.
1617e5c31af7Sopenharmony_ci    In this mode implementations will encode pictures independently of the
1618e5c31af7Sopenharmony_ci    output bitrate of prior video encode operations.
1619e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
1620e5c31af7Sopenharmony_ci  ** When using an <<encode-h264-profile,H.264 encode profile>>,
1621e5c31af7Sopenharmony_ci     implementations will use the QP value specified in
1622e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH264NaluSliceInfoKHR::pname:constantQp to control
1623e5c31af7Sopenharmony_ci     the quality of the encoded picture.
1624e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
1625e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
1626e5c31af7Sopenharmony_ci  ** When using an <<encode-h265-profile,H.265 encode profile>>,
1627e5c31af7Sopenharmony_ci     implementations will use the QP value specified in
1628e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH265NaluSliceSegmentInfoKHR::pname:constantQp to
1629e5c31af7Sopenharmony_ci     control the quality of the encoded picture.
1630e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
1631e5c31af7Sopenharmony_ci  * ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR specifies the use of
1632e5c31af7Sopenharmony_ci    constant bitrate (CBR) rate control mode.
1633e5c31af7Sopenharmony_ci    In this mode the implementation will attempt to produce the encoded
1634e5c31af7Sopenharmony_ci    bitstream at a constant bitrate while conforming to the constraints of
1635e5c31af7Sopenharmony_ci    other rate control parameters.
1636e5c31af7Sopenharmony_ci  * ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR specifies the use of
1637e5c31af7Sopenharmony_ci    variable bitrate (VBR) rate control mode.
1638e5c31af7Sopenharmony_ci    In this mode the implementation will produce the encoded bitstream at a
1639e5c31af7Sopenharmony_ci    variable bitrate according to the constraints of other rate control
1640e5c31af7Sopenharmony_ci    parameters.
1641e5c31af7Sopenharmony_ci--
1642e5c31af7Sopenharmony_ci
1643e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeRateControlModeFlagsKHR',desc='Bitmask of VkVideoEncodeRateControlModeFlagBitsKHR', type='flags']
1644e5c31af7Sopenharmony_ci--
1645e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkVideoEncodeRateControlModeFlagsKHR.adoc[]
1646e5c31af7Sopenharmony_ci
1647e5c31af7Sopenharmony_citname:VkVideoEncodeRateControlModeFlagsKHR is a bitmask type for setting a
1648e5c31af7Sopenharmony_cimask of zero or more elink:VkVideoEncodeRateControlModeFlagBitsKHR.
1649e5c31af7Sopenharmony_ci--
1650e5c31af7Sopenharmony_ci
1651e5c31af7Sopenharmony_ci
1652e5c31af7Sopenharmony_ci[[encode-leaky-bucket-model]]
1653e5c31af7Sopenharmony_ci=== Leaky Bucket Model
1654e5c31af7Sopenharmony_ci
1655e5c31af7Sopenharmony_ciVideo encoding implementations use the _leaky bucket model_ for stream-level
1656e5c31af7Sopenharmony_cirate control.
1657e5c31af7Sopenharmony_ciThe leaky bucket is a concept referring to the interface between the video
1658e5c31af7Sopenharmony_ciencoder and the consumer (for example, a network connection), where the
1659e5c31af7Sopenharmony_civideo encoder produces encoded bitstream data corresponding to the encoded
1660e5c31af7Sopenharmony_cipictures and adds them in the leaky bucket while its content are drained by
1661e5c31af7Sopenharmony_cithe consumer.
1662e5c31af7Sopenharmony_ci
1663e5c31af7Sopenharmony_ciAnalogously, a similar leaky bucket is considered to exist at the input
1664e5c31af7Sopenharmony_ciinterface of a video decoder, into which encoded bitstream data is
1665e5c31af7Sopenharmony_cicontinuously added and is subsequently consumed by the video decoder.
1666e5c31af7Sopenharmony_ciIt is desirable to avoid overflowing or underflowing this leaky bucked
1667e5c31af7Sopenharmony_cibecause:
1668e5c31af7Sopenharmony_ci
1669e5c31af7Sopenharmony_ci  * In case of an underflow, the video decoder will be unable to consume
1670e5c31af7Sopenharmony_ci    encoded bitstream data in order to decode pictures (and optionally
1671e5c31af7Sopenharmony_ci    display them).
1672e5c31af7Sopenharmony_ci  * In case of an overflow, the leaky bucket will be unable to accommodate
1673e5c31af7Sopenharmony_ci    more encoded bitstream data and such data may: need to be thrown away,
1674e5c31af7Sopenharmony_ci    leading to the loss of the corresponding encoded pictures.
1675e5c31af7Sopenharmony_ci
1676e5c31af7Sopenharmony_ciThese requirements can: be satisfied by imposing various constraints on the
1677e5c31af7Sopenharmony_ciencoder-side leaky bucket to avoid its overflow or underflow, depending on
1678e5c31af7Sopenharmony_cithe used rate control algorithm and codec parameters.
1679e5c31af7Sopenharmony_ciHowever, enumerating these constraints is outside the scope of this
1680e5c31af7Sopenharmony_cispecification.
1681e5c31af7Sopenharmony_ci
1682e5c31af7Sopenharmony_ciThe term _virtual buffer_ is often used as an alternative to refer to the
1683e5c31af7Sopenharmony_cileaky bucket.
1684e5c31af7Sopenharmony_ci
1685e5c31af7Sopenharmony_ciThis virtual buffer model is defined by the following parameters:
1686e5c31af7Sopenharmony_ci
1687e5c31af7Sopenharmony_ci  * The bitrate (`R`) at which the encoded bitstream is expected to be
1688e5c31af7Sopenharmony_ci    processed.
1689e5c31af7Sopenharmony_ci  * The size (`B`) of the virtual buffer.
1690e5c31af7Sopenharmony_ci  * The initial occupancy (`F`) of the virtual buffer.
1691e5c31af7Sopenharmony_ci
1692e5c31af7Sopenharmony_ciIn this model the virtual buffer is used to smooth out fluctuations in the
1693e5c31af7Sopenharmony_cibitrate of the encoded bitstream over time without experiencing buffer
1694e5c31af7Sopenharmony_cioverflow or underflow, as long as the bitrate of the encoded stream does not
1695e5c31af7Sopenharmony_cidiverge from the target bitrate for extended periods of time.
1696e5c31af7Sopenharmony_ci
1697e5c31af7Sopenharmony_ciThis buffering may: inherently impose a processing delay, as the goal of the
1698e5c31af7Sopenharmony_cimodel is to enable decoders maintain a consistent processing rate of an
1699e5c31af7Sopenharmony_ciencoded bitstream with varying data rate.
1700e5c31af7Sopenharmony_ci
1701e5c31af7Sopenharmony_ciThe initial or start-up delay (`D`) is computed as:
1702e5c31af7Sopenharmony_ci
1703e5c31af7Sopenharmony_ci  {empty}:: [eq]#`D` = `F` / `R`#
1704e5c31af7Sopenharmony_ci
1705e5c31af7Sopenharmony_ci[NOTE]
1706e5c31af7Sopenharmony_ci.Note
1707e5c31af7Sopenharmony_ci====
1708e5c31af7Sopenharmony_ciApplications need to configure the virtual buffer with sufficient size to
1709e5c31af7Sopenharmony_ciavoid or minimize buffer overflows and underflows while also keeping it
1710e5c31af7Sopenharmony_cismall enough to meet their latency goals.
1711e5c31af7Sopenharmony_ci====
1712e5c31af7Sopenharmony_ci
1713e5c31af7Sopenharmony_ci
1714e5c31af7Sopenharmony_ci[[encode-rate-control-layers]]
1715e5c31af7Sopenharmony_ci=== Rate Control Layers
1716e5c31af7Sopenharmony_ci
1717e5c31af7Sopenharmony_ciSome video compression standards and <<video-profiles,video profiles>> allow
1718e5c31af7Sopenharmony_ciassociating encoded pictures with specific _video coding layers_.
1719e5c31af7Sopenharmony_ciThe name, identification, and semantics associated with such video coding
1720e5c31af7Sopenharmony_cilayers are defined by the corresponding video compression standards.
1721e5c31af7Sopenharmony_ci
1722e5c31af7Sopenharmony_ciAnalogously, stream-level rate control can: be configured to use one or more
1723e5c31af7Sopenharmony_ci_rate control layers_:
1724e5c31af7Sopenharmony_ci
1725e5c31af7Sopenharmony_ci  * When a single rate control layer is configured, it is applied to all
1726e5c31af7Sopenharmony_ci    encoded pictures, regardless of the picture's video coding layer.
1727e5c31af7Sopenharmony_ci    In this case the distribution of the available bitrate budget across
1728e5c31af7Sopenharmony_ci    video coding layers is implementation-dependent.
1729e5c31af7Sopenharmony_ci  * When multiple rate control layers are configured, each rate control
1730e5c31af7Sopenharmony_ci    layer is applied to the corresponding video coding layer, i.e. only
1731e5c31af7Sopenharmony_ci    across encoded pictures pertaining to the corresponding video coding
1732e5c31af7Sopenharmony_ci    layer.
1733e5c31af7Sopenharmony_ci
1734e5c31af7Sopenharmony_ciIndividual rate control layers are identified using _layer indices_ between
1735e5c31af7Sopenharmony_cizero and `N-1`, where `N` is the number of active rate control layers.
1736e5c31af7Sopenharmony_ci
1737e5c31af7Sopenharmony_ciRate control layers are only applicable when using
1738e5c31af7Sopenharmony_ci<<encode-rate-control-modes,stream-level rate control modes>>.
1739e5c31af7Sopenharmony_ci
1740e5c31af7Sopenharmony_ci
1741e5c31af7Sopenharmony_ci[[encode-rate-control-state]]
1742e5c31af7Sopenharmony_ci=== Rate Control State
1743e5c31af7Sopenharmony_ci
1744e5c31af7Sopenharmony_ciRate control state is maintained by the implementation in the
1745e5c31af7Sopenharmony_ci<<video-session, video session>> objects and its parameters are specified
1746e5c31af7Sopenharmony_ciusing an instance of the sname:VkVideoEncodeRateControlInfoKHR structure.
1747e5c31af7Sopenharmony_ciThe complete rate control state of a video session is defined by the
1748e5c31af7Sopenharmony_cifollowing set of parameters:
1749e5c31af7Sopenharmony_ci
1750e5c31af7Sopenharmony_ci  * The values of the members of the slink:VkVideoEncodeRateControlInfoKHR
1751e5c31af7Sopenharmony_ci    structure used to configure the rate control state.
1752e5c31af7Sopenharmony_ci  * The values of the members of any
1753e5c31af7Sopenharmony_ci    slink:VkVideoEncodeRateControlLayerInfoKHR structures specified in
1754e5c31af7Sopenharmony_ci    slink:VkVideoEncodeRateControlInfoKHR::pname:pLayers used to configure
1755e5c31af7Sopenharmony_ci    the state of individual <<encode-rate-control-layers,rate control
1756e5c31af7Sopenharmony_ci    layers>>.
1757e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
1758e5c31af7Sopenharmony_ci  * If the video session was created with an <<encode-h264-profile,H.264
1759e5c31af7Sopenharmony_ci    encode profile>>:
1760e5c31af7Sopenharmony_ci  ** The values of the members of the
1761e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH264RateControlInfoKHR structure, if one is
1762e5c31af7Sopenharmony_ci     specified in the pname:pNext chain of the
1763e5c31af7Sopenharmony_ci     slink:VkVideoEncodeRateControlInfoKHR used to configure the rate
1764e5c31af7Sopenharmony_ci     control state.
1765e5c31af7Sopenharmony_ci  ** The values of the members of any
1766e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH264RateControlLayerInfoKHR structures included in
1767e5c31af7Sopenharmony_ci     the pname:pNext chain of a slink:VkVideoEncodeRateControlLayerInfoKHR
1768e5c31af7Sopenharmony_ci     structure used to configure the state of a rate control layer.
1769e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
1770e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
1771e5c31af7Sopenharmony_ci  * If the video session was created with an <<encode-h265-profile,H.265
1772e5c31af7Sopenharmony_ci    encode profile>>:
1773e5c31af7Sopenharmony_ci  ** The values of the members of the
1774e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH265RateControlInfoKHR structure, if one is
1775e5c31af7Sopenharmony_ci     specified in the pname:pNext chain of the
1776e5c31af7Sopenharmony_ci     slink:VkVideoEncodeRateControlInfoKHR used to configure the rate
1777e5c31af7Sopenharmony_ci     control state.
1778e5c31af7Sopenharmony_ci  ** The values of the members of any
1779e5c31af7Sopenharmony_ci     slink:VkVideoEncodeH265RateControlLayerInfoKHR structures included in
1780e5c31af7Sopenharmony_ci     the pname:pNext chain of a slink:VkVideoEncodeRateControlLayerInfoKHR
1781e5c31af7Sopenharmony_ci     structure used to configure the state of a rate control layer.
1782e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
1783e5c31af7Sopenharmony_ci
1784e5c31af7Sopenharmony_ci[[encode-rate-control-state-matching]]
1785e5c31af7Sopenharmony_ciTwo rate control states match if all the parameters listed above match
1786e5c31af7Sopenharmony_cibetween them.
1787e5c31af7Sopenharmony_ci
1788e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeRateControlInfoKHR',desc='Structure to set encode stream rate control parameters',type='structs']
1789e5c31af7Sopenharmony_ci--
1790e5c31af7Sopenharmony_ciThe sname:VkVideoEncodeRateControlInfoKHR structure is defined as:
1791e5c31af7Sopenharmony_ci
1792e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkVideoEncodeRateControlInfoKHR.adoc[]
1793e5c31af7Sopenharmony_ci
1794e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
1795e5c31af7Sopenharmony_ci  * pname:pNext is `NULL` or a pointer to a structure extending this
1796e5c31af7Sopenharmony_ci    structure.
1797e5c31af7Sopenharmony_ci  * pname:flags is reserved for future use.
1798e5c31af7Sopenharmony_ci  * pname:rateControlMode is a elink:VkVideoEncodeRateControlModeFlagBitsKHR
1799e5c31af7Sopenharmony_ci    value specifying the <<encode-rate-control-modes,rate control mode>>.
1800e5c31af7Sopenharmony_ci  * pname:layerCount specifies the number of <<encode-rate-control-layers,
1801e5c31af7Sopenharmony_ci    rate control layers>> to use.
1802e5c31af7Sopenharmony_ci  * pname:pLayers is a pointer to an array of pname:layerCount
1803e5c31af7Sopenharmony_ci    slink:VkVideoEncodeRateControlLayerInfoKHR structures, each specifying
1804e5c31af7Sopenharmony_ci    the rate control configuration of the corresponding rate control layer.
1805e5c31af7Sopenharmony_ci  * pname:virtualBufferSizeInMs is the size in milliseconds of the virtual
1806e5c31af7Sopenharmony_ci    buffer used by the implementation's rate control algorithm for the
1807e5c31af7Sopenharmony_ci    <<encode-leaky-bucket-model,leaky bucket model>>, with respect to the
1808e5c31af7Sopenharmony_ci    average bitrate of the stream calculated by summing the values of the
1809e5c31af7Sopenharmony_ci    pname:averageBitrate members of the elements of the pname:pLayers array.
1810e5c31af7Sopenharmony_ci  * pname:initialVirtualBufferSizeInMs is the initial occupancy in
1811e5c31af7Sopenharmony_ci    milliseconds of the virtual buffer used by the implementation's rate
1812e5c31af7Sopenharmony_ci    control algorithm for the <<encode-leaky-bucket-model,leaky bucket
1813e5c31af7Sopenharmony_ci    model>>.
1814e5c31af7Sopenharmony_ci
1815e5c31af7Sopenharmony_ciIf pname:layerCount is zero then the values of pname:virtualBufferSizeInMs
1816e5c31af7Sopenharmony_ciand pname:initialVirtualBufferSizeInMs are ignored.
1817e5c31af7Sopenharmony_ci
1818e5c31af7Sopenharmony_ciThis structure can: be specified in the following places:
1819e5c31af7Sopenharmony_ci
1820e5c31af7Sopenharmony_ci  * In the pname:pNext chain of slink:VkVideoBeginCodingInfoKHR to specify
1821e5c31af7Sopenharmony_ci    the current rate control state expected to be configured when beginning
1822e5c31af7Sopenharmony_ci    a <<video-coding-scope,video coding scope>>.
1823e5c31af7Sopenharmony_ci  * In the pname:pNext chain of slink:VkVideoCodingControlInfoKHR to change
1824e5c31af7Sopenharmony_ci    the rate control configuration of the bound video session.
1825e5c31af7Sopenharmony_ci
1826e5c31af7Sopenharmony_ciIncluding this structure in the pname:pNext chain of
1827e5c31af7Sopenharmony_cislink:VkVideoCodingControlInfoKHR and including
1828e5c31af7Sopenharmony_ciename:VK_VIDEO_CODING_CONTROL_ENCODE_RATE_CONTROL_BIT_KHR in
1829e5c31af7Sopenharmony_cislink:VkVideoCodingControlInfoKHR::pname:flags enables updating the rate
1830e5c31af7Sopenharmony_cicontrol configuration of the bound video session.
1831e5c31af7Sopenharmony_ciThis replaces the entire rate control configuration of the bound video
1832e5c31af7Sopenharmony_cisession and may: reset the state of all enabled rate control layers to an
1833e5c31af7Sopenharmony_ciinitial state according to the codec-specific rate control semantics defined
1834e5c31af7Sopenharmony_ciin the corresponding sections listed below.
1835e5c31af7Sopenharmony_ci
1836e5c31af7Sopenharmony_ciWhen pname:layerCount is greater than one, multiple
1837e5c31af7Sopenharmony_ci<<encode-rate-control-layers,rate control layers>> are configured, and each
1838e5c31af7Sopenharmony_cirate control layer is applied to the corresponding video coding layer
1839e5c31af7Sopenharmony_ciidentified by the index of the corresponding element of pname:pLayer.
1840e5c31af7Sopenharmony_ci
1841e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
1842e5c31af7Sopenharmony_ci  * If the video session was created with the video codec operation
1843e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, then this index
1844e5c31af7Sopenharmony_ci    specifies the H.264 temporal layer ID of the video coding layer the rate
1845e5c31af7Sopenharmony_ci    control layer is applied to.
1846e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
1847e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
1848e5c31af7Sopenharmony_ci  * If the video session was created with the video codec operation
1849e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, then this index
1850e5c31af7Sopenharmony_ci    specifies the H.265 temporal ID of the video coding layer the rate
1851e5c31af7Sopenharmony_ci    control layer is applied to.
1852e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
1853e5c31af7Sopenharmony_ci
1854e5c31af7Sopenharmony_ciAdditional structures providing codec-specific rate control parameters can:
1855e5c31af7Sopenharmony_cibe included in the pname:pNext chain of sname:VkVideoCodingControlInfoKHR
1856e5c31af7Sopenharmony_cidepending on the <<video-profiles,video profile>> the bound video session
1857e5c31af7Sopenharmony_ciwas created.
1858e5c31af7Sopenharmony_ciFor further details see:
1859e5c31af7Sopenharmony_ci
1860e5c31af7Sopenharmony_ci  * <<video-coding-control,Video Coding Control>>
1861e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
1862e5c31af7Sopenharmony_ci  * <<encode-h264-rate-control,H.264 Encode Rate Control>>
1863e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
1864e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
1865e5c31af7Sopenharmony_ci  * <<encode-h265-rate-control,H.265 Encode Rate Control>>
1866e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
1867e5c31af7Sopenharmony_ci
1868e5c31af7Sopenharmony_ciThe new rate control configuration takes effect when the corresponding
1869e5c31af7Sopenharmony_ciflink:vkCmdControlVideoCodingKHR is executed on the device, and only impacts
1870e5c31af7Sopenharmony_civideo encode operations that follow in execution order.
1871e5c31af7Sopenharmony_ci
1872e5c31af7Sopenharmony_ci.Valid Usage
1873e5c31af7Sopenharmony_ci****
1874e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-rateControlMode-08248]]
1875e5c31af7Sopenharmony_ci    If pname:rateControlMode is
1876e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DEFAULT_KHR or
1877e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR, then
1878e5c31af7Sopenharmony_ci    pname:layerCount must: be `0`
1879e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-rateControlMode-08275]]
1880e5c31af7Sopenharmony_ci    If pname:rateControlMode is
1881e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR or
1882e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR, then
1883e5c31af7Sopenharmony_ci    pname:layerCount must: be greater than `0`
1884e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-rateControlMode-08244]]
1885e5c31af7Sopenharmony_ci    If pname:rateControlMode is not
1886e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DEFAULT_KHR, then it must:
1887e5c31af7Sopenharmony_ci    specify one of the bits included in
1888e5c31af7Sopenharmony_ci    slink:VkVideoEncodeCapabilitiesKHR::pname:rateControlModes, as returned
1889e5c31af7Sopenharmony_ci    by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the used video
1890e5c31af7Sopenharmony_ci    profile
1891e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-layerCount-08245]]
1892e5c31af7Sopenharmony_ci    pname:layerCount member must: be less than or equal to
1893e5c31af7Sopenharmony_ci    slink:VkVideoEncodeCapabilitiesKHR::pname:maxRateControlLayers, as
1894e5c31af7Sopenharmony_ci    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the used
1895e5c31af7Sopenharmony_ci    video profile
1896e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-pLayers-08276]]
1897e5c31af7Sopenharmony_ci    For each element of pname:pLayers, its pname:averageBitrate member must:
1898e5c31af7Sopenharmony_ci    be between `1` and slink:VkVideoEncodeCapabilitiesKHR::pname:maxBitrate,
1899e5c31af7Sopenharmony_ci    as returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the
1900e5c31af7Sopenharmony_ci    used video profile
1901e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-pLayers-08277]]
1902e5c31af7Sopenharmony_ci    For each element of pname:pLayers, its pname:maxBitrate member must: be
1903e5c31af7Sopenharmony_ci    between `1` and slink:VkVideoEncodeCapabilitiesKHR::pname:maxBitrate, as
1904e5c31af7Sopenharmony_ci    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the used
1905e5c31af7Sopenharmony_ci    video profile
1906e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-rateControlMode-08356]]
1907e5c31af7Sopenharmony_ci    If pname:rateControlMode is
1908e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR, then for each
1909e5c31af7Sopenharmony_ci    element of pname:pLayers, its pname:averageBitrate member must: equal
1910e5c31af7Sopenharmony_ci    its pname:maxBitrate member
1911e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-rateControlMode-08278]]
1912e5c31af7Sopenharmony_ci    If pname:rateControlMode is
1913e5c31af7Sopenharmony_ci    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR, then for each
1914e5c31af7Sopenharmony_ci    element of pname:pLayers, its pname:averageBitrate member must: be less
1915e5c31af7Sopenharmony_ci    than or equal to its pname:maxBitrate member
1916e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-layerCount-08357]]
1917e5c31af7Sopenharmony_ci    If pname:layerCount is not zero, then pname:virtualBufferSizeInMs must:
1918e5c31af7Sopenharmony_ci    be greater than zero
1919e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-layerCount-08358]]
1920e5c31af7Sopenharmony_ci    If pname:layerCount is not zero, then pname:initialVirtualBufferSizeInMs
1921e5c31af7Sopenharmony_ci    must: be less than pname:virtualBufferSizeInMs
1922e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
1923e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-videoCodecOperation-07022]]
1924e5c31af7Sopenharmony_ci    If the pname:videoCodecOperation of the used video profile is
1925e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR, the pname:pNext
1926e5c31af7Sopenharmony_ci    chain this structure is included in also includes an instance of the
1927e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264RateControlInfoKHR structure, and
1928e5c31af7Sopenharmony_ci    pname:layerCount is greater than `1`, then pname:layerCount must: equal
1929e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH264RateControlInfoKHR::pname:temporalLayerCount
1930e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
1931e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
1932e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlInfoKHR-videoCodecOperation-07025]]
1933e5c31af7Sopenharmony_ci    If the pname:videoCodecOperation of the used video profile is
1934e5c31af7Sopenharmony_ci    ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR, the pname:pNext
1935e5c31af7Sopenharmony_ci    chain this structure is included in also includes an instance of the
1936e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265RateControlInfoKHR structure, and
1937e5c31af7Sopenharmony_ci    pname:layerCount is greater than `1`, then pname:layerCount must: equal
1938e5c31af7Sopenharmony_ci    slink:VkVideoEncodeH265RateControlInfoKHR::pname:subLayerCount
1939e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
1940e5c31af7Sopenharmony_ci****
1941e5c31af7Sopenharmony_ci
1942e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkVideoEncodeRateControlInfoKHR.adoc[]
1943e5c31af7Sopenharmony_ci--
1944e5c31af7Sopenharmony_ci
1945e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeRateControlFlagsKHR',desc='Reserved for future use',type='flags']
1946e5c31af7Sopenharmony_ci--
1947e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkVideoEncodeRateControlFlagsKHR.adoc[]
1948e5c31af7Sopenharmony_ci
1949e5c31af7Sopenharmony_citname:VkVideoEncodeRateControlFlagsKHR is a bitmask type for setting a mask,
1950e5c31af7Sopenharmony_cibut currently reserved for future use.
1951e5c31af7Sopenharmony_ci--
1952e5c31af7Sopenharmony_ci
1953e5c31af7Sopenharmony_ci
1954e5c31af7Sopenharmony_ci==== Rate Control Layer State
1955e5c31af7Sopenharmony_ci
1956e5c31af7Sopenharmony_ciThe configuration of individual rate control layers is specified using an
1957e5c31af7Sopenharmony_ciinstance of the sname:VkVideoEncodeRateControlLayerInfoKHR structure.
1958e5c31af7Sopenharmony_ci
1959e5c31af7Sopenharmony_ci[open,refpage='VkVideoEncodeRateControlLayerInfoKHR',desc='Structure to set encode per-layer rate control parameters',type='structs']
1960e5c31af7Sopenharmony_ci--
1961e5c31af7Sopenharmony_ciThe sname:VkVideoEncodeRateControlLayerInfoKHR structure is defined as:
1962e5c31af7Sopenharmony_ci
1963e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkVideoEncodeRateControlLayerInfoKHR.adoc[]
1964e5c31af7Sopenharmony_ci
1965e5c31af7Sopenharmony_ci  * pname:sType is a elink:VkStructureType value identifying this structure.
1966e5c31af7Sopenharmony_ci  * pname:pNext is a pointer to a structure extending this structure.
1967e5c31af7Sopenharmony_ci  * pname:averageBitrate is the average <<encode-bitrate,bitrate>> to be
1968e5c31af7Sopenharmony_ci    targeted by the implementation's rate control algorithm.
1969e5c31af7Sopenharmony_ci  * pname:maxBitrate is the peak <<encode-bitrate,bitrate>> to be targeted
1970e5c31af7Sopenharmony_ci    by the implementation's rate control algorithm.
1971e5c31af7Sopenharmony_ci  * pname:frameRateNumerator is the numerator of the frame rate assumed by
1972e5c31af7Sopenharmony_ci    the implementation's rate control algorithm.
1973e5c31af7Sopenharmony_ci  * pname:frameRateDenominator is the denominator of the frame rate assumed
1974e5c31af7Sopenharmony_ci    by the implementation's rate control algorithm.
1975e5c31af7Sopenharmony_ci
1976e5c31af7Sopenharmony_ci[NOTE]
1977e5c31af7Sopenharmony_ci.Note
1978e5c31af7Sopenharmony_ci====
1979e5c31af7Sopenharmony_ciThe ability of the implementation's rate control algorithm to be able to
1980e5c31af7Sopenharmony_cimatch the requested average and/or peak bitrates may: be limited by the set
1981e5c31af7Sopenharmony_ciof other codec-independent and codec-specific rate control parameters
1982e5c31af7Sopenharmony_cispecified by the application, the input content, as well as the application
1983e5c31af7Sopenharmony_ciconforming to the rate control guidance provided to the implementation, as
1984e5c31af7Sopenharmony_cidescribed <<encode-rate-control,earlier>>.
1985e5c31af7Sopenharmony_ci====
1986e5c31af7Sopenharmony_ci
1987e5c31af7Sopenharmony_ciAdditional structures providing codec-specific rate control parameters can:
1988e5c31af7Sopenharmony_cibe included in the pname:pNext chain of
1989e5c31af7Sopenharmony_cisname:VkVideoEncodeRateControlLayerInfoKHR depending on the
1990e5c31af7Sopenharmony_ci<<video-profiles,video profile>> the bound video session was created with.
1991e5c31af7Sopenharmony_ciFor further details see:
1992e5c31af7Sopenharmony_ci
1993e5c31af7Sopenharmony_ci  * <<video-coding-control,Video Coding Control>>
1994e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h264[]
1995e5c31af7Sopenharmony_ci  * <<encode-h264-rate-control,H.264 Encode Rate Control>>
1996e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h264[]
1997e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_h265[]
1998e5c31af7Sopenharmony_ci  * <<encode-h265-rate-control,H.265 Encode Rate Control>>
1999e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_h265[]
2000e5c31af7Sopenharmony_ci
2001e5c31af7Sopenharmony_ci.Valid Usage
2002e5c31af7Sopenharmony_ci****
2003e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlLayerInfoKHR-frameRateNumerator-08350]]
2004e5c31af7Sopenharmony_ci    pname:frameRateNumerator must: be greater than zero
2005e5c31af7Sopenharmony_ci  * [[VUID-VkVideoEncodeRateControlLayerInfoKHR-frameRateDenominator-08351]]
2006e5c31af7Sopenharmony_ci    pname:frameRateDenominator must: be greater than zero
2007e5c31af7Sopenharmony_ci****
2008e5c31af7Sopenharmony_ci
2009e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkVideoEncodeRateControlLayerInfoKHR.adoc[]
2010e5c31af7Sopenharmony_ci--
2011