[FFmpeg-devel] vf_drawtext: add force_boxw_equl_textw option

Submitted by su.gao on Feb. 14, 2017, 7:02 a.m.

Details

Message ID 1ad965e0.8d0d.15a3b6e456d.Coremail.sugao_cn@163.com
State New
Headers show

Commit Message

su.gao Feb. 14, 2017, 7:02 a.m.
Add this option to force the  box width equl text width:

Comments

Steven Liu Feb. 14, 2017, 7:25 a.m.
2017-02-14 15:02 GMT+08:00 su.gao <sugao_cn@163.com>:

> Add this option to force the  box width equl text width:
>
> diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
> index 0b94725..5b16cfa 100644
> --- a/libavfilter/vf_drawtext.c
> +++ b/libavfilter/vf_drawtext.c
> @@ -164,6 +164,7 @@ typedef struct DrawTextContext {
>      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
> +    int force_boxw_equl_textw;                    ///< tab size
>
>      FFDrawContext dc;
>      FFDrawColor fontcolor;          ///< foreground color
> @@ -209,6 +210,7 @@ static const AVOption drawtext_options[]= {
>      {"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_BOOL,   {.i64=0},     0,        1       , FLAGS},
> +    {"force_boxw_equl_textw",       "force the  box width equl text
> width",     OFFSET(force_boxw_equl_textw),           AV_OPT_TYPE_BOOL,
>  {.i64=0},     0,        1       , FLAGS},
>      {"boxborderw",  "set box border width", OFFSET(boxborderw),
>  AV_OPT_TYPE_INT,    {.i64=0},     INT_MIN,  INT_MAX , FLAGS},
>      {"line_spacing",  "set line spacing in pixels",
> OFFSET(line_spacing),   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},
> @@ -1298,7 +1300,11 @@ static int draw_text(AVFilterContext *ctx, AVFrame
> *frame,
>      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);
> +    if(0==s->force_boxw_equl_textw){
> +        box_w = FFMIN(width - 1 , max_text_line_w);
> +    }else{
> +        box_w =   (int)s->var_values[VAR_TEXT_W];
> +    }
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
don't use git diff make patch please,
You can use git commit and git format-patch make patch and use git
send-email send patch to maillist.

please refer to : https://ffmpeg.org/developer.html#toc-Submitting-patches-1

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 0b94725..5b16cfa 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -164,6 +164,7 @@  typedef struct DrawTextContext {
     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
+    int force_boxw_equl_textw;                    ///< tab size
 
     FFDrawContext dc;
     FFDrawColor fontcolor;          ///< foreground color
@@ -209,6 +210,7 @@  static const AVOption drawtext_options[]= {
     {"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_BOOL,   {.i64=0},     0,        1       , FLAGS},
+    {"force_boxw_equl_textw",       "force the  box width equl text width",     OFFSET(force_boxw_equl_textw),           AV_OPT_TYPE_BOOL,   {.i64=0},     0,        1       , FLAGS},
     {"boxborderw",  "set box border width", OFFSET(boxborderw),         AV_OPT_TYPE_INT,    {.i64=0},     INT_MIN,  INT_MAX , FLAGS},
     {"line_spacing",  "set line spacing in pixels", OFFSET(line_spacing),   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},
@@ -1298,7 +1300,11 @@  static int draw_text(AVFilterContext *ctx, AVFrame *frame,
     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);
+    if(0==s->force_boxw_equl_textw){
+        box_w = FFMIN(width - 1 , max_text_line_w);
+    }else{
+        box_w =   (int)s->var_values[VAR_TEXT_W];
+    }