vf_drawtext: add support for setting box border width

Signed-off-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Marton Balint 2015-03-31 00:52:47 +02:00 committed by Michael Niedermayer
parent 919d13d238
commit c84b75c89c
2 changed files with 8 additions and 1 deletions

View File

@ -3955,6 +3955,10 @@ Used to draw a box around text using the background color.
The value must be either 1 (enable) or 0 (disable). The value must be either 1 (enable) or 0 (disable).
The default value of @var{box} is 0. The default value of @var{box} is 0.
@item boxborderw
Set the width of the border to be drawn around the box using @var{boxcolor}.
The default value of @var{boxborderw} is 0.
@item boxcolor @item boxcolor
The color to be used for drawing box around text. For the syntax of this The color to be used for drawing box around text. For the syntax of this
option, check the "Color" section in the ffmpeg-utils manual. option, check the "Color" section in the ffmpeg-utils manual.

View File

@ -159,6 +159,7 @@ typedef struct DrawTextContext {
unsigned int fontsize; ///< font size to use unsigned int fontsize; ///< font size to use
short int draw_box; ///< draw box around text - true or false 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 use_kerning; ///< font kerning is used - true/false
int tabsize; ///< tab size int tabsize; ///< tab size
int fix_bounds; ///< do we let it go out of frame bounds - t/f int fix_bounds; ///< do we let it go out of frame bounds - t/f
@ -204,6 +205,7 @@ static const AVOption drawtext_options[]= {
{"bordercolor", "set border color", OFFSET(bordercolor.rgba), AV_OPT_TYPE_COLOR, {.str="black"}, CHAR_MIN, CHAR_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}, {"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}, {"box", "set box", OFFSET(draw_box), AV_OPT_TYPE_INT, {.i64=0}, 0, 1 , FLAGS},
{"boxborderw", "set box border width", OFFSET(boxborderw), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX , FLAGS},
{"fontsize", "set font size", OFFSET(fontsize), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX , FLAGS}, {"fontsize", "set font size", OFFSET(fontsize), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX , FLAGS},
{"x", "set x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX, FLAGS}, {"x", "set x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX, FLAGS},
{"y", "set y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX, FLAGS}, {"y", "set y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX, FLAGS},
@ -1245,7 +1247,8 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame,
if (s->draw_box) if (s->draw_box)
ff_blend_rectangle(&s->dc, &s->boxcolor, ff_blend_rectangle(&s->dc, &s->boxcolor,
frame->data, frame->linesize, width, height, 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 * 2, box_h + s->boxborderw * 2);
if (s->shadowx || s->shadowy) { if (s->shadowx || s->shadowy) {
if ((ret = draw_glyphs(s, frame, width, height, if ((ret = draw_glyphs(s, frame, width, height,