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) {
335 if (inlink->
w != outlink->
w || inlink->
w != outlink->
w) {
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,
const FFFilter ff_vf_scale_vulkan
static AVFormatContext * ctx
static AVDictionary * opts
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
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 av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
@ AV_SIDE_DATA_PROP_SIZE_DEPENDENT
Side data depends on the video dimensions.
#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...
int sws_scale_frame(SwsContext *sws, AVFrame *dst, const AVFrame *src)
Scale source data from src and write the output to dst.
SwsContext * sws_alloc_context(void)
Allocate an empty SwsContext and set its fields to default values.
void sws_free_context(SwsContext **ctx)
Free the context and everything associated with it, and write NULL to the provided pointer.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
static av_cold void uninit(AVBitStreamFilterContext *ctx)
void ff_fill_rgb2yuv_table(const AVLumaCoefficients *coeffs, double rgb2yuv[3][3])
#define FILTER_INPUTS(array)
#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...
#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.
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.
int ff_vk_init_sampler(FFVulkanContext *s, VkSampler *sampler, int unnorm_coords, VkFilter filt)
Create a sampler.
int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt)
Returns 1 if pixfmt is a usable RGB format.
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.
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.
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
AVColorRange
Visual content value range.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_RGBA64
#define AV_PIX_FMT_BAYER_RGGB16
@ 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...
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
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_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.
@ SCALE_FORCE_OAR_DISABLE
AVFilterLink ** inputs
array of pointers to input links
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
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
enum AVColorSpace colorspace
YUV colorspace type.
Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar calculations.
const VkAllocationCallbacks * alloc
Custom memory allocator, else NULL.
VkDevice act_dev
Active device.
AVVulkanDeviceContext * hwctx
enum AVColorRange out_range
AVVulkanDeviceQueueFamily * qf
Main external API structure.
const unsigned int ff_debayer_comp_spv_len
static int scale_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
static const AVFilterPad scale_vulkan_outputs[]
static int scale_vulkan_config_output(AVFilterLink *outlink)
static const AVFilterPad scale_vulkan_inputs[]
const unsigned char ff_debayer_comp_spv_data[]
static av_cold int init_debayer(AVFilterContext *ctx, AVFrame *in)
const unsigned char ff_scale_comp_spv_data[]
const unsigned int ff_scale_comp_spv_len
static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
static void scale_vulkan_uninit(AVFilterContext *avctx)
static const AVOption scale_vulkan_options[]
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
#define FF_VK_DEFAULT_EXEC_CONTEXTS
#define SPEC_LIST_ADD(name, idx, val_bits, val)
#define SPEC_LIST_CREATE(name, max_length, max_size)
int ff_vk_filter_config_input(AVFilterLink *inlink)
int ff_vk_filter_config_output(AVFilterLink *outlink)
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(AVFilterContext *avctx)
General lavfi IO functions.