#include "config.h"
#include "libavutil/avstring.h"
+#include "libavutil/common.h"
#include "libavutil/file.h"
#include "libavutil/eval.h"
#include "libavutil/opt.h"
return err;
}
-static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
+static av_cold int init(AVFilterContext *ctx, const char *args)
{
int err;
DrawTextContext *dtext = ctx->priv;
dtext->class = &drawtext_class;
av_opt_set_defaults(dtext);
- if ((err = av_set_options_string(dtext, args, "=", ":")) < 0) {
- av_log(ctx, AV_LOG_ERROR, "Error parsing options string: '%s'\n", args);
+ if ((err = av_set_options_string(dtext, args, "=", ":")) < 0)
return err;
- }
if (!dtext->fontfile && !CONFIG_FONTCONFIG) {
av_log(ctx, AV_LOG_ERROR, "No font filename provided\n");
av_expr_free(dtext->x_pexpr); dtext->x_pexpr = NULL;
av_expr_free(dtext->y_pexpr); dtext->y_pexpr = NULL;
av_expr_free(dtext->draw_pexpr); dtext->draw_pexpr = NULL;
-
- av_freep(&dtext->boxcolor_string);
- av_freep(&dtext->expanded_text);
- av_freep(&dtext->fontcolor_string);
- av_freep(&dtext->fontfile);
- av_freep(&dtext->shadowcolor_string);
- av_freep(&dtext->text);
- av_freep(&dtext->x_expr);
- av_freep(&dtext->y_expr);
- av_freep(&dtext->draw_expr);
+ av_opt_free(dtext);
av_freep(&dtext->positions);
dtext->nb_positions = 0;
int ret;
uninit(ctx);
dtext->reinit = 1;
- if ((ret = init(ctx, arg, NULL)) < 0)
+ if ((ret = init(ctx, arg)) < 0)
return ret;
return config_input(ctx->inputs[0]);
}
return 0;
}
-static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { }
+static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
+{
+ return 0;
+}
-static void end_frame(AVFilterLink *inlink)
+static int end_frame(AVFilterLink *inlink)
{
AVFilterContext *ctx = inlink->dst;
AVFilterLink *outlink = ctx->outputs[0];
DrawTextContext *dtext = ctx->priv;
AVFilterBufferRef *picref = inlink->cur_buf;
+ int ret;
dtext->var_values[VAR_T] = picref->pts == AV_NOPTS_VALUE ?
NAN : picref->pts * av_q2d(inlink->time_base);
dtext->var_values[VAR_N] += 1.0;
- ff_draw_slice(outlink, 0, picref->video->h, 1);
- ff_end_frame(outlink);
+ if ((ret = ff_draw_slice(outlink, 0, picref->video->h, 1)) < 0 ||
+ (ret = ff_end_frame(outlink)) < 0)
+ return ret;
+ return 0;
}
AVFilter avfilter_vf_drawtext = {
.uninit = uninit,
.query_formats = query_formats,
- .inputs = (const AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_VIDEO,
- .get_video_buffer = ff_null_get_video_buffer,
- .start_frame = ff_null_start_frame,
- .draw_slice = null_draw_slice,
- .end_frame = end_frame,
- .config_props = config_input,
- .min_perms = AV_PERM_WRITE |
- AV_PERM_READ,
- .rej_perms = AV_PERM_PRESERVE },
- { .name = NULL}},
- .outputs = (const AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_VIDEO, },
- { .name = NULL}},
+ .inputs = (const AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .get_video_buffer = ff_null_get_video_buffer,
+ .start_frame = ff_null_start_frame,
+ .draw_slice = null_draw_slice,
+ .end_frame = end_frame,
+ .config_props = config_input,
+ .min_perms = AV_PERM_WRITE |
+ AV_PERM_READ,
+ .rej_perms = AV_PERM_PRESERVE },
+ { .name = NULL}},
+ .outputs = (const AVFilterPad[]) {{ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO, },
+ { .name = NULL}},
.process_command = command,
};