[FFmpeg-devel] [PATCH] lavfi/drawtext: replace "draw" option with generic timeline interface.

Clément Bœsch u at pkh.me
Wed Aug 21 00:46:04 CEST 2013


---
 Changelog                 |  1 +
 doc/filters.texi          | 12 +-----------
 libavfilter/version.h     |  2 +-
 libavfilter/vf_drawtext.c | 17 +++--------------
 4 files changed, 6 insertions(+), 26 deletions(-)

diff --git a/Changelog b/Changelog
index 4a6c60c..4337ba2 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,7 @@ version <next>
   data read from an input file
 - incomplete Voxware MetaSound decoder
 - read EXIF metadata from JPEG
+- drawtext filter now uses the generic timeline interface
 
 
 version 2.0:
diff --git a/doc/filters.texi b/doc/filters.texi
index 0dc9288..8042275 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3239,16 +3239,6 @@ Either a string (e.g. "yellow") or in 0xRRGGBB[AA] format
 (e.g. "0xff00ff"), possibly followed by an alpha specifier.
 The default value of @var{boxcolor} is "white".
 
- at item draw
-Set an expression which specifies if the text should be drawn. If the
-expression evaluates to 0, the text is not drawn. This is useful for
-specifying that the text should be drawn only when specific conditions
-are met.
-
-Default value is "1".
-
-See below for the list of accepted constants and functions.
-
 @item expansion
 Select how the @var{text} is expanded. Can be either @code{none},
 @code{strftime} (deprecated) or
@@ -3548,7 +3538,7 @@ drawtext="fontsize=60:fontfile=FreeSerif.ttf:fontcolor=green:text=g:x=(w-max_gly
 @item
 Show text for 1 second every 3 seconds:
 @example
-drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:draw=lt(mod(t\,3)\,1):text='blink'"
+drawtext="fontfile=FreeSerif.ttf:fontcolor=white:x=100:y=x/dar:enable=lt(mod(t\,3)\,1):text='blink'"
 @end example
 
 @item
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 190ea2f..4d501b0 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR  3
 #define LIBAVFILTER_VERSION_MINOR  82
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 69124a9..5eeb502 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -155,9 +155,6 @@ typedef struct {
     AVExpr *x_pexpr, *y_pexpr;      ///< parsed expressions for x and y
     int64_t basetime;               ///< base pts time in the real world for display
     double var_values[VAR_VARS_NB];
-    char   *draw_expr;              ///< expression for draw
-    AVExpr *draw_pexpr;             ///< parsed expression for draw
-    int draw;                       ///< set to zero to prevent drawing
     AVLFG  prng;                    ///< random
     char       *tc_opt_string;      ///< specified timecode option string
     AVRational  tc_rate;            ///< frame rate for timecode
@@ -186,7 +183,6 @@ static const AVOption drawtext_options[]= {
     {"shadowy",     "set y",                OFFSET(shadowy),            AV_OPT_TYPE_INT,    {.i64=0},     INT_MIN,  INT_MAX , FLAGS},
     {"tabsize",     "set tab size",         OFFSET(tabsize),            AV_OPT_TYPE_INT,    {.i64=4},     0,        INT_MAX , FLAGS},
     {"basetime",    "set base time",        OFFSET(basetime),           AV_OPT_TYPE_INT64,  {.i64=AV_NOPTS_VALUE}, INT64_MIN, INT64_MAX , FLAGS},
-    {"draw",        "if false do not draw", OFFSET(draw_expr),          AV_OPT_TYPE_STRING, {.str="1"},   CHAR_MIN, CHAR_MAX, FLAGS},
 
     {"expansion", "set the expansion mode", OFFSET(exp_mode), AV_OPT_TYPE_INT, {.i64=EXP_NORMAL}, 0, 2, FLAGS, "expansion"},
         {"none",     "set no expansion",                    OFFSET(exp_mode), AV_OPT_TYPE_CONST, {.i64=EXP_NONE},     0, 0, FLAGS, "expansion"},
@@ -518,8 +514,6 @@ static av_cold void uninit(AVFilterContext *ctx)
 
     av_expr_free(s->x_pexpr);
     av_expr_free(s->y_pexpr);
-    av_expr_free(s->draw_pexpr);
-    s->x_pexpr = s->y_pexpr = s->draw_pexpr = NULL;
     av_freep(&s->positions);
     s->nb_positions = 0;
 
@@ -564,13 +558,11 @@ static int config_input(AVFilterLink *inlink)
 
     av_expr_free(s->x_pexpr);
     av_expr_free(s->y_pexpr);
-    av_expr_free(s->draw_pexpr);
-    s->x_pexpr = s->y_pexpr = s->draw_pexpr = NULL;
+    s->x_pexpr = s->y_pexpr = NULL;
+
     if ((ret = av_expr_parse(&s->x_pexpr, s->x_expr, var_names,
                              NULL, NULL, fun2_names, fun2, 0, ctx)) < 0 ||
         (ret = av_expr_parse(&s->y_pexpr, s->y_expr, var_names,
-                             NULL, NULL, fun2_names, fun2, 0, ctx)) < 0 ||
-        (ret = av_expr_parse(&s->draw_pexpr, s->draw_expr, var_names,
                              NULL, NULL, fun2_names, fun2, 0, ctx)) < 0)
 
         return AVERROR(EINVAL);
@@ -955,10 +947,6 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame,
     s->x = s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, &s->prng);
     s->y = s->var_values[VAR_Y] = av_expr_eval(s->y_pexpr, s->var_values, &s->prng);
     s->x = s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, &s->prng);
-    s->draw = av_expr_eval(s->draw_pexpr, s->var_values, &s->prng);
-
-    if(!s->draw)
-        return 0;
 
     box_w = FFMIN(width - 1 , max_text_line_w);
     box_h = FFMIN(height - 1, y + s->max_glyph_h);
@@ -1042,4 +1030,5 @@ AVFilter avfilter_vf_drawtext = {
     .inputs    = avfilter_vf_drawtext_inputs,
     .outputs   = avfilter_vf_drawtext_outputs,
     .process_command = command,
+    .flags           = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
-- 
1.8.3.4



More information about the ffmpeg-devel mailing list