FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_scale_vulkan.c File Reference
#include "libavutil/random_seed.h"
#include "libavutil/opt.h"
#include "libavutil/vulkan_spirv.h"
#include "vulkan_filter.h"
#include "scale_eval.h"
#include "filters.h"
#include "colorspace.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  ScaleVulkanContext
 

Macros

#define OFFSET(x)   offsetof(ScaleVulkanContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Enumerations

enum  ScalerFunc { F_BILINEAR = 0, F_NEAREST, F_NB }
 

Functions

static av_cold int init_filter (AVFilterContext *ctx, AVFrame *in)
 
static int scale_vulkan_filter_frame (AVFilterLink *link, AVFrame *in)
 
static int scale_vulkan_config_output (AVFilterLink *outlink)
 
static void scale_vulkan_uninit (AVFilterContext *avctx)
 
 AVFILTER_DEFINE_CLASS (scale_vulkan)
 

Variables

static const char scale_bilinear []
 
static const char rgb2yuv []
 
static const char write_nv12 []
 
static const char write_420 []
 
static const char write_444 []
 
static const AVOption scale_vulkan_options []
 
static const AVFilterPad scale_vulkan_inputs []
 
static const AVFilterPad scale_vulkan_outputs []
 
const AVFilter ff_vf_scale_vulkan
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(ScaleVulkanContext, x)

Definition at line 366 of file vf_scale_vulkan.c.

◆ FLAGS

Definition at line 367 of file vf_scale_vulkan.c.

Enumeration Type Documentation

◆ ScalerFunc

enum ScalerFunc
Enumerator
F_BILINEAR 
F_NEAREST 
F_NB 

Definition at line 30 of file vf_scale_vulkan.c.

Function Documentation

◆ init_filter()

static av_cold int init_filter ( AVFilterContext ctx,
AVFrame in 
)
static

Definition at line 111 of file vf_scale_vulkan.c.

Referenced by scale_vulkan_filter_frame().

◆ scale_vulkan_filter_frame()

static int scale_vulkan_filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 267 of file vf_scale_vulkan.c.

◆ scale_vulkan_config_output()

static int scale_vulkan_config_output ( AVFilterLink outlink)
static

Definition at line 305 of file vf_scale_vulkan.c.

◆ scale_vulkan_uninit()

static void scale_vulkan_uninit ( AVFilterContext avctx)
static

Definition at line 348 of file vf_scale_vulkan.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( scale_vulkan  )

Variable Documentation

◆ scale_bilinear

const char scale_bilinear[]
static
Initial value:
= {
C(0, vec4 scale_bilinear(int idx, ivec2 pos, vec2 crop_range, vec2 crop_off))
C(0, { )
C(1, vec2 npos = (vec2(pos) + 0.5f) / imageSize(output_img[idx]); )
C(1, npos *= crop_range; )
C(1, npos += crop_off; )
C(1, return texture(input_img[idx], npos); )
C(0, } )
}

Definition at line 59 of file vf_scale_vulkan.c.

Referenced by init_filter().

◆ rgb2yuv

const char rgb2yuv[]
static

◆ write_nv12

const char write_nv12[]
static
Initial value:
= {
C(0, void write_nv12(vec4 src, ivec2 pos) )
C(0, { )
C(1, imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0)); )
C(1, pos /= ivec2(2); )
C(1, imageStore(output_img[1], pos, vec4(src.g, src.b, 0.0, 0.0)); )
C(0, } )
}

Definition at line 83 of file vf_scale_vulkan.c.

Referenced by init_filter().

◆ write_420

const char write_420[]
static
Initial value:
= {
C(0, void write_420(vec4 src, ivec2 pos) )
C(0, { )
C(1, imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0)); )
C(1, pos /= ivec2(2); )
C(1, imageStore(output_img[1], pos, vec4(src.g, 0.0, 0.0, 0.0)); )
C(1, imageStore(output_img[2], pos, vec4(src.b, 0.0, 0.0, 0.0)); )
C(0, } )
}

Definition at line 92 of file vf_scale_vulkan.c.

Referenced by init_filter().

◆ write_444

const char write_444[]
static
Initial value:
= {
C(0, void write_444(vec4 src, ivec2 pos) )
C(0, { )
C(1, imageStore(output_img[0], pos, vec4(src.r, 0.0, 0.0, 0.0)); )
C(1, imageStore(output_img[1], pos, vec4(src.g, 0.0, 0.0, 0.0)); )
C(1, imageStore(output_img[2], pos, vec4(src.b, 0.0, 0.0, 0.0)); )
C(0, } )
}

Definition at line 102 of file vf_scale_vulkan.c.

Referenced by init_filter().

◆ scale_vulkan_options

const AVOption scale_vulkan_options[]
static
Initial value:
= {
{ "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, .flags = FLAGS },
{ "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = FLAGS },
{ "scaler", "Scaler function", OFFSET(scaler), AV_OPT_TYPE_INT, {.i64 = F_BILINEAR}, 0, F_NB, .flags = FLAGS, .unit = "scaler" },
{ "bilinear", "Bilinear interpolation (fastest)", 0, AV_OPT_TYPE_CONST, {.i64 = F_BILINEAR}, 0, 0, .flags = FLAGS, .unit = "scaler" },
{ "nearest", "Nearest (useful for pixel art)", 0, AV_OPT_TYPE_CONST, {.i64 = F_NEAREST}, 0, 0, .flags = FLAGS, .unit = "scaler" },
{ "format", "Output video format (software format of hardware frames)", OFFSET(out_format_string), AV_OPT_TYPE_STRING, .flags = FLAGS },
{ "out_range", "Output colour range (from 0 to 2) (default 0)", OFFSET(out_range), AV_OPT_TYPE_INT, {.i64 = AVCOL_RANGE_UNSPECIFIED}, AVCOL_RANGE_UNSPECIFIED, AVCOL_RANGE_JPEG, .flags = FLAGS, .unit = "range" },
{ "full", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, .unit = "range" },
{ "limited", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, .unit = "range" },
{ "jpeg", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, .unit = "range" },
{ "mpeg", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, .unit = "range" },
{ "tv", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, .unit = "range" },
{ "pc", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, .unit = "range" },
{ NULL },
}

Definition at line 368 of file vf_scale_vulkan.c.

◆ scale_vulkan_inputs

const AVFilterPad scale_vulkan_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = &scale_vulkan_filter_frame,
.config_props = &ff_vk_filter_config_input,
},
}

Definition at line 387 of file vf_scale_vulkan.c.

◆ scale_vulkan_outputs

const AVFilterPad scale_vulkan_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = &scale_vulkan_config_output,
},
}

Definition at line 396 of file vf_scale_vulkan.c.

◆ ff_vf_scale_vulkan

const AVFilter ff_vf_scale_vulkan
Initial value:
= {
.name = "scale_vulkan",
.description = NULL_IF_CONFIG_SMALL("Scale Vulkan frames"),
.priv_size = sizeof(ScaleVulkanContext),
.priv_class = &scale_vulkan_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}

Definition at line 404 of file vf_scale_vulkan.c.

FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
OFFSET
#define OFFSET(x)
Definition: vf_scale_vulkan.c:366
ff_vk_filter_init
int ff_vk_filter_init(AVFilterContext *avctx)
General lavfi IO functions.
Definition: vulkan_filter.c:233
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:717
scale_vulkan_outputs
static const AVFilterPad scale_vulkan_outputs[]
Definition: vf_scale_vulkan.c:396
b
#define b
Definition: input.c:41
rgb2yuv
static const char rgb2yuv[]
Definition: vf_scale_vulkan.c:69
write_nv12
static const char write_nv12[]
Definition: vf_scale_vulkan.c:83
write_420
static const char write_420[]
Definition: vf_scale_vulkan.c:92
AV_PIX_FMT_VULKAN
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition: pixfmt.h:379
C
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
Definition: writing_filters.txt:58
F_NEAREST
@ F_NEAREST
Definition: vf_scale_vulkan.c:32
F_BILINEAR
@ F_BILINEAR
Definition: vf_scale_vulkan.c:31
g
const char * g
Definition: vf_curves.c:128
scale_vulkan_filter_frame
static int scale_vulkan_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_scale_vulkan.c:267
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NULL
#define NULL
Definition: coverity.c:32
scale_vulkan_uninit
static void scale_vulkan_uninit(AVFilterContext *avctx)
Definition: vf_scale_vulkan.c:348
F_NB
@ F_NB
Definition: vf_scale_vulkan.c:34
FLAGS
#define FLAGS
Definition: vf_scale_vulkan.c:367
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:683
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: filters.h:206
f
f
Definition: af_crystalizer.c:122
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
AVFILTER_FLAG_HWDEVICE
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition: avfilter.h:173
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
scale_bilinear
static const char scale_bilinear[]
Definition: vf_scale_vulkan.c:59
write_444
static const char write_444[]
Definition: vf_scale_vulkan.c:102
scale_vulkan_inputs
static const AVFilterPad scale_vulkan_inputs[]
Definition: vf_scale_vulkan.c:387
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:700
pos
unsigned int pos
Definition: spdifenc.c:414
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
ScaleVulkanContext
Definition: vf_scale_vulkan.c:37
ff_vk_filter_config_input
int ff_vk_filter_config_input(AVFilterLink *inlink)
Definition: vulkan_filter.c:176
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
scale_vulkan_config_output
static int scale_vulkan_config_output(AVFilterLink *outlink)
Definition: vf_scale_vulkan.c:305
AV_OPT_TYPE_STRING
@ 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...
Definition: opt.h:276
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:252
src
#define src
Definition: vp8dsp.c:248