[FFmpeg-devel] [PATCH 2/2] new option for drawtext (boxborderw = set box border width)

Liviu Oniciuc klmno.dev at gmx.com
Tue Feb 3 18:01:30 CET 2015


at this time the drawtext box extends only for the width and height
of the text. for a better visual appearance a new option was added
(boxboderw) to set how much the box should extend outside of the
text area

Signed-off-by: Liviu Oniciuc <klmno.dev at gmx.com>
---
 libavfilter/vf_drawtext.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 libavfilter/vf_drawtext.c

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
old mode 100644
new mode 100755
index d20f805..138a32c
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -159,6 +159,7 @@ typedef struct DrawTextContext {
     unsigned int fontsize;          ///< font size to use
 
     short int draw_box;             ///< draw box around text - true or false
+    int boxborderw;                 ///< box border width
     int use_kerning;                ///< font kerning is used - true/false
     int tabsize;                    ///< tab size
     int fix_bounds;                 ///< do we let it go out of frame bounds - t/f
@@ -201,6 +202,7 @@ static const AVOption drawtext_options[]= {
     {"fontcolor",   "set foreground color", OFFSET(fontcolor.rgba),     AV_OPT_TYPE_COLOR,  {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS},
     {"fontcolor_expr", "set foreground color expression", OFFSET(fontcolor_expr), AV_OPT_TYPE_STRING, {.str=""}, CHAR_MIN, CHAR_MAX, FLAGS},
     {"boxcolor",    "set box color",        OFFSET(boxcolor.rgba),      AV_OPT_TYPE_COLOR,  {.str="white"}, CHAR_MIN, CHAR_MAX, FLAGS},
+    {"boxborderw",  "set box border width", OFFSET(boxborderw),         AV_OPT_TYPE_INT,    {.i64=0},     0,        INT_MAX , FLAGS},
     {"bordercolor", "set border color",     OFFSET(bordercolor.rgba),   AV_OPT_TYPE_COLOR,  {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS},
     {"shadowcolor", "set shadow color",     OFFSET(shadowcolor.rgba),   AV_OPT_TYPE_COLOR,  {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS},
     {"box",         "set box",              OFFSET(draw_box),           AV_OPT_TYPE_INT,    {.i64=0},     0,        1       , FLAGS},
@@ -1245,7 +1247,9 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame,
     if (s->draw_box)
         ff_blend_rectangle(&s->dc, &s->boxcolor,
                            frame->data, frame->linesize, width, height,
-                           s->x, s->y, box_w, box_h);
+                           s->x - s->boxborderw, s->y - s->boxborderw,
+                           box_w + s->boxborderw + s->boxborderw,
+                           box_h + s->boxborderw + s->boxborderw);
 
     if (s->shadowx || s->shadowy) {
         if ((ret = draw_glyphs(s, frame, width, height,
-- 
1.9.1



More information about the ffmpeg-devel mailing list