Go to the documentation of this file.
40 #define RGB_LINECACHE 4
135 AVFrame *enc_in, VkImageView *enc_in_views,
136 FFVkBuffer *slice_data_buf, uint32_t slice_data_size,
147 0, slice_data_size*
f->slice_count,
148 VK_FORMAT_UNDEFINED);
150 enc_in, enc_in_views,
152 VK_IMAGE_LAYOUT_GENERAL,
157 VK_SHADER_STAGE_COMPUTE_BIT,
179 uint32_t plane_state_size;
180 uint32_t slice_state_size;
181 uint32_t slice_data_size;
187 int has_inter = avctx->
gop_size > 1;
188 uint32_t context_count =
f->context_count[
f->context_model];
190 VkImageMemoryBarrier2 img_bar[37];
192 VkBufferMemoryBarrier2 buf_bar[8];
196 f->cur_enc_frame = pict;
205 f->slice_count =
f->max_slice_count;
209 plane_state_size = 8;
213 plane_state_size *= context_count;
214 slice_state_size = plane_state_size*
f->plane_count;
216 slice_data_size = 256;
217 slice_state_size += slice_data_size;
218 slice_state_size =
FFALIGN(slice_state_size, 8);
222 if (!slice_data_ref) {
225 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
226 NULL, slice_state_size*
f->slice_count,
227 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
240 VkMemoryPropertyFlagBits out_buf_flags;
241 if (maxsize < fv->max_heap_size) {
242 out_buf_flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
245 out_buf_flags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
247 out_buf_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
253 VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
254 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
255 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
256 NULL, maxsize, out_buf_flags));
282 .plane_state_size = plane_state_size,
283 .key_frame =
f->key_frame,
285 .micro_version =
f->micro_version,
291 .slice_size_max = out_data_buf->
size /
f->slice_count,
294 for (
int i = 0;
i <
f->quant_table_count;
i++) {
297 f->quant_tables[
i][4][127];
304 memcpy(pd.
fmt_lut, (
int [4]) { 2, 1, 0, 3 }, 4*
sizeof(
int));
319 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
320 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
323 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
324 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
330 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
331 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
332 VK_ACCESS_SHADER_READ_BIT,
333 VK_IMAGE_LAYOUT_GENERAL,
334 VK_QUEUE_FAMILY_IGNORED);
336 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
337 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
338 .pImageMemoryBarriers = img_bar,
339 .imageMemoryBarrierCount = nb_img_bar,
345 slice_data_buf, slice_data_size, &pd));
349 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
350 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
351 0, slice_data_size*
f->slice_count);
352 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
353 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
354 .pBufferMemoryBarriers = buf_bar,
355 .bufferMemoryBarrierCount = nb_buf_bar,
364 0, slice_data_size*
f->slice_count,
365 VK_FORMAT_UNDEFINED);
369 VK_SHADER_STAGE_COMPUTE_BIT,
377 vkf->
layout[0] = VK_IMAGE_LAYOUT_UNDEFINED;
378 vkf->
access[0] = VK_ACCESS_2_NONE;
385 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
386 VK_PIPELINE_STAGE_2_CLEAR_BIT,
387 VK_ACCESS_2_TRANSFER_WRITE_BIT,
388 VK_IMAGE_LAYOUT_GENERAL,
389 VK_QUEUE_FAMILY_IGNORED);
390 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
391 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
392 .pImageMemoryBarriers = img_bar,
393 .imageMemoryBarrierCount = nb_img_bar,
397 vk->CmdClearColorImage(exec->
buf, vkf->
img[0], VK_IMAGE_LAYOUT_GENERAL,
398 &((VkClearColorValue) { 0 }),
399 1, &((VkImageSubresourceRange) {
400 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
411 0, slice_data_size*
f->slice_count,
412 VK_FORMAT_UNDEFINED);
418 VK_FORMAT_UNDEFINED);
422 VK_SHADER_STAGE_COMPUTE_BIT,
431 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
432 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
433 0, slice_data_size*
f->slice_count);
436 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
437 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
438 slice_data_size*
f->slice_count, VK_WHOLE_SIZE);
441 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
442 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
443 slice_data_size*
f->slice_count, VK_WHOLE_SIZE);
446 fv->
optimize_rct ? VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT :
447 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
448 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
449 VK_ACCESS_SHADER_READ_BIT,
450 VK_IMAGE_LAYOUT_GENERAL,
451 VK_QUEUE_FAMILY_IGNORED);
455 VK_PIPELINE_STAGE_2_CLEAR_BIT,
456 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
457 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
458 VK_IMAGE_LAYOUT_GENERAL,
459 VK_QUEUE_FAMILY_IGNORED);
461 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
462 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
463 .pImageMemoryBarriers = img_bar,
464 .imageMemoryBarrierCount = nb_img_bar,
465 .pBufferMemoryBarriers = buf_bar,
466 .bufferMemoryBarrierCount = nb_buf_bar,
475 0, slice_data_size*
f->slice_count,
476 VK_FORMAT_UNDEFINED);
480 fd->
idx*
f->max_slice_count*
sizeof(uint32_t),
481 f->slice_count*
sizeof(uint32_t),
482 VK_FORMAT_UNDEFINED);
488 VK_FORMAT_UNDEFINED);
492 VK_IMAGE_LAYOUT_GENERAL,
498 VK_IMAGE_LAYOUT_GENERAL,
503 VK_SHADER_STAGE_COMPUTE_BIT,
527 VkBufferCopy *buf_regions,
int nb_regions,
541 VkBufferMemoryBarrier2 buf_bar[8];
545 VK_BUFFER_USAGE_TRANSFER_DST_BIT);
563 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
564 TRANSFER_BIT, TRANSFER_READ_BIT, NONE_KHR,
566 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
567 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
568 .pBufferMemoryBarriers = buf_bar,
569 .bufferMemoryBarrierCount = nb_buf_bar,
573 for (
int i = 0;
i < nb_regions;
i++)
574 buf_regions[
i].dstOffset += mapped_buf->virtual_offset;
576 vk->CmdCopyBuffer(exec->
buf,
577 out_data_buf->
buf, mapped_buf->buf,
578 nb_regions, buf_regions);
601 uint32_t slice_size_max = out_data_buf->
size /
f->slice_count;
607 uint32_t rb_off = fd->
idx*
f->max_slice_count*
sizeof(uint32_t);
609 VkMappedMemoryRange invalidate_data = {
610 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
613 .size =
f->slice_count*
sizeof(uint32_t),
616 1, &invalidate_data);
622 for (
int i = 0;
i <
f->slice_count;
i++) {
623 uint32_t sl_len =
AV_RN32(rb +
i*4);
627 .srcOffset =
i*slice_size_max,
659 if (!(out_data_buf->
flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
660 VkMappedMemoryRange invalidate_data = {
661 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
662 .memory = out_data_buf->
mem,
664 .size = VK_WHOLE_SIZE,
667 1, &invalidate_data);
671 for (
int i = 0;
i <
f->slice_count;
i++) {
673 memcpy(
pkt->
data + region->dstOffset,
755 vk_frames = frames_ctx->
hwctx;
756 vk_frames->
tiling = VK_IMAGE_TILING_OPTIMAL;
757 vk_frames->
usage = VK_IMAGE_USAGE_STORAGE_BIT |
758 VK_IMAGE_USAGE_TRANSFER_DST_BIT;
759 vk_frames->
img_flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
779 (uint32_t []) { 32, 32, 1 }, 0);
782 VK_SHADER_STAGE_COMPUTE_BIT);
786 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
787 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
794 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
795 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
798 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
799 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
822 (uint32_t []) { 1, 1, 1 }, 0);
825 VK_SHADER_STAGE_COMPUTE_BIT);
829 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
830 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
837 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
838 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
859 int wg_dim =
FFMIN(fv->
s.
props.properties.limits.maxComputeWorkGroupSize[0], 1024);
862 (uint32_t []) { wg_dim, 1, 1 }, 0);
865 VK_SHADER_STAGE_COMPUTE_BIT);
869 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
870 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
877 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
878 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
881 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
882 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
910 (uint32_t []) { wg_x, 1, 1 }, 0);
913 VK_SHADER_STAGE_COMPUTE_BIT);
917 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
918 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
921 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
922 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
925 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
926 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
933 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
934 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
937 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
938 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
941 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
942 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
945 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
946 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
950 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
951 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
985 size_t maxsize, max_heap_size, max_host_size;
1007 if (
f->bits_per_raw_sample > (
f->version > 3 ? 16 : 8)) {
1010 "forcing range coder\n");
1015 if (
f->version < 4 && avctx->
gop_size > 1) {
1026 if (
f->version == 4 &&
f->micro_version > 4)
1027 f->micro_version = 3;
1032 if (
f->num_h_slices <= 0 &&
f->num_v_slices <= 0) {
1038 f->num_h_slices = 32;
1039 f->num_v_slices = 32;
1041 }
else if (
f->num_h_slices &&
f->num_v_slices <= 0) {
1043 }
else if (
f->num_v_slices &&
f->num_h_slices <= 0) {
1047 f->num_h_slices =
FFMIN(
f->num_h_slices, avctx->
width);
1052 "by the standard is %i\n",
1057 f->max_slice_count =
f->num_h_slices *
f->num_v_slices;
1062 if (
f->version < 4) {
1063 if (((
f->chroma_h_shift > 0) && (avctx->
width % (64 <<
f->chroma_h_shift))) ||
1064 ((
f->chroma_v_shift > 0) && (avctx->
height % (64 <<
f->chroma_v_shift)))) {
1066 "dimensions is only supported in version 4 (-level 4)\n");
1072 if (
f->version < 4) {
1095 for (
int i = 0;
i < fv->
s.
mprops.memoryHeapCount;
i++) {
1096 if (fv->
s.
mprops.memoryHeaps[
i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
1099 if (!(fv->
s.
mprops.memoryHeaps[
i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT))
1100 max_host_size =
FFMAX(max_host_size,
1106 if (maxsize > fv->
s.
props_11.maxMemoryAllocationSize) {
1108 "than maximum device allocation (%zu), clipping\n",
1109 maxsize, fv->
s.
props_11.maxMemoryAllocationSize);
1110 maxsize = fv->
s.
props_11.maxMemoryAllocationSize;
1113 if (max_heap_size < maxsize) {
1115 "using host memory (slower)\n",
1119 max_heap_size = max_host_size - (max_host_size >> 1);
1122 max_heap_size = max_heap_size - (max_heap_size >> 3);
1125 av_log(avctx,
AV_LOG_INFO,
"Async buffers: %zuMiB per context, %zuMiB total, depth: %i\n",
1126 maxsize / (1024*1024),
1197 &fv->
setup, 0, 0, 0,
1199 256*
sizeof(uint32_t), 512*
sizeof(uint8_t),
1200 VK_FORMAT_UNDEFINED));
1206 256*
sizeof(uint32_t), 512*
sizeof(uint8_t),
1207 VK_FORMAT_UNDEFINED));
1211 256*
sizeof(uint32_t) + 512*
sizeof(uint8_t),
1213 VK_FORMAT_UNDEFINED));
1217 0, 256*
sizeof(uint32_t),
1218 VK_FORMAT_UNDEFINED));
1241 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
1242 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
1243 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
1289 #define OFFSET(x) offsetof(VulkanEncodeFFv1Context, x)
1290 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1293 { .i64 = -1 }, -1, 2,
VE },
1295 { .i64 = 0 }, 0, 1,
VE },
1305 { .i64 = -1 }, -1, 2,
VE , .unit =
"qtable"},
1309 { .i64 =
QTABLE_8BIT }, INT_MIN, INT_MAX,
VE, .unit =
"qtable" },
1319 { .i64 = 0 }, 0, 1,
VE },
1321 {
"rct_search",
"Run a search for RCT parameters (level 4 only)",
OFFSET(optimize_rct),
AV_OPT_TYPE_BOOL,
1322 { .i64 = 1 }, 0, 1,
VE },
1325 { .i64 = 1 }, 1, INT_MAX,
VE },
1348 .
p.
name =
"ffv1_vulkan",
1366 .p.wrapper_name =
"vulkan",
#define CODEC_PIXFMTS(...)
int ff_vk_create_buf(FFVulkanContext *s, FFVkBuffer *buf, size_t size, void *pNext, void *alloc_pNext, VkBufferUsageFlags usage, VkMemoryPropertyFlagBits flags)
#define AV_LOG_WARNING
Something somehow does not look correct.
const unsigned int ff_ffv1_enc_golomb_comp_spv_len
AVPixelFormat
Pixel format.
int ff_ffv1_encode_determine_slices(AVCodecContext *avctx)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
const unsigned int ff_ffv1_enc_comp_spv_len
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
@ AV_PIX_FMT_YA8
8 bits gray, 8 bits alpha
VkPhysicalDeviceVulkan11Properties props_11
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
FFVkExecContext * contexts
#define AVERROR_EOF
End of file.
uint8_t * data
The data buffer.
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
int ff_vk_exec_pool_init(FFVulkanContext *s, AVVulkanDeviceQueueFamily *qf, FFVkExecPool *pool, int nb_contexts, int nb_queries, VkQueryType query_type, int query_64bit, const void *query_create_pnext)
Allocates/frees an execution pool.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
#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...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
This structure describes decoded (raw) audio or video data.
static int ff_vk_map_buffer(FFVulkanContext *s, FFVkBuffer *buf, uint8_t **mem, int invalidate)
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
#define AC_RANGE_DEFAULT_TAB_FORCE
FFVulkanShader rct_search
const char * ff_source_ffv1_vlc_comp
#define AV_PIX_FMT_RGBA128
av_cold int ff_ffv1_write_extradata(AVCodecContext *avctx)
#define AV_LOG_VERBOSE
Detailed information.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int ff_vk_init(FFVulkanContext *s, void *log_parent, AVBufferRef *device_ref, AVBufferRef *frames_ref)
Initializes the AVClass, in case this context is not used as the main user's context.
FFVkExecContext * ff_vk_exec_get(FFVulkanContext *s, FFVkExecPool *pool)
Retrieve an execution pool.
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
#define SPEC_LIST_ADD(name, idx, val_bits, val)
int width
The allocated dimensions of the frames in this pool.
#define AC_RANGE_CUSTOM_TAB
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
int ff_vk_exec_add_dep_frame(FFVulkanContext *s, FFVkExecContext *e, AVFrame *f, VkPipelineStageFlagBits2 wait_stage, VkPipelineStageFlagBits2 signal_stage)
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
#define AV_CODEC_FLAG_COPY_OPAQUE
static const AVClass vulkan_encode_ffv1_class
AVCodec p
The public AVCodec.
#define AV_PIX_FMT_GBRP14
VkImage img[AV_NUM_DATA_POINTERS]
Vulkan images to which the memory is bound to.
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
#define AV_PIX_FMT_GBRP10
void ff_vk_shader_update_img_array(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, AVFrame *f, VkImageView *views, int set, int binding, VkImageLayout layout, VkSampler sampler)
Update a descriptor in a buffer with an image array.
Allocated as AVHWFramesContext.hwctx, used to set pool-specific options.
void ff_vk_frame_barrier(FFVulkanContext *s, FFVkExecContext *e, AVFrame *pic, VkImageMemoryBarrier2 *bar, int *nb_bar, VkPipelineStageFlags2 src_stage, VkPipelineStageFlags2 dst_stage, VkAccessFlagBits2 new_access, VkImageLayout new_layout, uint32_t new_qf)
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
int flags
AV_CODEC_FLAG_*.
int ff_vk_host_map_buffer(FFVulkanContext *s, AVBufferRef **dst, uint8_t *src_data, const AVBufferRef *src_buf, VkBufferUsageFlags usage)
Maps a system RAM buffer into a Vulkan buffer.
#define AV_CODEC_CAP_ENCODER_FLUSH
This encoder can be flushed using avcodec_flush_buffers().
const unsigned int ff_ffv1_enc_setup_comp_spv_len
AVBufferRef * keyframe_slice_data_ref
AVBufferRef * frame_opaque_ref
const FFCodec ff_ffv1_vulkan_encoder
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
const AVCodecHWConfigInternal *const vulkan_encode_ffv1_hw_configs[]
static int get_packet(AVCodecContext *avctx, FFVkExecContext *exec, AVPacket *pkt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
VulkanEncodeFFv1FrameData * exec_ctx_info
const unsigned char ff_ffv1_enc_reset_comp_spv_data[]
void ff_vk_exec_wait(FFVulkanContext *s, FFVkExecContext *e)
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
void ff_vk_set_perm(enum AVPixelFormat pix_fmt, int lut[4], int inv)
Since storage images may not be swizzled, we have to do this in the shader itself.
VkMemoryPropertyFlagBits host_cached_flag
VkImageCreateFlags img_flags
Flags to set during image creation.
static int vulkan_encode_ffv1_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
const char * ff_source_ffv1_common_comp
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static AVFormatContext * ctx
AVVulkanDeviceQueueFamily * transfer_qf
int ff_vk_exec_add_dep_buf(FFVulkanContext *s, FFVkExecContext *e, AVBufferRef **deps, int nb_deps, int ref)
Execution dependency management.
int ac
1=range coder <-> 0=golomb rice
av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx, enum AVPixelFormat pix_fmt)
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
void * opaque
for some private data of the user
#define CODEC_LONG_NAME(str)
const unsigned int ff_ffv1_enc_rct_search_comp_spv_len
uint32_t extend_lookup[8]
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
int ff_ffv1_vk_init_consts(FFVulkanContext *s, FFVkBuffer *vkb, FFV1Context *f)
#define AV_PIX_FMT_RGBA64
#define LIBAVUTIL_VERSION_INT
const unsigned int ff_ffv1_enc_rgb_comp_spv_len
Describe the class of an AVClass context structure.
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)
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
static int init_encode_shader(AVCodecContext *avctx, VkSpecializationInfo *sl)
#define FF_CODEC_RECEIVE_PACKET_CB(func)
const unsigned char ff_ffv1_enc_rgb_comp_spv_data[]
const char * av_default_item_name(void *ptr)
Return the context name.
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
int ff_vk_shader_link(FFVulkanContext *s, FFVulkanShader *shd, const char *spirv, size_t spirv_len, const char *entrypoint)
Link a shader into an executable.
VkImageUsageFlagBits usage
Defines extra usage of output frames.
#define SPEC_LIST_CREATE(name, max_length, max_size)
static int transfer_slices(AVCodecContext *avctx, VkBufferCopy *buf_regions, int nb_regions, VulkanEncodeFFv1FrameData *fd, uint8_t *dst, AVBufferRef *dst_ref)
const unsigned char ff_ffv1_enc_rgb_golomb_comp_spv_data[]
AVBufferPool * slice_data_pool
#define ff_vk_buf_barrier(dst, vkb, s_stage, s_access, s_access2, d_stage, d_access, d_access2, offs, bsz)
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
VkAccessFlagBits access[AV_NUM_DATA_POINTERS]
Updated after every barrier.
void ff_vk_shader_update_push_const(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, VkShaderStageFlagBits stage, int offset, size_t size, void *src)
Update push constant in a shader.
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_NUM_DATA_POINTERS
static int init_indirect(AVCodecContext *avctx, enum AVPixelFormat sw_format)
VkMemoryPropertyFlagBits flags
const unsigned int ff_ffv1_enc_reset_comp_spv_len
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
const char * ff_source_common_comp
AVBufferRef * out_data_ref
int ff_vk_shader_update_desc_buffer(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd, int set, int bind, int elem, FFVkBuffer *buf, VkDeviceSize offset, VkDeviceSize len, VkFormat fmt)
Update a descriptor in a buffer with a buffer.
int flags
A combination of AV_PKT_FLAG values.
const unsigned char ff_ffv1_enc_rct_search_comp_spv_data[]
#define AV_LOG_INFO
Standard information.
const unsigned char ff_ffv1_enc_golomb_comp_spv_data[]
void ff_ffv1_vk_set_common_sl(AVCodecContext *avctx, FFV1Context *f, VkSpecializationInfo *sl, enum AVPixelFormat sw_format)
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
#define FF_VK_EXT_EXTERNAL_HOST_MEMORY
const char * ff_source_ffv1_enc_comp
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
const unsigned char ff_ffv1_enc_reset_golomb_comp_spv_data[]
#define av_malloc_array(a, b)
#define AV_PIX_FMT_GBRP12
av_cold int ff_ffv1_common_init(AVCodecContext *avctx, FFV1Context *s)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
const char * name
Name of the codec implementation.
static av_cold int vulkan_encode_ffv1_close(AVCodecContext *avctx)
VkPhysicalDeviceProperties2 props
FFVulkanExtensions extensions
void ff_vk_free_buf(FFVulkanContext *s, FFVkBuffer *buf)
static int init_setup_shader(AVCodecContext *avctx, VkSpecializationInfo *sl)
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
void * av_calloc(size_t nmemb, size_t size)
VkPhysicalDeviceMemoryProperties mprops
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, FFVulkanShader *shd)
Bind a shader.
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames.
This struct describes a set or pool of "hardware" frames (i.e.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
size_t ff_ffv1_encode_buffer_size(AVCodecContext *avctx)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int ff_vk_create_imageviews(FFVulkanContext *s, FFVkExecContext *e, VkImageView views[AV_NUM_DATA_POINTERS], AVFrame *f, enum FFVkShaderRepFormat rep_fmt)
Create an imageview and add it as a dependency to an execution.
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
int ff_vk_shader_add_push_const(FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
AVBufferRef * intermediate_frames_ref
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
AVVulkanDeviceQueueFamily * ff_vk_qf_find(FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
Chooses an appropriate QF.
static const AVOption vulkan_encode_ffv1_options[]
main external API structure.
const unsigned char ff_ffv1_enc_comp_spv_data[]
int ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular, int print_to_shader_only)
Add descriptor to a shader.
FFVkExecPool transfer_exec_pool
static int init_reset_shader(AVCodecContext *avctx, VkSpecializationInfo *sl)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
static int vulkan_encode_ffv1_submit_frame(AVCodecContext *avctx, FFVkExecContext *exec, const AVFrame *pict)
VkImageTiling tiling
Controls the tiling of allocated frames.
AVVulkanDeviceQueueFamily * qf
static const FFCodecDefault vulkan_encode_ffv1_defaults[]
AVVulkanDeviceContext * hwctx
VkBufferCopy * buf_regions
int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
Called by encoders to get the next frame for encoding.
VkImageLayout layout[AV_NUM_DATA_POINTERS]
A reference to a data buffer.
av_cold int ff_ffv1_encode_init(AVCodecContext *avctx)
VkDevice act_dev
Active device.
void ff_vk_exec_discard_deps(FFVulkanContext *s, FFVkExecContext *e)
int slices
Number of slices.
This structure stores compressed data.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
int width
picture width / height.
static av_cold int vulkan_encode_ffv1_init(AVCodecContext *avctx)
uint16_t context_count[8]
const unsigned int ff_ffv1_enc_reset_golomb_comp_spv_len
int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
const unsigned char ff_ffv1_enc_setup_comp_spv_data[]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVHWFramesContext * frames
enum AVPixelFormat sw_pix_fmt
Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx.
VkDeviceAddress slice_data
const unsigned int ff_ffv1_enc_rgb_golomb_comp_spv_len
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
int ff_vk_shader_load(FFVulkanShader *shd, VkPipelineStageFlags stage, VkSpecializationInfo *spec, uint32_t wg_size[3], uint32_t required_subgroup_size)
Initialize a shader object.
int ff_vk_get_pooled_buffer(FFVulkanContext *ctx, AVBufferPool **buf_pool, AVBufferRef **buf, VkBufferUsageFlags usage, void *create_pNext, size_t size, VkMemoryPropertyFlagBits mem_props)
Initialize a pool and create AVBufferRefs containing FFVkBuffer.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
static int init_rct_search_shader(AVCodecContext *avctx, VkSpecializationInfo *sl)
AVBufferPool * out_data_pool
const char * ff_source_rangecoder_comp