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

[[encode-h265]]
== Encode H.265

The `apiext:VK_EXT_video_encode_h265` extension adds H.265 codec-specific
structures/types needed to support H.265 video encoding.
Unless otherwise noted, all references to the H.265 specification are to the
2013 edition published by the ITU-T, dated April 2013.
This specification is available at https://www.itu.int/rec/T-REC-H.265.

[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.
====


=== H.265 Encode Profile

An H.265 encode profile is specified by including the
slink:VkVideoEncodeH265ProfileInfoEXT structure in the pname:pNext chain of
the slink:VkVideoProfileInfoKHR structure when
slink:VkVideoProfileInfoKHR::pname:videoCodecOperation is
ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_EXT.

[open,refpage='VkVideoEncodeH265ProfileInfoEXT',desc='Structure specifying H.265 encode profile',type='structs']
--
The sname:VkVideoEncodeH265ProfileInfoEXT structure is defined as:

include::{generated}/api/structs/VkVideoEncodeH265ProfileInfoEXT.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:StdVideoH265ProfileIdc value specifying
    the H.265 codec profile IDC.

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


=== Capabilities

[open,refpage='VkVideoEncodeH265CapabilitiesEXT',desc='Structure specifying H.265 encode capabilities',type='structs']
--
When calling flink:vkGetPhysicalDeviceVideoCapabilitiesKHR with
pname:pVideoProfile->videoCodecOperation specified as
ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_EXT, the
slink:VkVideoEncodeH265CapabilitiesEXT structure must: be included in the
pname:pNext chain of the slink:VkVideoCapabilitiesKHR structure to retrieve
more capabilities specific to H.265 video encoding.

The sname:VkVideoEncodeH265CapabilitiesEXT structure is defined as:

include::{generated}/api/structs/VkVideoEncodeH265CapabilitiesEXT.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:flags is a bitmask of elink:VkVideoEncodeH265CapabilityFlagBitsEXT
    indicating supported H.265 encoding capabilities.
  * pname:maxLevelIdc is a code:StdVideoH265LevelIdc value indicating the
    maximum H.265 level supported.
  * pname:maxSliceSegmentCount indicates the maximum number of slice
    segments that can: be encoded for a single picture.
    Further restrictions may: apply to the number of slice segments that
    can: be encoded for a single picture depending on other capabilities and
    codec-specific rules.
  * pname:maxTiles indicates the maximum number of H.265 tile columns and
    rows that can: be encoded for a single picture.
    Further restrictions may: apply to the number of H.265 tiles that can:
    be encoded for a single picture depending on other capabilities and
    codec-specific rules.
  * pname:ctbSizes is a bitmask of elink:VkVideoEncodeH265CtbSizeFlagBitsEXT
    describing the supported CTB sizes.
  * pname:transformBlockSizes is a bitmask of
    elink:VkVideoEncodeH265TransformBlockSizeFlagBitsEXT describing the
    supported transform block sizes.
  * pname:maxPPictureL0ReferenceCount indicates the maximum number of
    reference pictures the implementation supports in the reference list L0
    for P pictures.
  * pname:maxBPictureL0ReferenceCount indicates the maximum number of
    reference pictures the implementation supports in the reference list L0
    for B pictures.
    The reported value is `0` if encoding of B pictures is not supported.
  * pname:maxL1ReferenceCount indicates the maximum number of reference
    pictures the implementation supports in the reference list L1 if
    encoding of B pictures is supported.
    The reported value is `0` if encoding of B pictures is not supported.
  * pname:maxSubLayerCount indicates the maximum number of H.265 sub-layers
    supported by the implementation.
  * pname:expectDyadicTemporalSubLayerPattern indicates that the
    implementation's rate control algorithms expect the application to use a
    dyadic temporal sub-layer pattern when encoding multiple temporal
    sub-layers.
  * pname:minQp indicates the minimum QP value supported.
  * pname:maxQp indicates the maximum QP value supported.
  * pname:prefersGopRemainingFrames indicates that the implementation's rate
    control algorithm prefers the application to specify the number of
    frames of each type remaining in the current group of pictures.
  * pname:requiresGopRemainingFrames indicates that the implementation's
    rate control algorithm requires the application to specify the number of
    frames of each type remaining in the current group of pictures.
  * pname:stdSyntaxFlags is a bitmask of
    elink:VkVideoEncodeH265StdFlagBitsEXT indicating capabilities related to
    H.265 syntax elements.

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

[open,refpage='VkVideoEncodeH265CapabilityFlagBitsEXT',desc='Video encode H.265 capability flags',type='enums']
--
Bits which may: be set in
slink:VkVideoEncodeH265CapabilitiesEXT::pname:flags indicating the supported
H.265 encoding capabilities, are:

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

  * ename:VK_VIDEO_ENCODE_H265_CAPABILITY_HRD_COMPLIANCE_BIT_EXT indicates
    if the implementation guarantees generating a HRD compliant bitstream if
    code:nal_hrd_parameters_present_flag,
    code:vcl_hrd_parameters_present_flag, or
    code:sub_pic_hrd_params_present_flag are enabled in
    code:StdVideoH265HrdFlags, or code:vui_hrd_parameters_present_flag is
    enabled in code:StdVideoH265SpsVuiFlags.
  * ename:VK_VIDEO_ENCODE_H265_CAPABILITY_PREDICTION_WEIGHT_TABLE_GENERATED_BIT_EXT
    indicates that when code:weighted_pred_flag or code:weighted_bipred_flag
    in code:StdVideoH265PpsFlags are enabled, the implementation is able to
    internally decide syntax for code:pred_weight_table.
  * ename:VK_VIDEO_ENCODE_H265_CAPABILITY_ROW_UNALIGNED_SLICE_SEGMENT_BIT_EXT
    indicates that each slice segment in a frame with a single or multiple
    tiles per slice may begin or finish at any offset in a CTB row.
    If not supported, all slice segments in such a frame must: begin at the
    start of a CTB row (and hence each slice segment must: finish at the end
    of a CTB row).
    Also indicates that each slice segment in a frame with multiple slices
    per tile may begin or finish at any offset within the enclosing tile's
    CTB row.
    If not supported, slice segments in such a frame must: begin at the
    start of the enclosing tile's CTB row (and hence each slice segment
    must: finish at the end of the enclosing tile's CTB row).
  * ename:VK_VIDEO_ENCODE_H265_CAPABILITY_DIFFERENT_SLICE_SEGMENT_TYPE_BIT_EXT
    indicates that when a frame is encoded with multiple slice segments, the
    implementation allows encoding each slice segment with a different
    code:StdVideoEncodeH265SliceSegmentHeader::code:slice_type.
    If not supported, all slice segments of the frame must: be encoded with
    the same code:slice_type which corresponds to the picture type of the
    frame.
    For example, all slice segments of a P-frame would be encoded as
    P-slices.
  * ename:VK_VIDEO_ENCODE_H265_CAPABILITY_B_FRAME_IN_L0_LIST_BIT_EXT
    indicates support for using a B frame as L0 reference.
  * ename:VK_VIDEO_ENCODE_H265_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_EXT
    indicates support for using a B frame as L1 reference.
  * ename:VK_VIDEO_ENCODE_H265_CAPABILITY_PER_PICTURE_TYPE_MIN_MAX_QP_BIT_EXT
    indicates support for specifying different QP values in the members of
    slink:VkVideoEncodeH265QpEXT.
  * ename:VK_VIDEO_ENCODE_H265_CAPABILITY_PER_SLICE_SEGMENT_CONSTANT_QP_BIT_EXT
    indicates support for specifying different constant QP values for each
    slice segment.
  * ename:VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_TILES_PER_SLICE_SEGMENT_BIT_EXT
    indicates if encoding multiple tiles per slice segment is supported.
    If not set, the implementation is only able to encode a single tile for
    each slice segment.
  * ename:VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_SLICE_SEGMENTS_PER_TILE_BIT_EXT
    indicates if encoding multiple slice segments per tile is supported.
    If not set, the implementation is only able to encode a single slice
    segment for each tile.
--

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

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

[open,refpage='VkVideoEncodeH265StdFlagBitsEXT',desc='Video encode H.265 syntax capability flags',type='enums']
--
Bits which may: be set in
slink:VkVideoEncodeH265CapabilitiesEXT::pname:stdSyntaxFlags, indicating the
capabilities related to the H.265 syntax elements, are:

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

  * ename:VK_VIDEO_ENCODE_H265_STD_SEPARATE_COLOR_PLANE_FLAG_SET_BIT_EXT
    indicates if enabling code:separate_colour_plane_flag in
    code:StdVideoH265SpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_SAMPLE_ADAPTIVE_OFFSET_ENABLED_FLAG_SET_BIT_EXT
    indicates if enabling code:sample_adaptive_offset_enabled_flag in
    code:StdVideoH265SpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_SCALING_LIST_DATA_PRESENT_FLAG_SET_BIT_EXT
    indicates if enabling code:scaling_list_enabled_flag and
    code:sps_scaling_list_data_present_flag in code:StdVideoH265SpsFlags, or
    enabling code:pps_scaling_list_data_present_flag in
    code:StdVideoH265PpsFlags are supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_PCM_ENABLED_FLAG_SET_BIT_EXT indicates if
    enabling code:pcm_enable_flag in code:StdVideoH265SpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_SPS_TEMPORAL_MVP_ENABLED_FLAG_SET_BIT_EXT
    indicates if enabling code:sps_temporal_mvp_enabled_flag in
    code:StdVideoH265SpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_INIT_QP_MINUS26_BIT_EXT indicates if
    setting non-zero code:init_qp_minus26 in
    code:StdVideoH265PictureParameterSet is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_WEIGHTED_PRED_FLAG_SET_BIT_EXT indicates
    if enabling code:weighted_pred_flag in code:StdVideoH265PpsFlags is
    supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_WEIGHTED_BIPRED_FLAG_SET_BIT_EXT
    indicates if enabling code:weighted_bipred_flag in
    code:StdVideoH265PpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_LOG2_PARALLEL_MERGE_LEVEL_MINUS2_BIT_EXT
    indicates if setting non-zero value for
    code:log2_parallel_merge_level_minus2 in
    code:StdVideoH265PictureParameterSet is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_SIGN_DATA_HIDING_ENABLED_FLAG_SET_BIT_EXT
    indicates if enabling code:sign_data_hiding_enabled_flag in
    code:StdVideoH265PpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_TRANSFORM_SKIP_ENABLED_FLAG_SET_BIT_EXT
    indicates if enabling code:transform_skip_enabled_flag in
    code:StdVideoH265PpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_TRANSFORM_SKIP_ENABLED_FLAG_UNSET_BIT_EXT
    indicates if disabling code:transform_skip_enabled_flag in
    code:StdVideoH265PpsFlags is supported.
    Implementations must: report at least one of
    ename:VK_VIDEO_ENCODE_H265_STD_TRANSFORM_SKIP_ENABLED_FLAG_SET_BIT_EXT
    and
    ename:VK_VIDEO_ENCODE_H265_STD_TRANSFORM_SKIP_ENABLED_FLAG_UNSET_BIT_EXT
    as supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_PPS_SLICE_CHROMA_QP_OFFSETS_PRESENT_FLAG_SET_BIT_EXT
    indicates if enabling code:pps_slice_chroma_qp_offsets_present_flag in
    code:StdVideoH265PpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_TRANSQUANT_BYPASS_ENABLED_FLAG_SET_BIT_EXT
    indicates if enabling code:transquant_bypass_enabled_flag in
    code:StdVideoH265PpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_CONSTRAINED_INTRA_PRED_FLAG_SET_BIT_EXT
    indicates if enabling code:constrained_intra_pred_flag in
    code:StdVideoH265PpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_ENTROPY_CODING_SYNC_ENABLED_FLAG_SET_BIT_EXT
    indicates if enabling code:entropy_coding_sync_enabled_flag in
    code:StdVideoH265PpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_DEBLOCKING_FILTER_OVERRIDE_ENABLED_FLAG_SET_BIT_EXT
    indicates if enabling code:deblocking_filter_override_enabled_flag in
    code:StdVideoH265PpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_DEPENDENT_SLICE_SEGMENTS_ENABLED_FLAG_SET_BIT_EXT
    indicates if enabling code:dependent_slice_segments_enabled_flag in
    code:StdVideoH265PpsFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_DEPENDENT_SLICE_SEGMENT_FLAG_SET_BIT_EXT
    indicates if enabling code:dependent_slice_segment_flag in
    code:StdVideoEncodeH265SliceHeaderFlags is supported.
  * ename:VK_VIDEO_ENCODE_H265_STD_SLICE_QP_DELTA_BIT_EXT indicates whether
    the implementation supports using the application-provided value for
    code:StdVideoEncodeH265SliceSegmentHeader::code:slice_qp_delta when that
    value is identical across the slice segments of the encoded frame.
  * ename:VK_VIDEO_ENCODE_H265_STD_DIFFERENT_SLICE_QP_DELTA_BIT_EXT
    indicates whether the implementation supports using the
    application-provided value for
    code:StdVideoEncodeH265SliceSegmentHeader::code:slice_qp_delta when that
    value is different across the slice segments of the encoded frame.
--

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

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

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

tname:VkVideoEncodeH265CtbSizeFlagsEXT is a bitmask type for setting a mask
of zero or more elink:VkVideoEncodeH265CtbSizeFlagBitsEXT.
Implementations must: set at least one of
ename:VkVideoEncodeH265CtbSizeFlagBitsEXT.
--

[open,refpage='VkVideoEncodeH265CtbSizeFlagBitsEXT',desc='Supported CTB sizes for H.265 video encode',type='enums']
--
Bits which may: be set in
slink:VkVideoEncodeH265CapabilitiesEXT::pname:ctbSizes, indicating the CTB
sizes supported by the implementation, are:

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

  * ename:VK_VIDEO_ENCODE_H265_CTB_SIZE_16_BIT_EXT specifies that a CTB size
    of 16x16 is supported.
  * ename:VK_VIDEO_ENCODE_H265_CTB_SIZE_32_BIT_EXT specifies that a CTB size
    of 32x32 is supported.
  * ename:VK_VIDEO_ENCODE_H265_CTB_SIZE_64_BIT_EXT specifies that a CTB size
    of 64x64 is supported.
--

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

tname:VkVideoEncodeH265TransformBlockSizeFlagsEXT is a bitmask type for
setting a mask of zero or more
elink:VkVideoEncodeH265TransformBlockSizeFlagBitsEXT.
Implementations must: set at least one of
ename:VkVideoEncodeH265TransformBlockSizeFlagBitsEXT.
--

[open,refpage='VkVideoEncodeH265TransformBlockSizeFlagBitsEXT',desc='Supported transform block sizes for H.265 video encode',type='enums']
--
Bits which may: be set in
slink:VkVideoEncodeH265CapabilitiesEXT::pname:transformBlockSizes,
indicating the transform block sizes supported by the implementation, are:

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

  * ename:VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_4_BIT_EXT specifies that
    a transform block size of 4x4 is supported.
  * ename:VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_8_BIT_EXT specifies that
    a transform block size of 8x8 is supported.
  * ename:VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_16_BIT_EXT specifies
    that a transform block size of 16x16 is supported.
  * ename:VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_32_BIT_EXT specifies
    that a transform block size of 32x32 is supported.
--


=== H.265 Encode Quality Level Properties

[open,refpage='VkVideoEncodeH265QualityLevelPropertiesEXT',desc='Structure describing the H.265 encode quality level properties',type='structs']
--
When calling flink:vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR
with pname:pVideoProfile->videoCodecOperation specified as
ename:VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_EXT, the
slink:VkVideoEncodeH265QualityLevelPropertiesEXT structure can: be included
in the pname:pNext chain of the slink:VkVideoEncodeQualityLevelPropertiesKHR
structure to retrieve additional video encode quality level properties
specific to H.265 encoding.

The slink:VkVideoEncodeH265QualityLevelPropertiesEXT structure is defined
as:

include::{generated}/api/structs/VkVideoEncodeH265QualityLevelPropertiesEXT.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:preferredRateControlFlags is a bitmask of
    elink:VkVideoEncodeH265RateControlFlagBitsEXT values indicating the
    preferred flags to use for
    slink:VkVideoEncodeH265RateControlInfoEXT::pname:flags.
  * pname:preferredGopFrameCount indicates the preferred value to use for
    slink:VkVideoEncodeH265RateControlInfoEXT::pname:gopFrameCount.
  * pname:preferredIdrPeriod indicates the preferred value to use for
    slink:VkVideoEncodeH265RateControlInfoEXT::pname:idrPeriod.
  * pname:preferredConsecutiveBFrameCount indicates the preferred value to
    use for
    slink:VkVideoEncodeH265RateControlInfoEXT::pname:consecutiveBFrameCount.
  * pname:preferredSubLayerCount indicates the preferred value to use for
    slink:VkVideoEncodeH265RateControlInfoEXT::pname:subLayerCount.
  * pname:preferredConstantQp indicates the preferred values to use for
    slink:VkVideoEncodeH265NaluSliceSegmentInfoEXT::pname:constantQp for
    each picture type when using rate control mode
    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR.
  * pname:preferredMaxL0ReferenceCount indicates the preferred maximum
    number of reference pictures to use in the reference list L0.
  * pname:preferredMaxL1ReferenceCount indicates the preferred maximum
    number of reference pictures to use in the reference list L1.

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


=== H.265 Encode Session

Additional parameters can be specified when creating a video session with an
H.265 encode profile by including an instance of the
slink:VkVideoEncodeH265SessionCreateInfoEXT structure in the pname:pNext
chain of slink:VkVideoSessionCreateInfoKHR.

[open,refpage='VkVideoEncodeH265SessionCreateInfoEXT',desc='Structure specifies H.265 encode session parameters',type='structs']
--
The sname:VkVideoEncodeH265SessionCreateInfoEXT structure is defined as:

include::{generated}/api/structs/VkVideoEncodeH265SessionCreateInfoEXT.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:useMaxLevelIdc indicates whether the value of pname:maxLevelIdc
    should be used by the implementation.
    When it is set to ename:VK_FALSE, the implementation ignores the value
    of pname:maxLevelIdc and uses the value of
    slink:VkVideoEncodeH265CapabilitiesEXT::pname:maxLevelIdc, as reported
    by flink:vkGetPhysicalDeviceVideoCapabilitiesKHR for the video profile.
  * pname:maxLevelIdc provides the upper bound on the H.265 level for the
    video bitstreams produced by the created video session.

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


=== Encoder H.265 Video Session Parameters Object

When creating a Video Session Parameters object, add a
slink:VkVideoEncodeH265SessionParametersCreateInfoEXT structure to the
pname:pNext chain of the slink:VkVideoSessionParametersCreateInfoKHR
structure passed to flink:vkCreateVideoSessionParametersKHR in order to
specify the H.265-specific video encoder session parameters.

[open,refpage='VkVideoEncodeH265SessionParametersCreateInfoEXT',desc='Structure specifies H.265 encoder parameter set info',type='structs']
--
The sname:VkVideoEncodeH265SessionParametersCreateInfoEXT structure is
defined as:

include::{generated}/api/structs/VkVideoEncodeH265SessionParametersCreateInfoEXT.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:maxStdVPSCount is the maximum number of entries of type
    code:StdVideoH265VideoParameterSet within
    sname:VkVideoSessionParametersKHR.
  * pname:maxStdSPSCount is the maximum number of entries of type
    code:StdVideoH265SequenceParameterSet within
    sname:VkVideoSessionParametersKHR.
  * pname:maxStdPPSCount is the maximum number of entries of type
    code:StdVideoH265PictureParameterSet within
    sname:VkVideoSessionParametersKHR.
  * pname:pParametersAddInfo is `NULL` or a pointer to a
    slink:VkVideoEncodeH265SessionParametersAddInfoEXT structure specifying
    the video session parameters to add upon creation of this object.

When a slink:VkVideoSessionParametersKHR object contains
pname:maxStdVPSCount code:StdVideoH265VideoParameterSet entries, no
additional code:StdVideoH265VideoParameterSet entries can be added to it,
and ename:VK_ERROR_TOO_MANY_OBJECTS will be returned if an attempt is made
to add these entries.
When a slink:VkVideoSessionParametersKHR object contains
pname:maxStdSPSCount code:StdVideoH265SequenceParameterSet entries, no
additional code:StdVideoH265SequenceParameterSet entries can be added to it,
and ename:VK_ERROR_TOO_MANY_OBJECTS will be returned if an attempt is made
to add these entries.
When a slink:VkVideoSessionParametersKHR object contains
pname:maxStdPPSCount code:StdVideoH265PictureParameterSet entries, no
additional code:StdVideoH265PictureParameterSet entries can be added to it,
and ename:VK_ERROR_TOO_MANY_OBJECTS will be returned if an attempt is made
to add these entries.

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

[open,refpage='VkVideoEncodeH265SessionParametersAddInfoEXT',desc='Structure specifies H.265 encoder parameter set info',type='structs']
--
The sname:VkVideoEncodeH265SessionParametersAddInfoEXT structure is defined
as:

include::{generated}/api/structs/VkVideoEncodeH265SessionParametersAddInfoEXT.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:stdVPSCount is the number of VPS elements in pname:pStdVPSs.
  * pname:pStdVPSs is a pointer to an array of pname:stdVPSCount
    code:StdVideoH265VideoParameterSet structures representing H.265 video
    parameter sets.
  * pname:stdSPSCount is the number of SPS elements in pname:pStdSPSs.
  * pname:pStdSPSs is a pointer to an array of pname:stdSPSCount
    code:StdVideoH265SequenceParameterSet structures representing H.265
    sequence parameter sets.
  * pname:stdPPSCount is the number of PPS elements in pname:pStdPPSs.
  * pname:pStdPPSs is a pointer to an array of pname:stdPPSCount
    code:StdVideoH265PictureParameterSet structures representing H.265
    picture parameter sets.

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

.Valid Usage
****
  * [[VUID-VkVideoEncodeH265SessionParametersAddInfoEXT-stdVPSCount-06438]]
    The values of pname:stdVPSCount, pname:stdSPSCount and pname:stdPPSCount
    must: be less than or equal to the values of
    slink:VkVideoEncodeH265SessionParametersCreateInfoEXT::pname:maxStdVPSCount,
    slink:VkVideoEncodeH265SessionParametersCreateInfoEXT:pname:maxStdSPSCount,
    and
    slink:VkVideoEncodeH265SessionParametersCreateInfoEXT:pname:maxStdPPSCount,
    respectively
  * [[VUID-VkVideoEncodeH265SessionParametersAddInfoEXT-pStdVPSs-06439]]
    Each code:StdVideoH265VideoParameterSet entry in pname:pStdVPSs must:
    have a unique H.265 VPS ID
  * [[VUID-VkVideoEncodeH265SessionParametersAddInfoEXT-pStdSPSs-06440]]
    Each code:StdVideoH265SequenceParameterSet entry in pname:pStdSPSs must:
    have a unique H.265 VPS-SPS ID pair
  * [[VUID-VkVideoEncodeH265SessionParametersAddInfoEXT-pStdPPSs-06441]]
    Each code:StdVideoH265PictureParameterSet entry in pname:pStdPPSs must:
    have a unique H.265 VPS-SPS-PPS ID tuple
  * [[VUID-VkVideoEncodeH265SessionParametersAddInfoEXT-None-06442]]
    Each entry to be added must: have a unique, to the rest of the parameter
    array entries and the existing parameters in the Video Session
    Parameters Object that is being updated, VPS-SPS-PPS IDs
  * [[VUID-VkVideoEncodeH265SessionParametersAddInfoEXT-None-06443]]
    Parameter entries that already exist in Video Session Parameters object
    with a particular VPS-SPS-PPS IDs must: not be replaced nor updated
  * [[VUID-VkVideoEncodeH265SessionParametersAddInfoEXT-None-06444]]
    When creating a new object using a Video Session Parameters as a
    template, the array's parameters with the same VPS-SPS-PPS IDs as the
    ones from the template take precedence
  * [[VUID-VkVideoEncodeH265SessionParametersAddInfoEXT-None-06445]]
    VPS/SPS/PPS parameters must: comply with the limits specified in
    slink:VkVideoSessionCreateInfoKHR during Video Session creation
****
--

[open,refpage='VkVideoEncodeH265SessionParametersGetInfoEXT',desc='Structure specifying parameters for retrieving encoded H.265 parameter set data',type='structs']
--
The sname:VkVideoEncodeH265SessionParametersGetInfoEXT structure is defined
as:

include::{generated}/api/structs/VkVideoEncodeH265SessionParametersGetInfoEXT.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:writeStdVPS indicates whether the encoded H.265 video parameter
    set identified by pname:stdVPSId is requested to be retrieved.
  * pname:writeStdSPS indicates whether the encoded H.265 sequence parameter
    set identified by the pair constructed from pname:stdVPSId and
    pname:stdSPSId is requested to be retrieved.
  * pname:writeStdPPS indicates whether the encoded H.265 picture parameter
    set identified by the triplet constructed from pname:stdVPSId,
    pname:stdSPSId, and pname:stdPPSId is requested to be retrieved.
  * pname:stdVPSId specifies the H.265 video parameter set ID used to
    identify the retrieved H.265 video, sequence, and/or picture parameter
    set(s).
  * pname:stdSPSId specifies the H.265 sequence parameter set ID used to
    identify the retrieved H.265 sequence and/or picture parameter set(s)
    when pname:writeStdSPS and/or pname:writeStdPPS is set to ename:VK_TRUE.
  * pname:stdPPSId specifies the H.265 picture parameter set ID used to
    identify the retrieved H.265 picture parameter set when
    pname:writeStdPPS is set to ename:VK_TRUE.

When this structure is specified in the pname:pNext chain of the
slink:VkVideoEncodeSessionParametersGetInfoKHR structure passed to
flink:vkGetEncodedVideoSessionParametersKHR, the command will write encoded
parameter data to the output buffer in the following order:

  . The H.265 video parameter set identified by pname:stdVPSId, if
    pname:writeStdVPS is set to ename:VK_TRUE.
  . The H.265 sequence parameter set identified by the pair constructed from
    pname:stdVPSId and pname:stdSPSId, if pname:writeStdSPS is set to
    ename:VK_TRUE.
  . The H.265 picture parameter set identified by the triplet constructed
    from pname:stdVPSId, pname:stdSPSId, and pname:stdPPSId, if
    pname:writeStdPPS is set to ename:VK_TRUE.

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

[open,refpage='VkVideoEncodeH265SessionParametersFeedbackInfoEXT',desc='Structure providing feedback about the requested H.265 video session parameters',type='structs']
--
The sname:VkVideoEncodeH265SessionParametersFeedbackInfoEXT structure is
defined as:

include::{generated}/api/structs/VkVideoEncodeH265SessionParametersFeedbackInfoEXT.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:hasStdVPSOverrides indicates whether any of the parameters of the
    requested H.265 video parameter set, if one was requested via
    slink:VkVideoEncodeH265SessionParametersGetInfoEXT::pname:writeStdVPS,
    were overridden by the implementation.
  * pname:hasStdSPSOverrides indicates whether any of the parameters of the
    requested H.265 sequence parameter set, if one was requested via
    slink:VkVideoEncodeH265SessionParametersGetInfoEXT::pname:writeStdSPS,
    were overridden by the implementation.
  * pname:hasStdPPSOverrides indicates whether any of the parameters of the
    requested H.265 picture parameter set, if one was requested via
    slink:VkVideoEncodeH265SessionParametersGetInfoEXT::pname:writeStdPPS,
    were overridden by the implementation.

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


=== Frame Encoding

In order to encode a frame, add a slink:VkVideoEncodeH265PictureInfoEXT
structure to the pname:pNext chain of the slink:VkVideoEncodeInfoKHR
structure passed to the flink:vkCmdEncodeVideoKHR command.

[open,refpage='VkVideoEncodeH265PictureInfoEXT',desc='Structure specifies H.265 encode frame parameters',type='structs']
--
The slink:VkVideoEncodeH265PictureInfoEXT structure representing a frame
encode operation is defined as:

include::{generated}/api/structs/VkVideoEncodeH265PictureInfoEXT.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:naluSliceSegmentEntryCount is the number of slice segment NALUs in
    the frame.
  * pname:pNaluSliceSegmentEntries is a pointer to an array of
    slink:VkVideoEncodeH265NaluSliceSegmentInfoEXT structures specifying the
    division of the current picture into slice segments and the properties
    of these slice segments.
  * pname:pStdPictureInfo is a pointer to a
    code:StdVideoEncodeH265PictureInfo structure specifying the syntax and
    other codec-specific information from the H.265 specification,
    associated with this picture.

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

[open,refpage='VkVideoEncodeH265NaluSliceSegmentInfoEXT',desc='Structure specifies H.265 encode slice segment NALU parameters',type='structs']
--
The slink:VkVideoEncodeH265NaluSliceSegmentInfoEXT structure representing a
slice segment is defined as:

include::{generated}/api/structs/VkVideoEncodeH265NaluSliceSegmentInfoEXT.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:constantQp is the QP to use for the slice segment if the current
    rate control mode configured for the video session is
    ename:VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR.
  * pname:pStdSliceSegmentHeader is a pointer to a
    code:StdVideoEncodeH265SliceSegmentHeader structure specifying the slice
    segment header for the current slice segment.

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

[open,refpage='VkVideoEncodeH265DpbSlotInfoEXT',desc='Structure specifies H.265 encode decoded pic info',type='structs']
--
The slink:VkVideoEncodeH265DpbSlotInfoEXT structure, representing a
reconstructed picture that is being used as a reference picture, is defined
as:

include::{generated}/api/structs/VkVideoEncodeH265DpbSlotInfoEXT.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:StdVideoEncodeH265ReferenceInfo structure specifying the syntax and
    other codec-specific information from the H.265 specification,
    associated with this reference picture.

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


=== Rate Control

[open,refpage='VkVideoEncodeH265RateControlInfoEXT',desc='Structure describing H.265 stream rate control parameters',type='structs']
--
The sname:VkVideoEncodeH265RateControlInfoEXT structure is defined as:

include::{generated}/api/structs/VkVideoEncodeH265RateControlInfoEXT.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:flags is a bitmask of
    elink:VkVideoEncodeH265RateControlFlagBitsEXT specifying H.265 rate
    control flags.
  * pname:gopFrameCount is the number of frames contained within the group
    of pictures (GOP), starting from an intra frame and until the next intra
    frame.
    If it is set to 0, the implementation chooses a suitable value.
    If it is set to code:UINT32_MAX, the GOP length is treated as infinite.
  * pname:idrPeriod is the interval, in terms of number of frames, between
    two IDR frames.
    If it is set to 0, the implementation chooses a suitable value.
    If it is set to code:UINT32_MAX, the IDR period is treated as infinite.
  * pname:consecutiveBFrameCount is the number of consecutive B-frames
    between I- and/or P-frames within the GOP.
  * pname:subLayerCount specifies the number of sub layers enabled in the
    stream.

In order to provide H.265-specific stream rate control parameters, add a
sname:VkVideoEncodeH265RateControlInfoEXT structure to the pname:pNext chain
of the slink:VkVideoEncodeRateControlInfoKHR structure in the pname:pNext
chain of the slink:VkVideoCodingControlInfoKHR structure passed to the
flink:vkCmdControlVideoCodingKHR command.

The parameters from this structure act as a guidance for implementations to
apply various rate control heuristics.

It is possible to infer the picture type to be used when encoding a frame,
on the basis of the values provided for pname:consecutiveBFrameCount,
pname:idrPeriod, and pname:gopFrameCount, but this inferred picture type
will not be used by implementations to override the picture type provided in
flink:vkCmdEncodeVideoKHR.
Additionally, it is not required for the video session to be reset if the
inferred picture type does not match the actual picture type.

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

[open,refpage='VkVideoEncodeH265RateControlFlagBitsEXT',desc='H.265 encode rate control bits',type='enums']
--
Bits which can: be set in
slink:VkVideoEncodeH265RateControlInfoEXT::pname:flags, specifying H.265
rate control flags, are:

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

  * ename:VK_VIDEO_ENCODE_H265_RATE_CONTROL_ATTEMPT_HRD_COMPLIANCE_BIT_EXT
    specifies that rate control should: attempt to produce an HRD compliant
    bitstream.
  * ename:VK_VIDEO_ENCODE_H265_RATE_CONTROL_REGULAR_GOP_BIT_EXT specifies
    that the application intends to use a regular GOP structure according to
    the parameters specified in the pname:gopFrameCount, pname:idrPeriod,
    and pname:consecutiveBFrameCount members of the
    slink:VkVideoEncodeH265RateControlInfoEXT structure.
  * ename:VK_VIDEO_ENCODE_H265_RATE_CONTROL_REFERENCE_PATTERN_FLAT_BIT_EXT
    specifies that the application intends to follow a flat reference
    pattern.
  * ename:VK_VIDEO_ENCODE_H265_RATE_CONTROL_REFERENCE_PATTERN_DYADIC_BIT_EXT
    specifies that the application intends to follow a dyadic reference
    pattern.
  * ename:VK_VIDEO_ENCODE_H265_RATE_CONTROL_TEMPORAL_SUB_LAYER_PATTERN_DYADIC_BIT_EXT
    specifies that the application intends to follow a dyadic temporal
    sub-layer pattern.
--


[open,refpage='VkVideoEncodeH265RateControlFlagsEXT',desc='Bitmask specifying H.265 encode rate control flags',type='flags']
--
include::{generated}/api/flags/VkVideoEncodeH265RateControlFlagsEXT.adoc[]

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

[open,refpage='VkVideoEncodeH265RateControlLayerInfoEXT',desc='Structure describing H.265 per-layer rate control parameters',type='structs']
--
The sname:VkVideoEncodeH265RateControlLayerInfoEXT structure is defined as:

include::{generated}/api/structs/VkVideoEncodeH265RateControlLayerInfoEXT.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:useMinQp indicates whether the values within pname:minQp should be
    used by the implementation.
    When it is set to ename:VK_FALSE, the implementation ignores the values
    in pname:minQp and chooses suitable values.
  * pname:minQp provides the lower bound on the QP values for each picture
    type, to be used in rate control calculations.
  * pname:useMaxQp indicates whether the values within pname:maxQp should be
    used by the implementation.
    When it is set to ename:VK_FALSE, the implementation ignores the values
    in pname:maxQp and chooses suitable values.
  * pname:maxQp provides the upper bound on the QP values for each picture
    type, to be used in rate control calculations.
  * pname:useMaxFrameSize indicates whether the values within
    pname:maxFrameSize should be used by the implementation.
  * pname:maxFrameSize provides the upper bound on the encoded frame size
    for each picture type.
    The implementation does not guarantee the encoded frame sizes will be
    within the specified limits, however these limits may: be used as a
    guide in rate control calculations.
    If enabled and not set properly, the pname:maxQp limit may prevent the
    implementation from respecting the pname:maxFrameSize limit.

H.265-specific per-layer rate control parameters must: be specified by
adding a sname:VkVideoEncodeH265RateControlLayerInfoEXT structure to the
pname:pNext chain of each slink:VkVideoEncodeRateControlLayerInfoKHR
structure in a call to flink:vkCmdControlVideoCodingKHR command, when the
command buffer context has an active video encode H.265 session.

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

[open,refpage='VkVideoEncodeH265QpEXT',desc='Structure describing H.265 QP values per picture type',type='structs']
--
The sname:VkVideoEncodeH265QpEXT structure is defined as:

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

  * pname:qpI is the QP to be used for I-frames.
  * pname:qpP is the QP to be used for P-frames.
  * pname:qpB is the QP to be used for B-frames.

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

[open,refpage='VkVideoEncodeH265FrameSizeEXT',desc='Structure describing frame size values per H.265 picture type',type='structs']
--
The sname:VkVideoEncodeH265FrameSizeEXT structure is defined as:

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

  * pname:frameISize is the size in bytes to be used for I-frames.
  * pname:framePSize is the size in bytes to be used for P-frames.
  * pname:frameBSize is the size in bytes to be used for B-frames.

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

[open,refpage='VkVideoEncodeH265GopRemainingFrameInfoEXT',desc='Structure specifying H.265 encode rate control GOP remaining frame counts',type='structs']
--
The sname:VkVideoEncodeH265GopRemainingFrameInfoEXT structure is defined as:

include::{generated}/api/structs/VkVideoEncodeH265GopRemainingFrameInfoEXT.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:useGopRemainingFrames indicates whether the implementation's rate
    control algorithm should: use the values specified in
    pname:gopRemainingI, pname:gopRemainingP, and pname:gopRemainingB.
    If pname:useGopRemainingFrames is ename:VK_FALSE, then the values of
    pname:gopRemainingI, pname:gopRemainingP, and pname:gopRemainingB are
    ignored.
  * pname:gopRemainingI specifies the number of I-frames the
    implementation's rate control algorithm should: assume to be remaining
    in the GOP prior to executing the video encode operation.
  * pname:gopRemainingP specifies the number of P-frames the
    implementation's rate control algorithm should: assume to be remaining
    in the GOP prior to executing the video encode operation.
  * pname:gopRemainingB specifies the number of B-frames the
    implementation's rate control algorithm should: assume to be remaining
    in the GOP prior to executing the video encode operation.

Setting pname:useGopRemainingFrames to ename:VK_TRUE and including this
structure in the pname:pNext chain of slink:VkVideoEncodeInfoKHR is only
mandatory if the
slink:VkVideoEncodeH265CapabilitiesEXT::pname:requiresGopRemainingFrames
reported for the used <<video-profiles,video profile>> is ename:VK_TRUE.
However, implementations may: use these remaining frame counts, when
specified, even when it is not required.
In particular, when the application does not use a regular GOP structure,
these values may: provide additional guidance for the implementation's rate
control algorithm.

The slink:VkVideoEncodeH265CapabilitiesEXT::pname:prefersGopRemainingFrames
capability is also used to indicate that the implementation's rate control
algorithm may: operate more accurately if the application specifies the
remaining frame counts using this structure.

As with other rate control guidance values, if the effective order and
number of frames encoded by the application are not in line with the
remaining frame counts specified in this structure at any given point, then
the behavior of the implementation's rate control algorithm may: deviate
from the one expected by the application.

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