Go to the documentation of this file.
89 VkFilter sampler_mode;
100 sampler_mode = VK_FILTER_NEAREST;
103 sampler_mode = VK_FILTER_LINEAR;
107 if (
s->vkctx.output_format ==
s->vkctx.input_format) {
110 switch (
s->vkctx.output_format) {
114 default:
return AVERROR(EINVAL);
128 (uint32_t []) { 32, 32, 1 }, 0);
133 .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
135 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
139 .name =
"output_img",
140 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
142 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
149 VK_SHADER_STAGE_COMPUTE_BIT);
153 double tmp_mat[3][3];
164 for (
int y = 0; y < 3; y++)
165 for (
int x = 0; x < 3; x++)
166 s->opts.yuv_matrix[x][y] = tmp_mat[x][y];
167 s->opts.yuv_matrix[3][3] = 1.0;
170 s->opts.in_dims[0] = in->
width;
171 s->opts.in_dims[1] = in->
height;
197 (uint32_t []) { 32, 32, 1 }, 0);
200 VK_SHADER_STAGE_COMPUTE_BIT);
205 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
206 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
210 .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
211 .stages = VK_SHADER_STAGE_COMPUTE_BIT,
259 out->color_range =
s->out_range;
260 if (
s->vkctx.output_format !=
s->vkctx.input_format)
264 if (!
s->initialized) {
279 s->sampler, 1, &
s->opts,
sizeof(
s->opts)));
318 if (
s->out_format_string) {
325 s->vkctx.output_format =
s->vkctx.input_format;
329 if (
s->vkctx.output_format ==
s->vkctx.input_format) {
339 }
else if ((
inlink->w == outlink->
w ||
inlink->h == outlink->
h) &&
340 (
s->vkctx.input_format !=
s->vkctx.output_format)) {
346 s->scaler ==
F_NEAREST ?
"point" :
"bilinear", 0);
347 }
else if (
s->vkctx.output_format !=
s->vkctx.input_format) {
385 #define OFFSET(x) offsetof(ScaleVulkanContext, x)
386 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
427 .
p.
name =
"scale_vulkan",
429 .p.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.
static av_cold int init_debayer(AVFilterContext *ctx, AVFrame *in)
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
@ SCALE_FORCE_OAR_DISABLE
void ff_vk_shader_free(FFVulkanContext *s, FFVulkanShader *shd)
Free a shader.
struct ScaleVulkanContext::@450 opts
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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.
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
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
const unsigned char ff_debayer_comp_spv_data[]
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...
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
static const AVOption scale_vulkan_options[]
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.
#define SPEC_LIST_ADD(name, idx, val_bits, val)
const char * name
Filter name.
A link between two filters.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
AVFILTER_DEFINE_CLASS(scale_vulkan)
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
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.
const VkAllocationCallbacks * alloc
Custom memory allocator, else NULL.
void * priv
private data for use by the filter
int ff_vk_shader_register_exec(FFVulkanContext *s, FFVkExecPool *pool, FFVulkanShader *shd)
Register a shader with an exec pool.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
const unsigned char ff_scale_comp_spv_data[]
@ AV_SIDE_DATA_PROP_SIZE_DEPENDENT
Side data depends on the video dimensions.
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const unsigned int ff_scale_comp_spv_len
#define FILTER_OUTPUTS(array)
static int scale_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
const FFFilter ff_vf_scale_vulkan
static AVFormatContext * ctx
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
void ff_vk_exec_pool_free(FFVulkanContext *s, FFVkExecPool *pool)
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
#define AV_PIX_FMT_RGBA64
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
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_shader_link(FFVulkanContext *s, FFVulkanShader *shd, const char *spirv, size_t spirv_len, const char *entrypoint)
Link a shader into an executable.
#define SPEC_LIST_CREATE(name, max_length, max_size)
enum AVColorRange out_range
@ AVCOL_RANGE_UNSPECIFIED
AVVulkanDeviceQueueFamily * qf
int(* init)(AVBSFContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext and set its fields to default values.
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
AVFilterContext * src
source filter
int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt)
Returns 1 if pixfmt is a usable RGB format.
void av_frame_side_data_remove_by_props(AVFrameSideData ***sd, int *nb_sd, int props)
Remove and free all side data instances that match any of the given side data properties.
void ff_fill_rgb2yuv_table(const AVLumaCoefficients *coeffs, double rgb2yuv[3][3])
int w
agreed upon image width
static const AVFilterPad scale_vulkan_inputs[]
static av_cold void uninit(AVBitStreamFilterContext *ctx)
const char * name
Pad name.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
void ff_vk_shader_add_descriptor_set(FFVulkanContext *s, FFVulkanShader *shd, const FFVulkanDescriptorSetBinding *desc, int nb, int singular)
Add descriptor to a shader.
@ 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...
int ff_vk_shader_add_push_const(FFVulkanShader *shd, int offset, int size, VkShaderStageFlagBits stage)
Add/update push constants for execution.
#define FILTER_INPUTS(array)
AVVulkanDeviceQueueFamily * ff_vk_qf_find(FFVulkanContext *s, VkQueueFlagBits dev_family, VkVideoCodecOperationFlagBitsKHR vid_ops)
Chooses an appropriate QF.
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
int h
agreed upon image height
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ 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)
AVFilter p
The public AVFilter.
AVVulkanDeviceContext * hwctx
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image dimensions or settings change in any way sws_scale_frame() is itself just a light-weight wrapper that runs ff_sws_graph_reinit() initially and on format changes
VkDevice act_dev
Active device.
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
void sws_free_context(SwsContext **ctx)
Free the context and everything associated with it, and write NULL to the provided pointer.
static int scale_vulkan_config_output(AVFilterLink *outlink)
static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AV_PIX_FMT_BAYER_RGGB16
AVColorRange
Visual content value range.
Main external API structure.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
int ff_scale_adjust_dimensions(AVFilterLink *inlink, int *ret_w, int *ret_h, int force_original_aspect_ratio, int force_divisible_by, double w_adj)
Transform evaluated width and height obtained from ff_scale_eval_dimensions into actual target width ...
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.
const unsigned int ff_debayer_comp_spv_len