FFmpeg
Loading...
Searching...
No Matches
vulkan_video.c File Reference
#include "config.h"
#include "libavutil/mem.h"
#include "encode.h"
#include "vulkan_video.h"

Go to the source code of this file.

Data Structures

struct  FFVkFormatMapEntry
 

Macros

#define ASPECT_2PLANE   (VK_IMAGE_ASPECT_PLANE_0_BIT | VK_IMAGE_ASPECT_PLANE_1_BIT)
 
#define ASPECT_3PLANE   (VK_IMAGE_ASPECT_PLANE_0_BIT | VK_IMAGE_ASPECT_PLANE_1_BIT | VK_IMAGE_ASPECT_PLANE_2_BIT)
 

Functions

enum AVPixelFormat ff_vk_pix_fmt_from_vkfmt (VkFormat vkf)
 Get pixfmt from a Vulkan format.
 
VkImageAspectFlags ff_vk_aspect_bits_from_vkfmt (VkFormat vkf)
 Get aspect bits which include all planes from a VkFormat.
 
VkVideoChromaSubsamplingFlagBitsKHR ff_vk_subsampling_from_av_desc (const AVPixFmtDescriptor *desc)
 Get Vulkan's chroma subsampling from a pixfmt descriptor.
 
VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth (int depth)
 Get Vulkan's bit depth from an [8:12] integer.
 
int ff_vk_h264_level_to_av (StdVideoH264LevelIdc level)
 Convert level from Vulkan to AV.
 
StdVideoH264LevelIdc ff_vk_h264_level_to_vk (int level_idc)
 
int ff_vk_h265_level_to_av (StdVideoH265LevelIdc level)
 
StdVideoH265LevelIdc ff_vk_h265_level_to_vk (int level_idc)
 
StdVideoAV1Level ff_vk_av1_level_to_vk (int level)
 
StdVideoH264ProfileIdc ff_vk_h264_profile_to_vk (int profile)
 Convert profile from/to AV to Vulkan.
 
StdVideoH265ProfileIdc ff_vk_h265_profile_to_vk (int profile)
 
StdVideoAV1Profile ff_vk_av1_profile_to_vk (int profile)
 
int ff_vk_create_view (FFVulkanContext *s, VkImageView *view, VkImageAspectFlags *aspect, VkImage img, VkFormat vkf, VkImageUsageFlags usage, int layered)
 Creates image views for video frames.
 
static void dpb_image_free (AVRefStructOpaque opaque, void *obj)
 
static int dpb_image_init (AVRefStructOpaque opaque, void *obj)
 
static void dpb_pool_free (AVRefStructOpaque opaque)
 
av_cold int ff_vk_video_dpb_init (FFVulkanContext *s, FFVkVideoCommon *common, VkFormat format, VkImageUsageFlags usage, VkImageTiling tiling, void *create_pnext, int width, int height, int nb_layers)
 Initialize the internal DPB image pool.
 
av_cold void ff_vk_video_common_uninit (FFVulkanContext *s, FFVkVideoCommon *common)
 Free video session and required resources.
 
av_cold int ff_vk_video_common_init (AVCodecContext *avctx, FFVulkanContext *s, FFVkVideoCommon *common, VkVideoSessionCreateInfoKHR *session_create)
 Initialize video session, allocating and binding necessary memory.
 
int ff_vk_encode_loop_init (FFVulkanContext *s, FFVkExecPool *pool, FFVkEncodeLoop *l, int(*submit_frame)(AVCodecContext *avctx, FFVkExecContext *exec, AVFrame *frame), int(*get_packet)(AVCodecContext *avctx, FFVkExecContext *exec, AVPacket *pkt))
 
static int loop_get_packet (AVCodecContext *avctx, FFVkEncodeLoop *l, AVPacket *pkt)
 
static int loop_oldest_done (FFVkEncodeLoop *l)
 
int ff_vk_encode_loop_receive_packet (AVCodecContext *avctx, FFVkEncodeLoop *l, AVPacket *pkt)
 Call from FFCodec.cb.receive_packet; the packet metadata is carried from the submitted frame to its packet.
 
void ff_vk_encode_loop_flush (AVCodecContext *avctx, FFVkEncodeLoop *l)
 Waits for and discards every frame in flight.
 
void ff_vk_encode_loop_uninit (FFVkEncodeLoop *l)
 

Variables

static const struct FFVkFormatMapEntry vk_format_map []
 
static const int nb_vk_format_map = FF_ARRAY_ELEMS(vk_format_map)
 

Macro Definition Documentation

◆ ASPECT_2PLANE

#define ASPECT_2PLANE   (VK_IMAGE_ASPECT_PLANE_0_BIT | VK_IMAGE_ASPECT_PLANE_1_BIT)

Definition at line 24 of file vulkan_video.c.

◆ ASPECT_3PLANE

#define ASPECT_3PLANE   (VK_IMAGE_ASPECT_PLANE_0_BIT | VK_IMAGE_ASPECT_PLANE_1_BIT | VK_IMAGE_ASPECT_PLANE_2_BIT)

Definition at line 25 of file vulkan_video.c.

Function Documentation

◆ ff_vk_pix_fmt_from_vkfmt()

enum AVPixelFormat ff_vk_pix_fmt_from_vkfmt ( VkFormat vkf)

Get pixfmt from a Vulkan format.

Definition at line 101 of file vulkan_video.c.

Referenced by ff_vulkan_encode_init(), and vulkan_decode_get_profile().

◆ ff_vk_aspect_bits_from_vkfmt()

VkImageAspectFlags ff_vk_aspect_bits_from_vkfmt ( VkFormat vkf)

Get aspect bits which include all planes from a VkFormat.

Definition at line 109 of file vulkan_video.c.

Referenced by ff_vk_create_view().

◆ ff_vk_subsampling_from_av_desc()

VkVideoChromaSubsamplingFlagBitsKHR ff_vk_subsampling_from_av_desc ( const AVPixFmtDescriptor * desc)

Get Vulkan's chroma subsampling from a pixfmt descriptor.

Definition at line 117 of file vulkan_video.c.

Referenced by ff_vulkan_encode_init(), and vulkan_setup_profile().

◆ ff_vk_depth_from_av_depth()

VkVideoComponentBitDepthFlagBitsKHR ff_vk_depth_from_av_depth ( int depth)

Get Vulkan's bit depth from an [8:12] integer.

Definition at line 130 of file vulkan_video.c.

Referenced by ff_vulkan_encode_init(), and vulkan_setup_profile().

◆ ff_vk_h264_level_to_av()

int ff_vk_h264_level_to_av ( StdVideoH264LevelIdc level)

Convert level from Vulkan to AV.

Definition at line 141 of file vulkan_video.c.

Referenced by vulkan_decode_get_profile().

◆ ff_vk_h264_level_to_vk()

StdVideoH264LevelIdc ff_vk_h264_level_to_vk ( int level_idc)

Definition at line 167 of file vulkan_video.c.

Referenced by base_unit_to_vk().

◆ ff_vk_h265_level_to_av()

int ff_vk_h265_level_to_av ( StdVideoH265LevelIdc level)

Definition at line 193 of file vulkan_video.c.

Referenced by vulkan_decode_get_profile().

◆ ff_vk_h265_level_to_vk()

StdVideoH265LevelIdc ff_vk_h265_level_to_vk ( int level_idc)

Definition at line 212 of file vulkan_video.c.

Referenced by base_unit_to_vk(), set_sps(), and set_vps().

◆ ff_vk_av1_level_to_vk()

StdVideoAV1Level ff_vk_av1_level_to_vk ( int level)

Definition at line 231 of file vulkan_video.c.

◆ ff_vk_h264_profile_to_vk()

StdVideoH264ProfileIdc ff_vk_h264_profile_to_vk ( int profile)

Convert profile from/to AV to Vulkan.

Definition at line 262 of file vulkan_video.c.

Referenced by base_unit_to_vk(), and init_profile().

◆ ff_vk_h265_profile_to_vk()

StdVideoH265ProfileIdc ff_vk_h265_profile_to_vk ( int profile)

Definition at line 274 of file vulkan_video.c.

Referenced by base_unit_to_vk(), init_profile(), and set_vps().

◆ ff_vk_av1_profile_to_vk()

StdVideoAV1Profile ff_vk_av1_profile_to_vk ( int profile)

Definition at line 284 of file vulkan_video.c.

Referenced by init_profile().

◆ ff_vk_create_view()

int ff_vk_create_view ( FFVulkanContext * s,
VkImageView * view,
VkImageAspectFlags * aspect,
VkImage img,
VkFormat vkf,
VkImageUsageFlags usage,
int layered )

Creates image views for video frames.

Definition at line 294 of file vulkan_video.c.

Referenced by dpb_image_init(), ff_vk_decode_prepare_frame(), and vulkan_encode_init().

◆ dpb_image_free()

static void dpb_image_free ( AVRefStructOpaque opaque,
void * obj )
static

Definition at line 337 of file vulkan_video.c.

Referenced by ff_vk_video_dpb_init().

◆ dpb_image_init()

static int dpb_image_init ( AVRefStructOpaque opaque,
void * obj )
static

Definition at line 350 of file vulkan_video.c.

Referenced by ff_vk_video_dpb_init().

◆ dpb_pool_free()

static void dpb_pool_free ( AVRefStructOpaque opaque)
static

Definition at line 375 of file vulkan_video.c.

Referenced by ff_vk_video_dpb_init().

◆ ff_vk_video_dpb_init()

av_cold int ff_vk_video_dpb_init ( FFVulkanContext * s,
FFVkVideoCommon * common,
VkFormat format,
VkImageUsageFlags usage,
VkImageTiling tiling,
void * create_pnext,
int width,
int height,
int nb_layers )

Initialize the internal DPB image pool.

Definition at line 380 of file vulkan_video.c.

Referenced by ff_vk_decode_init(), and vulkan_encode_create_dpb().

◆ ff_vk_video_common_uninit()

av_cold void ff_vk_video_common_uninit ( FFVulkanContext * s,
FFVkVideoCommon * common )

Free video session and required resources.

Definition at line 419 of file vulkan_video.c.

Referenced by ff_vk_video_common_init(), ff_vulkan_encode_uninit(), and free_common().

◆ ff_vk_video_common_init()

av_cold int ff_vk_video_common_init ( AVCodecContext * avctx,
FFVulkanContext * s,
FFVkVideoCommon * common,
VkVideoSessionCreateInfoKHR * session_create )

Initialize video session, allocating and binding necessary memory.

Definition at line 447 of file vulkan_video.c.

Referenced by ff_vk_decode_init(), and ff_vulkan_encode_init().

◆ ff_vk_encode_loop_init()

int ff_vk_encode_loop_init ( FFVulkanContext * s,
FFVkExecPool * pool,
FFVkEncodeLoop * l,
int(* submit_frame )(AVCodecContext *avctx, FFVkExecContext *exec, AVFrame *frame),
int(* get_packet )(AVCodecContext *avctx, FFVkExecContext *exec, AVPacket *pkt) )

Definition at line 640 of file vulkan_video.c.

Referenced by encode_init(), vulkan_encode_apv_init(), and vulkan_encode_ffv1_init().

◆ loop_get_packet()

static int loop_get_packet ( AVCodecContext * avctx,
FFVkEncodeLoop * l,
AVPacket * pkt )
static

Definition at line 660 of file vulkan_video.c.

Referenced by ff_vk_encode_loop_flush(), and ff_vk_encode_loop_receive_packet().

◆ loop_oldest_done()

static int loop_oldest_done ( FFVkEncodeLoop * l)
static

Definition at line 685 of file vulkan_video.c.

Referenced by ff_vk_encode_loop_receive_packet().

◆ ff_vk_encode_loop_receive_packet()

int ff_vk_encode_loop_receive_packet ( AVCodecContext * avctx,
FFVkEncodeLoop * l,
AVPacket * pkt )

Call from FFCodec.cb.receive_packet; the packet metadata is carried from the submitted frame to its packet.

Definition at line 696 of file vulkan_video.c.

Referenced by vulkan_encode_apv_receive_packet(), vulkan_encode_ffv1_receive_packet(), and vulkan_encode_prores_receive_packet().

◆ ff_vk_encode_loop_flush()

void ff_vk_encode_loop_flush ( AVCodecContext * avctx,
FFVkEncodeLoop * l )

Waits for and discards every frame in flight.

Definition at line 735 of file vulkan_video.c.

Referenced by vulkan_encode_apv_flush(), vulkan_encode_ffv1_flush(), and vulkan_encode_prores_flush().

◆ ff_vk_encode_loop_uninit()

void ff_vk_encode_loop_uninit ( FFVkEncodeLoop * l)

Definition at line 744 of file vulkan_video.c.

Referenced by encode_close(), vulkan_encode_apv_close(), and vulkan_encode_ffv1_close().

Variable Documentation

◆ vk_format_map

const struct FFVkFormatMapEntry vk_format_map[]
static

◆ nb_vk_format_map

const int nb_vk_format_map = FF_ARRAY_ELEMS(vk_format_map)
static

Definition at line 99 of file vulkan_video.c.

Referenced by ff_vk_aspect_bits_from_vkfmt(), and ff_vk_pix_fmt_from_vkfmt().