diff options
author | Paul B Mahol <onemda@gmail.com> | 2015-08-14 17:24:56 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2015-08-14 17:27:56 +0200 |
commit | 4b0e11244287b3f886d117d01f87ef0c095796dc (patch) | |
tree | e03cc64a35476b88665c47b9f41d6577757a481b /libavfilter/avf_avectorscope.c | |
parent | f3fbe790d9d4e93b2ec8c7476572f2d155e8b43e (diff) | |
download | ffmpeg-4b0e11244287b3f886d117d01f87ef0c095796dc.tar.gz |
avfilter/avf_avectorscope: add polar mode
Diffstat (limited to 'libavfilter/avf_avectorscope.c')
-rw-r--r-- | libavfilter/avf_avectorscope.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/libavfilter/avf_avectorscope.c b/libavfilter/avf_avectorscope.c index 381752f070..bc9e2356bc 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); |