+static int load_textfile(AVFilterContext *ctx)
+{
+ DrawTextContext *dtext = ctx->priv;
+ int err;
+ uint8_t *textbuf;
+ size_t textbuf_size;
+
+ if ((err = av_file_map(dtext->textfile, &textbuf, &textbuf_size, 0, ctx)) < 0) {
+ av_log(ctx, AV_LOG_ERROR,
+ "The text file '%s' could not be read or is empty\n",
+ dtext->textfile);
+ return err;
+ }
+
+ if (!(dtext->text = av_realloc(dtext->text, textbuf_size + 1)))
+ return AVERROR(ENOMEM);
+ memcpy(dtext->text, textbuf, textbuf_size);
+ dtext->text[textbuf_size] = 0;
+ av_file_unmap(textbuf, textbuf_size);
+
+ return 0;
+}
+