Go to the documentation of this file.
52 .
name =
"input_images",
53 .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
56 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
57 .updater =
s->input_images,
60 .name =
"output_images",
61 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
63 .mem_quali =
"writeonly",
66 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
67 .updater =
s->output_images,
72 if (!image_descs[0].sampler)
92 GLSLC(1, ivec2
pos = ivec2(gl_GlobalInvocationID.xy); );
100 GLSLF(2, vec4 res = texture(input_images[%
i], ivec2(
size.yx -
pos.yx)); ,
i);
104 GLSLF(2, vec4 res = texture(input_images[%
i],
pos.yx); ,
i);
105 GLSLF(2, imageStore(output_images[%
i],
pos, res); ,
i);
125 VkCommandBuffer cmd_buf;
142 &
s->input_images[
i].imageView, in->
img[
i],
147 &
s->output_images[
i].imageView,
out->img[
i],
151 s->input_images[
i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
152 s->output_images[
i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
158 VkImageMemoryBarrier barriers[] = {
160 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
162 .dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
164 .newLayout =
s->input_images[
i].imageLayout,
165 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
166 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
168 .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
169 .subresourceRange.levelCount = 1,
170 .subresourceRange.layerCount = 1,
173 .sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
175 .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
176 .oldLayout =
out->layout[
i],
177 .newLayout =
s->output_images[
i].imageLayout,
178 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
179 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
180 .image =
out->img[
i],
181 .subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
182 .subresourceRange.levelCount = 1,
183 .subresourceRange.layerCount = 1,
187 vk->CmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
188 VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0,
191 in->
layout[
i] = barriers[0].newLayout;
192 in->
access[
i] = barriers[0].dstAccessMask;
194 out->layout[
i] = barriers[1].newLayout;
195 out->access[
i] = barriers[1].dstAccessMask;
200 s->vkctx.output_height, 1);
277 "w:%d h:%d -> w:%d h:%d (passthrough mode)\n",
288 if (
inlink->sample_aspect_ratio.num)
290 inlink->sample_aspect_ratio);
297 #define OFFSET(x) offsetof(TransposeVulkanContext, x)
298 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
307 {
"passthrough",
"do not apply transposition if the input matches the specified geometry",
336 .
name =
"transpose_vulkan",
344 .priv_class = &transpose_vulkan_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
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
const VkComponentMapping ff_comp_identity_map
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
static av_cold void transpose_vulkan_uninit(AVFilterContext *avctx)
void ff_vk_bind_pipeline_exec(FFVulkanContext *s, FFVkExecContext *e, FFVulkanPipeline *pl)
Add a command to bind the completed pipeline and its descriptor sets.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
VkShaderStageFlags stages
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
int ff_vk_compile_shader(FFVulkanContext *s, FFVkSPIRVShader *shd, const char *entrypoint)
Compiles the shader, entrypoint must be set to "main".
#define AV_LOG_VERBOSE
Detailed information.
void ff_vk_uninit(FFVulkanContext *s)
Frees the main Vulkan context.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
const char * name
Filter name.
A link between two filters.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int ff_vk_add_exec_dep(FFVulkanContext *s, FFVkExecContext *e, AVFrame *frame, VkPipelineStageFlagBits in_wait_dst_flag)
Adds a frame as a queue dependency.
VkCommandBuffer ff_vk_get_exec_buf(FFVkExecContext *e)
Gets the command buffer to use for this submission from the exe context.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
static const AVFilterPad transpose_vulkan_outputs[]
VkImage img[AV_NUM_DATA_POINTERS]
Vulkan images to which the memory is bound to.
void * priv
private data for use by the filter
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
VkDescriptorImageInfo output_images[3]
A filter pad used for either input or output.
static int process_frames(AVFilterContext *avctx, AVFrame *outframe, AVFrame *inframe)
void ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family, int nb_queues)
Initialize a queue family with a specific number of queues.
#define FF_ARRAY_ELEMS(a)
int ff_vk_create_imageview(FFVulkanContext *s, FFVkExecContext *e, VkImageView *v, VkImage img, VkFormat fmt, const VkComponentMapping map)
Create an imageview.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
FFVkSPIRVShader * ff_vk_init_shader(FFVulkanPipeline *pl, const char *name, VkShaderStageFlags stage)
Inits a shader for a specific pipeline.
#define FILTER_INPUTS(array)
void ff_vk_update_descriptor_set(FFVulkanContext *s, FFVulkanPipeline *pl, int set_id)
Updates a descriptor set via the updaters defined.
static const struct @321 planes[]
int ff_vk_start_exec_recording(FFVulkanContext *s, FFVkExecContext *e)
Begin recording to the command buffer.
const VkFormat * av_vkfmt_from_pixfmt(enum AVPixelFormat p)
Returns the format of each image up to the number of planes for a given sw_format.
int main(int argc, char *argv[])
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Rational number (pair of numerator and denominator).
static const AVOption transpose_vulkan_options[]
AVFilterLink ** inputs
array of pointers to input links
int ff_vk_create_exec_ctx(FFVulkanContext *s, FFVkExecContext **ctx, FFVkQueueFamilyCtx *qf)
Init an execution context for command recording and queue submission.
int ff_vk_filter_config_output(AVFilterLink *outlink)
void ff_vk_qf_rotate(FFVkQueueFamilyCtx *qf)
Rotate through the queues in a queue family.
const AVFilter ff_vf_transpose_vulkan
void ff_vk_discard_exec_deps(FFVkExecContext *e)
Discards all queue dependencies.
static int config_props_output(AVFilterLink *outlink)
@ TRANSPOSE_PT_TYPE_PORTRAIT
AVFILTER_DEFINE_CLASS(transpose_vulkan)
VkAccessFlagBits access[AV_NUM_DATA_POINTERS]
Updated after every barrier.
VkDescriptorImageInfo input_images[3]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int ff_vk_init_pipeline_layout(FFVulkanContext *s, FFVulkanPipeline *pl)
Initializes the pipeline layout after all shaders and descriptor sets have been finished.
AVFilterContext * src
source filter
int ff_vk_submit_exec_queue(FFVulkanContext *s, FFVkExecContext *e)
Submits a command buffer to the queue for execution.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl)
Initializes a compute pipeline.
#define i(width, name, range_min, range_max)
int w
agreed upon image width
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Gets the glsl format string for a pixel format.
const char * name
Pad name.
FFVulkanPipeline * ff_vk_create_pipeline(FFVulkanContext *s, FFVkQueueFamilyCtx *qf)
Inits a pipeline.
static const AVFilterPad transpose_vulkan_inputs[]
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int ff_vk_add_descriptor_set(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int num, int only_print_to_shader)
Adds a descriptor set to the shader and registers them in the pipeline.
int h
agreed upon image height
static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
FFVkSampler * ff_vk_init_sampler(FFVulkanContext *s, int unnorm_coords, VkFilter filt)
Create a Vulkan sampler, will be auto-freed in ff_vk_filter_uninit()
@ TRANSPOSE_PT_TYPE_LANDSCAPE
int ff_vk_filter_config_input(AVFilterLink *inlink)
VkImageLayout layout[AV_NUM_DATA_POINTERS]
#define FILTER_OUTPUTS(array)
void ff_vk_set_compute_shader_sizes(FFVkSPIRVShader *shd, int local_size[3])
Writes the workgroup size for a shader.
static av_cold int uninit(AVCodecContext *avctx)