FFmpeg
Loading...
Searching...
No Matches
ffv1enc_vulkan.c File Reference
#include "libavutil/mem.h"
#include "libavutil/vulkan.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"
#include "ffv1_vulkan.h"

Go to the source code of this file.

Data Structures

struct  VulkanEncodeFFv1FrameData
 
struct  VulkanEncodeFFv1Context
 
struct  SegGatherPushData
 

Macros

#define LG_ALIGN_W   32
 
#define LG_ALIGN_H   32
 
#define RGB_LINECACHE   4
 
#define OFFSET(x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static size_t ffv1_vk_buffer_size (AVCodecContext *avctx)
 
static int run_rct_search (AVCodecContext *avctx, FFVkExecContext *exec, AVFrame *enc_in, VkImageView *enc_in_views, FFVkBuffer *slice_data_buf, uint32_t slice_data_size, FFv1ShaderParams *pd)
 
static int run_remap (AVCodecContext *avctx, FFVkExecContext *exec, AVFrame *enc_in, VkImageView *enc_in_views, FFVkBuffer *fltmap_buf, uint32_t fltmap_size, FFv1ShaderParams *pd)
 
static int run_sort32 (AVCodecContext *avctx, FFVkExecContext *exec, AVFrame *enc_in, VkImageView *enc_in_views, FFVkBuffer *units_buf, uint32_t units_size, FFv1ShaderParams *pd)
 
static int vulkan_encode_ffv1_submit_frame (AVCodecContext *avctx, FFVkExecContext *exec, const AVFrame *pict)
 
static void ffv1_vk_packet_free (void *opaque, uint8_t *data)
 
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 init_rct_search_shader (AVCodecContext *avctx, VkSpecializationInfo *sl)
 
static int init_sort32_shader (AVCodecContext *avctx, VkSpecializationInfo *sl)
 
static int init_remap_shader (AVCodecContext *avctx, VkSpecializationInfo *sl)
 
static int init_setup_shader (AVCodecContext *avctx, VkSpecializationInfo *sl)
 
static int init_reset_shader (AVCodecContext *avctx, VkSpecializationInfo *sl)
 
static int init_encode_shader (AVCodecContext *avctx, VkSpecializationInfo *sl)
 
static int init_gather_shader (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_enc_comp
 
const unsigned char ff_ffv1_enc_setup_comp_spv_data []
 
const unsigned int ff_ffv1_enc_setup_comp_spv_len
 
const unsigned char ff_ffv1_enc_reset_comp_spv_data []
 
const unsigned int ff_ffv1_enc_reset_comp_spv_len
 
const unsigned char ff_ffv1_enc_reset_golomb_comp_spv_data []
 
const unsigned int ff_ffv1_enc_reset_golomb_comp_spv_len
 
const unsigned char ff_ffv1_enc_comp_spv_data []
 
const unsigned int ff_ffv1_enc_comp_spv_len
 
const unsigned char ff_ffv1_enc_rgb_comp_spv_data []
 
const unsigned int ff_ffv1_enc_rgb_comp_spv_len
 
const unsigned char ff_ffv1_enc_golomb_comp_spv_data []
 
const unsigned int ff_ffv1_enc_golomb_comp_spv_len
 
const unsigned char ff_ffv1_enc_rgb_golomb_comp_spv_data []
 
const unsigned int ff_ffv1_enc_rgb_golomb_comp_spv_len
 
const unsigned char ff_ffv1_enc_rct_search_comp_spv_data []
 
const unsigned int ff_ffv1_enc_rct_search_comp_spv_len
 
const unsigned char ff_ffv1_enc_remap_comp_spv_data []
 
const unsigned int ff_ffv1_enc_remap_comp_spv_len
 
const unsigned char ff_ffv1_enc_rgb_float_comp_spv_data []
 
const unsigned int ff_ffv1_enc_rgb_float_comp_spv_len
 
const unsigned char ff_ffv1_enc_rgb_float_golomb_comp_spv_data []
 
const unsigned int ff_ffv1_enc_rgb_float_golomb_comp_spv_len
 
const unsigned char ff_ffv1_enc_sort32_comp_spv_data []
 
const unsigned int ff_ffv1_enc_sort32_comp_spv_len
 
const unsigned char ff_ffv1_enc_bayer_comp_spv_data []
 
const unsigned int ff_ffv1_enc_bayer_comp_spv_len
 
const unsigned char ff_ffv1_enc_bayer_golomb_comp_spv_data []
 
const unsigned int ff_ffv1_enc_bayer_golomb_comp_spv_len
 
const unsigned char ff_seg_gather_comp_spv_data []
 
const unsigned int ff_seg_gather_comp_spv_len
 
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 36 of file ffv1enc_vulkan.c.

◆ LG_ALIGN_H

#define LG_ALIGN_H   32

Definition at line 37 of file ffv1enc_vulkan.c.

◆ RGB_LINECACHE

#define RGB_LINECACHE   4

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 1613 of file ffv1enc_vulkan.c.

◆ VE

Definition at line 1614 of file ffv1enc_vulkan.c.

Function Documentation

◆ ffv1_vk_buffer_size()

static size_t ffv1_vk_buffer_size ( AVCodecContext * avctx)
static

Definition at line 173 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init(), and vulkan_encode_ffv1_submit_frame().

◆ run_rct_search()

static int run_rct_search ( AVCodecContext * avctx,
FFVkExecContext * exec,
AVFrame * enc_in,
VkImageView * enc_in_views,
FFVkBuffer * slice_data_buf,
uint32_t slice_data_size,
FFv1ShaderParams * pd )
static

Definition at line 187 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_submit_frame().

◆ run_remap()

static int run_remap ( AVCodecContext * avctx,
FFVkExecContext * exec,
AVFrame * enc_in,
VkImageView * enc_in_views,
FFVkBuffer * fltmap_buf,
uint32_t fltmap_size,
FFv1ShaderParams * pd )
static

Definition at line 218 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_submit_frame().

◆ run_sort32()

static int run_sort32 ( AVCodecContext * avctx,
FFVkExecContext * exec,
AVFrame * enc_in,
VkImageView * enc_in_views,
FFVkBuffer * units_buf,
uint32_t units_size,
FFv1ShaderParams * pd )
static

Definition at line 249 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 280 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_receive_packet().

◆ ffv1_vk_packet_free()

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

Definition at line 773 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 778 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 854 of file ffv1enc_vulkan.c.

◆ init_indirect()

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

Definition at line 908 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_rct_search_shader()

static int init_rct_search_shader ( AVCodecContext * avctx,
VkSpecializationInfo * sl )
static

Definition at line 943 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_sort32_shader()

static int init_sort32_shader ( AVCodecContext * avctx,
VkSpecializationInfo * sl )
static

Definition at line 986 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_remap_shader()

static int init_remap_shader ( AVCodecContext * avctx,
VkSpecializationInfo * sl )
static

Definition at line 1034 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_setup_shader()

static int init_setup_shader ( AVCodecContext * avctx,
VkSpecializationInfo * sl )
static

Definition at line 1081 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_reset_shader()

static int init_reset_shader ( AVCodecContext * avctx,
VkSpecializationInfo * sl )
static

Definition at line 1123 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_encode_shader()

static int init_encode_shader ( AVCodecContext * avctx,
VkSpecializationInfo * sl )
static

Definition at line 1172 of file ffv1enc_vulkan.c.

Referenced by vulkan_encode_ffv1_init().

◆ init_gather_shader()

static int init_gather_shader ( AVCodecContext * avctx)
static

Definition at line 1276 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 1306 of file ffv1enc_vulkan.c.

◆ vulkan_encode_ffv1_close()

static av_cold int vulkan_encode_ffv1_close ( AVCodecContext * avctx)
static

Definition at line 1569 of file ffv1enc_vulkan.c.

Variable Documentation

◆ ff_source_common_comp

const char* ff_source_common_comp
extern

◆ ff_source_rangecoder_comp

const char* ff_source_rangecoder_comp
extern

◆ ff_source_ffv1_vlc_comp

const char* ff_source_ffv1_vlc_comp
extern

◆ ff_source_ffv1_common_comp

const char* ff_source_ffv1_common_comp
extern

◆ ff_source_ffv1_enc_comp

const char* ff_source_ffv1_enc_comp
extern

◆ ff_ffv1_enc_setup_comp_spv_data

const unsigned char ff_ffv1_enc_setup_comp_spv_data[]
extern

Referenced by init_setup_shader().

◆ ff_ffv1_enc_setup_comp_spv_len

const unsigned int ff_ffv1_enc_setup_comp_spv_len
extern

Referenced by init_setup_shader().

◆ ff_ffv1_enc_reset_comp_spv_data

const unsigned char ff_ffv1_enc_reset_comp_spv_data[]
extern

Referenced by init_reset_shader().

◆ ff_ffv1_enc_reset_comp_spv_len

const unsigned int ff_ffv1_enc_reset_comp_spv_len
extern

Referenced by init_reset_shader().

◆ ff_ffv1_enc_reset_golomb_comp_spv_data

const unsigned char ff_ffv1_enc_reset_golomb_comp_spv_data[]
extern

Referenced by init_reset_shader().

◆ ff_ffv1_enc_reset_golomb_comp_spv_len

const unsigned int ff_ffv1_enc_reset_golomb_comp_spv_len
extern

Referenced by init_reset_shader().

◆ ff_ffv1_enc_comp_spv_data

const unsigned char ff_ffv1_enc_comp_spv_data[]
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_comp_spv_len

const unsigned int ff_ffv1_enc_comp_spv_len
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_rgb_comp_spv_data

const unsigned char ff_ffv1_enc_rgb_comp_spv_data[]
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_rgb_comp_spv_len

const unsigned int ff_ffv1_enc_rgb_comp_spv_len
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_golomb_comp_spv_data

const unsigned char ff_ffv1_enc_golomb_comp_spv_data[]
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_golomb_comp_spv_len

const unsigned int ff_ffv1_enc_golomb_comp_spv_len
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_rgb_golomb_comp_spv_data

const unsigned char ff_ffv1_enc_rgb_golomb_comp_spv_data[]
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_rgb_golomb_comp_spv_len

const unsigned int ff_ffv1_enc_rgb_golomb_comp_spv_len
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_rct_search_comp_spv_data

const unsigned char ff_ffv1_enc_rct_search_comp_spv_data[]
extern

Referenced by init_rct_search_shader().

◆ ff_ffv1_enc_rct_search_comp_spv_len

const unsigned int ff_ffv1_enc_rct_search_comp_spv_len
extern

Referenced by init_rct_search_shader().

◆ ff_ffv1_enc_remap_comp_spv_data

const unsigned char ff_ffv1_enc_remap_comp_spv_data[]
extern

Referenced by init_remap_shader().

◆ ff_ffv1_enc_remap_comp_spv_len

const unsigned int ff_ffv1_enc_remap_comp_spv_len
extern

Referenced by init_remap_shader().

◆ ff_ffv1_enc_rgb_float_comp_spv_data

const unsigned char ff_ffv1_enc_rgb_float_comp_spv_data[]
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_rgb_float_comp_spv_len

const unsigned int ff_ffv1_enc_rgb_float_comp_spv_len
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_rgb_float_golomb_comp_spv_data

const unsigned char ff_ffv1_enc_rgb_float_golomb_comp_spv_data[]
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_rgb_float_golomb_comp_spv_len

const unsigned int ff_ffv1_enc_rgb_float_golomb_comp_spv_len
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_sort32_comp_spv_data

const unsigned char ff_ffv1_enc_sort32_comp_spv_data[]
extern

Referenced by init_sort32_shader().

◆ ff_ffv1_enc_sort32_comp_spv_len

const unsigned int ff_ffv1_enc_sort32_comp_spv_len
extern

Referenced by init_sort32_shader().

◆ ff_ffv1_enc_bayer_comp_spv_data

const unsigned char ff_ffv1_enc_bayer_comp_spv_data[]
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_bayer_comp_spv_len

const unsigned int ff_ffv1_enc_bayer_comp_spv_len
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_bayer_golomb_comp_spv_data

const unsigned char ff_ffv1_enc_bayer_golomb_comp_spv_data[]
extern

Referenced by init_encode_shader().

◆ ff_ffv1_enc_bayer_golomb_comp_spv_len

const unsigned int ff_ffv1_enc_bayer_golomb_comp_spv_len
extern

Referenced by init_encode_shader().

◆ ff_seg_gather_comp_spv_data

const unsigned char ff_seg_gather_comp_spv_data[]
extern

◆ ff_seg_gather_comp_spv_len

const unsigned int ff_seg_gather_comp_spv_len
extern

◆ vulkan_encode_ffv1_options

const AVOption vulkan_encode_ffv1_options[]
static

Definition at line 1615 of file ffv1enc_vulkan.c.

◆ vulkan_encode_ffv1_defaults

const FFCodecDefault vulkan_encode_ffv1_defaults[]
static
Initial value:
= {
{ "g", "1" },
{ NULL },
}
#define NULL
Definition coverity.c:32

Definition at line 1665 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,
}
static const AVOption vulkan_encode_ffv1_options[]
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 1670 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),
}
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
Definition hwconfig.h:100

Definition at line 1677 of file ffv1enc_vulkan.c.

◆ ff_ffv1_vulkan_encoder

const FFCodec ff_ffv1_vulkan_encoder
Initial value:
= {
.p.name = "ffv1_vulkan",
CODEC_LONG_NAME("FFmpeg video codec #1 (Vulkan)"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(VulkanEncodeFFv1Context),
.p.priv_class = &vulkan_encode_ffv1_class,
.p.capabilities = AV_CODEC_CAP_DELAY |
.p.wrapper_name = "vulkan",
}
#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...
#define CODEC_PIXFMTS(...)
#define FF_CODEC_RECEIVE_PACKET_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static const FFCodecDefault vulkan_encode_ffv1_defaults[]
static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx)
static av_cold int vulkan_encode_ffv1_close(AVCodecContext *avctx)
const AVCodecHWConfigInternal *const vulkan_encode_ffv1_hw_configs[]
static int vulkan_encode_ffv1_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
static const AVClass vulkan_encode_ffv1_class
#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:147
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
Definition codec.h:154
#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:79
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition codec.h:133
@ AV_CODEC_ID_FFV1
Definition codec_id.h:83
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition pixfmt.h:379

Definition at line 1682 of file ffv1enc_vulkan.c.