FFmpeg
Data Structures | Macros | Functions | Variables
ffv1enc_vulkan.c File Reference
#include "libavutil/crc.h"
#include "libavutil/mem.h"
#include "libavutil/vulkan.h"
#include "libavutil/vulkan_spirv.h"
#include "avcodec.h"
#include "internal.h"
#include "hwconfig.h"
#include "encode.h"
#include "libavutil/opt.h"
#include "codec_internal.h"
#include "ffv1.h"
#include "ffv1enc.h"

Go to the source code of this file.

Data Structures

struct  VulkanEncodeFFv1FrameData
 
struct  VulkanEncodeFFv1Context
 
struct  FFv1VkRCTParameters
 
struct  FFv1VkResetParameters
 
struct  FFv1VkParameters
 

Macros

#define LG_ALIGN_W   32
 
#define LG_ALIGN_H   32
 
#define OFFSET(x)   offsetof(VulkanEncodeFFv1Context, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static void add_push_data (FFVulkanShader *shd)
 
static int run_rct (AVCodecContext *avctx, FFVkExecContext *exec, AVFrame *enc_in, VkImageView *enc_in_views, AVFrame **intermediate_frame, VkImageView *intermediate_views, VkImageMemoryBarrier2 *img_bar, int *nb_img_bar, VkBufferMemoryBarrier2 *buf_bar, int *nb_buf_bar, FFVkBuffer *slice_data_buf, uint32_t slice_data_size)
 
static int vulkan_encode_ffv1_submit_frame (AVCodecContext *avctx, FFVkExecContext *exec, const AVFrame *pict)
 
static int download_slices (AVCodecContext *avctx, VkBufferCopy *buf_regions, int nb_regions, VulkanEncodeFFv1FrameData *fd, AVBufferRef *pkt_data_ref)
 
static int get_packet (AVCodecContext *avctx, FFVkExecContext *exec, AVPacket *pkt)
 
static int vulkan_encode_ffv1_receive_packet (AVCodecContext *avctx, AVPacket *pkt)
 
static int init_indirect (AVCodecContext *avctx, enum AVPixelFormat sw_format)
 
static int check_support (AVHWFramesConstraints *constraints, enum AVPixelFormat fmt)
 
static enum AVPixelFormat get_supported_rgb_buffer_fmt (AVCodecContext *avctx)
 
static void define_shared_code (AVCodecContext *avctx, FFVulkanShader *shd)
 
static int init_setup_shader (AVCodecContext *avctx, FFVkSPIRVCompiler *spv)
 
static int init_reset_shader (AVCodecContext *avctx, FFVkSPIRVCompiler *spv)
 
static int init_rct_shader (AVCodecContext *avctx, FFVkSPIRVCompiler *spv)
 
static int init_encode_shader (AVCodecContext *avctx, FFVkSPIRVCompiler *spv)
 
static int init_state_transition_data (AVCodecContext *avctx)
 
static int init_quant_table_data (AVCodecContext *avctx)
 
static int init_crc_table_data (AVCodecContext *avctx)
 
static av_cold int vulkan_encode_ffv1_init (AVCodecContext *avctx)
 
static av_cold int vulkan_encode_ffv1_close (AVCodecContext *avctx)
 

Variables

const char * ff_source_common_comp
 
const char * ff_source_rangecoder_comp
 
const char * ff_source_ffv1_vlc_comp
 
const char * ff_source_ffv1_common_comp
 
const char * ff_source_ffv1_reset_comp
 
const char * ff_source_ffv1_enc_common_comp
 
const char * ff_source_ffv1_enc_rct_comp
 
const char * ff_source_ffv1_enc_vlc_comp
 
const char * ff_source_ffv1_enc_ac_comp
 
const char * ff_source_ffv1_enc_setup_comp
 
const char * ff_source_ffv1_enc_comp
 
const char * ff_source_ffv1_enc_rgb_comp
 
static const AVOption vulkan_encode_ffv1_options []
 
static const FFCodecDefault vulkan_encode_ffv1_defaults []
 
static const AVClass vulkan_encode_ffv1_class
 
const AVCodecHWConfigInternal *const vulkan_encode_ffv1_hw_configs []
 
const FFCodec ff_ffv1_vulkan_encoder
 

Macro Definition Documentation

◆ LG_ALIGN_W

#define LG_ALIGN_W   32

Definition at line 37 of file ffv1enc_vulkan.c.

◆ LG_ALIGN_H

#define LG_ALIGN_H   32

Definition at line 38 of file ffv1enc_vulkan.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(VulkanEncodeFFv1Context, x)

Definition at line 1784 of file ffv1enc_vulkan.c.

◆ VE

Definition at line 1785 of file ffv1enc_vulkan.c.

Function Documentation

◆ add_push_data()

static void add_push_data ( FFVulkanShader shd)
static

Definition at line 172 of file ffv1enc_vulkan.c.

Referenced by init_encode_shader(), and init_setup_shader().

◆ run_rct()

static int run_rct ( AVCodecContext avctx,
FFVkExecContext exec,
AVFrame enc_in,
VkImageView *  enc_in_views,
AVFrame **  intermediate_frame,
VkImageView *  intermediate_views,
VkImageMemoryBarrier2 *  img_bar,
int *  nb_img_bar,
VkBufferMemoryBarrier2 *  buf_bar,
int *  nb_buf_bar,
FFVkBuffer slice_data_buf,
uint32_t  slice_data_size 
)
static

Definition at line 207 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_submit_frame().

◆ vulkan_encode_ffv1_submit_frame()

static int vulkan_encode_ffv1_submit_frame ( AVCodecContext avctx,
FFVkExecContext exec,
const AVFrame pict 
)
static

Definition at line 302 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_receive_packet().

◆ download_slices()

static int download_slices ( AVCodecContext avctx,
VkBufferCopy *  buf_regions,
int  nb_regions,
VulkanEncodeFFv1FrameData fd,
AVBufferRef pkt_data_ref 
)
static

Definition at line 663 of file ffv1enc_vulkan.c.

Referenced by get_packet().

◆ get_packet()

static int get_packet ( AVCodecContext avctx,
FFVkExecContext exec,
AVPacket pkt 
)
static

Definition at line 737 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_receive_packet().

◆ vulkan_encode_ffv1_receive_packet()

static int vulkan_encode_ffv1_receive_packet ( AVCodecContext avctx,
AVPacket pkt 
)
static

Definition at line 817 of file ffv1enc_vulkan.c.

◆ init_indirect()

static int init_indirect ( AVCodecContext avctx,
enum AVPixelFormat  sw_format 
)
static

Definition at line 871 of file ffv1enc_vulkan.c.

Referenced by init_rct_shader().

◆ check_support()

static int check_support ( AVHWFramesConstraints constraints,
enum AVPixelFormat  fmt 
)
static

Definition at line 904 of file ffv1enc_vulkan.c.

Referenced by get_supported_rgb_buffer_fmt().

◆ get_supported_rgb_buffer_fmt()

static enum AVPixelFormat get_supported_rgb_buffer_fmt ( AVCodecContext avctx)
static

Definition at line 914 of file ffv1enc_vulkan.c.

Referenced by init_rct_shader().

◆ define_shared_code()

static void define_shared_code ( AVCodecContext avctx,
FFVulkanShader shd 
)
static

◆ init_setup_shader()

static int init_setup_shader ( AVCodecContext avctx,
FFVkSPIRVCompiler spv 
)
static

Definition at line 978 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_reset_shader()

static int init_reset_shader ( AVCodecContext avctx,
FFVkSPIRVCompiler spv 
)
static

Definition at line 1058 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_rct_shader()

static int init_rct_shader ( AVCodecContext avctx,
FFVkSPIRVCompiler spv 
)
static

Definition at line 1139 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_encode_shader()

static int init_encode_shader ( AVCodecContext avctx,
FFVkSPIRVCompiler spv 
)
static

Definition at line 1248 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_state_transition_data()

static int init_state_transition_data ( AVCodecContext avctx)
static

Definition at line 1359 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_quant_table_data()

static int init_quant_table_data ( AVCodecContext avctx)
static

Definition at line 1400 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_crc_table_data()

static int init_crc_table_data ( AVCodecContext avctx)
static

Definition at line 1433 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ vulkan_encode_ffv1_init()

static av_cold int vulkan_encode_ffv1_init ( AVCodecContext avctx)
static

Definition at line 1463 of file ffv1enc_vulkan.c.

◆ vulkan_encode_ffv1_close()

static av_cold int vulkan_encode_ffv1_close ( AVCodecContext avctx)
static

Definition at line 1740 of file ffv1enc_vulkan.c.

Variable Documentation

◆ ff_source_common_comp

const char* ff_source_common_comp

Referenced by define_shared_code().

◆ ff_source_rangecoder_comp

const char* ff_source_rangecoder_comp

Referenced by define_shared_code().

◆ ff_source_ffv1_vlc_comp

const char* ff_source_ffv1_vlc_comp

Referenced by define_shared_code().

◆ ff_source_ffv1_common_comp

const char* ff_source_ffv1_common_comp

Referenced by define_shared_code().

◆ ff_source_ffv1_reset_comp

const char* ff_source_ffv1_reset_comp

Referenced by init_reset_shader().

◆ ff_source_ffv1_enc_common_comp

const char* ff_source_ffv1_enc_common_comp

Referenced by init_encode_shader().

◆ ff_source_ffv1_enc_rct_comp

const char* ff_source_ffv1_enc_rct_comp

Referenced by init_rct_shader().

◆ ff_source_ffv1_enc_vlc_comp

const char* ff_source_ffv1_enc_vlc_comp

Referenced by init_encode_shader().

◆ ff_source_ffv1_enc_ac_comp

const char* ff_source_ffv1_enc_ac_comp

Referenced by init_encode_shader().

◆ ff_source_ffv1_enc_setup_comp

const char* ff_source_ffv1_enc_setup_comp

Referenced by init_setup_shader().

◆ ff_source_ffv1_enc_comp

const char* ff_source_ffv1_enc_comp

Referenced by init_encode_shader().

◆ ff_source_ffv1_enc_rgb_comp

const char* ff_source_ffv1_enc_rgb_comp

Referenced by init_encode_shader().

◆ vulkan_encode_ffv1_options

const AVOption vulkan_encode_ffv1_options[]
static

Definition at line 1786 of file ffv1enc_vulkan.c.

◆ vulkan_encode_ffv1_defaults

const FFCodecDefault vulkan_encode_ffv1_defaults[]
static
Initial value:
= {
{ "g", "1" },
{ NULL },
}

Definition at line 1820 of file ffv1enc_vulkan.c.

◆ vulkan_encode_ffv1_class

const AVClass vulkan_encode_ffv1_class
static
Initial value:
= {
.class_name = "ffv1_vulkan",
.item_name = av_default_item_name,
}

Definition at line 1825 of file ffv1enc_vulkan.c.

◆ vulkan_encode_ffv1_hw_configs

const AVCodecHWConfigInternal* const vulkan_encode_ffv1_hw_configs[]
Initial value:
= {
HW_CONFIG_ENCODER_FRAMES(VULKAN, VULKAN),
}

Definition at line 1832 of file ffv1enc_vulkan.c.

◆ ff_ffv1_vulkan_encoder

const FFCodec ff_ffv1_vulkan_encoder
Initial value:

Definition at line 1837 of file ffv1enc_vulkan.c.

AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:43
AV_CODEC_CAP_HARDWARE
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:145
FF_CODEC_CAP_EOF_FLUSH
#define FF_CODEC_CAP_EOF_FLUSH
The encoder has AV_CODEC_CAP_DELAY set, but does not actually have delay - it only wants to be flushe...
Definition: codec_internal.h:90
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
vulkan_encode_ffv1_class
static const AVClass vulkan_encode_ffv1_class
Definition: ffv1enc_vulkan.c:1825
AV_CODEC_CAP_ENCODER_FLUSH
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
Definition: codec.h:166
vulkan_encode_ffv1_hw_configs
const AVCodecHWConfigInternal *const vulkan_encode_ffv1_hw_configs[]
Definition: ffv1enc_vulkan.c:1832
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
vulkan_encode_ffv1_receive_packet
static int vulkan_encode_ffv1_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: ffv1enc_vulkan.c:817
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
FF_CODEC_RECEIVE_PACKET_CB
#define FF_CODEC_RECEIVE_PACKET_CB(func)
Definition: codec_internal.h:326
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
VulkanEncodeFFv1Context
Definition: ffv1enc_vulkan.c:56
AV_CODEC_ID_FFV1
@ AV_CODEC_ID_FFV1
Definition: codec_id.h:85
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
HW_CONFIG_ENCODER_FRAMES
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
Definition: hwconfig.h:98
vulkan_encode_ffv1_close
static av_cold int vulkan_encode_ffv1_close(AVCodecContext *avctx)
Definition: ffv1enc_vulkan.c:1740
vulkan_encode_ffv1_options
static const AVOption vulkan_encode_ffv1_options[]
Definition: ffv1enc_vulkan.c:1786
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
vulkan_encode_ffv1_defaults
static const FFCodecDefault vulkan_encode_ffv1_defaults[]
Definition: ffv1enc_vulkan.c:1820
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
vulkan_encode_ffv1_init
static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx)
Definition: ffv1enc_vulkan.c:1463