FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_drawvg.c File Reference
#include <cairo.h>
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bswap.h"
#include "libavutil/eval.h"
#include "libavutil/internal.h"
#include "libavutil/macros.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/sfc64.h"
#include "avfilter.h"
#include "filters.h"
#include "textutils.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  VGSConstant
 Constants for some commands, like setlinejoin. More...
 
struct  VGSParameter
 
struct  VGSCommandSpec
 
struct  VGSParser
 
struct  VGSParserToken
 
struct  VGSArgument
 Command arguments. More...
 
struct  VGSStatement
 Program statements. More...
 
struct  VGSProgram
 
struct  VGSProcedure
 Block assigned to a procedure by a call to the proc command. More...
 
struct  VGSEvalState
 
struct  DrawVGContext
 

Macros

#define USER_VAR_COUNT   20
 Number of user variables that can be created with setvar. More...
 
#define VAR_COUNT   (VAR_U0 + USER_VAR_COUNT)
 Total number of variables (default- and user-variables). More...
 
#define MAX_COMMAND_PARAMS   8
 
#define MAX_PROC_ARGS   (MAX_COMMAND_PARAMS - 2)
 
#define PARAMS(...)   (const struct VGSParameter[]){ __VA_ARGS__ }
 
#define L(...)   PARAMS(__VA_ARGS__, { PARAM_END })
 
#define R(...)   PARAMS(__VA_ARGS__, { PARAM_MAY_REPEAT })
 
#define NONE   PARAMS({ PARAM_END })
 
#define N   { PARAM_NUMERIC }
 
#define V   { PARAM_VAR_NAME }
 
#define P   { PARAM_SUBPROGRAM }
 
#define C(c)   { PARAM_CONSTANT, .constants = c }
 
#define WORD_SEPARATOR   " \n\t\r,"
 
#define FAIL(err)
 
#define RANDOM_STATES   4
 Number of different states for the randomg function. More...
 
#define ASSERT_ARGS(n)   av_assert0(statement->args_count == n)
 
#define MAY_PRESERVE(funcname)
 
#define C(v, o)   ((uint32_t)(av_clipd(v, 0, 1) * 255) << o)
 
#define OPT(name, field, help)
 

Enumerations

enum  {
  VAR_N, VAR_T, VAR_TS, VAR_W,
  VAR_H, VAR_DURATION, VAR_CX, VAR_CY,
  VAR_I, VAR_U0
}
 
enum  VGSCommand {
  CMD_ARC = 1, CMD_ARC_NEG, CMD_BREAK, CMD_CIRCLE,
  CMD_CLIP, CMD_CLIP_EO, CMD_CLOSE_PATH, CMD_COLOR_STOP,
  CMD_CURVE_TO, CMD_DEF_HSLA, CMD_DEF_RGBA, CMD_CURVE_TO_REL,
  CMD_ELLIPSE, CMD_FILL, CMD_FILL_EO, CMD_GET_METADATA,
  CMD_HORZ, CMD_HORZ_REL, CMD_IF, CMD_LINEAR_GRAD,
  CMD_LINE_TO, CMD_LINE_TO_REL, CMD_MOVE_TO, CMD_MOVE_TO_REL,
  CMD_NEW_PATH, CMD_PRESERVE, CMD_PRINT, CMD_PROC_ASSIGN,
  CMD_PROC_CALL, CMD_Q_CURVE_TO, CMD_Q_CURVE_TO_REL, CMD_RADIAL_GRAD,
  CMD_RECT, CMD_REPEAT, CMD_RESET_CLIP, CMD_RESET_DASH,
  CMD_RESET_MATRIX, CMD_RESTORE, CMD_ROTATE, CMD_ROUNDEDRECT,
  CMD_SAVE, CMD_SCALE, CMD_SCALEXY, CMD_SET_COLOR,
  CMD_SET_DASH, CMD_SET_DASH_OFFSET, CMD_SET_HSLA, CMD_SET_LINE_CAP,
  CMD_SET_LINE_JOIN, CMD_SET_LINE_WIDTH, CMD_SET_RGBA, CMD_SET_VAR,
  CMD_STROKE, CMD_S_CURVE_TO, CMD_S_CURVE_TO_REL, CMD_TRANSLATE,
  CMD_T_CURVE_TO, CMD_T_CURVE_TO_REL, CMD_VERT, CMD_VERT_REL
}
 

Functions

static double vgs_fn_pathlen (void *data, double arg)
 Function pathlen(n) for av_expr_eval. More...
 
static double vgs_fn_randomg (void *data, double arg)
 Function randomg(n) for av_expr_eval. More...
 
static double vgs_fn_p (void *data, double x0, double y0)
 Function p(x, y) for av_expr_eval. More...
 
static int vgs_comp_command_spec (const void *cs1, const void *cs2)
 Comparator for VGSCommandDecl, to be used with bsearch(3). More...
 
static const struct VGSCommandSpecvgs_get_command (const char *name, size_t length)
 Return the specs for the given command, or NULL if the name is not valid. More...
 
static int vgs_cmd_change_path (enum VGSCommand cmd)
 Return 1 if the command changes the current path in the cairo context. More...
 
static int vgs_token_is_string (const struct VGSParserToken *token, const char *str)
 Check if token is the value of str. More...
 
static void vgs_token_span (const struct VGSParser *parser, const struct VGSParserToken *token, size_t *line, size_t *column)
 Compute the line/column numbers of the given token. More...
 
static av_printf_format (4, 5)
 
static int vgs_parser_next_token (void *log_ctx, struct VGSParser *parser, struct VGSParserToken *token, int advance)
 Return the next token in the source. More...
 
static void vgs_free (struct VGSProgram *program)
 Release the memory allocated by the program. More...
 
static int vgs_parse (void *log_ctx, struct VGSParser *parser, struct VGSProgram *program, int subprogram)
 Build a program by parsing a script. More...
 
static void vgs_statement_free (struct VGSStatement *stm)
 
static int vgs_parse_numeric_argument (void *log_ctx, struct VGSParser *parser, struct VGSArgument *arg, int metadata)
 Consume the next argument as a numeric value, and store it in arg. More...
 
static int vgs_parser_can_repeat_cmd (void *log_ctx, struct VGSParser *parser)
 Check if the next token is a numeric value, so the last command must be repeated. More...
 
static int vgs_is_valid_identifier (const struct VGSParserToken *token)
 
static int vgs_parse_statement (void *log_ctx, struct VGSParser *parser, struct VGSProgram *program, const struct VGSCommandSpec *decl)
 Extract the arguments for a command, and add a new statement to the program. More...
 
static void vgs_parser_init (struct VGSParser *parser, const char *source)
 
static void vgs_parser_free (struct VGSParser *parser)
 
static int vgs_eval_state_init (struct VGSEvalState *state, const struct VGSProgram *program, void *log_ctx, AVFrame *frame)
 
static void vgs_eval_state_free (struct VGSEvalState *state)
 
static void draw_ellipse (cairo_t *c, double x, double y, double rx, double ry)
 Draw an ellipse. More...
 
static void draw_quad_curve_to (struct VGSEvalState *state, int relative, double x1, double y1, double x, double y)
 Draw a quadratic bezier from the current point to x, y, The control point is specified by x1, y1. More...
 
static void draw_cubic_curve_to (struct VGSEvalState *state, int relative, double x1, double y1, double x2, double y2, double x, double y)
 Similar to quad_curve_to, but for cubic curves. More...
 
static void draw_rounded_rect (cairo_t *c, double x, double y, double width, double height, double radius)
 
static void hsl2rgb (double h, double s, double l, double *pr, double *pg, double *pb)
 
static int vgs_eval (struct VGSEvalState *state, const struct VGSProgram *program)
 Interpreter for VGSProgram. More...
 
 AVFILTER_DEFINE_CLASS (drawvg)
 
static cairo_format_t cairo_format_from_pix_fmt (DrawVGContext *ctx, enum AVPixelFormat format)
 
static int drawvg_filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static int drawvg_config_props (AVFilterLink *inlink)
 
static av_cold int drawvg_init (AVFilterContext *ctx)
 
static av_cold void drawvg_uninit (AVFilterContext *ctx)
 

Variables

static const char *const vgs_default_vars []
 
static const char *const vgs_func1_names []
 
static double(*const vgs_func1_impls [])(void *, double)
 
static const char *const vgs_func2_names []
 
static double(*const vgs_func2_impls [])(void *, double, double)
 
static const struct VGSConstant vgs_consts_line_cap []
 
static const struct VGSConstant vgs_consts_line_join []
 
static const struct VGSCommandSpec vgs_commands []
 
static const AVOption drawvg_options []
 
static enum AVPixelFormat drawvg_pix_fmts []
 
static const AVFilterPad drawvg_inputs []
 
const FFFilter ff_vf_drawvg
 

Detailed Description

drawvg filter, draw vector graphics with cairo.

This file contains the parser and the interpreter for VGS, and the AVClass definitions for the drawvg filter.

Definition in file vf_drawvg.c.

Macro Definition Documentation

◆ USER_VAR_COUNT

#define USER_VAR_COUNT   20

Number of user variables that can be created with setvar.

It is possible to allow any number of variables, but this approach simplifies the implementation, and 20 variables is more than enough for the expected use of this filter.

Definition at line 75 of file vf_drawvg.c.

◆ VAR_COUNT

#define VAR_COUNT   (VAR_U0 + USER_VAR_COUNT)

Total number of variables (default- and user-variables).

Definition at line 78 of file vf_drawvg.c.

◆ MAX_COMMAND_PARAMS

#define MAX_COMMAND_PARAMS   8

Definition at line 237 of file vf_drawvg.c.

◆ MAX_PROC_ARGS

#define MAX_PROC_ARGS   (MAX_COMMAND_PARAMS - 2)

Definition at line 243 of file vf_drawvg.c.

◆ PARAMS

#define PARAMS (   ...)    (const struct VGSParameter[]){ __VA_ARGS__ }

Definition at line 254 of file vf_drawvg.c.

◆ L

#define L (   ...)    PARAMS(__VA_ARGS__, { PARAM_END })

Definition at line 255 of file vf_drawvg.c.

◆ R

#define R (   ...)    PARAMS(__VA_ARGS__, { PARAM_MAY_REPEAT })

Definition at line 256 of file vf_drawvg.c.

◆ NONE

#define NONE   PARAMS({ PARAM_END })

Definition at line 257 of file vf_drawvg.c.

◆ N

#define N   { PARAM_NUMERIC }

Definition at line 260 of file vf_drawvg.c.

◆ V

#define V   { PARAM_VAR_NAME }

Definition at line 261 of file vf_drawvg.c.

◆ P

#define P   { PARAM_SUBPROGRAM }

Definition at line 262 of file vf_drawvg.c.

◆ C [1/2]

#define C (   c)    { PARAM_CONSTANT, .constants = c }

Definition at line 263 of file vf_drawvg.c.

◆ WORD_SEPARATOR

#define WORD_SEPARATOR   " \n\t\r,"

◆ FAIL

#define FAIL (   err)
Value:
do { \
vgs_statement_free(&statement); \
return AVERROR(err); \
} while(0)

◆ RANDOM_STATES

#define RANDOM_STATES   4

Number of different states for the randomg function.

Definition at line 1334 of file vf_drawvg.c.

◆ ASSERT_ARGS

#define ASSERT_ARGS (   n)    av_assert0(statement->args_count == n)

◆ MAY_PRESERVE

#define MAY_PRESERVE (   funcname)
Value:
do { \
if (state->preserve_path) { \
state->preserve_path = 0; \
funcname##_preserve(state->cairo_ctx); \
} else { \
funcname(state->cairo_ctx); \
} \
} while(0)

◆ C [2/2]

#define C (   v,
 
)    ((uint32_t)(av_clipd(v, 0, 1) * 255) << o)

Definition at line 263 of file vf_drawvg.c.

◆ OPT

#define OPT (   name,
  field,
  help 
)
Value:
{ \
name, \
help, \
offsetof(DrawVGContext, field), \
AV_OPT_TYPE_STRING, \
{ .str = NULL }, \
0, 0, \
AV_OPT_FLAG_FILTERING_PARAM \
}

Definition at line 2517 of file vf_drawvg.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VAR_N 

Frame number.

VAR_T 

Timestamp in seconds.

VAR_TS 

Time in seconds of the first frame.

VAR_W 

Frame width.

VAR_H 

Frame height.

VAR_DURATION 

Frame duration.

VAR_CX 

X coordinate for current point.

VAR_CY 

Y coordinate for current point.

VAR_I 

Loop counter, to use with repeat {}.

VAR_U0 

User variables.

Definition at line 57 of file vf_drawvg.c.

◆ VGSCommand

enum VGSCommand
Enumerator
CMD_ARC 

arc (cx cy radius angle1 angle2)

CMD_ARC_NEG 

arcn (cx cy radius angle1 angle2)

CMD_BREAK 

break

CMD_CIRCLE 

circle (cx cy radius)

CMD_CLIP 

clip

CMD_CLIP_EO 

eoclip

CMD_CLOSE_PATH 

Z, z, closepath.

CMD_COLOR_STOP 

colorstop (offset color)

CMD_CURVE_TO 

C, curveto (x1 y1 x2 y2 x y)

CMD_DEF_HSLA 

defhsla (varname h s l a)

CMD_DEF_RGBA 

defrgba (varname r g b a)

CMD_CURVE_TO_REL 

c, rcurveto (dx1 dy1 dx2 dy2 dx dy)

CMD_ELLIPSE 

ellipse (cx cy rx ry)

CMD_FILL 

fill

CMD_FILL_EO 

eofill

CMD_GET_METADATA 

getmetadata varname key

CMD_HORZ 

H (x)

CMD_HORZ_REL 

h (dx)

CMD_IF 

if (condition) { subprogram }

CMD_LINEAR_GRAD 

lineargrad (x0 y0 x1 y1)

CMD_LINE_TO 

L, lineto (x y)

CMD_LINE_TO_REL 

l, rlineto (dx dy)

CMD_MOVE_TO 

M, moveto (x y)

CMD_MOVE_TO_REL 

m, rmoveto (dx dy)

CMD_NEW_PATH 

newpath

CMD_PRESERVE 

preserve

CMD_PRINT 

print (expr)*

CMD_PROC_ASSIGN 

proc name varnames* { subprogram }

CMD_PROC_CALL 

call name (expr)*

CMD_Q_CURVE_TO 

Q (x1 y1 x y)

CMD_Q_CURVE_TO_REL 

q (dx1 dy1 dx dy)

CMD_RADIAL_GRAD 

radialgrad (cx0 cy0 radius0 cx1 cy1 radius1)

CMD_RECT 

rect (x y width height)

CMD_REPEAT 

repeat (count) { subprogram }

CMD_RESET_CLIP 

resetclip

CMD_RESET_DASH 

resetdash

CMD_RESET_MATRIX 

resetmatrix

CMD_RESTORE 

restore

CMD_ROTATE 

rotate (angle)

CMD_ROUNDEDRECT 

roundedrect (x y width height radius)

CMD_SAVE 

save

CMD_SCALE 

scale (s)

CMD_SCALEXY 

scalexy (sx sy)

CMD_SET_COLOR 

setcolor (color)

CMD_SET_DASH 

setdash (length)

CMD_SET_DASH_OFFSET 

setdashoffset (offset)

CMD_SET_HSLA 

sethsla (h s l a)

CMD_SET_LINE_CAP 

setlinecap (cap)

CMD_SET_LINE_JOIN 

setlinejoin (join)

CMD_SET_LINE_WIDTH 

setlinewidth (width)

CMD_SET_RGBA 

setrgba (r g b a)

CMD_SET_VAR 

setvar (varname value)

CMD_STROKE 

stroke

CMD_S_CURVE_TO 

S (x2 y2 x y)

CMD_S_CURVE_TO_REL 

s (dx2 dy2 dx dy)

CMD_TRANSLATE 

translate (tx ty)

CMD_T_CURVE_TO 

T (x y)

CMD_T_CURVE_TO_REL 

t (dx dy)

CMD_VERT 

V (y)

CMD_VERT_REL 

v (dy)

Definition at line 133 of file vf_drawvg.c.

Function Documentation

◆ vgs_fn_pathlen()

static double vgs_fn_pathlen ( void *  data,
double  arg 
)
static

Function pathlen(n) for av_expr_eval.

Compute the length of the current path in the cairo context. If n > 0, it is the maximum number of segments to be added to the length.

Definition at line 1401 of file vf_drawvg.c.

◆ vgs_fn_randomg()

static double vgs_fn_randomg ( void *  data,
double  arg 
)
static

Function randomg(n) for av_expr_eval.

Compute a random value between 0 and 1. Similar to random(), but the state is global to the VGS program.

The last 2 bits of the integer representation of the argument are used as the state index. If the state is not initialized, the argument is the seed for that state.

Definition at line 1465 of file vf_drawvg.c.

◆ vgs_fn_p()

static double vgs_fn_p ( void *  data,
double  x0,
double  y0 
)
static

Function p(x, y) for av_expr_eval.

Return the pixel color in 0xRRGGBBAA format.

The transformation matrix is applied to the given coordinates.

If the coordinates are outside the frame, return NAN.

Definition at line 1489 of file vf_drawvg.c.

◆ vgs_comp_command_spec()

static int vgs_comp_command_spec ( const void *  cs1,
const void *  cs2 
)
static

Comparator for VGSCommandDecl, to be used with bsearch(3).

Definition at line 347 of file vf_drawvg.c.

Referenced by check_sorted_cmds_array(), and vgs_get_command().

◆ vgs_get_command()

static const struct VGSCommandSpec* vgs_get_command ( const char *  name,
size_t  length 
)
static

Return the specs for the given command, or NULL if the name is not valid.

The implementation assumes that vgs_commands is sorted by name.

Definition at line 357 of file vf_drawvg.c.

Referenced by vgs_parse(), and vgs_parser_can_repeat_cmd().

◆ vgs_cmd_change_path()

static int vgs_cmd_change_path ( enum VGSCommand  cmd)
static

Return 1 if the command changes the current path in the cairo context.

Definition at line 377 of file vf_drawvg.c.

Referenced by vgs_eval().

◆ vgs_token_is_string()

static int vgs_token_is_string ( const struct VGSParserToken token,
const char *  str 
)
static

Check if token is the value of str.

Definition at line 463 of file vf_drawvg.c.

Referenced by vgs_parse_numeric_argument(), vgs_parse_statement(), and vgs_parser_can_repeat_cmd().

◆ vgs_token_span()

static void vgs_token_span ( const struct VGSParser parser,
const struct VGSParserToken token,
size_t *  line,
size_t *  column 
)
static

Compute the line/column numbers of the given token.

Definition at line 469 of file vf_drawvg.c.

Referenced by av_printf_format(), and vgs_parse_numeric_argument().

◆ av_printf_format()

static av_printf_format ( ,
 
)
static

Definition at line 492 of file vf_drawvg.c.

◆ vgs_parser_next_token()

static int vgs_parser_next_token ( void *  log_ctx,
struct VGSParser parser,
struct VGSParserToken token,
int  advance 
)
static

Return the next token in the source.

Parameters
[out]tokenNext token.
[in]advanceIf true, the cursor is updated after finding a token.
Returns
0 on success, and a negative AVERROR code on failure.

Definition at line 522 of file vf_drawvg.c.

Referenced by vgs_parse(), vgs_parse_numeric_argument(), vgs_parse_statement(), and vgs_parser_can_repeat_cmd().

◆ vgs_free()

static void vgs_free ( struct VGSProgram program)
static

Release the memory allocated by the program.

Definition at line 706 of file vf_drawvg.c.

Referenced by check_script(), drawvg_uninit(), vgs_parse(), and vgs_statement_free().

◆ vgs_parse()

static int vgs_parse ( void *  log_ctx,
struct VGSParser parser,
struct VGSProgram program,
int  subprogram 
)
static

Build a program by parsing a script.

subprogram must be true when the function is called to parse the body of a block (like if or proc commands).

Return 0 on success, and a negative AVERROR code on failure.

Definition at line 1260 of file vf_drawvg.c.

Referenced by check_script(), drawvg_init(), and vgs_parse_statement().

◆ vgs_statement_free()

static void vgs_statement_free ( struct VGSStatement stm)
static

Definition at line 681 of file vf_drawvg.c.

Referenced by vgs_free().

◆ vgs_parse_numeric_argument()

static int vgs_parse_numeric_argument ( void *  log_ctx,
struct VGSParser parser,
struct VGSArgument arg,
int  metadata 
)
static

Consume the next argument as a numeric value, and store it in arg.

Return 0 on success, and a negative AVERROR code on failure.

Definition at line 726 of file vf_drawvg.c.

Referenced by vgs_parse_statement().

◆ vgs_parser_can_repeat_cmd()

static int vgs_parser_can_repeat_cmd ( void *  log_ctx,
struct VGSParser parser 
)
static

Check if the next token is a numeric value, so the last command must be repeated.

Definition at line 830 of file vf_drawvg.c.

Referenced by vgs_parse_statement().

◆ vgs_is_valid_identifier()

static int vgs_is_valid_identifier ( const struct VGSParserToken token)
static

Definition at line 868 of file vf_drawvg.c.

Referenced by vgs_parse_statement().

◆ vgs_parse_statement()

static int vgs_parse_statement ( void *  log_ctx,
struct VGSParser parser,
struct VGSProgram program,
const struct VGSCommandSpec decl 
)
static

Extract the arguments for a command, and add a new statement to the program.

On success, return 0.

Definition at line 892 of file vf_drawvg.c.

Referenced by vgs_parse().

◆ vgs_parser_init()

static void vgs_parser_init ( struct VGSParser parser,
const char *  source 
)
static

Definition at line 1229 of file vf_drawvg.c.

Referenced by check_script(), and drawvg_init().

◆ vgs_parser_free()

static void vgs_parser_free ( struct VGSParser parser)
static

Definition at line 1241 of file vf_drawvg.c.

Referenced by check_script(), and drawvg_init().

◆ vgs_eval_state_init()

static int vgs_eval_state_init ( struct VGSEvalState state,
const struct VGSProgram program,
void *  log_ctx,
AVFrame frame 
)
static

Definition at line 1534 of file vf_drawvg.c.

Referenced by check_script(), and drawvg_filter_frame().

◆ vgs_eval_state_free()

static void vgs_eval_state_free ( struct VGSEvalState state)
static

Definition at line 1560 of file vf_drawvg.c.

Referenced by check_script(), and drawvg_filter_frame().

◆ draw_ellipse()

static void draw_ellipse ( cairo_t *  c,
double  x,
double  y,
double  rx,
double  ry 
)
static

Draw an ellipse.

x/y specifies the center, and rx/ry the radius of the ellipse on the x/y axis.

Cairo does not provide a native way to create an ellipse, but it can be done by scaling the Y axis with the transformation matrix.

Definition at line 1575 of file vf_drawvg.c.

Referenced by vgs_eval().

◆ draw_quad_curve_to()

static void draw_quad_curve_to ( struct VGSEvalState state,
int  relative,
double  x1,
double  y1,
double  x,
double  y 
)
static

Draw a quadratic bezier from the current point to x, y, The control point is specified by x1, y1.

If the control point is NAN, use the reflected point.

cairo only supports cubic cuvers, so control points must be adjusted to simulate the behaviour in SVG.

Definition at line 1597 of file vf_drawvg.c.

Referenced by vgs_eval().

◆ draw_cubic_curve_to()

static void draw_cubic_curve_to ( struct VGSEvalState state,
int  relative,
double  x1,
double  y1,
double  x2,
double  y2,
double  x,
double  y 
)
static

Similar to quad_curve_to, but for cubic curves.

Definition at line 1646 of file vf_drawvg.c.

Referenced by vgs_eval().

◆ draw_rounded_rect()

static void draw_rounded_rect ( cairo_t *  c,
double  x,
double  y,
double  width,
double  height,
double  radius 
)
static

Definition at line 1693 of file vf_drawvg.c.

Referenced by vgs_eval().

◆ hsl2rgb()

static void hsl2rgb ( double  h,
double  s,
double  l,
double pr,
double pg,
double pb 
)
static

Definition at line 1711 of file vf_drawvg.c.

Referenced by vgs_eval().

◆ vgs_eval()

static int vgs_eval ( struct VGSEvalState state,
const struct VGSProgram program 
)
static

Interpreter for VGSProgram.

Its implementation is a simple switch-based dispatch.

To evaluate blocks (like if or call), it makes a recursive call with the subprogram allocated to the block.

Definition at line 1785 of file vf_drawvg.c.

Referenced by check_script(), and drawvg_filter_frame().

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( drawvg  )

◆ cairo_format_from_pix_fmt()

static cairo_format_t cairo_format_from_pix_fmt ( DrawVGContext ctx,
enum AVPixelFormat  format 
)
static

Definition at line 2550 of file vf_drawvg.c.

Referenced by drawvg_config_props().

◆ drawvg_filter_frame()

static int drawvg_filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 2574 of file vf_drawvg.c.

◆ drawvg_config_props()

static int drawvg_config_props ( AVFilterLink inlink)
static

Definition at line 2633 of file vf_drawvg.c.

◆ drawvg_init()

static av_cold int drawvg_init ( AVFilterContext ctx)
static

Definition at line 2647 of file vf_drawvg.c.

◆ drawvg_uninit()

static av_cold void drawvg_uninit ( AVFilterContext ctx)
static

Definition at line 2682 of file vf_drawvg.c.

Variable Documentation

◆ vgs_default_vars

const char* const vgs_default_vars[]
static
Initial value:
= {
"n",
"t",
"ts",
"w",
"h",
"duration",
"cx",
"cy",
"i",
NULL,
}

Definition at line 80 of file vf_drawvg.c.

Referenced by vgs_parser_init().

◆ vgs_func1_names

const char* const vgs_func1_names[]
static
Initial value:
= {
"pathlen",
"randomg",
}

Definition at line 95 of file vf_drawvg.c.

Referenced by vgs_parse_numeric_argument().

◆ vgs_func1_impls

double(*const vgs_func1_impls[])(void *, double)
static
Initial value:

Definition at line 104 of file vf_drawvg.c.

Referenced by vgs_parse_numeric_argument().

◆ vgs_func2_names

const char* const vgs_func2_names[]
static
Initial value:
= {
"p",
}

Definition at line 110 of file vf_drawvg.c.

Referenced by vgs_parse_numeric_argument().

◆ vgs_func2_impls

double(*const vgs_func2_impls[])(void *, double, double)
static
Initial value:
= {
}

Definition at line 117 of file vf_drawvg.c.

Referenced by vgs_parse_numeric_argument().

◆ vgs_consts_line_cap

const struct VGSConstant vgs_consts_line_cap[]
static
Initial value:
= {
{ "butt", CAIRO_LINE_CAP_BUTT },
{ "round", CAIRO_LINE_CAP_ROUND },
{ "square", CAIRO_LINE_CAP_SQUARE },
{ NULL, 0 },
}

Definition at line 202 of file vf_drawvg.c.

◆ vgs_consts_line_join

const struct VGSConstant vgs_consts_line_join[]
static
Initial value:
= {
{ "bevel", CAIRO_LINE_JOIN_BEVEL },
{ "miter", CAIRO_LINE_JOIN_MITER },
{ "round", CAIRO_LINE_JOIN_ROUND },
{ NULL, 0 },
}

Definition at line 209 of file vf_drawvg.c.

◆ vgs_commands

const struct VGSCommandSpec vgs_commands[]
static

Definition at line 268 of file vf_drawvg.c.

Referenced by check_sorted_cmds_array(), and vgs_get_command().

◆ drawvg_options

const AVOption drawvg_options[]
static
Initial value:
= {
OPT("script", script_text, "script source to draw the graphics"),
OPT("s", script_text, "script source to draw the graphics"),
OPT("file", script_file, "file to load the script source"),
{ NULL }
}

Definition at line 2529 of file vf_drawvg.c.

◆ drawvg_pix_fmts

enum AVPixelFormat drawvg_pix_fmts[]
static

◆ drawvg_inputs

const AVFilterPad drawvg_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = drawvg_filter_frame,
.config_props = drawvg_config_props,
},
}

Definition at line 2687 of file vf_drawvg.c.

◆ ff_vf_drawvg

const FFFilter ff_vf_drawvg
Initial value:
= {
.p.name = "drawvg",
.p.description = NULL_IF_CONFIG_SMALL("Draw vector graphics on top of video frames."),
.p.priv_class = &drawvg_class,
.priv_size = sizeof(DrawVGContext),
}

Definition at line 2697 of file vf_drawvg.c.

drawvg_inputs
static const AVFilterPad drawvg_inputs[]
Definition: vf_drawvg.c:2687
AVERROR
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
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:243
state
static struct @539 state
vgs_fn_pathlen
static double vgs_fn_pathlen(void *, double)
Function pathlen(n) for av_expr_eval.
Definition: vf_drawvg.c:1401
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:263
drawvg_init
static av_cold int drawvg_init(AVFilterContext *ctx)
Definition: vf_drawvg.c:2647
drawvg_config_props
static int drawvg_config_props(AVFilterLink *inlink)
Definition: vf_drawvg.c:2633
OPT
#define OPT(name, field, help)
Definition: vf_drawvg.c:2517
drawvg_uninit
static av_cold void drawvg_uninit(AVFilterContext *ctx)
Definition: vf_drawvg.c:2682
vgs_fn_randomg
static double vgs_fn_randomg(void *, double)
Function randomg(n) for av_expr_eval.
Definition: vf_drawvg.c:1465
ff_video_default_filterpad
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition: video.c:37
field
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this field
Definition: writing_filters.txt:78
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:264
NULL
#define NULL
Definition: coverity.c:32
AVFILTERPAD_FLAG_NEEDS_WRITABLE
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
Definition: filters.h:58
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
drawvg_filter_frame
static int drawvg_filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_drawvg.c:2574
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:524
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:197
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
vgs_fn_p
static double vgs_fn_p(void *, double, double)
Function p(x, y) for av_expr_eval.
Definition: vf_drawvg.c:1489
AV_OPT_FLAG_VIDEO_PARAM
#define AV_OPT_FLAG_VIDEO_PARAM
Definition: opt.h:358
AV_PIX_FMT_X2RGB10
#define AV_PIX_FMT_X2RGB10
Definition: pixfmt.h:632
AV_PIX_FMT_RGB565
#define AV_PIX_FMT_RGB565
Definition: pixfmt.h:539
drawvg_pix_fmts
static enum AVPixelFormat drawvg_pix_fmts[]
Definition: vf_drawvg.c:2541
AV_PIX_FMT_0RGB32
#define AV_PIX_FMT_0RGB32
Definition: pixfmt.h:528
DrawVGContext
Definition: vf_drawvg.c:2499
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200