Go to the documentation of this file.
40 #define RGB_LINECACHE 4
145 AVFrame *enc_in, VkImageView *enc_in_views,
146 FFVkBuffer *slice_data_buf, uint32_t slice_data_size,
157 0, slice_data_size*
f->slice_count,
158 VK_FORMAT_UNDEFINED);
160 enc_in, enc_in_views,
162 VK_IMAGE_LAYOUT_GENERAL,
167 VK_SHADER_STAGE_COMPUTE_BIT,
176 AVFrame *enc_in, VkImageView *enc_in_views,
186 enc_in, enc_in_views,
188 VK_IMAGE_LAYOUT_GENERAL,
193 0, fltmap_size*
f->slice_count,
194 VK_FORMAT_UNDEFINED);
198 VK_SHADER_STAGE_COMPUTE_BIT,
220 uint32_t plane_state_size;
221 uint32_t slice_state_size;
222 uint32_t slice_data_size;
227 uint32_t remap_data_size = 0;
233 int has_inter = avctx->
gop_size > 1;
234 uint32_t context_count =
f->context_count[
f->context_model];
236 VkImageMemoryBarrier2 img_bar[37];
238 VkBufferMemoryBarrier2 buf_bar[8];
242 f->cur_enc_frame = pict;
251 f->slice_count =
f->max_slice_count;
255 plane_state_size = 8;
259 plane_state_size *= context_count;
260 slice_state_size = plane_state_size*
f->plane_count;
262 slice_data_size = 256;
263 slice_state_size += slice_data_size;
264 slice_state_size =
FFALIGN(slice_state_size, 8);
268 if (!slice_data_ref) {
271 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
272 NULL, slice_state_size*
f->slice_count,
273 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
283 remap_data_size = 4*(1 <<
desc->comp[0].depth)*
sizeof(uint32_t);
287 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
288 NULL, remap_data_size*
f->slice_count,
289 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
299 VkMemoryPropertyFlagBits out_buf_flags;
300 if (maxsize < fv->max_heap_size) {
301 out_buf_flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
304 out_buf_flags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
306 out_buf_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
312 VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
313 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
314 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
315 NULL, maxsize, out_buf_flags));
341 .plane_state_size = plane_state_size,
342 .key_frame =
f->key_frame,
344 .micro_version =
f->micro_version,
350 .slice_size_max = out_data_buf->
size /
f->slice_count,
353 for (
int i = 0;
i <
f->quant_table_count;
i++) {
356 f->quant_tables[
i][4][127];
363 memcpy(pd.
fmt_lut, (
int [4]) { 2, 1, 0, 3 }, 4*
sizeof(
int));
378 remap_data_ref =
NULL;
382 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
383 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
386 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
387 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
392 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
393 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
394 VK_ACCESS_SHADER_READ_BIT,
395 VK_IMAGE_LAYOUT_GENERAL,
396 VK_QUEUE_FAMILY_IGNORED);
398 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
399 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
400 .pImageMemoryBarriers = img_bar,
401 .imageMemoryBarrierCount = nb_img_bar,
409 slice_data_buf, slice_data_size, &pd));
413 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
414 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
415 0, slice_data_size*
f->slice_count);
420 remap_data_buf, remap_data_size, &pd));
424 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
425 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
426 0, remap_data_size*
f->slice_count);
430 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
431 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
432 .pBufferMemoryBarriers = buf_bar,
433 .bufferMemoryBarrierCount = nb_buf_bar,
442 0, slice_data_size*
f->slice_count,
443 VK_FORMAT_UNDEFINED);
448 0, remap_data_size*
f->slice_count,
449 VK_FORMAT_UNDEFINED);
453 VK_SHADER_STAGE_COMPUTE_BIT,
461 vkf->
layout[0] = VK_IMAGE_LAYOUT_UNDEFINED;
462 vkf->
access[0] = VK_ACCESS_2_NONE;
469 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
470 VK_PIPELINE_STAGE_2_CLEAR_BIT,
471 VK_ACCESS_2_TRANSFER_WRITE_BIT,
472 VK_IMAGE_LAYOUT_GENERAL,
473 VK_QUEUE_FAMILY_IGNORED);
474 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
475 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
476 .pImageMemoryBarriers = img_bar,
477 .imageMemoryBarrierCount = nb_img_bar,
481 vk->CmdClearColorImage(exec->
buf, vkf->
img[0], VK_IMAGE_LAYOUT_GENERAL,
482 &((VkClearColorValue) { 0 }),
483 1, &((VkImageSubresourceRange) {
484 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
495 0, slice_data_size*
f->slice_count,
496 VK_FORMAT_UNDEFINED);
502 VK_FORMAT_UNDEFINED);
506 VK_SHADER_STAGE_COMPUTE_BIT,
515 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
516 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
517 0, slice_data_size*
f->slice_count);
520 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
521 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
522 slice_data_size*
f->slice_count, VK_WHOLE_SIZE);
525 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
526 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
527 slice_data_size*
f->slice_count, VK_WHOLE_SIZE);
530 fv->
optimize_rct ? VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT :
531 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
532 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
533 VK_ACCESS_SHADER_READ_BIT,
534 VK_IMAGE_LAYOUT_GENERAL,
535 VK_QUEUE_FAMILY_IGNORED);
539 VK_PIPELINE_STAGE_2_CLEAR_BIT,
540 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
541 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
542 VK_IMAGE_LAYOUT_GENERAL,
543 VK_QUEUE_FAMILY_IGNORED);
545 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
546 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
547 .pImageMemoryBarriers = img_bar,
548 .imageMemoryBarrierCount = nb_img_bar,
549 .pBufferMemoryBarriers = buf_bar,
550 .bufferMemoryBarrierCount = nb_buf_bar,
559 0, slice_data_size*
f->slice_count,
560 VK_FORMAT_UNDEFINED);
564 fd->
idx*
f->max_slice_count*
sizeof(uint32_t),
565 f->slice_count*
sizeof(uint32_t),
566 VK_FORMAT_UNDEFINED);
572 VK_FORMAT_UNDEFINED);
576 VK_IMAGE_LAYOUT_GENERAL,
582 VK_IMAGE_LAYOUT_GENERAL,
588 0, remap_data_size*
f->slice_count,
589 VK_FORMAT_UNDEFINED);
593 VK_SHADER_STAGE_COMPUTE_BIT,
617 VkBufferCopy *buf_regions,
int nb_regions,
631 VkBufferMemoryBarrier2 buf_bar[8];
635 VK_BUFFER_USAGE_TRANSFER_DST_BIT);
653 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
654 TRANSFER_BIT, TRANSFER_READ_BIT, NONE_KHR,
656 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
657 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
658 .pBufferMemoryBarriers = buf_bar,
659 .bufferMemoryBarrierCount = nb_buf_bar,
663 for (
int i = 0;
i < nb_regions;
i++)
664 buf_regions[
i].dstOffset += mapped_buf->virtual_offset;
666 vk->CmdCopyBuffer(exec->
buf,
667 out_data_buf->
buf, mapped_buf->buf,
668 nb_regions, buf_regions);
691 uint32_t slice_size_max = out_data_buf->
size /
f->slice_count;
697 uint32_t rb_off = fd->
idx*
f->max_slice_count*
sizeof(uint32_t);
699 VkMappedMemoryRange invalidate_data = {
700 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
703 .size =
f->slice_count*
sizeof(uint32_t),
706 1, &invalidate_data);
712 for (
int i = 0;
i <
f->slice_count;
i++) {
713 uint32_t sl_len =
AV_RN32(rb +
i*4);
717 .srcOffset =
i*slice_size_max,
749 if (!(out_data_buf->
flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
750 VkMappedMemoryRange invalidate_data = {
751 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
752 .memory = out_data_buf->
mem,
754 .size = VK_WHOLE_SIZE,
757 1, &invalidate_data);
761 for (
int i = 0;
i <
f->slice_count;
i++) {
763 memcpy(
pkt->
data + region->dstOffset,
845 vk_frames = frames_ctx->
hwctx;
846 vk_frames->
tiling = VK_IMAGE_TILING_OPTIMAL;
847 vk_frames->
usage = VK_IMAGE_USAGE_STORAGE_BIT |
848 VK_IMAGE_USAGE_TRANSFER_DST_BIT;
849 vk_frames->
img_flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
869 (uint32_t []) { 32, 32, 1 }, 0);
872 VK_SHADER_STAGE_COMPUTE_BIT);
876 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
877 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
884 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
885 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
888 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
889 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
912 (uint32_t []) { 32, 32, 1 }, 0);
915 VK_SHADER_STAGE_COMPUTE_BIT);
919 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
920 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
927 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
928 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
931 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
932 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
936 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
937 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
959 (uint32_t []) { 1, 1, 1 }, 0);
962 VK_SHADER_STAGE_COMPUTE_BIT);
966 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
967 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
974 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
975 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
978 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
979 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1000 int wg_dim =
FFMIN(fv->
s.
props.properties.limits.maxComputeWorkGroupSize[0], 1024);
1003 (uint32_t []) { wg_dim, 1, 1 }, 0);
1006 VK_SHADER_STAGE_COMPUTE_BIT);
1010 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1011 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1018 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1019 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1022 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1023 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1052 (uint32_t []) { wg_x, 1, 1 }, 0);
1055 VK_SHADER_STAGE_COMPUTE_BIT);
1059 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1060 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1063 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1064 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1067 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1068 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1075 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1076 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1079 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1080 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1083 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1084 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1087 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1088 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1092 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1093 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1096 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1097 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1101 4 + fv->
is_rgb + !!
f->remap_mode, 0, 0);
1103 if (
f->remap_mode) {
1136 size_t maxsize, max_heap_size, max_host_size;
1158 if (
f->bits_per_raw_sample > (
f->version > 3 ? 16 : 8)) {
1161 "forcing range coder\n");
1166 if (
f->version < 4 && avctx->
gop_size > 1) {
1177 if (
f->version == 4)
1178 f->micro_version =
f->remap_mode ? 9 : 3;
1183 if (
f->num_h_slices <= 0 &&
f->num_v_slices <= 0) {
1189 f->num_h_slices = 32;
1190 f->num_v_slices = 32;
1192 }
else if (
f->num_h_slices &&
f->num_v_slices <= 0) {
1194 }
else if (
f->num_v_slices &&
f->num_h_slices <= 0) {
1198 f->num_h_slices =
FFMIN(
f->num_h_slices, avctx->
width);
1203 "by the standard is %i\n",
1208 f->max_slice_count =
f->num_h_slices *
f->num_v_slices;
1213 if (
f->version < 4) {
1214 if (((
f->chroma_h_shift > 0) && (avctx->
width % (64 <<
f->chroma_h_shift))) ||
1215 ((
f->chroma_v_shift > 0) && (avctx->
height % (64 <<
f->chroma_v_shift)))) {
1217 "dimensions is only supported in version 4 (-level 4)\n");
1223 if (
f->version < 4) {
1246 for (
int i = 0;
i < fv->
s.
mprops.memoryHeapCount;
i++) {
1247 if (fv->
s.
mprops.memoryHeaps[
i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
1250 if (!(fv->
s.
mprops.memoryHeaps[
i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT))
1251 max_host_size =
FFMAX(max_host_size,
1257 if (maxsize > fv->
s.
props_11.maxMemoryAllocationSize) {
1259 "than maximum device allocation (%zu), clipping\n",
1260 maxsize, fv->
s.
props_11.maxMemoryAllocationSize);
1261 maxsize = fv->
s.
props_11.maxMemoryAllocationSize;
1264 if (max_heap_size < maxsize) {
1266 "using host memory (slower)\n",
1270 max_heap_size = max_host_size - (max_host_size >> 1);
1273 max_heap_size = max_heap_size - (max_heap_size >> 3);
1276 av_log(avctx,
AV_LOG_INFO,
"Async buffers: %zuMiB per context, %zuMiB total, depth: %i\n",
1277 maxsize / (1024*1024),
1323 if (
f->remap_mode) {
1355 &fv->
setup, 0, 0, 0,
1357 256*
sizeof(uint32_t), 512*
sizeof(uint8_t),
1358 VK_FORMAT_UNDEFINED));
1364 256*
sizeof(uint32_t), 512*
sizeof(uint8_t),
1365 VK_FORMAT_UNDEFINED));
1369 256*
sizeof(uint32_t) + 512*
sizeof(uint8_t),
1371 VK_FORMAT_UNDEFINED));
1375 0, 256*
sizeof(uint32_t),
1376 VK_FORMAT_UNDEFINED));
1399 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
1400 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
1401 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
1449 #define OFFSET(x) offsetof(VulkanEncodeFFv1Context, x)
1450 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1453 { .i64 = -1 }, -1, 2,
VE },
1455 { .i64 = 0 }, 0, 1,
VE },
1465 { .i64 = -1 }, -1, 2,
VE , .unit =
"qtable"},
1469 { .i64 =
QTABLE_8BIT }, INT_MIN, INT_MAX,
VE, .unit =
"qtable" },
1479 { .i64 = 0 }, 0, 1,
VE },
1481 {
"rct_search",
"Run a search for RCT parameters (level 4 only)",
OFFSET(optimize_rct),
AV_OPT_TYPE_BOOL,
1482 { .i64 = 1 }, 0, 1,
VE },
1485 { .i64 = 1 }, 1, INT_MAX,
VE },
1488 { .i64 = -1 }, -1, 2,
VE, .unit =
"remap_mode" },
1490 { .i64 = -1 }, INT_MIN, INT_MAX,
VE, .unit =
"remap_mode" },
1492 { .i64 = 0 }, INT_MIN, INT_MAX,
VE, .unit =
"remap_mode" },
1494 { .i64 = 1 }, INT_MIN, INT_MAX,
VE, .unit =
"remap_mode" },
1496 { .i64 = 2 }, INT_MIN, INT_MAX,
VE, .unit =
"remap_mode" },
1519 .
p.
name =
"ffv1_vulkan",
1537 .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
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#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
static int run_remap(AVCodecContext *avctx, FFVkExecContext *exec, AVFrame *enc_in, VkImageView *enc_in_views, FFVkBuffer *fltmap_buf, uint32_t fltmap_size, FFv1ShaderParams *pd)
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.
const unsigned int ff_ffv1_enc_rgb_float_comp_spv_len
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
#define SPEC_LIST_ADD(name, idx, val_bits, val)
static int init_remap_shader(AVCodecContext *avctx, VkSpecializationInfo *sl)
int width
The allocated dimensions of the frames in this pool.
#define AC_RANGE_CUSTOM_TAB
void ff_vk_exec_bind_shader(FFVulkanContext *s, FFVkExecContext *e, const FFVulkanShader *shd)
Bind a shader.
#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)
const unsigned int ff_ffv1_enc_remap_comp_spv_len
#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 i(width, name, range_min, range_max)
#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 char ff_ffv1_enc_remap_comp_spv_data[]
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
AVBufferPool * remap_data_pool
int ff_vk_exec_start(FFVulkanContext *s, FFVkExecContext *e)
Start/submit/wait an execution.
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
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)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
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
const unsigned char ff_ffv1_enc_rgb_float_comp_spv_data[]
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