Go to the documentation of this file.
19 #ifndef AVCODEC_VULKAN_ENCODE_H
20 #define AVCODEC_VULKAN_ENCODE_H
66 uint8_t *
data,
size_t *data_len);
79 uint8_t *
data,
size_t *data_len);
88 uint8_t *
data,
size_t *data_len);
97 #define VK_ENC_FLAG_NO_DELAY 1 << 6
119 VkVideoEncodeRateControlInfoKHR *rc_info,
120 VkVideoEncodeRateControlLayerInfoKHR *rc_layer);
126 VkVideoEncodeInfoKHR *encode_info);
133 uint8_t *
data,
size_t *data_len);
139 uint8_t *
data,
size_t *data_len);
147 uint8_t *
data,
size_t *data_len);
157 VkVideoEncodeUsageFlagBitsKHR
usage;
159 VkVideoEncodeTuningModeKHR
tune;
161 VkVideoEncodeRateControlModeFlagBitsKHR
rc_mode;
162 #define FF_VK_RC_MODE_AUTO 0xFFFFFFFF
197 #define VULKAN_ENCODE_COMMON_OPTIONS \
198 { "qp", "Use an explicit constant quantizer for the whole stream", OFFSET(common.opts.qp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, FLAGS }, \
199 { "quality", "Set encode quality (trades off against speed, higher is faster)", OFFSET(common.opts.quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FLAGS }, \
200 { "rc_mode", "Select rate control type", OFFSET(common.opts.rc_mode), AV_OPT_TYPE_INT, { .i64 = FF_VK_RC_MODE_AUTO }, 0, FF_VK_RC_MODE_AUTO, FLAGS, "rc_mode" }, \
201 { "auto", "Choose mode automatically based on parameters", 0, AV_OPT_TYPE_CONST, { .i64 = FF_VK_RC_MODE_AUTO }, INT_MIN, INT_MAX, FLAGS, "rc_mode" }, \
202 { "driver", "Driver-specific rate control", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DEFAULT_KHR }, INT_MIN, INT_MAX, FLAGS, "rc_mode" }, \
203 { "cqp", "Constant quantizer mode", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR }, INT_MIN, INT_MAX, FLAGS, "rc_mode" }, \
204 { "cbr", "Constant bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR }, INT_MIN, INT_MAX, FLAGS, "rc_mode" }, \
205 { "vbr", "Variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR }, INT_MIN, INT_MAX, FLAGS, "rc_mode" }, \
206 { "tune", "Select tuning type", OFFSET(common.opts.tune), AV_OPT_TYPE_INT, { .i64 = VK_VIDEO_ENCODE_TUNING_MODE_DEFAULT_KHR }, 0, INT_MAX, FLAGS, "tune" }, \
207 { "default", "Default tuning", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_TUNING_MODE_DEFAULT_KHR }, INT_MIN, INT_MAX, FLAGS, "tune" }, \
208 { "hq", "High quality tuning", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_TUNING_MODE_HIGH_QUALITY_KHR }, INT_MIN, INT_MAX, FLAGS, "tune" }, \
209 { "ll", "Low-latency tuning", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_TUNING_MODE_LOW_LATENCY_KHR }, INT_MIN, INT_MAX, FLAGS, "tune" }, \
210 { "ull", "Ultra low-latency tuning", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_TUNING_MODE_ULTRA_LOW_LATENCY_KHR }, INT_MIN, INT_MAX, FLAGS, "tune" }, \
211 { "lossless", "Lossless mode tuning", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_TUNING_MODE_LOSSLESS_KHR }, INT_MIN, INT_MAX, FLAGS, "tune" }, \
212 { "usage", "Select usage type", OFFSET(common.opts.usage), AV_OPT_TYPE_FLAGS, { .i64 = VK_VIDEO_ENCODE_USAGE_DEFAULT_KHR }, 0, INT_MAX, FLAGS, "usage" }, \
213 { "default", "Default optimizations", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_USAGE_DEFAULT_KHR }, INT_MIN, INT_MAX, FLAGS, "usage" }, \
214 { "transcode", "Optimize for transcoding", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_USAGE_TRANSCODING_BIT_KHR }, INT_MIN, INT_MAX, FLAGS, "usage" }, \
215 { "stream", "Optimize for streaming", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_USAGE_STREAMING_BIT_KHR }, INT_MIN, INT_MAX, FLAGS, "usage" }, \
216 { "record", "Optimize for offline recording", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_USAGE_RECORDING_BIT_KHR }, INT_MIN, INT_MAX, FLAGS, "usage" }, \
217 { "conference", "Optimize for teleconferencing", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_USAGE_CONFERENCING_BIT_KHR }, INT_MIN, INT_MAX, FLAGS, "usage" }, \
218 { "content", "Select content type", OFFSET(common.opts.content), AV_OPT_TYPE_FLAGS, { .i64 = VK_VIDEO_ENCODE_CONTENT_DEFAULT_KHR }, 0, INT_MAX, FLAGS, "content" }, \
219 { "default", "Default content", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_CONTENT_DEFAULT_KHR }, INT_MIN, INT_MAX, FLAGS, "content" }, \
220 { "camera", "Camera footage", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_CONTENT_CAMERA_BIT_KHR }, INT_MIN, INT_MAX, FLAGS, "content" }, \
221 { "desktop", "Screen recording", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_CONTENT_DESKTOP_BIT_KHR }, INT_MIN, INT_MAX, FLAGS, "content" }, \
222 { "rendered", "Game or 3D content", 0, AV_OPT_TYPE_CONST, { .i64 = VK_VIDEO_ENCODE_CONTENT_RENDERED_BIT_KHR }, INT_MIN, INT_MAX, FLAGS, "content" }
230 void *codec_caps,
void *quality_pnext);
252 void *codec_params_pnext);
VkVideoCodecOperationFlagBitsKHR encode_op
FFVulkanExtensions encode_extension
uint64_t FFVulkanExtensions
const AVCodecHWConfigInternal *const ff_vulkan_encode_hw_configs[]
Paperwork.
VkVideoProfileInfoKHR profile
VkVideoEncodeUsageInfoKHR usage_info
size_t filler_header_size
Size of the filler header.
VkVideoCapabilitiesKHR caps
int(* write_extra_headers)(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, uint8_t *data, size_t *data_len)
Callback for writing any extra units requested.
void ff_vulkan_encode_uninit(FFVulkanEncodeContext *ctx)
Uninitialize encoder.
VkExtensionProperties ext_props
int(* vkenc_cb_write_extra_headers)(AVCodecContext *avctx, FFVulkanEncodePicture *pic, uint8_t *data, size_t *data_len)
Callback for writing any extra units requested.
int(* write_sequence_headers)(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, uint8_t *data, size_t *data_len)
Callback for writing stream headers.
VkVideoEncodeQualityLevelPropertiesKHR quality_props
VkImageAspectFlags aspect
VkVideoProfileListInfoKHR profile_list
FFVkQueueFamilyCtx qf_enc
VkVideoSessionParametersKHR session_params
int(* init_pic_rc)(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, VkVideoEncodeRateControlInfoKHR *rc_info, VkVideoEncodeRateControlLayerInfoKHR *rc_layer)
Initialize codec-specific rate control structures for a picture.
struct FFVulkanEncodePicture::@284 dpb
int(* vkenc_cb_write_filler)(AVCodecContext *avctx, uint32_t filler, uint8_t *data, size_t *data_len)
Callback for writing alignment data.
FFHWBaseEncodeContext base
AVCodecID
Identify the syntax and semantics of the bitstream.
FFVkEncodeCommonOptions opts
av_cold int ff_vulkan_write_global_header(AVCodecContext *avctx, FFVulkanEncodeContext *ctx)
Write out the extradata in case its needed.
VkVideoEncodeRateControlModeFlagBitsKHR rc_mode
const FFVulkanCodec * codec
int(* vkenc_cb_write_stream_headers)(AVCodecContext *avctx, uint8_t *data, size_t *data_len)
Callback for writing stream-level headers.
int(* init_pic_params)(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, VkVideoEncodeInfoKHR *encode_info)
Initialize codec-specific picture parameters.
VkVideoEncodeTuningModeKHR tune
VkVideoEncodeUsageFlagBitsKHR usage
int(* vkenc_cb_init_pic_headers)(AVCodecContext *avctx, FFVulkanEncodePicture *pic)
Callback for initializing codec-specific picture headers.
int ff_vulkan_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Encode.
VkVideoEncodeCapabilitiesKHR enc_caps
main external API structure.
FFHWBaseEncodePicture base
int(* filler)(InterplayACMContext *s, unsigned ind, unsigned col)
int ff_vulkan_encode_create_session_params(AVCodecContext *avctx, FFVulkanEncodeContext *ctx, void *codec_params_pnext)
Create session parameters.
struct FFVulkanEncodePicture::@283 in
int(* init_profile)(AVCodecContext *avctx, VkVideoProfileInfoKHR *profile, void *pnext)
Initialize codec-specific structs in a Vulkan profile.
av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext *ctx, const FFVulkanEncodeDescriptor *vk_desc, const FFVulkanCodec *codec, void *codec_caps, void *quality_pnext)
Initialize encoder.
A reference to a data buffer.
int flags
Codec feature flags.
int(* write_filler)(AVCodecContext *avctx, uint32_t filler, uint8_t *data, size_t *data_len)
Callback for writing alignment data.
This structure stores compressed data.
size_t picture_priv_data_size
Size of the codec-specific picture struct.
VkVideoEncodeContentFlagBitsKHR content
FFHWBaseEncodePicture * slots[32]
VkVideoReferenceSlotInfoKHR dpb_slot
VkVideoPictureResourceInfoKHR dpb_res