85 (uint32_t []) { 32, 32, 1 }, 0);
88 VK_SHADER_STAGE_COMPUTE_BIT);
92 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
93 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
119 for (
int i = 0;
i < 4;
i++)
120 rgbad[
i] =
s->color_rgba[
i] / 255.0;
125 memcpy(yuvad, rgbad,
sizeof(rgbad));
130 for (
int i = 0;
i < 3;
i++) {
133 yuvad[
i] *= (
chroma ? 224.0 : 219.0) / 255.0;
134 yuvad[
i] += (
chroma ? 128.0 : 16.0) / 255.0;
142 if (
desc->nb_components <= 2)
146 for (
int i = 0;
i < 4;
i++)
147 color_comp[
i] = yuvad[
i];
151 for (
int i = 0, c_off = 0;
i <
planes;
i++) {
152 for (
int c = 0;
c <
desc->nb_components;
c++) {
153 if (
desc->comp[
c].plane ==
i) {
155 s->opts.color_data[
i][off] = color_comp[fmt_lut[c_off++]];
180 if (!
s->initialized) {
189 if (
s->duration >= 0 &&
196 if (
s->draw_once_reset) {
198 s->draw_once_reset = 0;
207 &
s->opts,
sizeof(
s->opts));
223 frame->sample_aspect_ratio =
s->sar;
227 &
s->opts,
sizeof(
s->opts));
247 if (!
s->out_format_string) {
270 s->vkctx.output_width =
s->w;
271 s->vkctx.output_height =
s->h;
296#define OFFSET(x) offsetof(TestSrcVulkanContext, x)
297#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
300 { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, { .str = "1920x1080" }, 0, 0, FLAGS }, \
301 { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, { .str = "1920x1080" }, 0, 0, FLAGS }, \
303 { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "60" }, 0, INT_MAX, FLAGS }, \
304 { "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, { .str = "60" }, 0, INT_MAX, FLAGS }, \
306 { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, FLAGS }, \
307 { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, FLAGS }, \
309 { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, { .dbl = 1 }, 0, INT_MAX, FLAGS }, \
311 { "format", "Output video format (software format of hardware frames)", OFFSET(out_format_string), AV_OPT_TYPE_STRING, .flags = FLAGS },
338 .p.name =
"color_vulkan",
342 .p.priv_class = &color_vulkan_class,
const FFFilter ff_vsrc_color_vulkan
static AVFormatContext * ctx
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
#define i(width, name, range_min, range_max)
static void fn rgb2yuv(uint8_t *_yuv[3], const ptrdiff_t yuv_stride[3], int16_t *rgb[3], ptrdiff_t s, int w, int h, const int16_t rgb2yuv_coeffs[3][3][8], const int16_t yuv_offset[8])
Colorspace value utility functions for libavutil.
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AVERROR_EOF
End of file.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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...
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
@ AV_PICTURE_TYPE_I
Intra.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
void ff_matrix_mul_3x3_vec(double dst[3], const double vec[3], const double mat[3][3])
void ff_fill_rgb2yuv_table(const AVLumaCoefficients *coeffs, double rgb2yuv[3][3])
#define FILTER_OUTPUTS(array)
#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 ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
#define AVFILTER_DEFINE_CLASS(fname)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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.
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.
void ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular)
Add descriptor to a shader.
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
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.
int ff_vk_shader_add_push_const(FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
AVVulkanDeviceQueueFamily * ff_vk_qf_find(FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
Chooses an appropriate QF.
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.
static const struct @257111027162314367033347246032313251342043035002 planes[]
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_JPEG
Full range content.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
AVColorSpace
YUV colorspace type.
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
void * priv
private data for use by the filter
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar calculations.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Rational number (pair of numerator and denominator).
enum AVPixelFormat output_format
Link properties exposed to filter code, but not external callers.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
AVVulkanDeviceQueueFamily * qf
int draw_once
draw only the first frame, always put out the same picture
AVRational sar
sample aspect ratio
int draw_once_reset
draw only the first frame or in case of reset
int64_t duration
duration expressed in microseconds
TestSrcVulkanPushData opts
AVFrame * picref
cached reference containing the painted picture
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
const unsigned char ff_color_comp_spv_data[]
const unsigned int ff_color_comp_spv_len
static const AVFilterPad testsrc_vulkan_outputs[]
static int testsrc_vulkan_config_props(AVFilterLink *outlink)
static av_cold int init_filter(AVFilterContext *ctx, enum TestSrcVulkanMode mode)
static void testsrc_vulkan_uninit(AVFilterContext *avctx)
static int testsrc_vulkan_activate(AVFilterContext *ctx)
static const AVOption color_vulkan_options[]
#define FF_VK_DEFAULT_EXEC_CONTEXTS
int ff_vk_filter_process_simple(FFVulkanContext *vkctx, FFVkExecPool *e, FFVulkanShader *shd, AVFrame *out_f, AVFrame *in_f, VkSampler sampler, uint32_t wgc_z, void *push_src, size_t push_size)
Submit a compute shader with a zero/one input and single out for execution.
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 ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.