34 #include <sys/types.h>
42 #if CONFIG_LIBFONTCONFIG
43 #include <fontconfig/fontconfig.h>
69 #include FT_FREETYPE_H
79 "max_glyph_a",
"ascent",
80 "max_glyph_d",
"descent",
98 static double drand(
void *opaque,
double min,
double max)
141 #if CONFIG_LIBFONTCONFIG
192 #if CONFIG_LIBFRIBIDI
198 #define OFFSET(x) offsetof(DrawTextContext, x)
199 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
220 #if CONFIG_LIBFONTCONFIG
236 {
"fix_bounds",
"if true, check and fix text coords to avoid clipping",
OFFSET(fix_bounds),
AV_OPT_TYPE_INT, {.i64=1}, 0, 1,
FLAGS},
237 {
"start_number",
"start frame number for n/frame_num variable",
OFFSET(start_number),
AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX,
FLAGS},
239 #if CONFIG_LIBFRIBIDI
244 {
"ft_load_flags",
"set font loading flags for libfreetype",
OFFSET(ft_load_flags),
AV_OPT_TYPE_FLAGS, { .i64 = FT_LOAD_DEFAULT }, 0, INT_MAX,
FLAGS,
"ft_load_flags" },
250 {
"vertical_layout",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = FT_LOAD_VERTICAL_LAYOUT }, .flags =
FLAGS, .unit =
"ft_load_flags" },
254 {
"ignore_global_advance_width",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH }, .flags =
FLAGS, .unit =
"ft_load_flags" },
256 {
"ignore_transform",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = FT_LOAD_IGNORE_TRANSFORM }, .flags =
FLAGS, .unit =
"ft_load_flags" },
265 #undef __FTERRORS_H__
266 #define FT_ERROR_START_LIST {
267 #define FT_ERRORDEF(e, v, s) { (e), (s) },
268 #define FT_ERROR_END_LIST { 0, NULL } };
277 #define FT_ERRMSG(e) ft_errors[e].err_msg
279 typedef struct Glyph {
281 FT_Glyph border_glyph;
284 FT_Bitmap border_bitmap;
293 const Glyph *
a = key, *bb =
b;
294 int64_t
diff = (int64_t)a->code - (int64_t)bb->code;
295 return diff > 0 ? 1 : diff < 0 ? -1 : 0;
304 FT_BitmapGlyph bitmapglyph;
320 if (FT_Get_Glyph(s->
face->glyph, &glyph->glyph)) {
325 glyph->border_glyph = glyph->glyph;
326 if (FT_Glyph_StrokeBorder(&glyph->border_glyph, s->
stroker, 0, 0) ||
327 FT_Glyph_To_Bitmap(&glyph->border_glyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
331 bitmapglyph = (FT_BitmapGlyph) glyph->border_glyph;
332 glyph->border_bitmap = bitmapglyph->bitmap;
334 if (FT_Glyph_To_Bitmap(&glyph->glyph, FT_RENDER_MODE_NORMAL, 0, 1)) {
338 bitmapglyph = (FT_BitmapGlyph) glyph->glyph;
340 glyph->bitmap = bitmapglyph->bitmap;
341 glyph->bitmap_left = bitmapglyph->left;
342 glyph->bitmap_top = bitmapglyph->top;
343 glyph->advance = s->
face->glyph->advance.x >> 6;
346 FT_Glyph_Get_CBox(glyph->glyph, ft_glyph_bbox_pixels, &glyph->bbox);
373 err = FT_New_Face(s->
library, path, index, &s->
face);
382 #if CONFIG_LIBFONTCONFIG
386 FcConfig *fontconfig;
387 FcPattern *pat, *best;
388 FcResult result = FcResultMatch;
394 fontconfig = FcInitLoadConfigAndFonts();
400 (
uint8_t *)(intptr_t)
"default");
406 FcPatternAddString(pat, FC_FAMILY, s->font);
408 FcPatternAddDouble(pat, FC_SIZE, (
double)s->
fontsize);
410 FcDefaultSubstitute(pat);
412 if (!FcConfigSubstitute(fontconfig, pat, FcMatchPattern)) {
414 FcPatternDestroy(pat);
418 best = FcFontMatch(fontconfig, pat, &result);
419 FcPatternDestroy(pat);
421 if (!best || result != FcResultMatch) {
423 "Cannot find a valid font for the family %s\n",
429 FcPatternGetInteger(best, FC_INDEX, 0, &index ) != FcResultMatch ||
430 FcPatternGetDouble (best, FC_SIZE, 0, &size ) != FcResultMatch) {
435 if (FcPatternGetString(best, FC_FILE, 0, &filename) != FcResultMatch) {
448 FcConfigDestroy(fontconfig);
450 FcPatternDestroy(best);
464 #if CONFIG_LIBFONTCONFIG
465 err = load_font_fontconfig(ctx);
482 "The text file '%s' could not be read or is empty\n",
487 if (textbuf_size > SIZE_MAX - 1 || !(tmp =
av_realloc(s->
text, textbuf_size + 1))) {
492 memcpy(s->
text, textbuf, textbuf_size);
493 s->
text[textbuf_size] = 0;
501 return c ==
'\n' || c ==
'\r' || c ==
'\f' || c ==
'\v';
504 #if CONFIG_LIBFRIBIDI
510 static const FriBidiFlags
flags = FRIBIDI_FLAGS_DEFAULT |
511 FRIBIDI_FLAGS_ARABIC;
512 FriBidiChar *unicodestr =
NULL;
514 FriBidiParType direction = FRIBIDI_PAR_LTR;
515 FriBidiStrIndex line_start = 0;
516 FriBidiStrIndex line_end = 0;
517 FriBidiLevel *embedding_levels =
NULL;
518 FriBidiArabicProp *ar_props =
NULL;
519 FriBidiCharType *bidi_types =
NULL;
522 len = strlen(s->
text);
526 len = fribidi_charset_to_unicode(FRIBIDI_CHAR_SET_UTF8,
527 s->
text, len, unicodestr);
534 fribidi_get_bidi_types(unicodestr, len, bidi_types);
537 if (!embedding_levels) {
541 if (!fribidi_get_par_embedding_levels(bidi_types, len, &direction,
551 fribidi_get_joining_types(unicodestr, len, ar_props);
552 fribidi_join_arabic(bidi_types, len, embedding_levels, ar_props);
553 fribidi_shape(flags, embedding_levels, len, ar_props, unicodestr);
555 for (line_end = 0, line_start = 0; line_end <
len; line_end++) {
556 if (
is_newline(unicodestr[line_end]) || line_end == len - 1) {
557 if (!fribidi_reorder_line(flags, bidi_types,
558 line_end - line_start + 1, line_start,
559 direction, embedding_levels, unicodestr,
563 line_start = line_end + 1;
568 for (i = 0, j = 0; i <
len; i++)
569 if (unicodestr[i] != FRIBIDI_CHAR_FILL)
570 unicodestr[j++] = unicodestr[i];
579 len = fribidi_unicode_to_charset(FRIBIDI_CHAR_SET_UTF8,
580 unicodestr, len, s->
text);
598 if (!s->
fontfile && !CONFIG_LIBFONTCONFIG) {
606 "Both text and text file provided. Please provide only one\n");
613 #if CONFIG_LIBFRIBIDI
615 if ((err = shape_text(ctx)) < 0)
635 "Either text, a valid file or a timecode must be provided\n");
639 if ((err = FT_Init_FreeType(&(s->
library)))) {
641 "Could not load FreeType: %s\n",
FT_ERRMSG(err));
650 if ((err = FT_Set_Pixel_Sizes(s->
face, 0, s->
fontsize))) {
661 FT_Stroker_Set(s->
stroker, s->
borderw << 6, FT_STROKER_LINECAP_ROUND,
662 FT_STROKER_LINEJOIN_ROUND, 0);
671 if ((err =
load_glyph(ctx, &glyph,
' ')) < 0) {
678 (strchr(s->
text,
'%') || strchr(s->
text,
'\\')))
696 FT_Done_Glyph(glyph->glyph);
697 FT_Done_Glyph(glyph->border_glyph);
717 FT_Done_Face(s->
face);
769 if (!strcmp(cmd,
"reinit")) {
775 if ((ret =
init(ctx)) < 0)
784 char *fct,
unsigned argc,
char **argv,
int tag)
793 char *fct,
unsigned argc,
char **argv,
int tag)
800 fmt = argc >= 1 ? argv[0] :
"flt";
809 if (!strcmp(fmt,
"flt")) {
811 }
else if (!strcmp(fmt,
"hms")) {
815 int64_t ms =
round(pts * 1000);
822 (
int)(ms / (60 * 60 * 1000)),
823 (
int)(ms / (60 * 1000)) % 60,
824 (
int)(ms / 1000) % 60,
835 char *fct,
unsigned argc,
char **argv,
int tag)
844 char *fct,
unsigned argc,
char **argv,
int tag)
855 char *fct,
unsigned argc,
char **argv,
int tag)
857 const char *
fmt = argc ? argv[0] :
"%Y-%m-%d %H:%M:%S";
871 char *fct,
unsigned argc,
char **argv,
int tag)
882 "Expression '%s' for the expr text expansion function is not valid\n",
891 char *fct,
unsigned argc,
char **argv,
int tag)
897 unsigned int positions = 0;
898 char fmt_str[30] =
"%";
911 "Expression '%s' for the expr text expansion function is not valid\n",
916 if (!strchr(
"xXdu", argv[1][0])) {
918 " allowed values: 'x', 'X', 'd', 'u'\n", argv[1][0]);
923 ret = sscanf(argv[2],
"%u", &positions);
926 " to print: '%s'\n", argv[2]);
931 feclearexcept(FE_ALL_EXCEPT);
933 if ((ret = fetestexcept(FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW))) {
934 av_log(ctx,
AV_LOG_ERROR,
"Conversion of floating-point result to int failed. Control register: 0x%08x. Conversion result: %d\n", ret, intval);
939 av_strlcatf(fmt_str,
sizeof(fmt_str),
"0%u", positions);
940 av_strlcatf(fmt_str,
sizeof(fmt_str),
"%c", argv[1][0]);
943 res, argv[0], fmt_str);
970 unsigned argc,
char **argv)
998 const char *text = *rtext;
999 char *argv[16] = {
NULL };
1000 unsigned argc = 0, i;
1025 if ((ret =
eval_function(ctx, bp, argv[0], argc - 1, argv + 1)) < 0)
1028 *rtext = (
char *)text + 1;
1031 for (i = 0; i < argc; i++)
1042 if (*text ==
'\\' && text[1]) {
1045 }
else if (*text ==
'%') {
1062 int x,
int y,
int borderw)
1068 Glyph *glyph =
NULL;
1070 for (i = 0, p = text; *p; i++) {
1072 Glyph
dummy = { 0 };
1076 if (code ==
'\n' || code ==
'\r' || code ==
'\t')
1082 bitmap = borderw ? glyph->border_bitmap : glyph->bitmap;
1084 if (glyph->bitmap.pixel_mode != FT_PIXEL_MODE_MONO &&
1085 glyph->bitmap.pixel_mode != FT_PIXEL_MODE_GRAY)
1093 bitmap.buffer, bitmap.pitch,
1094 bitmap.width, bitmap.rows,
1095 bitmap.pixel_mode == FT_PIXEL_MODE_MONO ? 0 : 3,
1119 else if (alpha <= 0)
1131 uint32_t code = 0, prev_code = 0;
1132 int x = 0,
y = 0, i = 0,
ret;
1133 int max_text_line_w = 0,
len;
1137 int y_min = 32000, y_max = -32000;
1138 int x_min = 32000, x_max = -32000;
1140 Glyph *glyph =
NULL, *prev_glyph =
NULL;
1141 Glyph
dummy = { 0 };
1143 time_t now = time(0);
1206 for (i = 0, p = text; *p; i++) {
1216 y_min =
FFMIN(glyph->bbox.yMin, y_min);
1217 y_max =
FFMAX(glyph->bbox.yMax, y_max);
1218 x_min =
FFMIN(glyph->bbox.xMin, x_min);
1219 x_max =
FFMAX(glyph->bbox.xMax, x_max);
1226 for (i = 0, p = text; *p; i++) {
1230 if (prev_code ==
'\r' && code ==
'\n')
1236 max_text_line_w =
FFMAX(max_text_line_w, x);
1248 if (s->
use_kerning && prev_glyph && glyph->code) {
1249 FT_Get_Kerning(s->
face, prev_glyph->code, glyph->code,
1250 ft_kerning_default, &delta);
1255 s->
positions[i].x = x + glyph->bitmap_left;
1256 s->
positions[i].y =
y - glyph->bitmap_top + y_max;
1258 else x += glyph->advance;
1261 max_text_line_w =
FFMAX(x, max_text_line_w);
1283 box_w =
FFMIN(width - 1 , max_text_line_w);
1301 &bordercolor, 0, 0, s->
borderw)) < 0)
1305 &fontcolor, 0, 0, 0)) < 0)
1323 #if CONFIG_LIBFRIBIDI
1324 if (s->text_shaping)
1325 if ((ret = shape_text(ctx)) < 0) {
1355 .needs_writable = 1,
1370 .description =
NULL_IF_CONFIG_SMALL(
"Draw text on top of video frames using libfreetype library."),
1372 .priv_class = &drawtext_class,
1376 .
inputs = avfilter_vf_drawtext_inputs,
1377 .
outputs = avfilter_vf_drawtext_outputs,
void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, uint8_t *mask, int mask_linesize, int mask_w, int mask_h, int l2depth, unsigned endianness, int x0, int y0)
Blend an alpha mask with an uniform color.
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
static int func_frame_num(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
char * y_expr
expression for y position
void av_bprintf(AVBPrint *buf, const char *fmt,...)
#define GET_UTF8(val, GET_BYTE, ERROR)
Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form.
int tc24hmax
1 if timecode is wrapped to 24 hours, 0 otherwise
This structure describes decoded (raw) audio or video data.
uint8_t * fontcolor_expr
fontcolor expression to evaluate
int x
x position to start drawing text
static double drand(void *opaque, double min, double max)
static int func_metadata(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
static const AVOption drawtext_options[]
unsigned int fontsize
font size to use
FFDrawColor boxcolor
background color
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
char * x_expr
expression for x position
Main libavfilter public API header.
uint8_t * fontfile
font to be used
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
int h
agreed upon image height
static const struct drawtext_function functions[]
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
static int draw_text(AVFilterContext *ctx, AVFrame *frame, int width, int height)
uint8_t * text
text to be drawn
#define FF_ARRAY_ELEMS(a)
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
char * tc_opt_string
specified timecode option string
static int draw_glyphs(DrawTextContext *s, AVFrame *frame, int width, int height, FFDrawColor *color, int x, int y, int borderw)
int(* func)(AVFilterContext *, AVBPrint *, char *, unsigned, char **, int)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
int boxborderw
box border width
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
struct AVTreeNode * av_tree_node_alloc(void)
Allocate an AVTreeNode.
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
Parse timecode representation (hh:mm:ss[:;.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
FT_Stroker stroker
freetype stroker handle
static int glyph_enu_free(void *opaque, void *elem)
void * av_tree_find(const AVTreeNode *t, void *key, int(*cmp)(void *key, const void *b), void *next[2])
static int func_pict_type(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
static void drawtext(AVFrame *pic, int x, int y, int ftid, const uint8_t *color, const char *fmt,...)
static av_always_inline av_const int isnan(float x)
static av_cold int end(AVCodecContext *avctx)
FT_Face face
freetype font face handle
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static av_cold int init(AVFilterContext *ctx)
int start_number
starting frame number for n/frame_num var
static int load_font_file(AVFilterContext *ctx, const char *path, int index)
static double av_q2d(AVRational a)
Convert rational to double.
static const AVFilterPad avfilter_vf_drawtext_inputs[]
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
static av_cold void uninit(AVFilterContext *ctx)
FT_Vector * positions
positions for each element in the text
void av_tree_destroy(AVTreeNode *t)
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, void *log_ctx)
Put the RGBA values that correspond to color_string in rgba_color.
A filter pad used for either input or output.
A link between two filters.
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
void * av_tree_insert(AVTreeNode **tp, void *key, int(*cmp)(void *key, const void *b), AVTreeNode **next)
Insert or remove an element.
static double alpha(void *priv, double x, double y)
double var_values[VAR_VARS_NB]
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
AVBPrint expanded_text
used to contain the expanded text
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, int log_offset, void *log_ctx)
Read the file with name filename, and put its content in a newly allocated buffer or map it with mmap...
#define AV_BPRINT_SIZE_UNLIMITED
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVExpr * y_pexpr
parsed expressions for x and y
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int y
y position to start drawing text
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
static int expand_function(AVFilterContext *ctx, AVBPrint *bp, char **rtext)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
static av_always_inline av_const double round(double x)
FFDrawColor fontcolor
foreground color
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
static const char *const fun2_names[]
static struct tm * gmtime_r(const time_t *clock, struct tm *result)
int reload
reload text file for each frame
AVBPrint expanded_fontcolor
used to contain the expanded fontcolor spec
int w
agreed upon image width
static const struct ft_error ft_errors[]
enum AVPictureType pict_type
Picture type of the frame.
#define AV_TIME_BASE
Internal time base represented as integer.
static struct tm * localtime_r(const time_t *clock, struct tm *result)
int64_t basetime
base pts time in the real world for display
int max_glyph_h
max glyph height
AVRational tc_rate
frame rate for timecode
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
static int process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
static int func_eval_expr(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
double(* eval_func2)(void *, double a, double b)
int format
agreed upon media format
AVTimecode tc
timecode context
static void update_color_with_alpha(DrawTextContext *s, FFDrawColor *color, const FFDrawColor incolor)
#define AV_LOG_INFO
Standard information.
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
char * av_strdup(const char *s)
Duplicate the string s.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int load_font(AVFilterContext *ctx)
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
timecode wraps after 24 hours
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
BYTE int const BYTE int int int height
AVDictionary * av_frame_get_metadata(const AVFrame *frame)
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
static int func_strftime(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
rational number numerator/denominator
void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, int x0, int y0, int w, int h)
Blend a rectangle with an uniform color.
struct AVTreeNode * glyphs
rendered glyphs, stored using the UTF-32 char code
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static int is_newline(uint32_t c)
const char * name
Filter name.
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
Init a draw context.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
static int expand_text(AVFilterContext *ctx, char *text, AVBPrint *bp)
AVFilterLink ** outputs
array of pointers to output links
int tag
opaque argument to func
short int draw_box
draw box around text - true or false
static int config_input(AVFilterLink *inlink)
static int64_t pts
Global timestamp for the audio frames.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm)
Append a formatted date and time to a print buffer.
char * av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
Load timecode string in buf.
AVFILTER_DEFINE_CLASS(drawtext)
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
static void update_alpha(DrawTextContext *s)
static const char *const var_names[]
int use_kerning
font kerning is used - true/false
common internal and external API header
static int glyph_cmp(void *key, const void *b)
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
static int query_formats(AVFilterContext *ctx)
FT_Library library
freetype font library handle
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static const AVFilterPad avfilter_vf_drawtext_outputs[]
static av_always_inline int diff(const uint32_t a, const uint32_t b)
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
AVFilterContext * dst
dest filter
int reinit
tells if the filter is being reinited
FFDrawColor shadowcolor
shadow color
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
int max_glyph_w
max glyph width
static const eval_func2 fun2[]
static int func_pts(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
int fix_bounds
do we let it go out of frame bounds - t/f
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
#define av_malloc_array(a, b)
char * textfile
file with text to be drawn
static int load_glyph(AVFilterContext *ctx, Glyph **glyph_ptr, uint32_t code)
Load glyphs corresponding to the UTF-32 codepoint code.
static int load_textfile(AVFilterContext *ctx)
static int eval_function(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv)
int ft_load_flags
flags used for loading fonts, see FT_LOAD_*
int exp_mode
expansion mode to use for the text
uint32_t flags
flags such as drop frame, +24 hours support, ...
void av_tree_enumerate(AVTreeNode *t, void *opaque, int(*cmp)(void *opaque, void *elem), int(*enu)(void *opaque, void *elem))
Apply enu(opaque, &elem) to all the elements in the tree in a given range.
#define AVERROR_EXTERNAL
Generic error in an external library.
size_t nb_positions
number of elements of positions array
FFDrawColor bordercolor
border color
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t frame_count
Number of past frames sent through the link.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIMECODE_STR_SIZE
simple arithmetic expression evaluator
static int func_eval_expr_int_format(AVFilterContext *ctx, AVBPrint *bp, char *fct, unsigned argc, char **argv, int tag)
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.