1// Copyright 2018-2023 The Khronos Group Inc.
2//
3// SPDX-License-Identifier: CC-BY-4.0
4
5[[video-decode-operations]]
6== Video Decode Operations
7
8[[decode-output-picture]]
9Video decode operations consume compressed video data from a video bitstream
10buffer and zero or more reference pictures, and produce a _decode output
11picture_ and an optional <<reconstructed-picture,reconstructed picture>>.
12
13[NOTE]
14.Note:
15====
16Such decode output pictures can be shared with the <<dpb,Decoded Picture
17Buffer>>, and can also be used
18ifdef::VK_KHR_video_encode_queue[]
19as the <<encode-input-picture,input>> of video encode operations,
20endif::VK_KHR_video_encode_queue[]
21with graphics or compute operations,
22ifdef::VK_KHR_surface[]
23or with <<wsi,Window System Integration>> APIs,
24endif::VK_KHR_surface[]
25depending on the capabilities of the implementation.
26====
27
28Video decode operations may: access the following resources in the
29ename:VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR stage:
30
31  * The source video bitstream buffer range and the image subregions
32    corresponding to the list of <<decode-active-reference-picture-info,
33    active reference pictures>> with access
34    ename:VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR.
35  * The image subregions corresponding to the target
36    <<decode-output-picture-info,decode output picture>> and
37    <<decode-reconstructed-picture-info,reconstructed picture>> with access
38    ename:VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR.
39
40The image subresource of each <<video-picture-resources,video picture
41resource>> accessed by the video coding operation is specified using a
42corresponding slink:VkVideoPictureResourceInfoKHR structure.
43Each such image subresource must: be in the appropriate image layout as
44follows:
45
46  * If the image subresource is used in the video decode operation only as
47    <<decode-output-picture,decode output picture>>, then it must: be in the
48    ename:VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR layout.
49  * If the image subresource is used in the video decode operation both as
50    <<decode-output-picture,decode output picture>> and
51    <<reconstructed-picture,reconstructed picture>>, then it must: be in the
52    ename:VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR layout.
53  * If the image subresource is used in the video decode operation only as
54    <<reconstructed-picture,reconstructed picture>>, then it must: be in the
55    ename:VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR layout.
56  * If the image subresource is used in the video decode operation as a
57    <<reference-picture,reference picture>>, then it must: be in the
58    ename:VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR layout.
59
60[[decode-unsuccessful]]
61A video decode operation may: complete unsuccessfully.
62In this case the <<decode-output-picture,decode output picture>> will have
63undefined: contents.
64Similarly, if a <<reconstructed-picture,reconstructed picture>> is
65specified, it will also have undefined: contents, and the activated DPB slot
66will have an <<dpb-slot-states,invalid picture reference>>.
67
68
69[[decode-codec-specific-semantics]]
70=== Codec-Specific Semantics
71
72The following aspects of video decode operations are codec-specific:
73
74  * The interpretation of the contents of the source video bitstream buffer
75    range.
76  * The construction and interpretation of the list of
77    <<decode-active-reference-picture-info,active reference pictures>> and
78    the interpretation of the picture data referred to by the corresponding
79    image subregions.
80  * The construction and interpretation of information related to the
81    <<decode-output-picture-info,decode output picture>> and the generation
82    of picture data to the corresponding image subregion.
83  * The construction and interpretation of information related to the
84    optional <<decode-reconstructed-picture-info,reconstructed picture>> and
85    the generation of picture data to the corresponding image subregion.
86
87These codec-specific behaviors are defined for each video codec operation
88separately.
89
90ifdef::VK_KHR_video_decode_h264[]
91  * If the used video codec operation is
92    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, then the
93    codec-specific aspects of the video decoding process are performed as
94    defined in the <<decode-h264,H.264 Decode Operations>> section.
95endif::VK_KHR_video_decode_h264[]
96ifdef::VK_KHR_video_decode_h265[]
97  * If the used video codec operation is
98    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, then the
99    codec-specific aspects of the video decoding process are performed as
100    defined in the <<decode-h265,H.265 Decode Operations>> section.
101endif::VK_KHR_video_decode_h265[]
102
103
104[[decode-operation-steps]]
105=== Video Decode Operation Steps
106
107Each video decode operation performs the following steps in the
108ename:VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR stage:
109
110  1. Reads the encoded video data from the source video bitstream buffer
111     range.
112  2. Performs picture reconstruction of the encoded video data according to
113     the <<decode-codec-specific-semantics,codec-specific semantics>>,
114     applying any prediction data read from the <<active-reference-pictures,
115     active reference pictures>> in the process;
116  3. Writes the decoded picture data to the <<decode-output-picture,decode
117     output picture>>, and to the <<reconstructed-picture,reconstructed
118     picture>>, if one is specified and is different from the decode output
119     picture, according to the <<decode-codec-specific-semantics,
120     codec-specific semantics>>;
121  4. When <<decode-reconstructed-picture-info,reconstructed picture
122     information>> is provided, the requested <<dpb-slot,DPB slot>> is
123     <<dpb-slot-states,activated>> with the specified picture and the DPB
124     slot index is associated with the corresponding
125     <<bound-reference-picture-resources,bound reference picture resource>>.
126
127
128=== Capabilities
129
130[open,refpage='VkVideoDecodeCapabilitiesKHR',desc='Structure describing general video decode capabilities for a video profile',type='structs']
131--
132When calling flink:vkGetPhysicalDeviceVideoCapabilitiesKHR with
133pname:pVideoProfile->videoCodecOperation specifying a decode operation, the
134sname:VkVideoDecodeCapabilitiesKHR structure must: be included in the
135pname:pNext chain of the slink:VkVideoCapabilitiesKHR structure to retrieve
136capabilities specific to video decoding.
137
138The sname:VkVideoDecodeCapabilitiesKHR structure is defined as:
139
140include::{generated}/api/structs/VkVideoDecodeCapabilitiesKHR.adoc[]
141
142  * pname:sType is a elink:VkStructureType value identifying this structure.
143  * pname:pNext is `NULL` or a pointer to a structure extending this
144    structure.
145  * pname:flags is a bitmask of elink:VkVideoDecodeCapabilityFlagBitsKHR
146    describing the supported video decoding capabilities.
147
148include::{generated}/validity/structs/VkVideoDecodeCapabilitiesKHR.adoc[]
149--
150
151[open,refpage='VkVideoDecodeCapabilityFlagBitsKHR',desc='Video decode capability flags',type='enums']
152--
153Bits which may: be set in slink:VkVideoDecodeCapabilitiesKHR::pname:flags,
154indicating the decoding capabilities supported, are:
155
156include::{generated}/api/enums/VkVideoDecodeCapabilityFlagBitsKHR.adoc[]
157
158  * ename:VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR
159    indicates support for using the same video picture resource as the
160    <<reconstructed-picture,reconstructed picture>> and
161    <<decode-output-picture,decode output picture>> in a video decode
162    operation.
163  * ename:VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR
164    indicates support for using distinct video picture resources as the
165    <<reconstructed-picture,reconstructed picture>> and
166    <<decode-output-picture,decode output picture>> in a video decode
167    operation.
168
169Implementations are only required: to support one of
170ename:VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR and
171ename:VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR.
172Accordingly, applications should: handle both cases to maximize portability.
173
174[NOTE]
175.Note:
176====
177If both ename:VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR and
178ename:VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR are
179supported, an application can choose to create separate images for decode
180DPB and decode output.
181E.g. in cases when linear tiling is preferred (and supported) for the decode
182output picture and the DPB requires optimal tiling, this avoids the need for
183a separate copy at the expense of additional memory bandwidth requirements
184during decoding.
185====
186--
187
188[open,refpage='VkVideoDecodeCapabilityFlagsKHR',desc='Bitmask of VkVideoDecodeCapabilityFlagBitsKHR',type='flags']
189--
190include::{generated}/api/flags/VkVideoDecodeCapabilityFlagsKHR.adoc[]
191
192tname:VkVideoDecodeCapabilityFlagsKHR is a bitmask type for setting a mask
193of zero or more elink:VkVideoDecodeCapabilityFlagBitsKHR.
194--
195
196
197=== Video Decode Commands
198
199[open,refpage='vkCmdDecodeVideoKHR',desc='Launch a video decode operation',type='protos']
200--
201To launch video decode operations, call:
202
203include::{generated}/api/protos/vkCmdDecodeVideoKHR.adoc[]
204
205  * pname:commandBuffer is the command buffer in which to record the
206    command.
207  * pname:pDecodeInfo is a pointer to a slink:VkVideoDecodeInfoKHR structure
208    specifying the parameters of the video decode operations.
209
210Each call issues one or more video decode operations.
211The implicit parameter pname:opCount corresponds to the number of video
212decode operations issued by the command.
213After calling this command, the
214<<queries-operation-active-query-index,active query index>> of each
215<<queries-operation-active,active>> query is incremented by pname:opCount.
216
217Currently each call to this command results in the issue of a single video
218decode operation.
219
220[[decode-active-reference-picture-info]]
221Active Reference Picture Information::
222
223The list of <<active-reference-pictures,active reference pictures>> used by
224a video decode operation is a list of image subregions used as the source of
225<<reference-picture,reference picture>> data and related parameters, and is
226derived from the slink:VkVideoReferenceSlotInfoKHR structures provided as
227the elements of the pname:pDecodeInfo->pReferenceSlots array.
228For each element of pname:pDecodeInfo->pReferenceSlots, one or more elements
229are added to the active reference picture list, as defined by the
230<<decode-codec-specific-semantics,codec-specific semantics>>.
231Each element of this list contains the following information:
232
233  * The image subregion within the image subresource
234    <<video-image-subresource-reference,referred>> to by the
235    <<video-picture-resources,video picture resource>> used as the reference
236    picture.
237  * The <<dpb-slot,DPB slot>> index the reference picture is associated
238    with.
239  * The codec-specific reference information related to the reference
240    picture.
241
242[[decode-reconstructed-picture-info]]
243Reconstructed Picture Information::
244
245Information related to the optional <<reconstructed-picture,reconstructed
246picture>> used by a video decode operation is derived from the
247slink:VkVideoReferenceSlotInfoKHR structure pointed to by
248pname:pDecodeInfo->pSetupReferenceSlot, if not `NULL`, as defined by the
249<<decode-codec-specific-semantics,codec-specific semantics>>, and consists
250of the following:
251
252  * The image subregion within the image subresource
253    <<video-image-subresource-reference,referred>> to by the
254    <<video-picture-resources,video picture resource>> used as the
255    reconstructed picture.
256  * The <<dpb-slot,DPB slot>> index to <<dpb-slot-states,activate>> with the
257    reconstructed picture.
258  * The codec-specific reference information related to the reconstructed
259    picture.
260
261[[decode-output-picture-info]]
262Decode Output Picture Information::
263
264Information related to the <<decode-output-picture,decode output picture>>
265used by a video decode operation is derived from
266pname:pDecodeInfo->dstPictureResource and any codec-specific parameters
267provided in the pname:pDecodeInfo->pNext chain, as defined by the
268<<decode-codec-specific-semantics,codec-specific semantics>>, and consists
269of the following:
270
271  * The image subregion within the image subresource
272    <<video-image-subresource-reference,referred>> to by the
273    <<video-picture-resources,video picture resource>> used as the decode
274    output picture.
275  * The codec-specific picture information related to the decode output
276    picture.
277
278Several limiting values are defined below that are referenced by the
279relevant valid usage statements of this command.
280
281  * Let `uint32_t activeReferencePictureCount` be the size of the list of
282    active reference pictures used by the video decode operation.
283    Unless otherwise defined, pname:activeReferencePictureCount is set to
284    the value of pname:pDecodeInfo->referenceSlotCount.
285ifdef::VK_KHR_video_decode_h264[]
286  ** If the bound video session was created with an <<decode-h264-profile,
287     H.264 decode profile>>, then let pname:activeReferencePictureCount be
288     the value of pname:pDecodeInfo->referenceSlotCount plus the number of
289     elements of the pname:pDecodeInfo->pReferenceSlots array that have a
290     slink:VkVideoDecodeH264DpbSlotInfoKHR structure included in their
291     pname:pNext chain with both
292     pname:pStdReferenceInfo->flags.top_field_flag and
293     pname:pStdReferenceInfo->flags.bottom_field_flag set.
294+
295[NOTE]
296.Note
297====
298This means that the elements of pname:pDecodeInfo->pReferenceSlots that
299include both a top and bottom field reference are counted as two separate
300active reference pictures, as described in the
301<<decode-h264-active-reference-picture-info,active reference picture list
302construction rules for H.264 decode operations>>.
303====
304endif::VK_KHR_video_decode_h264[]
305  * Let `VkOffset2D codedOffsetGranularity` be the minimum alignment
306    requirement for the coded offset of video picture resources.
307    Unless otherwise defined, the value of the pname:x and pname:y members
308    of pname:codedOffsetGranularity are `0`.
309ifdef::VK_KHR_video_decode_h264[]
310  ** If the bound video session was created with an <<decode-h264-profile,
311     H.264 decode profile>> with a
312     slink:VkVideoDecodeH264ProfileInfoKHR::pname:pictureLayout of
313     ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_KHR,
314     then pname:codedOffsetGranularity is equal to
315     slink:VkVideoDecodeH264CapabilitiesKHR::pname:fieldOffsetGranularity,
316     as returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for that
317     video profile.
318endif::VK_KHR_video_decode_h264[]
319  * Let `uint32_t dpbFrameUseCount[]` be an array of size pname:maxDpbSlots,
320    where pname:maxDpbSlots is the
321    slink:VkVideoSessionCreateInfoKHR::pname:maxDpbSlots the bound video
322    session was created with, with each element indicating the number of
323    times a frame associated with the corresponding DPB slot index is
324    referred to by the video coding operation.
325    Let the initial value of each element of the array be `0`.
326  ** If pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, then
327     `dpbFrameUseCount[i]` is incremented by one, where pname:i equals
328     pname:pDecodeInfo->pSetupReferenceSlot->slotIndex.
329ifdef::VK_KHR_video_decode_h264[]
330     If the bound video session object was created with an
331     <<decode-h264-profile,H.264 decode profile>>, then
332     `dpbFrameUseCount[i]` is decremented by one if either
333     pname:pStdReferenceInfo->flags.top_field_flag or
334     pname:pStdReferenceInfo->flags.bottom_field_flag is set in the
335     slink:VkVideoDecodeH264DpbSlotInfoKHR structure in the
336     pname:pDecodeInfo->pSetupReferenceSlot->pNext chain.
337endif::VK_KHR_video_decode_h264[]
338  ** For each element of pname:pDecodeInfo->pReferenceSlots,
339     `dpbFrameUseCount[i]` is incremented by one, where pname:i equals the
340     pname:slotIndex member of the corresponding element.
341ifdef::VK_KHR_video_decode_h264[]
342     If the bound video session object was created with an
343     <<decode-h264-profile,H.264 decode profile>>, then
344     `dpbFrameUseCount[i]` is decremented by one if either
345     pname:pStdReferenceInfo->flags.top_field_flag or
346     pname:pStdReferenceInfo->flags.bottom_field_flag is set in the
347     slink:VkVideoDecodeH264DpbSlotInfoKHR structure in the pname:pNext
348     chain of the corresponding element of
349     pname:pDecodeInfo->pReferenceSlots.
350  * Let `uint32_t dpbTopFieldUseCount[]` and `uint32_t
351    dpbBottomFieldUseCount[]` be arrays of size pname:maxDpbSlots, where
352    pname:maxDpbSlots is the
353    slink:VkVideoSessionCreateInfoKHR::pname:maxDpbSlots the bound video
354    session was created with, with each element indicating the number of
355    times the top field or the bottom field, respectively, associated with
356    the corresponding DPB slot index is referred to by the video coding
357    operation.
358    Let the initial value of each element of the arrays be `0`.
359  ** If the bound video session object was created with an
360     <<decode-h264-profile,H.264 decode profile>> and
361     pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, then perform the
362     following:
363  *** If pname:pStdReferenceInfo->flags.top_field_flag is set in the
364      slink:VkVideoDecodeH264DpbSlotInfoKHR structure in the
365      pname:pDecodeInfo->pSetupReferenceSlot->pNext chain, then
366      `dpbTopFieldUseCount[i]` is incremented by one, where pname:i equals
367      pname:pDecodeInfo->pSetupReferenceSlot->slotIndex.
368  *** If pname:pStdReferenceInfo->flags.bottom_field_flag is set in the
369      slink:VkVideoDecodeH264DpbSlotInfoKHR structure in the
370      pname:pDecodeInfo->pSetupReferenceSlot->pNext chain, then
371      `dpbBottomFieldUseCount[i]` is incremented by one, where pname:i
372      equals pname:pDecodeInfo->pSetupReferenceSlot->slotIndex.
373  ** If the bound video session object was created with an
374     <<decode-h264-profile,H.264 decode profile>>, then perform the
375     following for each element of pname:pDecodeInfo->pReferenceSlots:
376  *** If pname:pStdReferenceInfo->flags.top_field_flag is set in the
377      slink:VkVideoDecodeH264DpbSlotInfoKHR structure in the pname:pNext
378      chain of the element, then `dpbTopFieldUseCount[i]` is incremented by
379      one, where pname:i equals the pname:slotIndex member of the element.
380  *** If pname:pStdReferenceInfo->flags.bottom_field_flag is set in the
381      slink:VkVideoDecodeH264DpbSlotInfoKHR structure in the pname:pNext
382      chain of the element, then `dpbBottomFieldUseCount[i]` is incremented
383      by one, where pname:i equals the pname:slotIndex member of the
384      element.
385endif::VK_KHR_video_decode_h264[]
386
387.Valid Usage
388****
389  * [[VUID-vkCmdDecodeVideoKHR-None-07011]]
390    The bound video session must: not be in <<video-session-uninitialized,
391    uninitialized>> state at the time the command is executed on the device
392  * [[VUID-vkCmdDecodeVideoKHR-opCount-07134]]
393    For each <<queries-operation-active,active>> query, the
394    <<queries-operation-active-query-index,active query index>>
395    corresponding to the query type of that query plus pname:opCount must:
396    be less than or equal to the
397    <<queries-operation-last-activatable-query-index,last activatable query
398    index>> corresponding to the query type of that query plus one
399  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07135]]
400    pname:pDecodeInfo->srcBuffer must: be <<video-profile-compatibility,
401    compatible>> with the video profile the bound video session was created
402    with
403  * [[VUID-vkCmdDecodeVideoKHR-commandBuffer-07136]]
404    If pname:commandBuffer is an unprotected command buffer and
405    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
406    then pname:pDecodeInfo->srcBuffer must: not be a protected buffer
407  * [[VUID-vkCmdDecodeVideoKHR-commandBuffer-07137]]
408    If pname:commandBuffer is a protected command buffer and
409    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
410    then pname:pDecodeInfo->srcBuffer must: be a protected buffer
411  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07138]]
412    pname:pDecodeInfo->srcBufferOffset must: be an integer multiple of
413    slink:VkVideoCapabilitiesKHR::pname:minBitstreamBufferOffsetAlignment,
414    as returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the
415    video profile the bound video session was created with
416  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07139]]
417    pname:pDecodeInfo->srcBufferRange must: be an integer multiple of
418    slink:VkVideoCapabilitiesKHR::pname:minBitstreamBufferSizeAlignment, as
419    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video
420    profile the bound video session was created with
421  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07140]]
422    If pname:pDecodeInfo->pSetupReferenceSlot is not `NULL` and
423    slink:VkVideoDecodeCapabilitiesKHR::pname:flags does not include
424    ename:VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR, as
425    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video
426    profile the bound video session was created with, then the video picture
427    resources specified by pname:pDecodeInfo->dstPictureResource and
428    pname:pDecodeInfo->pSetupReferenceSlot->pPictureResource must: not
429    <<video-picture-resource-matching,match>>
430  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07141]]
431    If pname:pDecodeInfo->pSetupReferenceSlot is not `NULL` and
432    slink:VkVideoDecodeCapabilitiesKHR::pname:flags does not include
433    ename:VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR, as
434    returned by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video
435    profile the bound video session was created with, then the video picture
436    resources specified by pname:pDecodeInfo->dstPictureResource and
437    pname:pDecodeInfo->pSetupReferenceSlot->pPictureResource must:
438    <<video-picture-resource-matching,match>>
439  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07142]]
440    pname:pDecodeInfo->dstPictureResource.imageViewBinding must: be
441    <<video-profile-compatibility,compatible>> with the video profile the
442    bound video session was created with
443  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07143]]
444    The format of pname:pDecodeInfo->dstPictureResource.imageViewBinding
445    must: match the slink:VkVideoSessionCreateInfoKHR::pname:pictureFormat
446    the bound video session was created with
447  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07144]]
448    pname:pDecodeInfo->dstPictureResource.codedOffset must: be an integer
449    multiple of pname:codedOffsetGranularity
450  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07145]]
451    pname:pDecodeInfo->dstPictureResource.codedExtent must: be between
452    pname:minCodedExtent and pname:maxCodedExtent, inclusive, the bound
453    video session was created with
454  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07146]]
455    pname:pDecodeInfo->dstPictureResource.imageViewBinding must: have been
456    created with ename:VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR
457  * [[VUID-vkCmdDecodeVideoKHR-commandBuffer-07147]]
458    If pname:commandBuffer is an unprotected command buffer and
459    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
460    then pname:pDecodeInfo->dstPictureResource.imageViewBinding must: not
461    have been created from a protected image
462  * [[VUID-vkCmdDecodeVideoKHR-commandBuffer-07148]]
463    If pname:commandBuffer is a protected command buffer and
464    <<limits-protectedNoFault, pname:protectedNoFault>> is not supported,
465    then pname:pDecodeInfo->dstPictureResource.imageViewBinding must: have
466    been created from a protected image
467  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07170]]
468    If pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, then
469    pname:pDecodeInfo->pSetupReferenceSlot->slotIndex must: be less than the
470    slink:VkVideoSessionCreateInfoKHR::pname:maxDpbSlots specified when the
471    bound video session was created
472  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07173]]
473    If pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, then
474    pname:pDecodeInfo->pSetupReferenceSlot->pPictureResource->codedOffset
475    must: be an integer multiple of pname:codedOffsetGranularity
476  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07149]]
477    If pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, then
478    pname:pDecodeInfo->pSetupReferenceSlot->pPictureResource must:
479    <<video-picture-resource-matching,match>> one of the
480    <<bound-reference-picture-resources,bound reference picture resource>>
481  * [[VUID-vkCmdDecodeVideoKHR-activeReferencePictureCount-07150]]
482    pname:activeReferencePictureCount must: be less than or equal to the
483    slink:VkVideoSessionCreateInfoKHR::pname:maxActiveReferencePictures
484    specified when the bound video session was created
485  * [[VUID-vkCmdDecodeVideoKHR-slotIndex-07256]]
486    The pname:slotIndex member of each element of
487    pname:pDecodeInfo->pReferenceSlots must: be less than the
488    slink:VkVideoSessionCreateInfoKHR::pname:maxDpbSlots specified when the
489    bound video session was created
490  * [[VUID-vkCmdDecodeVideoKHR-codedOffset-07257]]
491    The pname:codedOffset member of the slink:VkVideoPictureResourceInfoKHR
492    structure pointed to by the pname:pPictureResource member of each
493    element of pname:pDecodeInfo->pReferenceSlots must: be an integer
494    multiple of pname:codedOffsetGranularity
495  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07151]]
496    The pname:pPictureResource member of each element of
497    pname:pDecodeInfo->pReferenceSlots must:
498    <<video-picture-resource-matching,match>> one of the
499    <<bound-reference-picture-resources,bound reference picture resource>>
500    associated with the DPB slot index specified in the pname:slotIndex
501    member of that element
502  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07264]]
503    Each video picture resource corresponding to the pname:pPictureResource
504    member specified in the elements of pname:pDecodeInfo->pReferenceSlots
505    must: be <<video-picture-resource-uniqueness,unique>> within
506    pname:pDecodeInfo->pReferenceSlots
507  * [[VUID-vkCmdDecodeVideoKHR-dpbFrameUseCount-07176]]
508    All elements of pname:dpbFrameUseCount must: be less than or equal to
509    `1`
510ifdef::VK_KHR_video_decode_h264[]
511  * [[VUID-vkCmdDecodeVideoKHR-dpbTopFieldUseCount-07177]]
512    All elements of pname:dpbTopFieldUseCount must: be less than or equal to
513    `1`
514  * [[VUID-vkCmdDecodeVideoKHR-dpbBottomFieldUseCount-07178]]
515    All elements of pname:dpbBottomFieldUseCount must: be less than or equal
516    to `1`
517endif::VK_KHR_video_decode_h264[]
518  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07252]]
519    If pname:pDecodeInfo->pSetupReferenceSlot is `NULL` or
520    pname:pDecodeInfo->pSetupReferenceSlot->pPictureResource does not
521    <<video-image-subresource-reference,refer>> to the same image
522    subresource as pname:pDecodeInfo->dstPictureResource, then the image
523    subresource <<video-image-subresource-reference,referred>> to by
524    pname:pDecodeInfo->dstPictureResource must: be in the
525    ename:VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR layout at the time the video
526    decode operation is executed on the device
527  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07253]]
528    If pname:pDecodeInfo->pSetupReferenceSlot is not `NULL` and
529    pname:pDecodeInfo->pSetupReferenceSlot->pPictureResource
530    <<video-image-subresource-reference,refers>> to the same image
531    subresource as pname:pDecodeInfo->dstPictureResource, then the image
532    subresource <<video-image-subresource-reference,referred>> to by
533    pname:pDecodeInfo->dstPictureResource must: be in the
534    ename:VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR layout at the time the video
535    decode operation is executed on the device
536  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07254]]
537    If pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, then the image
538    subresource <<video-image-subresource-reference,referred>> to by
539    pname:pDecodeInfo->pSetupReferenceSlot->pPictureResource must: be in the
540    ename:VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR layout at the time the video
541    decode operation is executed on the device
542  * [[VUID-vkCmdDecodeVideoKHR-pPictureResource-07255]]
543    The image subresource <<video-image-subresource-reference,referred>> to
544    by the pname:pPictureResource member of each element of
545    pname:pDecodeInfo->pReferenceSlots must: be in the
546    ename:VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR layout at the time the video
547    decode operation is executed on the device
548ifdef::VK_KHR_video_decode_h264[]
549  * [[VUID-vkCmdDecodeVideoKHR-pNext-07152]]
550    If the bound video session was created with the video codec operation
551    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, then the pname:pNext
552    chain of pname:pDecodeInfo must: include a
553    slink:VkVideoDecodeH264PictureInfoKHR structure
554  * [[VUID-vkCmdDecodeVideoKHR-None-07258]]
555    If the bound video session was created with the video codec operation
556    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR but was not created
557    with <<decode-h264-interlaced-support,interlaced frame support>>, then
558    the <<decode-h264-output-picture-info,decode output picture>> must:
559    represent a frame
560  * [[VUID-vkCmdDecodeVideoKHR-pSliceOffsets-07153]]
561    If the bound video session was created with the video codec operation
562    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, then all elements of
563    the pname:pSliceOffsets member of the
564    slink:VkVideoDecodeH264PictureInfoKHR structure included in the
565    pname:pNext chain of pname:pDecodeInfo must: be less than
566    pname:pDecodeInfo->srcBufferRange
567  * [[VUID-vkCmdDecodeVideoKHR-StdVideoH264SequenceParameterSet-07154]]
568    If the bound video session was created with the video codec operation
569    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, then the bound video
570    session parameters object must: contain a
571    code:StdVideoH264SequenceParameterSet entry with
572    pname:seq_parameter_set_id matching
573    code:StdVideoDecodeH264PictureInfo::pname:seq_parameter_set_id that is
574    provided in the pname:pStdPictureInfo member of the
575    slink:VkVideoDecodeH264PictureInfoKHR structure included in the
576    pname:pNext chain of pname:pDecodeInfo
577  * [[VUID-vkCmdDecodeVideoKHR-StdVideoH264PictureParameterSet-07155]]
578    If the bound video session was created with the video codec operation
579    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, then the bound video
580    session parameters object must: contain a
581    code:StdVideoH264PictureParameterSet entry with
582    pname:seq_parameter_set_id and pname:pic_parameter_set_id matching
583    code:StdVideoDecodeH264PictureInfo::pname:seq_parameter_set_id and
584    code:StdVideoDecodeH264PictureInfo::pname:pic_parameter_set_id,
585    respectively, that are provided in the pname:pStdPictureInfo member of
586    the slink:VkVideoDecodeH264PictureInfoKHR structure included in the
587    pname:pNext chain of pname:pDecodeInfo
588  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07156]]
589    If the bound video session was created with the video codec operation
590    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR and
591    pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, then the
592    pname:pNext chain of pname:pDecodeInfo->pSetupReferenceSlot must:
593    include a slink:VkVideoDecodeH264DpbSlotInfoKHR structure
594  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07259]]
595    If the bound video session was created with the video codec operation
596    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR but was not created
597    with <<decode-h264-interlaced-support,interlaced frame support>>, and
598    pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, then the
599    <<decode-h264-reconstructed-picture-info,reconstructed picture>> must:
600    represent a frame
601  * [[VUID-vkCmdDecodeVideoKHR-pNext-07157]]
602    If the bound video session was created with the video codec operation
603    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, then the pname:pNext
604    chain of each element of pname:pDecodeInfo->pReferenceSlots must:
605    include a slink:VkVideoDecodeH264DpbSlotInfoKHR structure
606  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07260]]
607    If the bound video session was created with the video codec operation
608    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR but was not created
609    with <<decode-h264-interlaced-support,interlaced frame support>>, then
610    each <<decode-h264-active-reference-picture-info,active reference
611    picture>> corresponding to the elements of
612    pname:pDecodeInfo->pReferenceSlots must: represent a frame
613  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07261]]
614    If the bound video session was created with the video codec operation
615    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR,
616    pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, and the
617    <<decode-h264-output-picture-info,decode output picture>> represents a
618    frame, then the <<decode-h264-reconstructed-picture-info,reconstructed
619    picture>> must: also represent a frame
620  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07262]]
621    If the bound video session was created with the video codec operation
622    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR,
623    pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, and the
624    <<decode-h264-output-picture-info,decode output picture>> represents a
625    top field, then the
626    <<decode-h264-reconstructed-picture-info,reconstructed picture>> must:
627    also represent a top field
628  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07263]]
629    If the bound video session was created with the video codec operation
630    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR,
631    pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, and the
632    <<decode-h264-output-picture-info,decode output picture>> represents a
633    bottom field, then the <<decode-h264-reconstructed-picture-info,
634    reconstructed picture>> must: also represent a bottom field
635  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07266]]
636    If the bound video session was created with the video codec operation
637    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR and an
638    <<decode-h264-active-reference-picture-info,active reference picture>>
639    corresponding to any element of pname:pDecodeInfo->pReferenceSlots
640    represents a frame, then the DPB slot index of the bound video session
641    specified by the pname:slotIndex member of that element must: be
642    currently associated with a frame picture
643    <<video-picture-resource-matching, matching>> the video picture resource
644    specified by the pname:pPictureResource member of the same element at
645    the time the command is executed on the device
646  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07267]]
647    If the bound video session was created with the video codec operation
648    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR and an
649    <<decode-h264-active-reference-picture-info,active reference picture>>
650    corresponding to any element of pname:pDecodeInfo->pReferenceSlots
651    represents a top field, then the DPB slot index of the bound video
652    session specified by the pname:slotIndex member of that element must: be
653    currently associated with a top field picture
654    <<video-picture-resource-matching, matching>> the video picture resource
655    specified by the pname:pPictureResource member of the same element at
656    the time the command is executed on the device
657  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07268]]
658    If the bound video session was created with the video codec operation
659    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR and an
660    <<decode-h264-active-reference-picture-info,active reference picture>>
661    corresponding to any element of pname:pDecodeInfo->pReferenceSlots
662    represents a bottom field, then the DPB slot index of the bound video
663    session specified by the pname:slotIndex member of that element must: be
664    currently associated with a bottom field picture
665    <<video-picture-resource-matching,matching>> the video picture resource
666    specified by the pname:pPictureResource member of the same element at
667    the time the command is executed on the device
668endif::VK_KHR_video_decode_h264[]
669ifdef::VK_KHR_video_decode_h265[]
670  * [[VUID-vkCmdDecodeVideoKHR-pNext-07158]]
671    If the bound video session was created with the video codec operation
672    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, then the pname:pNext
673    chain of pname:pDecodeInfo must: include a
674    slink:VkVideoDecodeH265PictureInfoKHR structure
675  * [[VUID-vkCmdDecodeVideoKHR-pSliceSegmentOffsets-07159]]
676    If the bound video session was created with the video codec operation
677    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, then all elements of
678    the pname:pSliceSegmentOffsets member of the
679    slink:VkVideoDecodeH265PictureInfoKHR structure included in the
680    pname:pNext chain of pname:pDecodeInfo must: be less than
681    pname:pDecodeInfo->srcBufferRange
682  * [[VUID-vkCmdDecodeVideoKHR-StdVideoH265VideoParameterSet-07160]]
683    If the bound video session was created with the video codec operation
684    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, then the bound video
685    session parameters object must: contain a
686    code:StdVideoH265VideoParameterSet entry with
687    pname:vps_video_parameter_set_id matching
688    code:StdVideoDecodeH265PictureInfo::pname:sps_video_parameter_set_id
689    that is provided in the pname:pStdPictureInfo member of the
690    slink:VkVideoDecodeH265PictureInfoKHR structure included in the
691    pname:pNext chain of pname:pDecodeInfo
692  * [[VUID-vkCmdDecodeVideoKHR-StdVideoH265SequenceParameterSet-07161]]
693    If the bound video session was created with the video codec operation
694    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, then the bound video
695    session parameters object must: contain a
696    code:StdVideoH265SequenceParameterSet entry with
697    pname:sps_video_parameter_set_id and pname:sps_seq_parameter_set_id
698    matching
699    code:StdVideoDecodeH265PictureInfo::pname:sps_video_parameter_set_id and
700    code:StdVideoDecodeH265PictureInfo::pname:pps_seq_parameter_set_id,
701    respectively, that are provided in the pname:pStdPictureInfo member of
702    the slink:VkVideoDecodeH265PictureInfoKHR structure included in the
703    pname:pNext chain of pname:pDecodeInfo
704  * [[VUID-vkCmdDecodeVideoKHR-StdVideoH265PictureParameterSet-07162]]
705    If the bound video session was created with the video codec operation
706    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, then the bound video
707    session parameters object must: contain a
708    code:StdVideoH265PictureParameterSet entry with
709    pname:sps_video_parameter_set_id, pname:pps_seq_parameter_set_id, and
710    pname:pps_pic_parameter_set_id matching
711    code:StdVideoDecodeH265PictureInfo::pname:sps_video_parameter_set_id,
712    code:StdVideoDecodeH265PictureInfo::pname:pps_seq_parameter_set_id, and
713    code:StdVideoDecodeH265PictureInfo::pname:pps_pic_parameter_set_id,
714    respectively, that are provided in the pname:pStdPictureInfo member of
715    the slink:VkVideoDecodeH265PictureInfoKHR structure included in the
716    pname:pNext chain of pname:pDecodeInfo
717  * [[VUID-vkCmdDecodeVideoKHR-pDecodeInfo-07163]]
718    If the bound video session was created with the video codec operation
719    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR and
720    pname:pDecodeInfo->pSetupReferenceSlot is not `NULL`, then the
721    pname:pNext chain of pname:pDecodeInfo->pSetupReferenceSlot must:
722    include a slink:VkVideoDecodeH265DpbSlotInfoKHR structure
723  * [[VUID-vkCmdDecodeVideoKHR-pNext-07164]]
724    If the bound video session was created with the video codec operation
725    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR, then the pname:pNext
726    chain of each element of pname:pDecodeInfo->pReferenceSlots must:
727    include a slink:VkVideoDecodeH265DpbSlotInfoKHR structure
728endif::VK_KHR_video_decode_h265[]
729****
730
731include::{generated}/validity/protos/vkCmdDecodeVideoKHR.adoc[]
732--
733
734[open,refpage='VkVideoDecodeInfoKHR',desc='Structure specifying video decode parameters',type='structs']
735--
736The sname:VkVideoDecodeInfoKHR structure is defined as:
737
738include::{generated}/api/structs/VkVideoDecodeInfoKHR.adoc[]
739
740  * pname:sType is a elink:VkStructureType value identifying this structure.
741  * pname:pNext is `NULL` or a pointer to a structure extending this
742    structure.
743  * pname:flags is reserved for future use.
744  * pname:srcBuffer is the source video bitstream buffer to read the encoded
745    bitstream from.
746  * pname:srcBufferOffset is the starting offset in bytes from the start of
747    pname:srcBuffer to read the encoded bitstream from.
748  * pname:srcBufferRange is the size in bytes of the encoded bitstream to
749    decode from pname:srcBuffer, starting from pname:srcBufferOffset.
750  * pname:dstPictureResource is the video picture resource to use as the
751    <<decode-output-picture,decode output picture>>.
752  * pname:pSetupReferenceSlot is `NULL` or a pointer to a
753    slink:VkVideoReferenceSlotInfoKHR structure describing the DPB slot to
754    <<dpb-slot-states,activate>> and the video picture resource to use as
755    the <<reconstructed-picture,reconstructed picture>> to activate the DPB
756    slot with.
757  * pname:referenceSlotCount is the number of elements in the
758    pname:pReferenceSlots array.
759  * pname:pReferenceSlots is `NULL` or a pointer to an array of
760    slink:VkVideoReferenceSlotInfoKHR structures describing the DPB slots
761    and corresponding <<reference-picture,reference picture>> resources to
762    use in this video decode operation (the set of
763    <<active-reference-pictures, active reference pictures>>).
764
765.Valid Usage
766****
767  * [[VUID-VkVideoDecodeInfoKHR-srcBuffer-07165]]
768    pname:srcBuffer must: have been created with
769    ename:VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR set
770  * [[VUID-VkVideoDecodeInfoKHR-srcBufferOffset-07166]]
771    pname:srcBufferOffset must: be less than the size of pname:srcBuffer
772  * [[VUID-VkVideoDecodeInfoKHR-srcBufferRange-07167]]
773    pname:srcBufferRange must: be less than or equal to the size of
774    pname:srcBuffer minus pname:srcBufferOffset
775  * [[VUID-VkVideoDecodeInfoKHR-pSetupReferenceSlot-07168]]
776    If pname:pSetupReferenceSlot is not `NULL`, then its pname:slotIndex
777    member must: not be negative
778  * [[VUID-VkVideoDecodeInfoKHR-pSetupReferenceSlot-07169]]
779    If pname:pSetupReferenceSlot is not `NULL`, then its
780    pname:pPictureResource must: not be `NULL`
781  * [[VUID-VkVideoDecodeInfoKHR-slotIndex-07171]]
782    The pname:slotIndex member of each element of pname:pReferenceSlots
783    must: not be negative
784  * [[VUID-VkVideoDecodeInfoKHR-pPictureResource-07172]]
785    The pname:pPictureResource member of each element of
786    pname:pReferenceSlots must: not be `NULL`
787****
788
789include::{generated}/validity/structs/VkVideoDecodeInfoKHR.adoc[]
790--
791
792[open,refpage='VkVideoDecodeFlagsKHR',desc='Reserved for future use',type='flags']
793--
794include::{generated}/api/flags/VkVideoDecodeFlagsKHR.adoc[]
795
796tname:VkVideoDecodeFlagsKHR is a bitmask type for setting a mask, but is
797currently reserved for future use.
798--
799