MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / init

Function init

libavfilter/vf_drawtext.c:969–1080  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

967};
968
969static av_cold int init(AVFilterContext *ctx)
970{
971 int err;
972 DrawTextContext *s = ctx->priv;
973
974 av_expr_free(s->fontsize_pexpr);
975 s->fontsize_pexpr = NULL;
976
977 s->fontsize = 0;
978 s->default_fontsize = 16;
979
980 if (!s->fontfile && !CONFIG_LIBFONTCONFIG) {
981 av_log(ctx, AV_LOG_ERROR, "No font filename provided\n");
982 return AVERROR(EINVAL);
983 }
984
985 if (s->textfile) {
986 if (s->text) {
987 av_log(ctx, AV_LOG_ERROR,
988 "Both text and text file provided. Please provide only one\n");
989 return AVERROR(EINVAL);
990 }
991 if ((err = ff_load_textfile(ctx, (const char *)s->textfile, &s->text, NULL)) < 0)
992 return err;
993 }
994
995 if (s->reload && !s->textfile)
996 av_log(ctx, AV_LOG_WARNING, "No file to reload\n");
997
998 if (s->tc_opt_string) {
999 int ret = av_timecode_init_from_string(&s->tc, s->tc_rate,
1000 s->tc_opt_string, ctx);
1001 if (ret < 0)
1002 return ret;
1003 if (s->tc24hmax)
1004 s->tc.flags |= AV_TIMECODE_FLAG_24HOURSMAX;
1005 if (!s->text)
1006 s->text = av_strdup("");
1007 }
1008
1009 if (s->text_source_string) {
1010 s->text_source = text_source_string_parse(s->text_source_string);
1011 if ((int)s->text_source < 0) {
1012 av_log(ctx, AV_LOG_ERROR, "Error text source: %s\n", s->text_source_string);
1013 return AVERROR(EINVAL);
1014 }
1015 }
1016
1017 if (s->text_source == AV_FRAME_DATA_DETECTION_BBOXES) {
1018 if (s->text) {
1019 av_log(ctx, AV_LOG_WARNING, "Multiple texts provided, will use text_source only\n");
1020 av_free(s->text);
1021 }
1022 s->text = av_mallocz((AV_DETECTION_BBOX_LABEL_NAME_MAX_SIZE + 1) *
1023 (AV_NUM_DETECTION_BBOX_CLASSIFY + 1));
1024 if (!s->text)
1025 return AVERROR(ENOMEM);
1026 }

Callers 1

commandFunction · 0.70

Calls 13

av_expr_freeFunction · 0.85
av_logFunction · 0.85
ff_load_textfileFunction · 0.85
av_strdupFunction · 0.85
text_source_string_parseFunction · 0.85
shape_textFunction · 0.85
load_fontFunction · 0.85
update_fontsizeFunction · 0.85
load_glyphFunction · 0.85
av_bprint_initFunction · 0.85
av_freeFunction · 0.50

Tested by

no test coverage detected