static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
{
- DrawTextContext *s = ctx->priv;
+ DrawTextContext *old = ctx->priv;
+ DrawTextContext *new = NULL;
+ int ret;
if (!strcmp(cmd, "reinit")) {
- int ret;
+ new = av_mallocz(sizeof(DrawTextContext));
+ if (!new)
+ return AVERROR(ENOMEM);
+
+ new->class = &drawtext_class;
+ ret = av_opt_copy(new, old);
+ if (ret < 0)
+ goto fail;
+
+ ctx->priv = new;
+ ret = av_set_options_string(ctx, arg, "=", ":");
+ if (ret < 0) {
+ ctx->priv = old;
+ goto fail;
+ }
+
+ ret = init(ctx);
+ if (ret < 0) {
+ uninit(ctx);
+ ctx->priv = old;
+ goto fail;
+ }
+
+ new->reinit = 1;
+
+ ctx->priv = old;
uninit(ctx);
- s->reinit = 1;
- if ((ret = av_set_options_string(ctx, arg, "=", ":")) < 0)
- return ret;
- if ((ret = init(ctx)) < 0)
- return ret;
+ av_freep(&old);
+
+ ctx->priv = new;
return config_input(ctx->inputs[0]);
- }
+ } else
+ return AVERROR(ENOSYS);
- return AVERROR(ENOSYS);
+fail:
+ av_log(ctx, AV_LOG_ERROR, "Failed to process command. Continuing with existing parameters.\n");
+ av_freep(&new);
+ return ret;
}
static int func_pict_type(AVFilterContext *ctx, AVBPrint *bp,
sign = '-';
ms = -ms;
}
+ if (argc >= 3) {
+ if (!strcmp(argv[2], "24HH")) {
+ ms %= 24 * 60 * 60 * 1000;
+ } else {
+ av_log(ctx, AV_LOG_ERROR, "Invalid argument '%s'\n", argv[2]);
+ return AVERROR(EINVAL);
+ }
+ }
av_bprintf(bp, "%c%02d:%02d:%02d.%03d", sign,
(int)(ms / (60 * 60 * 1000)),
(int)(ms / (60 * 1000)) % 60,
update_color_with_alpha(s, &bordercolor, s->bordercolor);
update_color_with_alpha(s, &boxcolor , s->boxcolor );
- box_w = FFMIN(width - 1 , max_text_line_w);
- box_h = FFMIN(height - 1, y + s->max_glyph_h);
+ box_w = max_text_line_w;
+ box_h = y + s->max_glyph_h;
if (s->fix_bounds) {