| 967 | }; |
| 968 | |
| 969 | static 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 | } |
no test coverage detected