[FFmpeg-devel] [PATCH] vf_drawtext: use more explicit variable names in draw_text()

Stefano Sabatini stefasab at gmail.com
Tue Sep 20 20:30:25 CEST 2011


In particular, rename:
str_w       -> max_text_line_w
text_height -> max_text_line_h
---
 libavfilter/vf_drawtext.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index b16494a..f480925 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -561,10 +561,10 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
     DrawTextContext *dtext = ctx->priv;
     uint32_t code = 0, prev_code = 0;
     int x = 0, y = 0, i = 0, ret;
-    int text_height, baseline;
+    int max_text_line_h, baseline;
+    int max_text_line_w = 0, len;
     char *text = dtext->text;
     uint8_t *p;
-    int str_w = 0, len;
     int y_min = 32000, y_max = -32000;
     FT_Vector delta;
     Glyph *glyph = NULL, *prev_glyph = NULL;
@@ -624,7 +624,7 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
         y_min = FFMIN(glyph->bbox.yMin, y_min);
         y_max = FFMAX(glyph->bbox.yMax, y_max);
     }
-    text_height = y_max - y_min;
+    max_text_line_h = y_max - y_min;
     baseline    = y_max;
 
     /* compute and save position for each glyph */
@@ -638,8 +638,8 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
 
         prev_code = code;
         if (is_newline(code)) {
-            str_w = FFMAX(str_w, x - dtext->x);
-            y += text_height;
+            max_text_line_w = FFMAX(max_text_line_w, x - dtext->x);
+            y += max_text_line_h;
             x = dtext->x;
             continue;
         }
@@ -657,8 +657,8 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
         }
 
         if (x + glyph->bbox.xMax >= width) {
-            str_w = FFMAX(str_w, x - dtext->x);
-            y += text_height;
+            max_text_line_w = FFMAX(max_text_line_w, x - dtext->x);
+            y += max_text_line_h;
             x = dtext->x;
         }
 
@@ -669,12 +669,12 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
         else              x += glyph->advance;
     }
 
-    str_w = FFMIN(width - dtext->x - 1, str_w);
-    y     = FFMIN(y + text_height, height - 1);
+    max_text_line_w = FFMIN(width - dtext->x - 1, max_text_line_w);
+    y               = FFMIN(y + max_text_line_h, height - 1);
 
     /* draw box */
     if (dtext->draw_box)
-        drawbox(picref, dtext->x, dtext->y, str_w, y-dtext->y,
+        drawbox(picref, dtext->x, dtext->y, max_text_line_w, y-dtext->y,
                 dtext->box_line, dtext->pixel_step, dtext->boxcolor,
                 dtext->hsub, dtext->vsub, dtext->is_packed_rgb, dtext->rgba_map);
 
-- 
1.7.2.5



More information about the ffmpeg-devel mailing list