[FFmpeg-cvslog] avfilter/vf_waveform: make sure that x/y for text position is positive

Paul B Mahol git at videolan.org
Tue Mar 8 22:08:41 CET 2016


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Mar  8 22:04:57 2016 +0100| [209cff2d9ca1e76ca3a4b1033b9242d765d7650e] | committer: Paul B Mahol

avfilter/vf_waveform: make sure that x/y for text position is positive

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=209cff2d9ca1e76ca3a4b1033b9242d765d7650e
---

 libavfilter/vf_waveform.c |   26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_waveform.c b/libavfilter/vf_waveform.c
index 3e14d50..99a0c25 100644
--- a/libavfilter/vf_waveform.c
+++ b/libavfilter/vf_waveform.c
@@ -1369,9 +1369,12 @@ static void graticule_green_row(WaveformContext *s, AVFrame *out)
         }
 
         for (l = 0; l < FF_ARRAY_ELEMS(lines[0]) && (s->flags & 1); l++) {
-            const int x = offset + (s->mirror ? 255 - lines[c][l] : lines[c][l]) - 10;
+            int x = offset + (s->mirror ? 255 - lines[c][l] : lines[c][l]) - 10;
             char text[16];
 
+            if (x < 0)
+                x = 4;
+
             snprintf(text, sizeof(text), "%d", lines[c][l]);
             draw_vtext(out, x, 2, o1, o2, text, green_yuva_color);
         }
@@ -1403,9 +1406,12 @@ static void graticule16_green_row(WaveformContext *s, AVFrame *out)
         }
 
         for (l = 0; l < FF_ARRAY_ELEMS(lines[0]) && (s->flags & 1); l++) {
-            const int x = offset + (s->mirror ? s->size - 1 - lines[c][l] * mult : lines[c][l] * mult) - 10;
+            int x = offset + (s->mirror ? s->size - 1 - lines[c][l] * mult : lines[c][l] * mult) - 10;
             char text[16];
 
+            if (x < 0)
+                x = 4;
+
             snprintf(text, sizeof(text), "%d", lines[c][l] * mult);
             draw_vtext16(out, x, 2, mult, o1, o2, text, green_yuva_color);
         }
@@ -1436,12 +1442,14 @@ static void graticule_green_column(WaveformContext *s, AVFrame *out)
         }
 
         for (l = 0; l < FF_ARRAY_ELEMS(lines[0]) && (s->flags & 1); l++) {
-            const int y = offset + (s->mirror ? 255 - lines[c][l] : lines[c][l]) - 10;
+            int y = offset + (s->mirror ? 255 - lines[c][l] : lines[c][l]) - 10;
             char text[16];
 
+            if (y < 0)
+                y = 4;
+
             snprintf(text, sizeof(text), "%d", lines[c][l]);
-            draw_htext(out, 2, y,
-                       o1, o2, text, green_yuva_color);
+            draw_htext(out, 2, y, o1, o2, text, green_yuva_color);
         }
 
         offset += 256 * s->display;
@@ -1471,12 +1479,14 @@ static void graticule16_green_column(WaveformContext *s, AVFrame *out)
         }
 
         for (l = 0; l < FF_ARRAY_ELEMS(lines[0]) && (s->flags & 1); l++) {
-            const int y = offset + (s->mirror ? s->size - 1 - lines[c][l] * mult : lines[c][l] * mult) - 10;
+            int y = offset + (s->mirror ? s->size - 1 - lines[c][l] * mult : lines[c][l] * mult) - 10;
             char text[16];
 
+            if (y < 0)
+                y = 4;
+
             snprintf(text, sizeof(text), "%d", lines[c][l] * mult);
-            draw_htext16(out, 2, y,
-                         mult, o1, o2, text, green_yuva_color);
+            draw_htext16(out, 2, y, mult, o1, o2, text, green_yuva_color);
         }
 
         offset += s->size * s->display;



More information about the ffmpeg-cvslog mailing list