diff options
author | Paul B Mahol <onemda@gmail.com> | 2016-03-09 00:34:42 +0300 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2016-03-09 01:14:57 +0300 |
commit | b3e0371818917364be0b2f4b24831b4ed987392f (patch) | |
tree | 977efcafedf1f531a8069effe5ea111c83a90096 | |
parent | 209cff2d9ca1e76ca3a4b1033b9242d765d7650e (diff) |
avfilter/vf_waveform: make it possible to draw dots instead of lines
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | doc/filters.texi | 3 | ||||
-rw-r--r-- | libavfilter/vf_waveform.c | 37 |
2 files changed, 24 insertions, 16 deletions
diff --git a/doc/filters.texi b/doc/filters.texi index 778d799820..797c5010f5 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. + +@item dots +Draw dots instead of lines. @end table @end table diff --git a/libavfilter/vf_waveform.c b/libavfilter/vf_waveform.c index 99a0c25e3b..9a5f5e3f0e 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); } } |