[FFmpeg-cvslog] avfilter/vf_waveform: make it possible to draw dots instead of lines

Paul B Mahol git at videolan.org
Tue Mar 8 23:16:04 CET 2016


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Mar  8 22:34:42 2016 +0100| [b3e0371818917364be0b2f4b24831b4ed987392f] | committer: Paul B Mahol

avfilter/vf_waveform: make it possible to draw dots instead of lines

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

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

 doc/filters.texi          |    3 +++
 libavfilter/vf_waveform.c |   37 +++++++++++++++++++++----------------
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 778d799..797c501 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -13185,6 +13185,9 @@ Set graticule flags.
 @table @samp
 @item numbers
 Draw numbers above lines. By default enabled.
+
+ at item dots
+Draw dots instead of lines.
 @end table
 @end table
 
diff --git a/libavfilter/vf_waveform.c b/libavfilter/vf_waveform.c
index 99a0c25..9a5f5e3 100644
--- a/libavfilter/vf_waveform.c
+++ b/libavfilter/vf_waveform.c
@@ -106,9 +106,10 @@ static const AVOption waveform_options[] = {
         { "green", NULL, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "graticule" },
     { "opacity", "set graticule opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, FLAGS },
     { "o",       "set graticule opacity", OFFSET(opacity), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, FLAGS },
-    { "flags", "set graticule flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=1}, 0, 1, FLAGS, "flags" },
-    { "fl",    "set graticule flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=1}, 0, 1, FLAGS, "flags" },
+    { "flags", "set graticule flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=1}, 0, 3, FLAGS, "flags" },
+    { "fl",    "set graticule flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64=1}, 0, 3, FLAGS, "flags" },
         { "numbers",  "draw numbers", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "flags" },
+        { "dots",     "draw dots instead of lines", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "flags" },
     { NULL }
 };
 
@@ -1201,42 +1202,42 @@ static const uint8_t green_yuva_color[4] = { 255, 0, 0, 255 };
 static const uint8_t black_gbrp_color[4] = { 0, 0, 0, 255 };
 static const uint8_t lines[4][2] = { { 16, 235 }, { 16, 240 }, { 16, 240 }, { 0, 255 } };
 
-static void blend_vline(uint8_t *dst, int height, int linesize, float o1, float o2, int v)
+static void blend_vline(uint8_t *dst, int height, int linesize, float o1, float o2, int v, int step)
 {
     int y;
 
-    for (y = 0; y < height; y++) {
+    for (y = 0; y < height; y += step) {
         dst[0] = v * o1 + dst[0] * o2;
 
-        dst += linesize;
+        dst += linesize * step;
     }
 }
 
-static void blend_vline16(uint16_t *dst, int height, int linesize, float o1, float o2, int v)
+static void blend_vline16(uint16_t *dst, int height, int linesize, float o1, float o2, int v, int step)
 {
     int y;
 
-    for (y = 0; y < height; y++) {
+    for (y = 0; y < height; y += step) {
         dst[0] = v * o1 + dst[0] * o2;
 
-        dst += linesize / 2;
+        dst += (linesize / 2) * step;
     }
 }
 
-static void blend_hline(uint8_t *dst, int width, float o1, float o2, int v)
+static void blend_hline(uint8_t *dst, int width, float o1, float o2, int v, int step)
 {
     int x;
 
-    for (x = 0; x < width; x++) {
+    for (x = 0; x < width; x += step) {
         dst[x] = v * o1 + dst[x] * o2;
     }
 }
 
-static void blend_hline16(uint16_t *dst, int width, float o1, float o2, int v)
+static void blend_hline16(uint16_t *dst, int width, float o1, float o2, int v, int step)
 {
     int x;
 
-    for (x = 0; x < width; x++) {
+    for (x = 0; x < width; x += step) {
         dst[x] = v * o1 + dst[x] * o2;
     }
 }
@@ -1349,6 +1350,7 @@ static void graticule_none(WaveformContext *s, AVFrame *out)
 
 static void graticule_green_row(WaveformContext *s, AVFrame *out)
 {
+    const int step = s->flags & 2 + 1;
     const float o1 = s->opacity;
     const float o2 = 1. - o1;
     int k = 0, c, p, l, offset = 0;
@@ -1364,7 +1366,7 @@ static void graticule_green_row(WaveformContext *s, AVFrame *out)
                 int x = offset + (s->mirror ? 255 - lines[c][l] : lines[c][l]);
                 uint8_t *dst = out->data[p] + x;
 
-                blend_vline(dst, out->height, out->linesize[p], o1, o2, v);
+                blend_vline(dst, out->height, out->linesize[p], o1, o2, v, step);
             }
         }
 
@@ -1385,6 +1387,7 @@ static void graticule_green_row(WaveformContext *s, AVFrame *out)
 
 static void graticule16_green_row(WaveformContext *s, AVFrame *out)
 {
+    const int step = s->flags & 2 + 1;
     const float o1 = s->opacity;
     const float o2 = 1. - o1;
     const int mult = s->size / 256;
@@ -1401,7 +1404,7 @@ static void graticule16_green_row(WaveformContext *s, AVFrame *out)
                 int x = offset + (s->mirror ? s->size - 1 - lines[c][l] * mult : lines[c][l] * mult);
                 uint16_t *dst = (uint16_t *)(out->data[p]) + x;
 
-                blend_vline16(dst, out->height, out->linesize[p], o1, o2, v);
+                blend_vline16(dst, out->height, out->linesize[p], o1, o2, v, step);
             }
         }
 
@@ -1422,6 +1425,7 @@ static void graticule16_green_row(WaveformContext *s, AVFrame *out)
 
 static void graticule_green_column(WaveformContext *s, AVFrame *out)
 {
+    const int step = s->flags & 2 + 1;
     const float o1 = s->opacity;
     const float o2 = 1. - o1;
     int k = 0, c, p, l, offset = 0;
@@ -1437,7 +1441,7 @@ static void graticule_green_column(WaveformContext *s, AVFrame *out)
                 int y = offset + (s->mirror ? 255 - lines[c][l] : lines[c][l]);
                 uint8_t *dst = out->data[p] + y * out->linesize[p];
 
-                blend_hline(dst, out->width, o1, o2, v);
+                blend_hline(dst, out->width, o1, o2, v, step);
             }
         }
 
@@ -1458,6 +1462,7 @@ static void graticule_green_column(WaveformContext *s, AVFrame *out)
 
 static void graticule16_green_column(WaveformContext *s, AVFrame *out)
 {
+    const int step = s->flags & 2 + 1;
     const float o1 = s->opacity;
     const float o2 = 1. - o1;
     const int mult = s->size / 256;
@@ -1474,7 +1479,7 @@ static void graticule16_green_column(WaveformContext *s, AVFrame *out)
                 int y = offset + (s->mirror ? s->size - 1 - lines[c][l] * mult : lines[c][l] * mult);
                 uint16_t *dst = (uint16_t *)(out->data[p] + y * out->linesize[p]);
 
-                blend_hline16(dst, out->width, o1, o2, v);
+                blend_hline16(dst, out->width, o1, o2, v, step);
             }
         }
 



More information about the ffmpeg-cvslog mailing list