Go to the documentation of this file.
72 void *spv_opaque =
NULL;
81 spv = ff_vk_spirv_init();
90 VK_SHADER_STAGE_COMPUTE_BIT, 0));
94 GLSLC(0,
layout(push_constant, std430) uniform pushConstants { );
95 GLSLC(1, vec4 color_comp; );
100 VK_SHADER_STAGE_COMPUTE_BIT);
104 .
name =
"output_img",
105 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
107 .mem_quali =
"writeonly",
110 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
118 GLSLC(1, ivec2
pos = ivec2(gl_GlobalInvocationID.xy); );
139 for (
int i = 0;
i < 4;
i++)
140 rgbad[
i] =
s->color_rgba[
i] / 255.0;
145 memcpy(yuvad, rgbad,
sizeof(rgbad));
150 for (
int i = 0;
i < 3;
i++) {
153 yuvad[
i] *= (
chroma ? 224.0 : 219.0) / 255.0;
154 yuvad[
i] += (
chroma ? 128.0 : 16.0) / 255.0;
162 if (
desc->nb_components <= 2)
165 for (
int i = 0;
i < 4;
i++)
166 s->opts.color_comp[
i] = yuvad[
i];
170 for (
int i = 0, c_off = 0;
i <
planes;
i++) {
171 for (
int c = 0;
c <
desc->nb_components;
c++) {
172 if (
desc->comp[
c].plane ==
i) {
174 GLSLF(1,
r[%
i] = color_comp[%
i]; ,off, c_off++);
208 if (!
s->initialized) {
217 if (
s->duration >= 0 &&
224 if (
s->draw_once_reset) {
226 s->draw_once_reset = 0;
234 NULL, &
s->opts,
sizeof(
s->opts));
253 NULL, &
s->opts,
sizeof(
s->opts));
272 if (!
s->out_format_string) {
295 s->vkctx.output_width =
s->w;
296 s->vkctx.output_height =
s->h;
322 #define OFFSET(x) offsetof(TestSrcVulkanContext, x)
323 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
325 #define COMMON_OPTS \
326 { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, { .str = "1920x1080" }, 0, 0, FLAGS }, \
327 { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, { .str = "1920x1080" }, 0, 0, FLAGS }, \
329 { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "60" }, 0, INT_MAX, FLAGS }, \
330 { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "60" }, 0, INT_MAX, FLAGS }, \
332 { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, FLAGS }, \
333 { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, FLAGS }, \
335 { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, { .dbl = 1 }, 0, INT_MAX, FLAGS }, \
337 { "format", "Output video format (software format of hardware frames)", OFFSET(out_format_string), AV_OPT_TYPE_STRING, .flags = FLAGS },
364 .
name =
"color_vulkan",
374 .priv_class = &color_vulkan_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
void ff_vk_pipeline_free(FFVulkanContext *s, FFVulkanPipeline *pl)
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
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static void testsrc_vulkan_uninit(AVFilterContext *avctx)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int64_t duration
Duration of the frame, in the same units as pts.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AVERROR_EOF
End of file.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family)
Chooses a QF and loads it into a context.
int64_t duration
duration expressed in microseconds
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.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
@ AVCOL_RANGE_JPEG
Full range content.
const struct AVLumaCoefficients * av_csp_luma_coeffs_from_avcsp(enum AVColorSpace csp)
Retrieves the Luma coefficients necessary to construct a conversion matrix from an enum constant desc...
int ff_vk_shader_create(FFVulkanContext *s, FFVkSPIRVShader *shd, uint8_t *spirv, size_t spirv_size, const char *entrypoint)
static const char rgb2yuv[]
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar calculations.
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
static av_cold int init_filter(AVFilterContext *ctx, enum TestSrcVulkanMode mode)
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
const char * name
Filter name.
int ff_vk_pipeline_descriptor_set_add(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd, FFVulkanDescriptorSetBinding *desc, int nb, int read_only, int print_to_shader_only)
Add descriptor to a pipeline.
AVFILTER_DEFINE_CLASS(color_vulkan)
void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z)
A link between two filters.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
int ff_vk_add_push_constant(FFVulkanPipeline *pl, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
void * priv
private data for use by the filter
int ff_vk_filter_init_context(AVFilterContext *avctx, FFVulkanContext *s, AVBufferRef *frames_ref, int width, int height, enum AVPixelFormat sw_format)
Can be called manually, if not using ff_vk_filter_config_output.
int draw_once_reset
draw only the first frame or in case of reset
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
enum AVColorRange out_range
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
AVFrame * picref
cached reference containing the painted picture
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
int(* init)(AVBSFContext *ctx)
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable; if left to 0/0,...
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static int testsrc_vulkan_activate(AVFilterContext *ctx)
void ff_matrix_mul_3x3_vec(double dst[3], const double vec[3], const double mat[3][3])
int(* compile_shader)(struct FFVkSPIRVCompiler *ctx, void *avctx, struct FFVkSPIRVShader *shd, uint8_t **data, size_t *size, const char *entrypoint, void **opaque)
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
const AVFilter ff_vsrc_color_vulkan
TestSrcVulkanPushData opts
Rational number (pair of numerator and denominator).
filter_frame For filters that do not use the activate() callback
@ AV_PICTURE_TYPE_I
Intra.
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd)
static const AVFilterPad testsrc_vulkan_outputs[]
int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *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.
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 inputs
@ AVCOL_RANGE_UNSPECIFIED
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int ff_vk_shader_init(FFVulkanPipeline *pl, FFVkSPIRVShader *shd, const char *name, VkShaderStageFlags stage, uint32_t required_subgroup_size)
Shader management.
int main(int argc, char **argv)
enum AVPictureType pict_type
Picture type of the frame.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
enum AVPixelFormat output_format
AVFilterContext * src
source filter
#define AVERROR_EXTERNAL
Generic error in an external library.
AVRational sar
sample aspect ratio
int ff_vk_filter_process_simple(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanPipeline *pl, AVFrame *out_f, AVFrame *in_f, VkSampler sampler, void *push_src, size_t push_size)
Submit a compute shader with a zero/one input and single out for execution.
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 layout
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
static const AVOption color_vulkan_options[]
void ff_fill_rgb2yuv_table(const AVLumaCoefficients *coeffs, double rgb2yuv[3][3])
#define i(width, name, range_min, range_max)
int w
agreed upon image width
AVColorSpace
YUV colorspace type.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
static const struct @363 planes[]
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Returns the format to use for images in shaders.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
const char * name
Pad name.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
int h
agreed upon image height
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int draw_once
draw only the first frame, always put out the same picture
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int testsrc_vulkan_config_props(AVFilterLink *outlink)
#define FILTER_OUTPUTS(array)
int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanPipeline *pl)
Register a pipeline with an exec pool.
#define flags(name, subs,...)
static av_cold int uninit(AVCodecContext *avctx)
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd)
AVColorRange
Visual content value range.