diff mbox

[FFmpeg-devel] avfilter/drawtext: fix box sizing

Message ID ea491c3a-2c74-c429-e89f-330dfba8bbde@gmail.com
State Accepted
Commit 1a31c2b5df1179fdc1b8e84c8fa89d853e517309
Headers show

Commit Message

Gyan July 10, 2018, 10:01 a.m. UTC
Test command:

ffplay -f lavfi -i "color,\
drawtext=fontfile='arial.ttf':fontcolor=white:fontsize=H/5:\
text='A string of characters':\
box=1:boxcolor=green:boxborderw=5:\
x='w-w*t/5':y=-th+h*t/10"
From b98969d12b3f6959ab1a036f20ba649951bcd1ea Mon Sep 17 00:00:00 2001
From: Gyan Doshi <ffmpeg@gyani.pro>
Date: Tue, 10 Jul 2018 15:14:06 +0530
Subject: [PATCH] avfilter/drawtext: fix box sizing

At present, box size is clipped to frame size before being drawn,
which can lead to the box not fully covering animated text which is
longer than one or both frame dimensions.

Since ff_blend_rectangle correctly takes care of clipping, it is skipped
here which results in correct box sizing
---
 libavfilter/vf_drawtext.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Gyan July 13, 2018, 4:43 a.m. UTC | #1
On 10-07-2018 03:31 PM, Gyan Doshi wrote:
> Test command:
> 
> ffplay -f lavfi -i "color,\
> drawtext=fontfile='arial.ttf':fontcolor=white:fontsize=H/5:\
> text='A string of characters':\
> box=1:boxcolor=green:boxborderw=5:\
> x='w-w*t/5':y=-th+h*t/10"

Pushed as 1a31c2b5df1179fdc1b8e84c8fa89d853e517309
diff mbox

Patch

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 3affa736c7..cca2cbcb88 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -1407,8 +1407,8 @@  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);
-    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) {