FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Macros | Functions | Variables
vulkan_decode.c File Reference
#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.

Macros

#define DECODER_IS_SDR(codec_id)   ((codec_id) == AV_CODEC_ID_FFV1)
 

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 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. More...
 
int ff_vk_decode_prepare_frame_sdr (FFVulkanDecodeContext *dec, AVFrame *pic, FFVulkanDecodePicture *vkpic, int is_current, enum FFVkShaderRepFormat rep_fmt, int alloc_dpb)
 Software-defined decoder version of ff_vk_decode_prepare_frame. 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 (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. 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...
 
static int create_empty_session_parameters (AVCodecContext *avctx, FFVulkanDecodeShared *ctx)
 
int ff_vk_decode_init (AVCodecContext *avctx)
 Initialize decoder. More...
 

Variables

static const FFVulkanDecodeDescriptordec_descs []
 

Macro Definition Documentation

◆ DECODER_IS_SDR

#define DECODER_IS_SDR (   codec_id)    ((codec_id) == AV_CODEC_ID_FFV1)

Definition at line 27 of file vulkan_decode.c.

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 67 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 91 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 110 of file vulkan_decode.c.

◆ vk_get_dpb_pool()

static AVFrame* vk_get_dpb_pool ( FFVulkanDecodeShared ctx)
static

◆ init_frame()

static void init_frame ( FFVulkanDecodeContext dec,
FFVulkanDecodePicture vkpic 
)
static

Definition at line 131 of file vulkan_decode.c.

Referenced by ff_vk_decode_prepare_frame(), and ff_vk_decode_prepare_frame_sdr().

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

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

◆ ff_vk_decode_prepare_frame_sdr()

int ff_vk_decode_prepare_frame_sdr ( FFVulkanDecodeContext dec,
AVFrame pic,
FFVulkanDecodePicture vkpic,
int  is_current,
enum FFVkShaderRepFormat  rep_fmt,
int  alloc_dpb 
)

Software-defined decoder version of ff_vk_decode_prepare_frame.

Definition at line 204 of file vulkan_decode.c.

Referenced by vk_ffv1_start_frame().

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

Referenced by vk_av1_decode_slice(), vk_ffv1_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 332 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 368 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 574 of file vulkan_decode.c.

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

◆ free_common()

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

Definition at line 607 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 635 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 676 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 751 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 1011 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 1016 of file vulkan_decode.c.

◆ vk_decode_free_params()

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

Definition at line 1094 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 1104 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 1133 of file vulkan_decode.c.

Referenced by ff_vk_decode_init().

◆ create_empty_session_parameters()

static int create_empty_session_parameters ( AVCodecContext avctx,
FFVulkanDecodeShared ctx 
)
static

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

Referenced by vk_decode_ffv1_init().

Variable Documentation

◆ dec_descs

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

Definition at line 43 of file vulkan_decode.c.

Referenced by get_codecdesc().