C Specification
To launch video encode operations, call:
// Provided by VK_KHR_video_encode_queue
void vkCmdEncodeVideoKHR(
VkCommandBuffer commandBuffer,
const VkVideoEncodeInfoKHR* pEncodeInfo);
Parameters
-
commandBuffer
is the command buffer in which to record the command. -
pEncodeInfo
is a pointer to a VkVideoEncodeInfoKHR structure specifying the parameters of the video encode operations.
Description
Each call issues one or more video encode operations.
The implicit parameter opCount
corresponds to the number of video
encode operations issued by the command.
After calling this command, the
active query index of each
active query is incremented by opCount
.
Currently each call to this command results in the issue of a single video encode operation.
If the bound video session was created with
VK_VIDEO_SESSION_CREATE_INLINE_QUERIES_BIT_KHR
and the pNext
chain of pEncodeInfo
includes a VkVideoInlineQueryInfoKHR
structure with its queryPool
member specifying a valid
VkQueryPool
handle, then this command will execute a query for each
video encode operation issued by it.
- Active Reference Picture Information
-
The list of active reference pictures used by a video encode operation is a list of image subregions used as the source of reference picture data and related parameters, and is derived from the VkVideoReferenceSlotInfoKHR structures provided as the elements of the
pEncodeInfo->pReferenceSlots
array. For each element ofpEncodeInfo->pReferenceSlots
, one or more elements are added to the active reference picture list, as defined by the codec-specific semantics. Each element of this list contains the following information:-
The image subregion within the image subresource referred to by the video picture resource used as the reference picture.
-
The DPB slot index the reference picture is associated with.
-
The codec-specific reference information related to the reference picture.
-
- Reconstructed Picture Information
-
Information related to the optional reconstructed picture used by a video encode operation is derived from the VkVideoReferenceSlotInfoKHR structure pointed to by
pEncodeInfo->pSetupReferenceSlot
, if notNULL
, as defined by the codec-specific semantics, and consists of the following:-
The image subregion within the image subresource referred to by the video picture resource used as the reconstructed picture.
-
The DPB slot index to use for picture reconstruction.
-
The codec-specific reference information related to the reconstructed picture.
-
Specifying a valid VkVideoReferenceSlotInfoKHR structure in
pEncodeInfo->pSetupReferenceSlot
is always required, unless the video
session was created with VkVideoSessionCreateInfoKHR::maxDpbSlot
equal to zero.
However, the DPB slot identified by
pEncodeInfo->pSetupReferenceSlot->slotIndex
is only
activated with the reconstructed
picture specified in
pEncodeInfo->pSetupReferenceSlot->pPictureResource
if reference
picture setup is requested according to the
codec-specific semantics.
If reconstructed picture information is specified, but reference picture setup is not requested, according to the codec-specific semantics, the contents of the video picture resource corresponding to the reconstructed picture will be undefined after the video encode operation.
Note
Some implementations may always output the reconstructed picture or use it as temporary storage during the video encode operation even when the reconstructed picture is not marked for future reference. |
- Encode Input Picture Information
-
Information related to the encode input picture used by a video encode operation is derived from
pEncodeInfo->srcPictureResource
and any codec-specific parameters provided in thepEncodeInfo->pNext
chain, as defined by the codec-specific semantics, and consists of the following:-
The image subregion within the image subresource referred to by the video picture resource used as the encode input picture.
-
The codec-specific picture information related to the encoded picture.
-
Several limiting values are defined below that are referenced by the relevant valid usage statements of this command.
-
Let
uint32_t activeReferencePictureCount
be the size of the list of active reference pictures used by the video encode operation. Unless otherwise defined,activeReferencePictureCount
is set to the value ofpEncodeInfo->referenceSlotCount
. -
Let
VkOffset2D codedOffsetGranularity
be the minimum alignment requirement for the coded offset of video picture resources. Unless otherwise defined, the value of thex
andy
members ofcodedOffsetGranularity
are0
. -
Let
uint32_t dpbFrameUseCount[]
be an array of sizemaxDpbSlots
, wheremaxDpbSlots
is the VkVideoSessionCreateInfoKHR::maxDpbSlots
the bound video session was created with, with each element indicating the number of times a frame associated with the corresponding DPB slot index is referred to by the video coding operation. Let the initial value of each element of the array be0
.-
If
pEncodeInfo->pSetupReferenceSlot
is notNULL
, thendpbFrameUseCount[i]
is incremented by one, wherei
equalspEncodeInfo->pSetupReferenceSlot->slotIndex
. -
For each element of
pEncodeInfo->pReferenceSlots
,dpbFrameUseCount[i]
is incremented by one, wherei
equals theslotIndex
member of the corresponding element.
-
-
Let
VkExtent2D maxCodingBlockSize
be the maximum codec-specific coding block size that may be used by the video encode operation.-
If the bound video session object was created with an H.264 encode profile, then let
maxCodingBlockSize
be equal to the size of an H.264 macroblock, i.e.{16,16}
. -
If the bound video session object was created with an H.265 encode profile, then let
maxCodingBlockSize
be equal to the maximum H.265 coding block size that may be used by the video encode operation derived as the maximum of the CTB sizes corresponding to the VkVideoEncodeH265CtbSizeFlagBitsKHR bits set in VkVideoEncodeH265CapabilitiesKHR::ctbSizes
, as returned by vkGetPhysicalDeviceVideoCapabilitiesKHR for the video profile the bound video session was created with. -
Otherwise,
maxCodingBlockSize
is undefined.
-
-
If
maxCodingBlockSize
is defined, then letVkExtent2D minCodingBlockExtent
be the coded extent of the encode input picture expressed in terms of codec-specific coding blocks, assuming the maximum size of such coding blocks, as defined bymaxCodingBlockSize
, calculated from the value of thecodedExtent
member ofpEncodeInfo->srcPictureResource
as follows:-
minCodingBlockExtent.width
= (codedExtent.width
maxCodingBlockSize.width
- 1) /maxCodingBlockSize.width
-
minCodingBlockExtent.height
= (codedExtent.height
maxCodingBlockSize.height
- 1) /maxCodingBlockSize.height
-
-
If the bound video session object was created with an H.264 encode profile, then:
-
Let
StdVideoH264PictureType h264PictureType
be the picture type of the encoded picture set to the value ofpStdPictureInfo->primary_pic_type
specified in the VkVideoEncodeH264PictureInfoKHR structure included in thepEncodeInfo->pNext
chain. -
Let
StdVideoH264PictureType h264L0PictureTypes[]
andStdVideoH264PictureType h264L1PictureTypes[]
be the picture types of the reference pictures in the L0 and L1 reference lists, respectively. IfpStdPictureInfo->pRefLists
specified in the VkVideoEncodeH264PictureInfoKHR structure included in thepEncodeInfo->pNext
chain is notNULL
, then for each reference index specified in the elements of thepStdPictureInfo->pRefLists->RefPicList0
andpStdPictureInfo->pRefLists->RefPicList1
arrays, if the reference index is notSTD_VIDEO_H264_NO_REFERENCE_PICTURE
,pStdReferenceInfo->primary_pic_type
is added toh264L0PictureTypes
orh264L1PictureTypes
, respectively, wherepStdReferenceInfo
is the member of the VkVideoEncodeH264DpbSlotInfoKHR structure included in thepNext
chain of the element ofpEncodeInfo->pReferenceSlots
for whichslotIndex
equals the reference index in question.
-
-
If the bound video session object was created with an H.265 encode profile, then:
-
Let
StdVideoH265PictureType h265PictureType
be the picture type of the encoded picture set to the value ofpStdPictureInfo->pic_type
specified in the VkVideoEncodeH265PictureInfoKHR structure included in thepEncodeInfo->pNext
chain. -
Let
StdVideoH265PictureType h265L0PictureTypes[]
andStdVideoH265PictureType h265L1PictureTypes[]
be the picture types of the reference pictures in the L0 and L1 reference lists, respectively. IfpStdPictureInfo->pRefLists
specified in the VkVideoEncodeH265PictureInfoKHR structure included in thepEncodeInfo->pNext
chain is notNULL
, then for each reference index specified in the elements of thepStdPictureInfo->pRefLists->RefPicList0
andpStdPictureInfo->pRefLists->RefPicList1
arrays, if the reference index is notSTD_VIDEO_H265_NO_REFERENCE_PICTURE
,pStdReferenceInfo->pic_type
is added toh265L0PictureTypes
orh265L1PictureTypes
, respectively, wherepStdReferenceInfo
is the member of the VkVideoEncodeH265DpbSlotInfoKHR structure included in thepNext
chain of the element ofpEncodeInfo->pReferenceSlots
for whichslotIndex
equals the reference index in question.
-
Document Notes
For more information, see the Vulkan Specification
This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.