[FFmpeg-cvslog] avfilter/avf_avectorscope: add polar mode

Paul B Mahol git at videolan.org
Fri Aug 14 17:31:29 CEST 2015


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Aug 14 17:24:56 2015 +0200| [4b0e11244287b3f886d117d01f87ef0c095796dc] | committer: Paul B Mahol

avfilter/avf_avectorscope: add polar mode

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

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

diff --git a/doc/filters.texi b/doc/filters.texi
index e99a308..2dd7d22 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11713,6 +11713,9 @@ Lissajous rotated by 45 degrees.
 
 @item lissajous_xy
 Same as above but not rotated.
+
+ at item polar
+Shape resembling half of circle.
 @end table
 
 Default value is @samp{lissajous}.
diff --git a/libavfilter/avf_avectorscope.c b/libavfilter/avf_avectorscope.c
index 381752f..bc9e235 100644
--- a/libavfilter/avf_avectorscope.c
+++ b/libavfilter/avf_avectorscope.c
@@ -36,6 +36,7 @@
 enum VectorScopeMode {
     LISSAJOUS,
     LISSAJOUS_XY,
+    POLAR,
     MODE_NB,
 };
 
@@ -59,6 +60,7 @@ static const AVOption avectorscope_options[] = {
     { "m",    "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=LISSAJOUS}, 0, MODE_NB-1, FLAGS, "mode" },
     { "lissajous",    "", 0, AV_OPT_TYPE_CONST, {.i64=LISSAJOUS},    0, 0, FLAGS, "mode" },
     { "lissajous_xy", "", 0, AV_OPT_TYPE_CONST, {.i64=LISSAJOUS_XY}, 0, 0, FLAGS, "mode" },
+    { "polar",        "", 0, AV_OPT_TYPE_CONST, {.i64=POLAR},        0, 0, FLAGS, "mode" },
     { "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, 0, FLAGS },
     { "r",    "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, 0, FLAGS },
     { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str="400x400"}, 0, 0, FLAGS },
@@ -210,9 +212,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
             if (s->mode == LISSAJOUS) {
                 x = ((src[1] - src[0]) * zoom / (float)(UINT16_MAX) + 1) * hw;
                 y = (1.0 - (src[0] + src[1]) * zoom / (float)UINT16_MAX) * hh;
-            } else {
+            } else if (s->mode == LISSAJOUS_XY) {
                 x = (src[1] * zoom / (float)INT16_MAX + 1) * hw;
                 y = (src[0] * zoom / (float)INT16_MAX + 1) * hh;
+            } else {
+                float sx, sy, cx, cy;
+
+                sx = src[1] * zoom / (float)INT16_MAX;
+                sy = src[0] * zoom / (float)INT16_MAX;
+                cx = sx * sqrtf(1 - 0.5*sy*sy);
+                cy = sy * sqrtf(1 - 0.5*sx*sx);
+                x = hw + hw * FFSIGN(cx + cy) * (cx - cy) * .7;
+                y = s->h - s->h * FFABS(cx + cy) * .7;
             }
 
             draw_dot(s, x, y);
@@ -225,9 +236,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
             if (s->mode == LISSAJOUS) {
                 x = ((src[1] - src[0]) * zoom / 2 + 1) * hw;
                 y = (1.0 - (src[0] + src[1]) * zoom / 2) * hh;
-            } else {
+            } else if (s->mode == LISSAJOUS_XY){
                 x = (src[1] * zoom + 1) * hw;
                 y = (src[0] * zoom + 1) * hh;
+            } else {
+                float sx, sy, cx, cy;
+
+                sx = src[1] * zoom;
+                sy = src[0] * zoom;
+                cx = sx * sqrtf(1 - 0.5 * sy * sy);
+                cy = sy * sqrtf(1 - 0.5 * sx * sx);
+                x = hw + hw * FFSIGN(cx + cy) * (cx - cy) * .7;
+                y = s->h - s->h * FFABS(cx + cy) * .7;
             }
 
             draw_dot(s, x, y);



More information about the ffmpeg-cvslog mailing list