FFmpeg
Loading...
Searching...
No Matches
vulkan_decode.c File Reference
#include "libavutil/attributes.h"
#include "libavutil/refstruct.h"
#include "vulkan_video.h"
#include "vulkan_decode.h"
#include "config_components.h"
#include "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "libavutil/vulkan_loader.h"

Go to the source code of this file.

Data Structures

struct  FFVulkanDecodeProfileData
 

Macros

#define DECODER_IS_SDR(codec_id)
 

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.
 
int ff_vk_params_invalidate (AVCodecContext *avctx, int t, const uint8_t *b, uint32_t s)
 Removes current session parameters to recreate them.
 
static AVFramevk_get_dpb_pool (FFVulkanDecodeShared *ctx)
 
static void init_frame (FFVulkanDecodeContext *dec, FFVulkanDecodePicture *vkpic)
 
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.
 
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.
 
static int create_empty_session_parameters (AVCodecContext *avctx, FFVulkanDecodeShared *ctx, VkVideoSessionParametersKHR *empty_session_params)
 
static int decode_reset (AVCodecContext *avctx, FFVulkanDecodeShared *ctx)
 
int ff_vk_decode_frame (AVCodecContext *avctx, AVFrame *pic, FFVulkanDecodePicture *vp, AVFrame *rpic[], FFVulkanDecodePicture *rvkp[])
 Decode a frame.
 
void ff_vk_decode_free_frame (AVHWDeviceContext *dev_ctx, FFVulkanDecodePicture *vp)
 Free a frame and its state.
 
static void free_common (AVRefStructOpaque 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.
 
static void vk_decode_free_params (AVRefStructOpaque opaque, void *obj)
 
int ff_vk_decode_create_params (VkVideoSessionParametersKHR **par_ref, void *logctx, FFVulkanDecodeShared *ctx, const VkVideoSessionParametersCreateInfoKHR *session_params_create)
 Create VkVideoSessionParametersKHR wrapped in an AVBufferRef.
 
int ff_vk_decode_uninit (AVCodecContext *avctx)
 Free decoder.
 
int ff_vk_decode_init (AVCodecContext *avctx)
 Initialize decoder.
 

Variables

static const FFVulkanDecodeDescriptordec_descs []
 

Macro Definition Documentation

◆ DECODER_IS_SDR

#define DECODER_IS_SDR ( codec_id)
Value:
@ AV_CODEC_ID_APV
Definition codec_id.h:323
@ AV_CODEC_ID_FFV1
Definition codec_id.h:83
@ AV_CODEC_ID_PRORES_RAW
Definition codec_id.h:324
@ AV_CODEC_ID_PRORES
Definition codec_id.h:198
@ AV_CODEC_ID_DPX
Definition codec_id.h:178
enum AVCodecID codec_id

Definition at line 28 of file vulkan_decode.c.

Referenced by ff_vk_decode_add_slice(), ff_vk_decode_init(), and ff_vk_frame_params().

Function Documentation

◆ get_codecdesc()

static const FFVulkanDecodeDescriptor * get_codecdesc ( enum AVCodecID codec_id)
static

◆ get_video_profile()

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

Definition at line 115 of file vulkan_decode.c.

Referenced by ff_vk_decode_init().

◆ 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 142 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 157 of file vulkan_decode.c.

◆ vk_get_dpb_pool()

static AVFrame * vk_get_dpb_pool ( FFVulkanDecodeShared * ctx)
static

Definition at line 164 of file vulkan_decode.c.

Referenced by ff_vk_decode_init(), and ff_vk_decode_prepare_frame().

◆ init_frame()

static void init_frame ( FFVulkanDecodeContext * dec,
FFVulkanDecodePicture * vkpic )
static

Definition at line 178 of file vulkan_decode.c.

Referenced by 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 191 of file vulkan_decode.c.

Referenced by vk_av1_fill_pict(), vk_h264_fill_pict(), vk_hevc_fill_pict(), and vk_vp9_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 )

◆ create_empty_session_parameters()

static int create_empty_session_parameters ( AVCodecContext * avctx,
FFVulkanDecodeShared * ctx,
VkVideoSessionParametersKHR * empty_session_params )
static

Definition at line 349 of file vulkan_decode.c.

Referenced by decode_reset().

◆ decode_reset()

static int decode_reset ( AVCodecContext * avctx,
FFVulkanDecodeShared * ctx )
static

Definition at line 390 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 442 of file vulkan_decode.c.

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

◆ ff_vk_decode_free_frame()

◆ free_common()

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

Definition at line 651 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 672 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 713 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 801 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 1078 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 1083 of file vulkan_decode.c.

◆ vk_decode_free_params()

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

Definition at line 1185 of file vulkan_decode.c.

Referenced by ff_vk_decode_create_params().

◆ ff_vk_decode_create_params()

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

Create VkVideoSessionParametersKHR wrapped in an AVBufferRef.

Definition at line 1194 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 1220 of file vulkan_decode.c.

Referenced by ff_vk_decode_init().

◆ ff_vk_decode_init()

int ff_vk_decode_init ( AVCodecContext * avctx)

Variable Documentation

◆ dec_descs

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

Definition at line 63 of file vulkan_decode.c.

Referenced by get_codecdesc().