FFmpeg
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
vf_drawtext.c File Reference
#include "config.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <fenv.h>
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/common.h"
#include "libavutil/file.h"
#include "libavutil/eval.h"
#include "libavutil/opt.h"
#include "libavutil/random_seed.h"
#include "libavutil/parseutils.h"
#include "libavutil/timecode.h"
#include "libavutil/time_internal.h"
#include "libavutil/tree.h"
#include "libavutil/lfg.h"
#include "libavutil/detection_bbox.h"
#include "avfilter.h"
#include "drawutils.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
#include <ft2build.h>
#include <FT_FREETYPE_H>
#include <FT_GLYPH_H>
#include <FT_STROKER_H>
#include <FT_ERRORS_H>

Go to the source code of this file.

Data Structures

struct  DrawTextContext
 
struct  ft_error
 
struct  drawtext_function
 

Macros

#define OFFSET(x)   offsetof(DrawTextContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define FT_ERROR_START_LIST   {
 
#define FT_ERRORDEF(e, v, s)   { (e), (s) },
 
#define FT_ERROR_END_LIST   { 0, NULL } };
 
#define FT_ERRMSG(e)   ft_errors[e].err_msg
 

Typedefs

typedef double(* eval_func2) (void *, double a, double b)
 

Enumerations

enum  var_name {
  VAR_N, VAR_TB, VAR_PTS, VAR_DTS,
  VAR_NOPTS, VAR_STARTPTS, VAR_STARTDTS, VAR_DURATION,
  VAR_D, VAR_POS, VAR_SIZE, VAR_KEY,
  VAR_STATE, VAR_VARS_NB, VAR_N, VAR_TS,
  VAR_POS, VAR_PREV_INPTS, VAR_PREV_INDTS, VAR_PREV_OUTPTS,
  VAR_PREV_OUTDTS, VAR_PTS, VAR_DTS, VAR_STARTPTS,
  VAR_STARTDTS, VAR_TB, VAR_SR, VAR_NOPTS,
  VAR_VARS_NB, VAR_CH, VAR_N, VAR_NB_IN_CHANNELS,
  VAR_NB_OUT_CHANNELS, VAR_T, VAR_S, VAR_VARS_NB,
  VAR_W, VAR_H, VAR_CW, VAR_CH,
  VAR_HSUB, VAR_VSUB, VARS_NB, VAR_VALUE1,
  VAR_VALUE2, VAR_FRAMEVAL, VAR_USERVAL, VAR_VARS_NB,
  VAR_TB, VAR_PTS, VAR_START_PTS, VAR_PREV_PTS,
  VAR_PREV_SELECTED_PTS, VAR_T, VAR_START_T, VAR_PREV_T,
  VAR_PREV_SELECTED_T, VAR_PICT_TYPE, VAR_I, VAR_P,
  VAR_B, VAR_S, VAR_SI, VAR_SP,
  VAR_BI, VAR_PICT_TYPE_I, VAR_PICT_TYPE_P, VAR_PICT_TYPE_B,
  VAR_PICT_TYPE_S, VAR_PICT_TYPE_SI, VAR_PICT_TYPE_SP, VAR_PICT_TYPE_BI,
  VAR_INTERLACE_TYPE, VAR_INTERLACE_TYPE_P, VAR_INTERLACE_TYPE_T, VAR_INTERLACE_TYPE_B,
  VAR_CONSUMED_SAMPLES_N, VAR_SAMPLES_N, VAR_SAMPLE_RATE, VAR_N,
  VAR_SELECTED_N, VAR_PREV_SELECTED_N, VAR_KEY, VAR_POS,
  VAR_SCENE, VAR_CONCATDEC_SELECT, VAR_VARS_NB, VAR_N,
  VAR_T, VAR_POS, VAR_PTS, VAR_TS,
  VAR_TE, VAR_TI, VAR_VARS_NB, VAR_IN_W,
  VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W,
  VAR_OW, VAR_OUT_H, VAR_OH, VAR_A,
  VAR_SAR, VAR_DAR, VAR_HSUB, VAR_VSUB,
  VAR_OHSUB, VAR_OVSUB, VARS_NB, VAR_FRAME_RATE,
  VAR_INTERLACED, VAR_N, VAR_NB_CONSUMED_SAMPLES, VAR_NB_SAMPLES,
  VAR_POS, VAR_PREV_INPTS, VAR_PREV_INT, VAR_PREV_OUTPTS,
  VAR_PREV_OUTT, VAR_PTS, VAR_SAMPLE_RATE, VAR_STARTPTS,
  VAR_STARTT, VAR_T, VAR_TB, VAR_RTCTIME,
  VAR_RTCSTART, VAR_S, VAR_SR, VAR_FR,
  VAR_VARS_NB, VAR_AVTB, VAR_INTB, VAR_SR,
  VAR_VARS_NB, VAR_W, VAR_H, VAR_A,
  VAR_DAR, VAR_SAR, VAR_HSUB, VAR_VSUB,
  VARS_NB, VAR_IN_W, VAR_IW, VAR_IN_H,
  VAR_IH, VAR_OUT_W, VAR_OW, VAR_OUT_H,
  VAR_OH, VAR_A, VAR_SAR, VAR_DAR,
  VAR_HSUB, VAR_VSUB, VAR_X, VAR_Y,
  VAR_N, VAR_POS, VAR_T, VAR_VARS_NB,
  VAR_X, VAR_Y, VAR_W, VAR_H,
  VAR_N, VAR_T, VAR_VARS_NB, VAR_DAR,
  VAR_HSUB, VAR_VSUB, VAR_IN_H, VAR_IH,
  VAR_IN_W, VAR_IW, VAR_SAR, VAR_X,
  VAR_Y, VAR_H, VAR_W, VAR_T,
  VAR_MAX, VARS_NB, VAR_DAR, VAR_HSUB,
  VAR_VSUB, VAR_LINE_H, VAR_LH, VAR_MAIN_H,
  VAR_h, VAR_H, VAR_MAIN_W, VAR_w,
  VAR_W, VAR_MAX_GLYPH_A, VAR_ASCENT, VAR_MAX_GLYPH_D,
  VAR_DESCENT, VAR_MAX_GLYPH_H, VAR_MAX_GLYPH_W, VAR_N,
  VAR_SAR, VAR_T, VAR_TEXT_H, VAR_TH,
  VAR_TEXT_W, VAR_TW, VAR_X, VAR_Y,
  VAR_PICT_TYPE, VAR_PKT_POS, VAR_PKT_DURATION, VAR_PKT_SIZE,
  VAR_VARS_NB, VAR_N, VAR_POS, VAR_R,
  VAR_T, VAR_NB, VAR_SOURCE_FPS, VAR_FPS_NTSC,
  VAR_FPS_PAL, VAR_FPS_FILM, VAR_FPS_NTSC_FILM, VARS_NB,
  VAR_N, VAR_PTS, VAR_R, VAR_T,
  VAR_TB, VAR_NB, VAR_W, VAR_H,
  VAR_VAL, VAR_MAXVAL, VAR_MINVAL, VAR_NEGVAL,
  VAR_CLIPVAL, VAR_VARS_NB, VAR_W, VAR_H,
  VAR_X, VAR_Y, VAR_BITDEPTHX, VAR_BITDEPTHY,
  VAR_VARS_NB, VAR_MAIN_W, VAR_MW, VAR_MAIN_H,
  VAR_MH, VAR_OVERLAY_W, VAR_OW, VAR_OVERLAY_H,
  VAR_OH, VAR_HSUB, VAR_VSUB, VAR_X,
  VAR_Y, VAR_N, VAR_POS, VAR_T,
  VAR_VARS_NB, VAR_MAIN_W, VAR_MW, VAR_MAIN_H,
  VAR_MH, VAR_OVERLAY_W, VAR_OW, VAR_OVERLAY_H,
  VAR_OH, VAR_X, VAR_Y, VAR_N,
  VAR_POS, VAR_T, VAR_VARS_NB, VAR_MAIN_iW,
  VAR_MW, VAR_MAIN_iH, VAR_MH, VAR_OVERLAY_iW,
  VAR_OVERLAY_iH, VAR_OVERLAY_X, VAR_OX, VAR_OVERLAY_Y,
  VAR_OY, VAR_OVERLAY_W, VAR_OW, VAR_OVERLAY_H,
  VAR_OH, VAR_VARS_NB, VAR_IN_W, VAR_IW,
  VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW,
  VAR_OUT_H, VAR_OH, VAR_X, VAR_Y,
  VAR_A, VAR_SAR, VAR_DAR, VAR_HSUB,
  VAR_VSUB, VARS_NB, VAR_IN_W, VAR_IW,
  VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW,
  VAR_OUT_H, VAR_OH, VAR_X, VAR_Y,
  VAR_A, VAR_SAR, VAR_DAR, VARS_NB,
  VAR_W, VAR_H, VAR_VAL, VAR_YMIN,
  VAR_UMIN, VAR_VMIN, VAR_AMIN, VAR_YMAX,
  VAR_UMAX, VAR_VMAX, VAR_AMAX, VAR_VARS_NB,
  VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH,
  VAR_OUT_W, VAR_OW, VAR_OUT_H, VAR_OH,
  VAR_HSUB, VAR_VSUB, VAR_N, VAR_T,
  VAR_VARS_NB, VAR_IN_W, VAR_IW, VAR_IN_H,
  VAR_IH, VAR_OUT_W, VAR_OW, VAR_OUT_H,
  VAR_OH, VAR_A, VAR_SAR, VAR_DAR,
  VAR_HSUB, VAR_VSUB, VAR_OHSUB, VAR_OVSUB,
  VAR_N, VAR_T, VAR_POS, VAR_S2R_MAIN_W,
  VAR_S2R_MAIN_H, VAR_S2R_MAIN_A, VAR_S2R_MAIN_SAR, VAR_S2R_MAIN_DAR,
  VAR_S2R_MDAR, VAR_S2R_MAIN_HSUB, VAR_S2R_MAIN_VSUB, VAR_S2R_MAIN_N,
  VAR_S2R_MAIN_T, VAR_S2R_MAIN_POS, VARS_NB, VAR_IN_W,
  VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W,
  VAR_OW, VAR_OUT_H, VAR_OH, VAR_A,
  VAR_SAR, VAR_DAR, VAR_N, VAR_T,
  VAR_POS, VAR_S2R_MAIN_W, VAR_S2R_MAIN_H, VAR_S2R_MAIN_A,
  VAR_S2R_MAIN_SAR, VAR_S2R_MAIN_DAR, VAR_S2R_MDAR, VAR_S2R_MAIN_N,
  VAR_S2R_MAIN_T, VAR_S2R_MAIN_POS, VARS_NB, VAR_PI,
  VAR_PHI, VAR_E, VAR_IN_W, VAR_IW,
  VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW,
  VAR_OUT_H, VAR_OH, VAR_A, VAR_DAR,
  VAR_SAR, VARS_NB, VAR_W, VAR_H,
  VAR_N, VAR_PTS, VAR_R, VAR_T,
  VAR_TB, VAR_NB, VAR_iW, VAR_IN_W,
  VAR_iH, VAR_IN_H, VAR_oW, VAR_OUT_W,
  VAR_W, VAR_oH, VAR_OUT_H, VAR_H,
  CW, CH, CX, CY,
  VAR_VARS_NB, VAR_IN_W, VAR_IW, VAR_IN_H,
  VAR_IH, VAR_OUT_W, VAR_OW, VAR_OUT_H,
  VAR_OH, VAR_IN, VAR_ON, VAR_DURATION,
  VAR_PDURATION, VAR_IN_TIME, VAR_IT, VAR_TIME,
  VAR_OUT_TIME, VAR_OT, VAR_FRAME, VAR_ZOOM,
  VAR_PZOOM, VAR_X, VAR_PX, VAR_Y,
  VAR_PY, VAR_A, VAR_SAR, VAR_DAR,
  VAR_HSUB, VAR_VSUB, VARS_NB, VAR_IN_W,
  VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W,
  VAR_OW, VAR_OUT_H, VAR_OH, VAR_A,
  VAR_SAR, VAR_DAR, VAR_HSUB, VAR_VSUB,
  VAR_OHSUB, VAR_OVSUB, VARS_NB, VAR_X,
  VAR_Y, VAR_W, VAR_H, VAR_TIME,
  VAR_SPEED, VAR_TEMPO, VAR_ORDER, VAR_PATTERN,
  VAR_ROW, VAR_VARS_NB
}
 
enum  expansion_mode { EXP_NONE, EXP_NORMAL, EXP_STRFTIME }
 

Functions

static double drand (void *opaque, double min, double max)
 
 AVFILTER_DEFINE_CLASS (drawtext)
 
static int glyph_cmp (const void *key, const void *b)
 
static int load_glyph (AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code)
 Load glyphs corresponding to the UTF-32 codepoint code. More...
 
static av_cold int set_fontsize (AVFilterContext *ctx, unsigned int fontsize)
 
static av_cold int parse_fontsize (AVFilterContext *ctx)
 
static av_cold int update_fontsize (AVFilterContext *ctx)
 
static int load_font_file (AVFilterContext *ctx, const char *path, int index)
 
static int load_font (AVFilterContext *ctx)
 
static int is_newline (uint32_t c)
 
static int load_textfile (AVFilterContext *ctx)
 
static enum AVFrameSideDataType text_source_string_parse (const char *text_source_string)
 
static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int glyph_enu_free (void *opaque, void *elem)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static int command (AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
 
static int func_pict_type (AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
 
static int func_pts (AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
 
static int func_frame_num (AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
 
static int func_metadata (AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
 
static int func_strftime (AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
 
static int func_eval_expr (AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
 
static int func_eval_expr_int_format (AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
 
static int eval_function (AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv)
 
static int expand_function (AVFilterContext *ctx, AVBPrint *bp, char **rtext)
 
static int expand_text (AVFilterContext *ctx, char *text, AVBPrint *bp)
 
static int draw_glyphs (DrawTextContext *s, AVFrame *frame, int width, int height, FFDrawColor *color, int x, int y, int borderw)
 
static void update_color_with_alpha (DrawTextContext *s, FFDrawColor *color, const FFDrawColor incolor)
 
static void update_alpha (DrawTextContext *s)
 
static int draw_text (AVFilterContext *ctx, AVFrame *frame, int width, int height)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 

Variables

static const char *const var_names []
 
static const char *const fun2_names []
 
static const eval_func2 fun2 []
 
static const AVOption drawtext_options []
 
static const struct ft_error ft_errors []
 
static const struct drawtext_function functions []
 
static const AVFilterPad avfilter_vf_drawtext_inputs []
 
static const AVFilterPad avfilter_vf_drawtext_outputs []
 
const AVFilter ff_vf_drawtext
 

Detailed Description

drawtext filter, based on the original vhook/drawtext.c filter by Gustavo Sverzut Barbieri

Definition in file vf_drawtext.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 211 of file vf_drawtext.c.

◆ FLAGS

Definition at line 212 of file vf_drawtext.c.

◆ FT_ERROR_START_LIST

#define FT_ERROR_START_LIST   {

Definition at line 281 of file vf_drawtext.c.

◆ FT_ERRORDEF

#define FT_ERRORDEF (   e,
  v,
  s 
)    { (e), (s) },

Definition at line 282 of file vf_drawtext.c.

◆ FT_ERROR_END_LIST

#define FT_ERROR_END_LIST   { 0, NULL } };

Definition at line 283 of file vf_drawtext.c.

◆ FT_ERRMSG

#define FT_ERRMSG (   e)    ft_errors[e].err_msg

Typedef Documentation

◆ eval_func2

typedef double(* eval_func2) (void *, double a, double b)

Definition at line 107 of file vf_drawtext.c.

Enumeration Type Documentation

◆ var_name

enum var_name
Enumerator
VAR_N 
VAR_TB 
VAR_PTS 
VAR_DTS 
VAR_NOPTS 
VAR_STARTPTS 
VAR_STARTDTS 
VAR_DURATION 
VAR_D 
VAR_POS 
VAR_SIZE 
VAR_KEY 
VAR_STATE 
VAR_VARS_NB 
VAR_N 
VAR_TS 
VAR_POS 
VAR_PREV_INPTS 
VAR_PREV_INDTS 
VAR_PREV_OUTPTS 
VAR_PREV_OUTDTS 
VAR_PTS 
VAR_DTS 
VAR_STARTPTS 
VAR_STARTDTS 
VAR_TB 
VAR_SR 
VAR_NOPTS 
VAR_VARS_NB 
VAR_CH 
VAR_N 
VAR_NB_IN_CHANNELS 
VAR_NB_OUT_CHANNELS 
VAR_T 
VAR_S 
VAR_VARS_NB 
VAR_W 
VAR_H 
VAR_CW 
VAR_CH 
VAR_HSUB 
VAR_VSUB 
VARS_NB 
VAR_VALUE1 
VAR_VALUE2 
VAR_FRAMEVAL 
VAR_USERVAL 
VAR_VARS_NB 
VAR_TB 
VAR_PTS 
VAR_START_PTS 
VAR_PREV_PTS 
VAR_PREV_SELECTED_PTS 
VAR_T 
VAR_START_T 
VAR_PREV_T 
VAR_PREV_SELECTED_T 
VAR_PICT_TYPE 
VAR_I 
VAR_P 
VAR_B 
VAR_S 
VAR_SI 
VAR_SP 
VAR_BI 
VAR_PICT_TYPE_I 
VAR_PICT_TYPE_P 
VAR_PICT_TYPE_B 
VAR_PICT_TYPE_S 
VAR_PICT_TYPE_SI 
VAR_PICT_TYPE_SP 
VAR_PICT_TYPE_BI 
VAR_INTERLACE_TYPE 
VAR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B 
VAR_X 
VAR_Y 
VAR_W 
VAR_H 
VAR_TIME 
VAR_SPEED 
VAR_TEMPO 
VAR_ORDER 
VAR_PATTERN 
VAR_ROW 
VAR_VARS_NB 

Definition at line 114 of file vf_drawtext.c.

◆ expansion_mode

Enumerator
EXP_NONE 
EXP_NORMAL 
EXP_STRFTIME 

Definition at line 138 of file vf_drawtext.c.

Function Documentation

◆ drand()

static double drand ( void *  opaque,
double  min,
double  max 
)
static

Definition at line 102 of file vf_drawtext.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( drawtext  )

◆ glyph_cmp()

static int glyph_cmp ( const void *  key,
const void *  b 
)
static

Definition at line 306 of file vf_drawtext.c.

Referenced by draw_glyphs(), draw_text(), and load_glyph().

◆ load_glyph()

static int load_glyph ( AVFilterContext ctx,
Glyph **  glyph_ptr,
uint32_t  code 
)
static

Load glyphs corresponding to the UTF-32 codepoint code.

Definition at line 320 of file vf_drawtext.c.

Referenced by draw_text(), and init().

◆ set_fontsize()

static av_cold int set_fontsize ( AVFilterContext ctx,
unsigned int  fontsize 
)
static

Definition at line 388 of file vf_drawtext.c.

Referenced by update_fontsize().

◆ parse_fontsize()

static av_cold int parse_fontsize ( AVFilterContext ctx)
static

Definition at line 404 of file vf_drawtext.c.

Referenced by update_fontsize().

◆ update_fontsize()

static av_cold int update_fontsize ( AVFilterContext ctx)
static

Definition at line 422 of file vf_drawtext.c.

Referenced by draw_text(), and init().

◆ load_font_file()

static int load_font_file ( AVFilterContext ctx,
const char *  path,
int  index 
)
static

Definition at line 458 of file vf_drawtext.c.

Referenced by load_font().

◆ load_font()

static int load_font ( AVFilterContext ctx)
static

Definition at line 558 of file vf_drawtext.c.

Referenced by init().

◆ is_newline()

static int is_newline ( uint32_t  c)
inlinestatic

Definition at line 575 of file vf_drawtext.c.

Referenced by draw_text(), and load_textfile().

◆ load_textfile()

static int load_textfile ( AVFilterContext ctx)
static

Definition at line 580 of file vf_drawtext.c.

Referenced by filter_frame(), and init().

◆ text_source_string_parse()

static enum AVFrameSideDataType text_source_string_parse ( const char *  text_source_string)
static

Definition at line 697 of file vf_drawtext.c.

Referenced by init().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 707 of file vf_drawtext.c.

Referenced by command().

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 822 of file vf_drawtext.c.

◆ glyph_enu_free()

static int glyph_enu_free ( void *  opaque,
void *  elem 
)
static

Definition at line 827 of file vf_drawtext.c.

Referenced by uninit().

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 837 of file vf_drawtext.c.

Referenced by command().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 863 of file vf_drawtext.c.

Referenced by command().

◆ command()

static int command ( AVFilterContext ctx,
const char *  cmd,
const char *  arg,
char *  res,
int  res_len,
int  flags 
)
static

◆ func_pict_type()

static int func_pict_type ( AVFilterContext ctx,
AVBPrint *  bp,
char *  fct,
unsigned  argc,
char **  argv,
int  tag 
)
static

Definition at line 953 of file vf_drawtext.c.

◆ func_pts()

static int func_pts ( AVFilterContext ctx,
AVBPrint *  bp,
char *  fct,
unsigned  argc,
char **  argv,
int  tag 
)
static

Definition at line 962 of file vf_drawtext.c.

◆ func_frame_num()

static int func_frame_num ( AVFilterContext ctx,
AVBPrint *  bp,
char *  fct,
unsigned  argc,
char **  argv,
int  tag 
)
static

Definition at line 1022 of file vf_drawtext.c.

◆ func_metadata()

static int func_metadata ( AVFilterContext ctx,
AVBPrint *  bp,
char *  fct,
unsigned  argc,
char **  argv,
int  tag 
)
static

Definition at line 1031 of file vf_drawtext.c.

◆ func_strftime()

static int func_strftime ( AVFilterContext ctx,
AVBPrint *  bp,
char *  fct,
unsigned  argc,
char **  argv,
int  tag 
)
static

Definition at line 1044 of file vf_drawtext.c.

◆ func_eval_expr()

static int func_eval_expr ( AVFilterContext ctx,
AVBPrint *  bp,
char *  fct,
unsigned  argc,
char **  argv,
int  tag 
)
static

Definition at line 1060 of file vf_drawtext.c.

◆ func_eval_expr_int_format()

static int func_eval_expr_int_format ( AVFilterContext ctx,
AVBPrint *  bp,
char *  fct,
unsigned  argc,
char **  argv,
int  tag 
)
static

Definition at line 1080 of file vf_drawtext.c.

◆ eval_function()

static int eval_function ( AVFilterContext ctx,
AVBPrint *  bp,
char *  fct,
unsigned  argc,
char **  argv 
)
static

Definition at line 1161 of file vf_drawtext.c.

Referenced by expand_function().

◆ expand_function()

static int expand_function ( AVFilterContext ctx,
AVBPrint *  bp,
char **  rtext 
)
static

Definition at line 1188 of file vf_drawtext.c.

Referenced by expand_text().

◆ expand_text()

static int expand_text ( AVFilterContext ctx,
char *  text,
AVBPrint *  bp 
)
static

Definition at line 1228 of file vf_drawtext.c.

Referenced by draw_text().

◆ draw_glyphs()

static int draw_glyphs ( DrawTextContext s,
AVFrame frame,
int  width,
int  height,
FFDrawColor color,
int  x,
int  y,
int  borderw 
)
static

Definition at line 1251 of file vf_drawtext.c.

Referenced by draw_text().

◆ update_color_with_alpha()

static void update_color_with_alpha ( DrawTextContext s,
FFDrawColor color,
const FFDrawColor  incolor 
)
static

Definition at line 1297 of file vf_drawtext.c.

Referenced by draw_text().

◆ update_alpha()

static void update_alpha ( DrawTextContext s)
static

Definition at line 1304 of file vf_drawtext.c.

Referenced by draw_text().

◆ draw_text()

static int draw_text ( AVFilterContext ctx,
AVFrame frame,
int  width,
int  height 
)
static

Definition at line 1319 of file vf_drawtext.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 1546 of file vf_drawtext.c.

Variable Documentation

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"dar",
"hsub", "vsub",
"line_h", "lh",
"main_h", "h", "H",
"main_w", "w", "W",
"max_glyph_a", "ascent",
"max_glyph_d", "descent",
"max_glyph_h",
"max_glyph_w",
"n",
"sar",
"t",
"text_h", "th",
"text_w", "tw",
"x",
"y",
"pict_type",
"pkt_pos",
"pkt_duration",
"pkt_size",
}

Definition at line 74 of file vf_drawtext.c.

Referenced by config_input(), func_eval_expr(), func_eval_expr_int_format(), and parse_fontsize().

◆ fun2_names

const char* const fun2_names[]
static
Initial value:
= {
"rand"
}

Definition at line 98 of file vf_drawtext.c.

Referenced by config_input(), func_eval_expr(), func_eval_expr_int_format(), and parse_fontsize().

◆ fun2

const eval_func2 fun2[]
static
Initial value:
= {
}

Definition at line 109 of file vf_drawtext.c.

Referenced by config_input(), func_eval_expr(), func_eval_expr_int_format(), and parse_fontsize().

◆ drawtext_options

const AVOption drawtext_options[]
static

Definition at line 214 of file vf_drawtext.c.

◆ ft_errors

const struct ft_error ft_errors[]
static
Initial value:
=
#define FT_ERRMSG(e)
typedef struct Glyph {
FT_Glyph glyph;
FT_Glyph border_glyph;
uint32_t code;
unsigned int fontsize;
FT_Bitmap bitmap;
FT_Bitmap border_bitmap;
FT_BBox bbox;
int advance;
int bitmap_left;
int bitmap_top;
} Glyph

◆ functions

const struct drawtext_function functions[]
static
Initial value:
= {
{ "expr", 1, 1, 0, func_eval_expr },
{ "e", 1, 1, 0, func_eval_expr },
{ "expr_int_format", 2, 3, 0, func_eval_expr_int_format },
{ "eif", 2, 3, 0, func_eval_expr_int_format },
{ "pict_type", 0, 0, 0, func_pict_type },
{ "pts", 0, 3, 0, func_pts },
{ "gmtime", 0, 1, 'G', func_strftime },
{ "localtime", 0, 1, 'L', func_strftime },
{ "frame_num", 0, 0, 0, func_frame_num },
{ "n", 0, 0, 0, func_frame_num },
{ "metadata", 1, 2, 0, func_metadata },
}

Referenced by eval_function().

◆ avfilter_vf_drawtext_inputs

const AVFilterPad avfilter_vf_drawtext_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_input,
},
}

Definition at line 1614 of file vf_drawtext.c.

◆ avfilter_vf_drawtext_outputs

const AVFilterPad avfilter_vf_drawtext_outputs[]
static
Initial value:
= {
{
.name = "default",
},
}

Definition at line 1624 of file vf_drawtext.c.

◆ ff_vf_drawtext

const AVFilter ff_vf_drawtext
Initial value:
= {
.name = "drawtext",
.description = NULL_IF_CONFIG_SMALL("Draw text on top of video frames using libfreetype library."),
.priv_size = sizeof(DrawTextContext),
.priv_class = &drawtext_class,
.init = init,
.process_command = command,
}

Definition at line 1631 of file vf_drawtext.c.

filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_drawtext.c:1546
func_pts
static int func_pts(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
Definition: vf_drawtext.c:962
func_frame_num
static int func_frame_num(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
Definition: vf_drawtext.c:1022
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:168
func_pict_type
static int func_pict_type(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
Definition: vf_drawtext.c:953
func_metadata
static int func_metadata(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
Definition: vf_drawtext.c:1031
func_eval_expr
static int func_eval_expr(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
Definition: vf_drawtext.c:1060
avfilter_vf_drawtext_inputs
static const AVFilterPad avfilter_vf_drawtext_inputs[]
Definition: vf_drawtext.c:1614
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
command
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Definition: vf_drawtext.c:906
NULL
#define NULL
Definition: coverity.c:32
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_drawtext.c:822
DrawTextContext
Definition: vf_drawtext.c:144
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_drawtext.c:837
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:117
drand
static double drand(void *opaque, double min, double max)
Definition: vf_drawtext.c:102
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:146
code
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: filter_design.txt:178
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_drawtext.c:707
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_drawtext.c:863
func_strftime
static int func_strftime(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
Definition: vf_drawtext.c:1044
func_eval_expr_int_format
static int func_eval_expr_int_format(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
Definition: vf_drawtext.c:1080
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
avfilter_vf_drawtext_outputs
static const AVFilterPad avfilter_vf_drawtext_outputs[]
Definition: vf_drawtext.c:1624
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
AVFILTERPAD_FLAG_NEEDS_WRITABLE
#define AVFILTERPAD_FLAG_NEEDS_WRITABLE
The filter expects writable frames from its input link, duplicating data buffers if needed.
Definition: internal.h:69