FFmpeg
Functions | Variables
vulkan_decode.c File Reference
#include "refstruct.h"
#include "vulkan_video.h"
#include "vulkan_decode.h"
#include "config_components.h"
#include "libavutil/avassert.h"
#include "libavutil/vulkan_loader.h"

Go to the source code of this file.

Functions

static const FFVulkanDecodeDescriptorget_codecdesc (enum AVCodecID codec_id)
 
static const VkVideoProfileInfoKHR * get_video_profile (FFVulkanDecodeShared *ctx, enum AVCodecID codec_id)
 
int ff_vk_update_thread_context (AVCodecContext *dst, const AVCodecContext *src)
 Synchronize the contexts between 2 threads. More...
 
int ff_vk_params_invalidate (AVCodecContext *avctx, int t, const uint8_t *b, uint32_t s)
 Removes current session parameters to recreate them. More...
 
static int vk_decode_create_view (FFVulkanDecodeContext *dec, VkImageView *dst_view, VkImageAspectFlags *aspect, AVVkFrame *src, VkFormat vkf, int is_current)
 
static AVFramevk_get_dpb_pool (FFVulkanDecodeShared *ctx)
 
int ff_vk_decode_prepare_frame (FFVulkanDecodeContext *dec, AVFrame *pic, FFVulkanDecodePicture *vkpic, int is_current, int alloc_dpb)
 Prepare a frame, creates the image view, and sets up the dpb fields. More...
 
int ff_vk_decode_add_slice (AVCodecContext *avctx, FFVulkanDecodePicture *vp, const uint8_t *data, size_t size, int add_startcode, uint32_t *nb_slices, const uint32_t **offsets)
 Add slice data to frame. More...
 
void ff_vk_decode_flush (AVCodecContext *avctx)
 Flush decoder. More...
 
int ff_vk_decode_frame (AVCodecContext *avctx, AVFrame *pic, FFVulkanDecodePicture *vp, AVFrame *rpic[], FFVulkanDecodePicture *rvkp[])
 Decode a frame. More...
 
void ff_vk_decode_free_frame (AVHWDeviceContext *dev_ctx, FFVulkanDecodePicture *vp)
 Free a frame and its state. More...
 
static void free_common (FFRefStructOpaque unused, void *obj)
 
static int vulkan_decode_bootstrap (AVCodecContext *avctx, AVBufferRef *frames_ref)
 
static VkResult vulkan_setup_profile (AVCodecContext *avctx, FFVulkanDecodeProfileData *prof, AVVulkanDeviceContext *hwctx, FFVulkanFunctions *vk, const FFVulkanDecodeDescriptor *vk_desc, VkVideoDecodeH264CapabilitiesKHR *h264_caps, VkVideoDecodeH265CapabilitiesKHR *h265_caps, VkVideoDecodeAV1CapabilitiesKHR *av1_caps, VkVideoCapabilitiesKHR *caps, VkVideoDecodeCapabilitiesKHR *dec_caps, int cur_profile)
 
static int vulkan_decode_get_profile (AVCodecContext *avctx, AVBufferRef *frames_ref, enum AVPixelFormat *pix_fmt, VkFormat *vk_fmt, FFVulkanDecodeProfileData *prof, int *dpb_dedicate)
 
static void free_profile_data (AVHWFramesContext *hwfc)
 
int ff_vk_frame_params (AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
 Initialize hw_frames_ctx with the parameters needed to decode the stream using the parameters from avctx. More...
 
static void vk_decode_free_params (void *opaque, uint8_t *data)
 
int ff_vk_decode_create_params (AVBufferRef **par_ref, void *logctx, FFVulkanDecodeShared *ctx, const VkVideoSessionParametersCreateInfoKHR *session_params_create)
 Create VkVideoSessionParametersKHR wrapped in an AVBufferRef. More...
 
int ff_vk_decode_uninit (AVCodecContext *avctx)
 Free decoder. More...
 
int ff_vk_decode_init (AVCodecContext *avctx)
 Initialize decoder. More...
 

Variables

static const FFVulkanDecodeDescriptordec_descs []
 

Function Documentation

◆ get_codecdesc()

static const FFVulkanDecodeDescriptor* get_codecdesc ( enum AVCodecID  codec_id)
static

Definition at line 48 of file vulkan_decode.c.

Referenced by ff_vk_decode_init(), and vulkan_decode_get_profile().

◆ get_video_profile()

static const VkVideoProfileInfoKHR* get_video_profile ( FFVulkanDecodeShared ctx,
enum AVCodecID  codec_id 
)
static

Definition at line 57 of file vulkan_decode.c.

Referenced by ff_vk_decode_init(), and ff_vk_update_thread_context().

◆ ff_vk_update_thread_context()

int ff_vk_update_thread_context ( AVCodecContext dst,
const AVCodecContext src 
)

Synchronize the contexts between 2 threads.

Definition at line 79 of file vulkan_decode.c.

◆ ff_vk_params_invalidate()

int ff_vk_params_invalidate ( AVCodecContext avctx,
int  t,
const uint8_t *  b,
uint32_t  s 
)

Removes current session parameters to recreate them.

Definition at line 120 of file vulkan_decode.c.

◆ vk_decode_create_view()

static int vk_decode_create_view ( FFVulkanDecodeContext dec,
VkImageView *  dst_view,
VkImageAspectFlags *  aspect,
AVVkFrame src,
VkFormat  vkf,
int  is_current 
)
static

Definition at line 127 of file vulkan_decode.c.

Referenced by ff_vk_decode_init(), and ff_vk_decode_prepare_frame().

◆ vk_get_dpb_pool()

static AVFrame* vk_get_dpb_pool ( FFVulkanDecodeShared ctx)
static

Definition at line 172 of file vulkan_decode.c.

Referenced by ff_vk_decode_init(), and ff_vk_decode_prepare_frame().

◆ ff_vk_decode_prepare_frame()

int ff_vk_decode_prepare_frame ( FFVulkanDecodeContext dec,
AVFrame pic,
FFVulkanDecodePicture vkpic,
int  is_current,
int  alloc_dpb 
)

Prepare a frame, creates the image view, and sets up the dpb fields.

Definition at line 186 of file vulkan_decode.c.

Referenced by vk_av1_fill_pict(), vk_h264_fill_pict(), and vk_hevc_fill_pict().

◆ ff_vk_decode_add_slice()

int ff_vk_decode_add_slice ( AVCodecContext avctx,
FFVulkanDecodePicture vp,
const uint8_t *  data,
size_t  size,
int  add_startcode,
uint32_t *  nb_slices,
const uint32_t **  offsets 
)

Add slice data to frame.

Definition at line 250 of file vulkan_decode.c.

Referenced by vk_av1_decode_slice(), vk_h264_decode_slice(), and vk_hevc_decode_slice().

◆ ff_vk_decode_flush()

void ff_vk_decode_flush ( AVCodecContext avctx)

Flush decoder.

Definition at line 312 of file vulkan_decode.c.

Referenced by ff_vk_decode_init().

◆ ff_vk_decode_frame()

int ff_vk_decode_frame ( AVCodecContext avctx,
AVFrame pic,
FFVulkanDecodePicture vp,
AVFrame rpic[],
FFVulkanDecodePicture rvkp[] 
)

Decode a frame.

Definition at line 342 of file vulkan_decode.c.

Referenced by vk_av1_end_frame(), vk_h264_end_frame(), and vk_hevc_end_frame().

◆ ff_vk_decode_free_frame()

void ff_vk_decode_free_frame ( AVHWDeviceContext dev_ctx,
FFVulkanDecodePicture vp 
)

Free a frame and its state.

Definition at line 572 of file vulkan_decode.c.

Referenced by vk_av1_free_frame_priv(), vk_h264_free_frame_priv(), and vk_hevc_free_frame_priv().

◆ free_common()

static void free_common ( FFRefStructOpaque  unused,
void *  obj 
)
static

Definition at line 603 of file vulkan_decode.c.

Referenced by vulkan_decode_bootstrap().

◆ vulkan_decode_bootstrap()

static int vulkan_decode_bootstrap ( AVCodecContext avctx,
AVBufferRef frames_ref 
)
static

Definition at line 632 of file vulkan_decode.c.

Referenced by ff_vk_frame_params().

◆ vulkan_setup_profile()

static VkResult vulkan_setup_profile ( AVCodecContext avctx,
FFVulkanDecodeProfileData prof,
AVVulkanDeviceContext hwctx,
FFVulkanFunctions vk,
const FFVulkanDecodeDescriptor vk_desc,
VkVideoDecodeH264CapabilitiesKHR *  h264_caps,
VkVideoDecodeH265CapabilitiesKHR *  h265_caps,
VkVideoDecodeAV1CapabilitiesKHR *  av1_caps,
VkVideoCapabilitiesKHR *  caps,
VkVideoDecodeCapabilitiesKHR *  dec_caps,
int  cur_profile 
)
static

Definition at line 670 of file vulkan_decode.c.

Referenced by vulkan_decode_get_profile().

◆ vulkan_decode_get_profile()

static int vulkan_decode_get_profile ( AVCodecContext avctx,
AVBufferRef frames_ref,
enum AVPixelFormat pix_fmt,
VkFormat vk_fmt,
FFVulkanDecodeProfileData prof,
int dpb_dedicate 
)
static

Definition at line 745 of file vulkan_decode.c.

Referenced by ff_vk_frame_params().

◆ free_profile_data()

static void free_profile_data ( AVHWFramesContext hwfc)
static

Definition at line 1001 of file vulkan_decode.c.

Referenced by ff_vk_frame_params().

◆ ff_vk_frame_params()

int ff_vk_frame_params ( AVCodecContext avctx,
AVBufferRef hw_frames_ctx 
)

Initialize hw_frames_ctx with the parameters needed to decode the stream using the parameters from avctx.

NOTE: if avctx->internal->hwaccel_priv_data exists, will partially initialize the context.

Definition at line 1006 of file vulkan_decode.c.

◆ vk_decode_free_params()

static void vk_decode_free_params ( void *  opaque,
uint8_t *  data 
)
static

Definition at line 1053 of file vulkan_decode.c.

Referenced by ff_vk_decode_create_params().

◆ ff_vk_decode_create_params()

int ff_vk_decode_create_params ( AVBufferRef **  par_ref,
void *  logctx,
FFVulkanDecodeShared ctx,
const VkVideoSessionParametersCreateInfoKHR *  session_params_create 
)

Create VkVideoSessionParametersKHR wrapped in an AVBufferRef.

Definition at line 1063 of file vulkan_decode.c.

Referenced by vk_av1_create_params(), vk_h264_create_params(), and vk_hevc_create_params().

◆ ff_vk_decode_uninit()

int ff_vk_decode_uninit ( AVCodecContext avctx)

Free decoder.

Definition at line 1092 of file vulkan_decode.c.

Referenced by ff_vk_decode_init().

◆ ff_vk_decode_init()

int ff_vk_decode_init ( AVCodecContext avctx)

Initialize decoder.

Definition at line 1107 of file vulkan_decode.c.

Variable Documentation

◆ dec_descs

const FFVulkanDecodeDescriptor* dec_descs[]
static
Initial value:
= {
}

Definition at line 36 of file vulkan_decode.c.

Referenced by get_codecdesc().