Commit 4b0e1124 authored by Paul B Mahol's avatar Paul B Mahol

avfilter/avf_avectorscope: add polar mode

parent f3fbe790
...@@ -11713,6 +11713,9 @@ Lissajous rotated by 45 degrees. ...@@ -11713,6 +11713,9 @@ Lissajous rotated by 45 degrees.
@item lissajous_xy @item lissajous_xy
Same as above but not rotated. Same as above but not rotated.
@item polar
Shape resembling half of circle.
@end table @end table
Default value is @samp{lissajous}. Default value is @samp{lissajous}.
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
enum VectorScopeMode { enum VectorScopeMode {
LISSAJOUS, LISSAJOUS,
LISSAJOUS_XY, LISSAJOUS_XY,
POLAR,
MODE_NB, MODE_NB,
}; };
...@@ -59,6 +60,7 @@ static const AVOption avectorscope_options[] = { ...@@ -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" }, { "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", "", 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" }, { "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 }, { "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 }, { "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 }, { "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) ...@@ -210,9 +212,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
if (s->mode == LISSAJOUS) { if (s->mode == LISSAJOUS) {
x = ((src[1] - src[0]) * zoom / (float)(UINT16_MAX) + 1) * hw; x = ((src[1] - src[0]) * zoom / (float)(UINT16_MAX) + 1) * hw;
y = (1.0 - (src[0] + src[1]) * zoom / (float)UINT16_MAX) * hh; 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; x = (src[1] * zoom / (float)INT16_MAX + 1) * hw;
y = (src[0] * zoom / (float)INT16_MAX + 1) * hh; 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); draw_dot(s, x, y);
...@@ -225,9 +236,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) ...@@ -225,9 +236,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
if (s->mode == LISSAJOUS) { if (s->mode == LISSAJOUS) {
x = ((src[1] - src[0]) * zoom / 2 + 1) * hw; x = ((src[1] - src[0]) * zoom / 2 + 1) * hw;
y = (1.0 - (src[0] + src[1]) * zoom / 2) * hh; y = (1.0 - (src[0] + src[1]) * zoom / 2) * hh;
} else { } else if (s->mode == LISSAJOUS_XY){
x = (src[1] * zoom + 1) * hw; x = (src[1] * zoom + 1) * hw;
y = (src[0] * zoom + 1) * hh; 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); draw_dot(s, x, y);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment