diff options
author | Paul B Mahol <onemda@gmail.com> | 2016-03-08 22:04:57 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2016-03-08 22:04:57 +0100 |
commit | 209cff2d9ca1e76ca3a4b1033b9242d765d7650e (patch) | |
tree | 2244a48ffc73aada02a52aa5a2caaa96082dff69 /libavfilter | |
parent | 8ca2c872b650182958f733db8b1d99c061dd3bf9 (diff) | |
download | ffmpeg-209cff2d9ca1e76ca3a4b1033b9242d765d7650e.tar.gz |
avfilter/vf_waveform: make sure that x/y for text position is positive
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_waveform.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/libavfilter/vf_waveform.c b/libavfilter/vf_waveform.c index 3e14d509ee..99a0c25e3b 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; |