// Copyright 2018-2024 The Khronos Group Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

[[decode-h264]]
== H.264 Decode Operations

Video decode operations using an <<decode-h264-profile,H.264 decode
profile>> can: be used to decode elementary video stream sequences compliant
to the <<itu-t-h264,ITU-T H.264 Specification>>.

[NOTE]
.Note
====
Refer to the <<preamble,Preamble>> for information on how the Khronos
Intellectual Property Rights Policy relates to normative references to
external materials not created by Khronos.
====

This process is performed according to the <<decode-operation-steps,video
decode operation steps>> with the codec-specific semantics defined in
section 8 of the <<itu-t-h264,ITU-T H.264 Specification>> as follows:

  * Syntax elements, derived values, and other parameters are applied from
    the following structures:
  ** The code:StdVideoH264SequenceParameterSet structure corresponding to
     the <<decode-h264-active-sps,active SPS>> specifying the
     <<decode-h264-sps, H.264 sequence parameter set>>.
  ** The code:StdVideoH264PictureParameterSet structure corresponding to the
     <<decode-h264-active-pps,active PPS>> specifying the <<decode-h264-pps,
     H.264 picture parameter set>>.
  ** The code:StdVideoDecodeH264PictureInfo structure specifying the
     <<decode-h264-picture-info,H.264 picture information>>.
  ** The code:StdVideoDecodeH264ReferenceInfo structures specifying the
     <<decode-h264-reference-info,H.264 reference information>>
     corresponding to the optional <<reconstructed-picture,reconstructed
     picture>> and any <<active-reference-pictures,active reference
     pictures>>.
  * The contents of the provided video bitstream buffer range are
    interpreted as defined in the <<decode-h264-bitstream-data-access,H.264
    Decode Bitstream Data Access>> section.
  * Picture data in the <<video-picture-resources,video picture resources>>
    corresponding to the used <<decode-h264-active-reference-picture-info,
    active reference pictures>>, <<decode-h264-output-picture-info,decode
    output picture>>, and optional <<decode-h264-reconstructed-picture-info,
    reconstructed picture>> is accessed as defined in the
    <<decode-h264-picture-data-access,H.264 Decode Picture Data Access>>
    section.
  * The decision on <<decode-ref-pic-setup,reference picture setup>> is made
    according to the parameters specified in the
    <<decode-h264-ref-pic-setup,H.264 picture information>>.

If the parameters and the bitstream adhere to the syntactic and semantic
requirements defined in the corresponding sections of the <<itu-t-h264,ITU-T
H.264 Specification>>, as described above, and the <<dpb-slot,DPB slots>>
associated with the <<active-reference-pictures,active reference pictures>>
all refer to <<dpb-slot-states,valid picture references>>, then the video
decode operation will complete successfully.
Otherwise, the video decode operation may: complete
<<decode-unsuccessful,unsuccessfully>>.


[[decode-h264-bitstream-data-access]]
=== H.264 Decode Bitstream Data Access

If the target <<decode-h264-output-picture-info,decode output picture>> is a
frame, then the video bitstream buffer range should: contain a VCL NAL unit
comprised of the slice headers and data of a picture representing an entire
frame, as defined in sections 7.3.3 and 7.3.4, and this data is interpreted
as defined in sections 7.4.3 and 7.4.4 of the <<itu-t-h264,ITU-T H.264
Specification>>, respectively.

If the target <<decode-h264-output-picture-info,decode output picture>> is a
field, then the video bitstream buffer range should contain a VCL NAL unit
comprised of the slice headers and data of a picture representing a field,
as defined in sections 7.3.3 and 7.3.4, and this data is interpreted as
defined in sections 7.4.3 and 7.4.4 of the <<itu-t-h264,ITU-T H.264
Specification>>, respectively.

The offsets provided in
slink:VkVideoDecodeH264PictureInfoKHR::pname:pSliceOffsets should: specify
the starting offsets corresponding to each slice header within the video
bitstream buffer range.


[[decode-h264-picture-data-access]]
=== H.264 Decode Picture Data Access

The effective pname:imageOffset and pname:imageExtent corresponding to a
<<decode-output-picture,decode output picture>>,
<<reference-picture,reference picture>>, or
<<reconstructed-picture,reconstructed picture>> used in video decode
operations with an <<decode-h264-profile,H.264 decode profile>> are defined
as follows:

  * pname:imageOffset is [eq]#(pname:codedOffset.x,pname:codedOffset.y)# and
    pname:imageExtent is [eq]#(pname:codedExtent.width,
    pname:codedExtent.height)#, if the picture represents a frame.
  * pname:imageOffset is [eq]#(pname:codedOffset.x,pname:codedOffset.y)# and
    pname:imageExtent is [eq]#(pname:codedExtent.width,
    pname:codedExtent.height)#, if the picture represents a field and the
    picture layout of the used <<decode-h264-profile,H.264 decode profile>>
    is
    ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR.
  * pname:imageOffset is [eq]#(pname:codedOffset.x,pname:codedOffset.y)# and
    pname:imageExtent is [eq]#(pname:codedExtent.width,
    pname:codedExtent.height / 2)#, if the picture represents a field and
    the picture layout of the used <<decode-h264-profile,H.264 decode
    profile>> is
    ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_KHR.

Where pname:codedOffset and pname:codedExtent are the members of the
slink:VkVideoPictureResourceInfoKHR structure corresponding to the picture.

However, accesses to image data within a video picture resource happen at
the granularity indicated by
slink:VkVideoCapabilitiesKHR::pname:pictureAccessGranularity, as returned by
flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the used <<video-profiles,
video profile>>.
This means that the complete image subregion accessed by video coding
operations using an <<decode-h264-profile,H.264 decode profile>> for the
video picture resource is defined as the set of texels within the coordinate
range:

  {empty}:: [eq]#([pname:startX,pname:endX),[pname:startY,pname:endY))#

Where:

  * [eq]#pname:startX# equals pname:imageOffset.x rounded down to the
    nearest integer multiple of pname:pictureAccessGranularity.width;
  * [eq]#pname:endX# equals [eq]#pname:imageOffset.x {plus}
    pname:imageExtent.width# rounded up to the nearest integer multiple of
    pname:pictureAccessGranularity.width and clamped to the width of the
    image subresource <<video-image-subresource-reference,referred>> to by
    the corresponding slink:VkVideoPictureResourceInfoKHR structure;
  * [eq]#startY# equals pname:imageOffset.y rounded down to the nearest
    integer multiple of pname:pictureAccessGranularity.height;
  * [eq]#endY# equals [eq]#pname:imageOffset.y {plus}
    pname:imageExtent.height# rounded up to the nearest integer multiple of
    pname:pictureAccessGranularity.height and clamped to the height of the
    image subresource <<video-image-subresource-reference,referred>> to by
    the corresponding slink:VkVideoPictureResourceInfoKHR structure.

In case of video decode operations using an <<decode-h264-profile,H.264
decode profile>>, any access to a picture at the coordinates
[eq]#(pname:x,pname:y)#, as defined by the <<itu-t-h264,ITU-T H.264
Specification>>, is an access to the image subresource
<<video-image-subresource-reference,referred>> to by the corresponding
slink:VkVideoPictureResourceInfoKHR structure at the texel coordinates
specified below:

  * [eq]#(pname:x,pname:y)#, if the accessed picture represents a frame.
  * [eq]#(pname:x,pname:y {times} 2)#, if the accessed picture represents a
    top field and the picture layout of the used <<decode-h264-profile,H.264
    decode profile>> is
    ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR.
  * [eq]#(pname:x,pname:y {times} 2 {plus} 1)#, if the accessed picture
    represents a bottom field and the picture layout of the used
    <<decode-h264-profile,H.264 decode profile>> is
    ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR.
  * [eq]#(pname:x,pname:y)#, if the accessed picture represents a top field
    and the picture layout of the used <<decode-h264-profile,H.264 decode
    profile>> is
    ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_KHR.
  * [eq]#(pname:codedOffset.x {plus} pname:x,pname:codedOffset.y {plus}
    pname:y)#, if the accessed picture represents a bottom field and the
    picture layout of the used <<decode-h264-profile,H.264 decode profile>>
    is
    ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_KHR.

Where pname:codedOffset is the member of the corresponding
slink:VkVideoPictureResourceInfoKHR structure.


[[decode-h264-profile]]
=== H.264 Decode Profile

[open,refpage='VkVideoDecodeH264ProfileInfoKHR',desc='Structure specifying H.264 decode-specific video profile parameters',type='structs']
--
A video profile supporting H.264 video decode operations is specified by
setting slink:VkVideoProfileInfoKHR::pname:videoCodecOperation to
ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR and adding a
sname:VkVideoDecodeH264ProfileInfoKHR structure to the
slink:VkVideoProfileInfoKHR::pname:pNext chain.

The sname:VkVideoDecodeH264ProfileInfoKHR structure is defined as:

include::{generated}/api/structs/VkVideoDecodeH264ProfileInfoKHR.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:stdProfileIdc is a code:StdVideoH264ProfileIdc value specifying
    the H.264 codec profile IDC, as defined in section A.2 of the
    <<itu-t-h264,ITU-T H.264 Specification>>.
  * pname:pictureLayout is a elink:VkVideoDecodeH264PictureLayoutFlagBitsKHR
    value specifying the picture layout used by the H.264 video sequence to
    be decoded.

include::{generated}/validity/structs/VkVideoDecodeH264ProfileInfoKHR.adoc[]
--

[open,refpage='VkVideoDecodeH264PictureLayoutFlagBitsKHR',desc='H.264 video decode picture layout flags',type='enums']
--
The H.264 video decode picture layout flags are defined as follows:

include::{generated}/api/enums/VkVideoDecodeH264PictureLayoutFlagBitsKHR.adoc[]

  * ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_KHR specifies
    support for progressive content.
    This flag has the value `0`.
  * ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR
    specifies support for or use of a picture layout for interlaced content
    where all lines belonging to the top field are decoded to the
    even-numbered lines within the picture resource, and all lines belonging
    to the bottom field are decoded to the odd-numbered lines within the
    picture resource.
  * ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_KHR
    specifies support for or use of a picture layout for interlaced content
    where all lines belonging to a field are grouped together in a single
    image subregion, and the two fields comprising the frame can: be stored
    in separate image subregions of the same image subresource or in
    separate image subresources.
--

[open,refpage='VkVideoDecodeH264PictureLayoutFlagsKHR',desc='Bitmask of VkVideoDecodeH264PictureLayoutFlagBitsKHR',type='flags']
--
include::{generated}/api/flags/VkVideoDecodeH264PictureLayoutFlagsKHR.adoc[]

tname:VkVideoDecodeH264PictureLayoutFlagsKHR is a bitmask type for setting a
mask of zero or more elink:VkVideoDecodeH264PictureLayoutFlagBitsKHR.
--


=== H.264 Decode Capabilities

[open,refpage='VkVideoDecodeH264CapabilitiesKHR',desc='Structure describing H.264 decode capabilities',type='structs']
--
When calling flink:vkGetPhysicalDeviceVideoCapabilitiesKHR to query the
capabilities for an <<decode-h264-profile,H.264 decode profile>>, the
slink:VkVideoCapabilitiesKHR::pname:pNext chain must: include a
sname:VkVideoDecodeH264CapabilitiesKHR structure that will be filled with
the profile-specific capabilities.

The sname:VkVideoDecodeH264CapabilitiesKHR structure is defined as:

include::{generated}/api/structs/VkVideoDecodeH264CapabilitiesKHR.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:maxLevelIdc is a code:StdVideoH264LevelIdc value indicating the
    maximum H.264 level supported by the profile, where enum constant
    `STD_VIDEO_H264_LEVEL_IDC_<major>_<minor>` identifies H.264 level
    `<major>.<minor>` as defined in section A.3 of the <<itu-t-h264,ITU-T
    H.264 Specification>>.
  * pname:fieldOffsetGranularity is the minimum alignment for
    slink:VkVideoPictureResourceInfoKHR::pname:codedOffset specified for a
    <<video-picture-resources,video picture resource>> when using the
    picture layout
    ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_KHR.

include::{generated}/validity/structs/VkVideoDecodeH264CapabilitiesKHR.adoc[]
--


[[decode-h264-parameter-sets]]
=== H.264 Decode Parameter Sets

<<video-session-parameters,Video session parameters>> objects created with
the video codec operation ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR
can: contain the following types of parameters:

:operationType: decode
include::{chapters}/video/h264_parameter_sets.adoc[]

[open,refpage='VkVideoDecodeH264SessionParametersCreateInfoKHR',desc='Structure specifies H.264 decoder parameter set information',type='structs']
--
When a <<video-session-parameters,video session parameters>> object is
created with the codec operation
ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, the
slink:VkVideoSessionParametersCreateInfoKHR::pname:pNext chain must: include
a sname:VkVideoDecodeH264SessionParametersCreateInfoKHR structure specifying
the capacity and initial contents of the object.

The sname:VkVideoDecodeH264SessionParametersCreateInfoKHR structure is
defined as:

include::{generated}/api/structs/VkVideoDecodeH264SessionParametersCreateInfoKHR.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:maxStdSPSCount is the maximum number of <<decode-h264-sps,H.264
    SPS>> entries the created sname:VkVideoSessionParametersKHR can:
    contain.
  * pname:maxStdPPSCount is the maximum number of <<decode-h264-pps,H.264
    PPS>> entries the created sname:VkVideoSessionParametersKHR can:
    contain.
  * pname:pParametersAddInfo is `NULL` or a pointer to a
    slink:VkVideoDecodeH264SessionParametersAddInfoKHR structure specifying
    H.264 parameters to add upon object creation.

include::{generated}/validity/structs/VkVideoDecodeH264SessionParametersCreateInfoKHR.adoc[]
--

[open,refpage='VkVideoDecodeH264SessionParametersAddInfoKHR',desc='Structure specifies H.264 decoder parameter set information',type='structs']
--
The sname:VkVideoDecodeH264SessionParametersAddInfoKHR structure is defined
as:

include::{generated}/api/structs/VkVideoDecodeH264SessionParametersAddInfoKHR.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:stdSPSCount is the number of elements in the pname:pStdSPSs array.
  * pname:pStdSPSs is a pointer to an array of
    code:StdVideoH264SequenceParameterSet structures describing the
    <<decode-h264-sps,H.264 SPS>> entries to add.
  * pname:stdPPSCount is the number of elements in the pname:pStdPPSs array.
  * pname:pStdPPSs is a pointer to an array of
    code:StdVideoH264PictureParameterSet structures describing the
    <<decode-h264-pps,H.264 PPS>> entries to add.

This structure can: be specified in the following places:

  * In the pname:pParametersAddInfo member of the
    slink:VkVideoDecodeH264SessionParametersCreateInfoKHR structure
    specified in the pname:pNext chain of
    slink:VkVideoSessionParametersCreateInfoKHR used to create a
    <<video-session-parameters,video session parameters>> object.
    In this case, if the video codec operation the video session parameters
    object is created with is
    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, then it defines the
    set of initial parameters to add to the created object (see
    <<creating-video-session-parameters,Creating Video Session
    Parameters>>).
  * In the pname:pNext chain of slink:VkVideoSessionParametersUpdateInfoKHR.
    In this case, if the video codec operation the
    <<video-session-parameters,video session parameters>> object to be
    updated was created with is
    ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, then it defines the
    set of parameters to add to it (see
    <<video-session-parameters-update,Updating Video Session Parameters>>).

.Valid Usage
****
  * [[VUID-VkVideoDecodeH264SessionParametersAddInfoKHR-None-04825]]
    The pname:seq_parameter_set_id member of each
    code:StdVideoH264SequenceParameterSet structure specified in the
    elements of pname:pStdSPSs must: be unique within pname:pStdSPSs
  * [[VUID-VkVideoDecodeH264SessionParametersAddInfoKHR-None-04826]]
    The pair constructed from the pname:seq_parameter_set_id and
    pname:pic_parameter_set_id members of each
    code:StdVideoH264PictureParameterSet structure specified in the elements
    of pname:pStdPPSs must: be unique within pname:pStdPPSs
****

include::{generated}/validity/structs/VkVideoDecodeH264SessionParametersAddInfoKHR.adoc[]
--


=== H.264 Decoding Parameters

[open,refpage='VkVideoDecodeH264PictureInfoKHR',desc='Structure specifies H.264 decode picture parameters when decoding a picture',type='structs']
--
The sname:VkVideoDecodeH264PictureInfoKHR structure is defined as:

include::{generated}/api/structs/VkVideoDecodeH264PictureInfoKHR.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:pStdPictureInfo is a pointer to a
    code:StdVideoDecodeH264PictureInfo structure specifying
    <<decode-h264-picture-info,H.264 picture information>>.
  * pname:sliceCount is the number of elements in pname:pSliceOffsets.
  * pname:pSliceOffsets is a pointer to an array of pname:sliceCount offsets
    specifying the start offset of the slices of the picture within the
    video bitstream buffer range specified in slink:VkVideoDecodeInfoKHR.

This structure is specified in the pname:pNext chain of the
slink:VkVideoDecodeInfoKHR structure passed to flink:vkCmdDecodeVideoKHR to
specify the codec-specific picture information for an <<decode-h264,H.264
decode operation>>.

[[decode-h264-output-picture-info]]
Decode Output Picture Information::

When this structure is specified in the pname:pNext chain of the
slink:VkVideoDecodeInfoKHR structure passed to flink:vkCmdDecodeVideoKHR,
the information related to the <<decode-output-picture-info,decode output
picture>> is defined as follows:

  * If pname:pStdPictureInfo->flags.field_pic_flag is not set, then the
    picture represents a frame.
  * If pname:pStdPictureInfo->flags.field_pic_flag is set, then the picture
    represents a field.
    Specifically:
  ** If pname:pStdPictureInfo->flags.bottom_field_flag is not set, then the
     picture represents the top field of the frame.
  ** If pname:pStdPictureInfo->flags.bottom_field_flag is set, then the
     picture represents the bottom field of the frame.
  * The image subregion used is determined according to the
    <<decode-h264-picture-data-access,H.264 Decode Picture Data Access>>
    section.
  * The decode output picture is associated with the
    <<decode-h264-picture-info,H.264 picture information>> provided in
    pname:pStdPictureInfo.

[[decode-h264-picture-info]]
Std Picture Information::

The members of the code:StdVideoDecodeH264PictureInfo structure pointed to
by pname:pStdPictureInfo are interpreted as follows:

  * code:reserved1 and code:reserved2 are used only for padding purposes and
    are otherwise ignored;
  * code:flags.is_intra as defined in section 3.73 of the <<itu-t-h264,ITU-T
    H.264 Specification>>;
  * code:flags.is_reference as defined in section 3.136 of the <<itu-t-h264,
    ITU-T H.264 Specification>>;
  * code:flags.complementary_field_pair as defined in section 3.35 of the
    <<itu-t-h264,ITU-T H.264 Specification>>;
  * code:seq_parameter_set_id and code:pic_parameter_set_id are used to
    identify the active parameter sets, as described below;
  * all other members are interpreted as defined in section 7.4.3 of the
    <<itu-t-h264,ITU-T H.264 Specification>>.

[[decode-h264-ref-pic-setup]]
Reference picture setup is controlled by the value of
code:StdVideoDecodeH264PictureInfo::pname:flags.is_reference.
If it is set and a <<decode-reconstructed-picture-info,reconstructed
picture>> is specified, then the latter is used as the target of picture
reconstruction to <<dpb-slot-states,activate>> the <<dpb-slot,DPB slot>>
specified in pname:pDecodeInfo->pSetupReferenceSlot->slotIndex.
If code:StdVideoDecodeH264PictureInfo::pname:flags.is_reference is not set,
but a <<decode-reconstructed-picture-info,reconstructed picture>> is
specified, then the corresponding picture reference associated with the
<<dpb-slot,DPB slot>> is invalidated, as described in the
<<dpb-slot-states,DPB Slot States>> section.

Active Parameter Sets::

The members of the code:StdVideoDecodeH264PictureInfo structure pointed to
by pname:pStdPictureInfo are used to select the active parameter sets to use
from the bound video session parameters object, as follows:

  * [[decode-h264-active-sps]] The _active SPS_ is the
    <<decode-h264-sps,SPS>> identified by the key specified in
    code:StdVideoDecodeH264PictureInfo::code:seq_parameter_set_id.
  * [[decode-h264-active-pps]] The _active PPS_ is the
    <<decode-h264-pps,PPS>> identified by the key specified by the pair
    constructed from
    code:StdVideoDecodeH264PictureInfo::code:seq_parameter_set_id and
    code:StdVideoDecodeH264PictureInfo::code:pic_parameter_set_id.

include::{generated}/validity/structs/VkVideoDecodeH264PictureInfoKHR.adoc[]
--

[open,refpage='VkVideoDecodeH264DpbSlotInfoKHR',desc='Structure specifies H.264 decode DPB picture information',type='structs']
--
The sname:VkVideoDecodeH264DpbSlotInfoKHR structure is defined as:

include::{generated}/api/structs/VkVideoDecodeH264DpbSlotInfoKHR.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:pStdReferenceInfo is a pointer to a
    code:StdVideoDecodeH264ReferenceInfo structure specifying
    <<decode-h264-reference-info,H.264 reference information>>.

This structure is specified in the pname:pNext chain of
slink:VkVideoDecodeInfoKHR::pname:pSetupReferenceSlot, if not `NULL`, and
the pname:pNext chain of the elements of
slink:VkVideoDecodeInfoKHR::pname:pReferenceSlots to specify the
codec-specific reference picture information for an <<decode-h264,H.264
decode operation>>.

[[decode-h264-active-reference-picture-info]]
Active Reference Picture Information::

When this structure is specified in the pname:pNext chain of the elements of
slink:VkVideoDecodeInfoKHR::pname:pReferenceSlots, one or two elements are
added to the list of <<decode-active-reference-picture-info,active reference
pictures>> used by the video decode operation for each element of
slink:VkVideoDecodeInfoKHR::pname:pReferenceSlots as follows:

  * If neither pname:pStdReferenceInfo->flags.top_field_flag nor
    pname:pStdReferenceInfo->flags.bottom_field_flag is set, then the
    picture is added as a frame reference to the list of active reference
    pictures.
  * If pname:pStdReferenceInfo->flags.top_field_flag is set, then the
    picture is added as a top field reference to the list of active
    reference pictures.
  * If pname:pStdReferenceInfo->flags.bottom_field_flag is set, then the
    picture is added as a bottom field reference to the list of active
    reference pictures.
  * For each added reference picture, the corresponding image subregion used
    is determined according to the <<decode-h264-picture-data-access,H.264
    Decode Picture Data Access>> section.
  * Each added reference picture is associated with the <<dpb-slot,DPB
    slot>> index specified in the pname:slotIndex member of the
    corresponding element of
    slink:VkVideoDecodeInfoKHR::pname:pReferenceSlots.
  * Each added reference picture is associated with the
    <<decode-h264-reference-info,H.264 reference information>> provided in
    pname:pStdReferenceInfo.

[NOTE]
.Note
====
When both the top and bottom field of an interlaced frame currently
associated with a DPB slot is intended to be used as an active reference
picture and both fields are stored in the same image subregion (which is the
case when using
ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR
which stores the two fields at even and odd scanlines of the same image
subregion), both references have to be provided through a single
slink:VkVideoReferenceSlotInfoKHR structure that has both
code:flags.top_field_flag and code:flags.bottom_field_flag set in the
code:StdVideoDecodeH264ReferenceInfo structure pointed to by the
pname:pStdReferenceInfo member of the slink:VkVideoDecodeH264DpbSlotInfoKHR
structure included in the corresponding slink:VkVideoReferenceSlotInfoKHR
structure's pname:pNext chain.
However, this approach can only be used when both fields are stored in the
same image subregion.
If that is not the case (e.g. when using
ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_KHR
which requires separate pname:codedOffset values for the two fields and also
allows storing the two fields of a frame in separate image layers or
entirely separate images), then a separate slink:VkVideoReferenceSlotInfoKHR
structure needs to be provided for referencing the two fields, each only
setting one of code:flags.top_field_flag or code:flags.bottom_field_flag,
and providing the appropriate video picture resource information in
slink:VkVideoReferenceSlotInfoKHR::pname:pPictureResource.
====

[[decode-h264-reconstructed-picture-info]]
Reconstructed Picture Information::

When this structure is specified in the pname:pNext chain of
slink:VkVideoDecodeInfoKHR::pname:pSetupReferenceSlot, the information
related to the <<decode-reconstructed-picture-info,reconstructed picture>>
is defined as follows:

  * If neither pname:pStdReferenceInfo->flags.top_field_flag nor
    pname:pStdReferenceInfo->flags.bottom_field_flag is set, then the
    picture represents a frame.
  * If pname:pStdReferenceInfo->flags.top_field_flag is set, then the
    picture represents a field, specifically, the top field of the frame.
  * If pname:pStdReferenceInfo->flags.bottom_field_flag is set, then the
    picture represents a field, specifically, the bottom field of the frame.
  * The image subregion used is determined according to the
    <<decode-h264-picture-data-access,H.264 Decode Picture Data Access>>
    section.
  * If <<decode-ref-pic-setup,reference picture setup>> is requested, then
    the reconstructed picture is used to <<dpb-slot-states,activate>> the
    <<dpb-slot,DPB slot>> with the index specified in
    slink:VkVideoDecodeInfoKHR::pname:pSetupReferenceSlot->slotIndex.
  * The reconstructed picture is associated with the
    <<decode-h264-reference-info,H.264 reference information>> provided in
    pname:pStdReferenceInfo.

[[decode-h264-reference-info]]
Std Reference Information::

The members of the code:StdVideoDecodeH264ReferenceInfo structure pointed to
by pname:pStdReferenceInfo are interpreted as follows:

  * code:flags.top_field_flag is used to indicate whether the reference is
    used as top field reference;
  * code:flags.bottom_field_flag is used to indicate whether the reference
    is used as bottom field reference;
  * code:flags.used_for_long_term_reference is used to indicate whether the
    picture is marked as "`used for long-term reference`" as defined in
    section 8.2.5.1 of the <<itu-t-h264,ITU-T H.264 Specification>>;
  * code:flags.is_non_existing is used to indicate whether the picture is
    marked as "`non-existing`" as defined in section 8.2.5.2 of the
    <<itu-t-h264,ITU-T H.264 Specification>>;
  * all other members are interpreted as defined in section 8.2 of the
    <<itu-t-h264,ITU-T H.264 Specification>>.

include::{generated}/validity/structs/VkVideoDecodeH264DpbSlotInfoKHR.adoc[]
--


[[decode-h264-requirements]]
=== H.264 Decode Requirements

This section describes the required: H.264 decoding capabilities for
physical devices that have at least one queue family that supports the video
codec operation ename:VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR, as
returned by flink:vkGetPhysicalDeviceQueueFamilyProperties2 in
slink:VkQueueFamilyVideoPropertiesKHR::pname:videoCodecOperations.

.Required <<video-std-header-version,Video Std Header Versions>>
[options="header"]
|====
| Video Std Header Name | Version
| `vulkan_video_codec_h264std_decode` | 1.0.0
|====

ifdef::VK_KHR_video_maintenance1[]
.Required Video Capabilities
[width="100%",cols="<35,<14,<11",options="header"]
|====
| Video Capability | Requirement | Requirement Type^1^
| **slink:VkVideoCapabilitiesKHR** | |
| pname:flags | - | min
| pname:minBitstreamBufferOffsetAlignment | 4096 | max
| pname:minBitstreamBufferSizeAlignment | 4096 | max
| pname:pictureAccessGranularity | (64,64) | max
| pname:minCodedExtent | - | max
| pname:maxCodedExtent | - | min
| pname:maxDpbSlots | 0 | min
| pname:maxActiveReferencePictures | 0 | min
| **slink:VkVideoDecodeCapabilitiesKHR** | |
| pname:flags | ename:VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR or
                ename:VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR | min
| **slink:VkVideoDecodeH264CapabilitiesKHR** | |
| pname:maxLevelIdc | code:STD_VIDEO_H264_LEVEL_IDC_1_0 | min
| pname:fieldOffsetGranularity | (0,0) except for profiles using ename:VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_KHR | implementation-dependent
|====

1::
    The *Requirement Type* column specifies the requirement is either the
    minimum value all implementations must: support, the maximum value all
    implementations must: support, or the exact value all implementations
    must: support.
    For bitmasks a minimum value is the least bits all implementations must:
    set, but they may: have additional bits set beyond this minimum.
endif::VK_KHR_video_maintenance1[]
