Go to the documentation of this file.
63 C(1, vec2 npos = (vec2(
pos) + 0.5
f) / imageSize(output_img[idx]); )
64 C(1, npos *= crop_range; )
65 C(1, npos += crop_off; )
66 C(1,
return texture(input_img[idx], npos); )
73 C(1,
src *= yuv_matrix; )
74 C(1,
if (fullrange == 1) { )
75 C(2,
src += vec4(0.0, 0.5, 0.5, 0.0); )
77 C(2,
src *= vec4(219.0 / 255.0, 224.0 / 255.0, 224.0 / 255.0, 1.0); )
78 C(2,
src += vec4(16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0, 0.0); )
87 C(1, imageStore(output_img[0],
pos, vec4(
src.r, 0.0, 0.0, 0.0)); )
88 C(1,
pos /= ivec2(2); )
89 C(1, imageStore(output_img[1],
pos, vec4(
src.g,
src.b, 0.0, 0.0)); )
96 C(1, imageStore(output_img[0],
pos, vec4(
src.r, 0.0, 0.0, 0.0)); )
97 C(1,
pos /= ivec2(2); )
98 C(1, imageStore(output_img[1],
pos, vec4(
src.g, 0.0, 0.0, 0.0)); )
99 C(1, imageStore(output_img[2],
pos, vec4(
src.b, 0.0, 0.0, 0.0)); )
106 C(1, imageStore(output_img[0],
pos, vec4(
src.r, 0.0, 0.0, 0.0)); )
107 C(1, imageStore(output_img[1],
pos, vec4(
src.g, 0.0, 0.0, 0.0)); )
108 C(1, imageStore(output_img[2],
pos, vec4(
src.b, 0.0, 0.0, 0.0)); )
117 void *spv_opaque =
NULL;
118 VkFilter sampler_mode;
133 sampler_mode = VK_FILTER_NEAREST;
136 sampler_mode = VK_FILTER_LINEAR;
140 spv = ff_vk_spirv_init();
150 VK_SHADER_STAGE_COMPUTE_BIT, 0));
154 GLSLC(0,
layout(push_constant, std430) uniform pushConstants { );
155 GLSLC(1, mat4 yuv_matrix; );
160 VK_SHADER_STAGE_COMPUTE_BIT);
165 .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
168 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
172 .name =
"output_img",
173 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
175 .mem_quali =
"writeonly",
178 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
186 if (
s->vkctx.output_format !=
s->vkctx.input_format) {
190 switch (
s->vkctx.output_format) {
200 GLSLC(1, ivec2
pos = ivec2(gl_GlobalInvocationID.xy); );
202 GLSLF(1, vec2 c_r = vec2(%
i, %
i) / in_d; ,crop_w, crop_h);
203 GLSLF(1, vec2 c_o = vec2(%
i, %
i) / in_d; ,crop_x,crop_y);
206 if (
s->vkctx.output_format ==
s->vkctx.input_format) {
207 for (
int i = 0;
i <
desc[1].elems;
i++) {
214 GLSLF(2, imageStore(output_img[%
i],
pos, res); ,
i);
222 switch (
s->vkctx.output_format) {
226 default:
return AVERROR(EINVAL);
232 if (
s->vkctx.output_format !=
s->vkctx.input_format) {
234 double tmp_mat[3][3];
244 for (
int y = 0; y < 3; y++)
245 for (
int x = 0; x < 3; x++)
246 s->opts.yuv_matrix[x][y] = tmp_mat[x][y];
247 s->opts.yuv_matrix[3][3] = 1.0;
285 s->sampler, &
s->opts,
sizeof(
s->opts)));
292 out->color_range =
s->out_range;
293 if (
s->vkctx.output_format !=
s->vkctx.input_format)
320 if (
s->out_format_string) {
327 s->vkctx.output_format =
s->vkctx.input_format;
330 if (
s->vkctx.output_format !=
s->vkctx.input_format) {
368 #define OFFSET(x) offsetof(ScaleVulkanContext, x)
369 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
407 .
name =
"scale_vulkan",
415 .priv_class = &scale_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...
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_vk_qf_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkQueueFlagBits dev_family)
Chooses a QF and loads it into a context.
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.
enum AVColorSpace colorspace
YUV colorspace type.
This structure describes decoded (raw) audio or video data.
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
@ AVCOL_RANGE_JPEG
Full range content.
static const AVFilterPad scale_vulkan_outputs[]
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 AVOption scale_vulkan_options[]
static const char rgb2yuv[]
static const char write_nv12[]
int ff_scale_eval_dimensions(void *log_ctx, const char *w_expr, const char *h_expr, AVFilterLink *inlink, AVFilterLink *outlink, int *ret_w, int *ret_h)
Parse and evaluate string expressions for width and height.
Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar calculations.
void ff_vk_uninit(FFVulkanContext *s)
Frees main context.
void(* uninit)(struct FFVkSPIRVCompiler **ctx)
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.
void ff_vk_shader_set_compute_sizes(FFVkSPIRVShader *shd, int x, int y, int z)
A link between two filters.
static const char write_420[]
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
struct ScaleVulkanContext::@287 opts
AVFILTER_DEFINE_CLASS(scale_vulkan)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
const VkAllocationCallbacks * alloc
Custom memory allocator, else NULL.
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
A filter pad used for either input or output.
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int scale_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
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)
#define FILTER_INPUTS(array)
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 link
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
static void scale_vulkan_uninit(AVFilterContext *avctx)
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
AVFilterLink ** inputs
array of pointers to input links
int ff_vk_filter_config_output(AVFilterLink *outlink)
int ff_vk_init_compute_pipeline(FFVulkanContext *s, FFVulkanPipeline *pl, FFVkSPIRVShader *shd)
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.
enum AVColorRange out_range
@ AVCOL_RANGE_UNSPECIFIED
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)
int(* init)(AVBSFContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
AVFilterContext * src
source filter
#define AVERROR_EXTERNAL
Generic error in an external library.
int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt)
Returns 1 if pixfmt is a usable RGB format.
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 void uninit(AVBSFContext *ctx)
void ff_fill_rgb2yuv_table(const AVLumaCoefficients *coeffs, double rgb2yuv[3][3])
const AVFilter ff_vf_scale_vulkan
#define i(width, name, range_min, range_max)
int w
agreed upon image width
static const char scale_bilinear[]
static const char write_444[]
const char * ff_vk_shader_rep_fmt(enum AVPixelFormat pixfmt)
Returns the format to use for images in shaders.
static const AVFilterPad scale_vulkan_inputs[]
const char * name
Pad name.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
void(* free_shader)(struct FFVkSPIRVCompiler *ctx, void **opaque)
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
int h
agreed upon image height
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int ff_vk_filter_config_input(AVFilterLink *inlink)
AVVulkanDeviceContext * hwctx
VkDevice act_dev
Active device.
#define FILTER_OUTPUTS(array)
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
int ff_vk_exec_pipeline_register(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanPipeline *pl)
Register a pipeline with an exec pool.
static int scale_vulkan_config_output(AVFilterLink *outlink)
static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
void ff_vk_shader_free(FFVulkanContext *s, FFVkSPIRVShader *shd)
AVColorRange
Visual content value range.