Go to the documentation of this file.
40 #define RGB_LINECACHE 4
160 AVFrame *enc_in, VkImageView *enc_in_views,
161 FFVkBuffer *slice_data_buf, uint32_t slice_data_size,
172 0, slice_data_size*
f->slice_count,
173 VK_FORMAT_UNDEFINED);
175 enc_in, enc_in_views,
177 VK_IMAGE_LAYOUT_GENERAL,
182 VK_SHADER_STAGE_COMPUTE_BIT,
191 AVFrame *enc_in, VkImageView *enc_in_views,
201 enc_in, enc_in_views,
203 VK_IMAGE_LAYOUT_GENERAL,
208 0, fltmap_size*
f->slice_count,
209 VK_FORMAT_UNDEFINED);
213 VK_SHADER_STAGE_COMPUTE_BIT,
222 AVFrame *enc_in, VkImageView *enc_in_views,
232 enc_in, enc_in_views,
234 VK_IMAGE_LAYOUT_GENERAL,
239 0, units_size*
f->slice_count,
240 VK_FORMAT_UNDEFINED);
244 VK_SHADER_STAGE_COMPUTE_BIT,
266 uint32_t plane_state_size;
267 uint32_t slice_state_size;
268 uint32_t slice_data_size;
273 uint32_t remap_data_size = 0;
279 int has_inter = avctx->
gop_size > 1;
280 uint32_t context_count =
f->context_count[
f->context_model];
282 VkImageMemoryBarrier2 img_bar[37];
284 VkBufferMemoryBarrier2 buf_bar[8];
288 f->cur_enc_frame = pict;
297 f->slice_count =
f->max_slice_count;
301 plane_state_size = 8;
305 plane_state_size *= context_count;
306 slice_state_size = plane_state_size*
f->plane_count;
308 slice_data_size = 256;
309 slice_state_size += slice_data_size;
310 slice_state_size =
FFALIGN(slice_state_size, 8);
314 if (!slice_data_ref) {
317 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
318 NULL, slice_state_size*
f->slice_count,
319 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
333 remap_data_size = 4*(1 <<
desc->comp[0].depth)*
sizeof(uint32_t);
338 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
339 NULL, remap_data_size*
f->slice_count,
340 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
349 VkMemoryPropertyFlagBits out_buf_flags;
350 if (maxsize < fv->max_heap_size) {
351 out_buf_flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
354 out_buf_flags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
356 out_buf_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
362 VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
363 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
364 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
365 NULL, maxsize, out_buf_flags));
391 .plane_state_size = plane_state_size,
392 .key_frame =
f->key_frame,
394 .micro_version =
f->micro_version,
400 .slice_size_max = out_data_buf->
size /
f->slice_count,
404 for (
int i = 0;
i <
f->quant_table_count;
i++) {
407 f->quant_tables[
i][4][127];
414 memcpy(pd.
fmt_lut, (
int [4]) { 2, 1, 0, 3 }, 4*
sizeof(
int));
433 remap_data_ref =
NULL;
437 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
438 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT));
441 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
442 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);
453 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
454 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
455 .pImageMemoryBarriers = img_bar,
456 .imageMemoryBarrierCount = nb_img_bar,
464 slice_data_buf, slice_data_size, &pd));
468 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
469 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
470 0, slice_data_size*
f->slice_count);
476 remap_data_buf, remap_data_size, &pd));
479 remap_data_buf, remap_data_size, &pd));
484 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
485 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
486 0, remap_data_size*
f->slice_count);
490 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
491 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
492 .pBufferMemoryBarriers = buf_bar,
493 .bufferMemoryBarrierCount = nb_buf_bar,
502 0, slice_data_size*
f->slice_count,
503 VK_FORMAT_UNDEFINED);
508 0, remap_data_size*
f->slice_count,
509 VK_FORMAT_UNDEFINED);
513 VK_SHADER_STAGE_COMPUTE_BIT,
521 vkf->
layout[0] = VK_IMAGE_LAYOUT_UNDEFINED;
522 vkf->
access[0] = VK_ACCESS_2_NONE;
529 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
530 VK_PIPELINE_STAGE_2_CLEAR_BIT,
531 VK_ACCESS_2_TRANSFER_WRITE_BIT,
532 VK_IMAGE_LAYOUT_GENERAL,
533 VK_QUEUE_FAMILY_IGNORED);
534 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
535 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
536 .pImageMemoryBarriers = img_bar,
537 .imageMemoryBarrierCount = nb_img_bar,
541 vk->CmdClearColorImage(exec->
buf, vkf->
img[0], VK_IMAGE_LAYOUT_GENERAL,
542 &((VkClearColorValue) { 0 }),
543 1, &((VkImageSubresourceRange) {
544 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
555 0, slice_data_size*
f->slice_count,
556 VK_FORMAT_UNDEFINED);
562 VK_FORMAT_UNDEFINED);
566 VK_SHADER_STAGE_COMPUTE_BIT,
575 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
576 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
577 0, slice_data_size*
f->slice_count);
583 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
584 COMPUTE_SHADER_BIT, SHADER_READ_BIT, NONE_KHR,
585 0, remap_data_size*
f->slice_count);
588 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
589 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
590 slice_data_size*
f->slice_count, VK_WHOLE_SIZE);
593 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
594 COMPUTE_SHADER_BIT, SHADER_READ_BIT, SHADER_WRITE_BIT,
595 slice_data_size*
f->slice_count, VK_WHOLE_SIZE);
598 fv->
optimize_rct ? VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT :
599 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
600 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
601 VK_ACCESS_SHADER_READ_BIT,
602 VK_IMAGE_LAYOUT_GENERAL,
603 VK_QUEUE_FAMILY_IGNORED);
607 VK_PIPELINE_STAGE_2_CLEAR_BIT,
608 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
609 VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT,
610 VK_IMAGE_LAYOUT_GENERAL,
611 VK_QUEUE_FAMILY_IGNORED);
613 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
614 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
615 .pImageMemoryBarriers = img_bar,
616 .imageMemoryBarrierCount = nb_img_bar,
617 .pBufferMemoryBarriers = buf_bar,
618 .bufferMemoryBarrierCount = nb_buf_bar,
627 0, slice_data_size*
f->slice_count,
628 VK_FORMAT_UNDEFINED);
632 fd->
idx*
f->max_slice_count*
sizeof(uint32_t),
633 f->slice_count*
sizeof(uint32_t),
634 VK_FORMAT_UNDEFINED);
640 VK_FORMAT_UNDEFINED);
644 VK_IMAGE_LAYOUT_GENERAL,
650 VK_IMAGE_LAYOUT_GENERAL,
656 0, remap_data_size*
f->slice_count,
657 VK_FORMAT_UNDEFINED);
661 VK_SHADER_STAGE_COMPUTE_BIT,
685 VkBufferCopy *buf_regions,
int nb_regions,
699 VkBufferMemoryBarrier2 buf_bar[8];
703 VK_BUFFER_USAGE_TRANSFER_DST_BIT);
721 COMPUTE_SHADER_BIT, SHADER_WRITE_BIT, NONE_KHR,
722 TRANSFER_BIT, TRANSFER_READ_BIT, NONE_KHR,
724 vk->CmdPipelineBarrier2(exec->
buf, &(VkDependencyInfo) {
725 .sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO,
726 .pBufferMemoryBarriers = buf_bar,
727 .bufferMemoryBarrierCount = nb_buf_bar,
731 for (
int i = 0;
i < nb_regions;
i++)
732 buf_regions[
i].dstOffset += mapped_buf->virtual_offset;
734 vk->CmdCopyBuffer(exec->
buf,
735 out_data_buf->
buf, mapped_buf->buf,
736 nb_regions, buf_regions);
759 uint32_t slice_size_max = out_data_buf->
size /
f->slice_count;
765 uint32_t rb_off = fd->
idx*
f->max_slice_count*
sizeof(uint32_t);
767 VkMappedMemoryRange invalidate_data = {
768 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
771 .size =
f->slice_count*
sizeof(uint32_t),
774 1, &invalidate_data);
780 for (
int i = 0;
i <
f->slice_count;
i++) {
781 uint32_t sl_len =
AV_RN32(rb +
i*4);
785 .srcOffset =
i*slice_size_max,
817 if (!(out_data_buf->
flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
818 VkMappedMemoryRange invalidate_data = {
819 .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE,
820 .memory = out_data_buf->
mem,
822 .size = VK_WHOLE_SIZE,
825 1, &invalidate_data);
829 for (
int i = 0;
i <
f->slice_count;
i++) {
831 memcpy(
pkt->
data + region->dstOffset,
913 vk_frames = frames_ctx->
hwctx;
914 vk_frames->
tiling = VK_IMAGE_TILING_OPTIMAL;
915 vk_frames->
usage = VK_IMAGE_USAGE_STORAGE_BIT |
916 VK_IMAGE_USAGE_TRANSFER_DST_BIT;
917 vk_frames->
img_flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT;
937 (uint32_t []) { 32, 32, 1 }, 0);
940 VK_SHADER_STAGE_COMPUTE_BIT);
944 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
945 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
952 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
953 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
956 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
957 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
981 (uint32_t []) { wg_x, 1, 1 }, 0);
984 VK_SHADER_STAGE_COMPUTE_BIT);
988 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
989 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
996 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
997 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1000 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1001 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1005 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1006 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1028 (uint32_t []) { 32, 32, 1 }, 0);
1031 VK_SHADER_STAGE_COMPUTE_BIT);
1035 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1036 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1043 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1044 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1047 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1048 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1052 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1053 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1075 (uint32_t []) { 1, 1, 1 }, 0);
1078 VK_SHADER_STAGE_COMPUTE_BIT);
1082 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1083 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1090 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1091 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1094 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1095 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1116 int wg_dim =
FFMIN(fv->
s.
props.properties.limits.maxComputeWorkGroupSize[0], 1024);
1119 (uint32_t []) { wg_dim, 1, 1 }, 0);
1122 VK_SHADER_STAGE_COMPUTE_BIT);
1126 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1127 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1134 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1135 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1138 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1139 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1168 (uint32_t []) { wg_x, 1, 1 }, 0);
1171 VK_SHADER_STAGE_COMPUTE_BIT);
1175 .
type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1176 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1179 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1180 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1183 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1184 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1191 .
type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1192 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1195 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1196 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1199 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1200 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1203 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1204 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1208 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
1209 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1212 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1213 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
1217 4 + fv->
is_rgb + !!
f->remap_mode, 0);
1228 }
else if (
f->remap_mode) {
1266 size_t maxsize, max_heap_size, max_host_size;
1282 f->version =
f->bayer ? 4 : 3;
1289 if (
f->bits_per_raw_sample > (
f->version > 3 ? 16 : 8)) {
1292 "forcing range coder\n");
1297 if (
f->version < 4 && avctx->
gop_size > 1) {
1308 if (
f->version == 4)
1309 f->micro_version =
f->bayer ? 10 : (
f->remap_mode ? 9 : 3);
1314 if (
f->num_h_slices <= 0 &&
f->num_v_slices <= 0) {
1320 f->num_h_slices = 32;
1321 f->num_v_slices = 32;
1323 }
else if (
f->num_h_slices &&
f->num_v_slices <= 0) {
1325 }
else if (
f->num_v_slices &&
f->num_h_slices <= 0) {
1329 f->num_h_slices =
FFMIN(
f->num_h_slices, avctx->
width);
1334 "by the standard is %i\n",
1339 f->max_slice_count =
f->num_h_slices *
f->num_v_slices;
1344 if (
f->version < 4) {
1345 if (((
f->chroma_h_shift > 0) && (avctx->
width % (64 <<
f->chroma_h_shift))) ||
1346 ((
f->chroma_v_shift > 0) && (avctx->
height % (64 <<
f->chroma_v_shift)))) {
1348 "dimensions is only supported in version 4 (-level 4)\n");
1354 if (
f->version < 4) {
1377 for (
int i = 0;
i < fv->
s.
mprops.memoryHeapCount;
i++) {
1378 if (fv->
s.
mprops.memoryHeaps[
i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
1379 max_heap_size =
FFMAX(max_heap_size,
1381 if (!(fv->
s.
mprops.memoryHeaps[
i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT))
1382 max_host_size =
FFMAX(max_host_size,
1388 if (maxsize > fv->
s.
props_11.maxMemoryAllocationSize) {
1390 "than maximum device allocation (%"PRIu64
"), clipping\n",
1391 maxsize, fv->
s.
props_11.maxMemoryAllocationSize);
1392 maxsize = fv->
s.
props_11.maxMemoryAllocationSize;
1395 if (max_heap_size < maxsize) {
1397 "using host memory (slower)\n",
1401 max_heap_size = max_host_size - (max_host_size >> 1);
1404 max_heap_size = max_heap_size - (max_heap_size >> 3);
1407 av_log(avctx,
AV_LOG_INFO,
"Async buffers: %zuMiB per context, %zuMiB total, depth: %i\n",
1408 maxsize / (1024*1024),
1442 uint32_t mw = (avctx->
width +
f->num_h_slices - 1) /
f->num_h_slices;
1443 uint32_t
mh = (avctx->
height +
f->num_v_slices - 1) /
f->num_v_slices;
1446 uint32_t pn = mw*
mh;
1474 if (
f->remap_mode) {
1509 &fv->
setup, 0, 0, 0,
1511 256*
sizeof(uint32_t), 512*
sizeof(uint8_t),
1512 VK_FORMAT_UNDEFINED));
1518 256*
sizeof(uint32_t), 512*
sizeof(uint8_t),
1519 VK_FORMAT_UNDEFINED));
1523 256*
sizeof(uint32_t) + 512*
sizeof(uint8_t),
1525 VK_FORMAT_UNDEFINED));
1529 0, 256*
sizeof(uint32_t),
1530 VK_FORMAT_UNDEFINED));
1553 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
1554 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
1555 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
1604 #define OFFSET(x) offsetof(VulkanEncodeFFv1Context, x)
1605 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1608 { .i64 = -1 }, -1, 2,
VE },
1610 { .i64 = 0 }, 0, 1,
VE },
1620 { .i64 = -1 }, -1, 2,
VE , .unit =
"qtable"},
1624 { .i64 =
QTABLE_8BIT }, INT_MIN, INT_MAX,
VE, .unit =
"qtable" },
1634 { .i64 = 0 }, 0, 1,
VE },
1636 {
"rct_search",
"Run a search for RCT parameters (level 4 only)",
OFFSET(optimize_rct),
AV_OPT_TYPE_BOOL,
1637 { .i64 = 1 }, 0, 1,
VE },
1640 { .i64 = 1 }, 1, INT_MAX,
VE },
1643 { .i64 = -1 }, -1, 2,
VE, .unit =
"remap_mode" },
1645 { .i64 = -1 }, INT_MIN, INT_MAX,
VE, .unit =
"remap_mode" },
1647 { .i64 = 0 }, INT_MIN, INT_MAX,
VE, .unit =
"remap_mode" },
1649 { .i64 = 1 }, INT_MIN, INT_MAX,
VE, .unit =
"remap_mode" },
1651 { .i64 = 2 }, INT_MIN, INT_MAX,
VE, .unit =
"remap_mode" },
1674 .
p.
name =
"ffv1_vulkan",
1692 .p.wrapper_name =
"vulkan",
const unsigned char ff_ffv1_enc_sort32_comp_spv_data[]
#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
const unsigned char ff_ffv1_enc_rgb_float_golomb_comp_spv_data[]
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)
const unsigned int ff_ffv1_enc_rgb_float_golomb_comp_spv_len
#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
const unsigned char ff_ffv1_enc_bayer_comp_spv_data[]
#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_bayer_golomb_comp_spv_data[]
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[]
VkAccessFlagBits2 access[AV_NUM_DATA_POINTERS]
Updated after every barrier.
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.
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_PIX_FMT_GBRPF32
#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)
const unsigned int ff_ffv1_enc_sort32_comp_spv_len
#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 int ff_ffv1_enc_bayer_comp_spv_len
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 unsigned int ff_ffv1_enc_bayer_golomb_comp_spv_len
void ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular)
Add descriptor to a shader.
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[]
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.
static int run_sort32(AVCodecContext *avctx, FFVkExecContext *exec, AVFrame *enc_in, VkImageView *enc_in_views, FFVkBuffer *units_buf, uint32_t units_size, FFv1ShaderParams *pd)
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AV_PIX_FMT_GBRAPF32
#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.
uint32_t max_pixels_per_slice
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.
static int init_sort32_shader(AVCodecContext *avctx, VkSpecializationInfo *sl)
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