summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-11-30 19:55:17 +0100
committerPaul B Mahol <onemda@gmail.com>2022-11-30 20:08:18 +0100
commit569b1a24cd8f06683396d1fbef236b22b1592138 (patch)
tree533c1a76cab54a65e5b3007437f20f5d017e2a4c
parent7d20635aeb4e6dc51549424d1999e44c86b38e11 (diff)
avfilter/avf_showcwt: add yet another mode variant
-rw-r--r--doc/filters.texi2
-rw-r--r--libavfilter/avf_showcwt.c26
2 files changed, 27 insertions, 1 deletions
diff --git a/doc/filters.texi b/doc/filters.texi
index d64ce1734b..4ed6d50750 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -29343,6 +29343,8 @@ Show combination of magnitude and phase.
Magnitude is mapped to brightness and phase to color.
@item channel
Show unique color per channel magnitude.
+@item stereo
+Show unique color per stereo difference.
@end table
Default value is @code{magnitude}.
diff --git a/libavfilter/avf_showcwt.c b/libavfilter/avf_showcwt.c
index 5e09ee5d04..b5a4ed0554 100644
--- a/libavfilter/avf_showcwt.c
+++ b/libavfilter/avf_showcwt.c
@@ -132,11 +132,12 @@ static const AVOption showcwt_options[] = {
{ "logb", "set logarithmic basis", OFFSET(logarithmic_basis), AV_OPT_TYPE_FLOAT, {.dbl = 0.0001}, 0, 1, FLAGS },
{ "deviation", "set frequency deviation", OFFSET(deviation), AV_OPT_TYPE_FLOAT, {.dbl = 1.}, 0, 10, FLAGS },
{ "pps", "set pixels per second", OFFSET(pps), AV_OPT_TYPE_INT, {.i64 = 64}, 1, 1024, FLAGS },
- { "mode", "set output mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS, "mode" },
+ { "mode", "set output mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 4, FLAGS, "mode" },
{ "magnitude", "magnitude", 0, AV_OPT_TYPE_CONST,{.i64=0}, 0, 0, FLAGS, "mode" },
{ "phase", "phase", 0, AV_OPT_TYPE_CONST,{.i64=1}, 0, 0, FLAGS, "mode" },
{ "magphase", "magnitude+phase", 0, AV_OPT_TYPE_CONST,{.i64=2}, 0, 0, FLAGS, "mode" },
{ "channel", "color per channel", 0, AV_OPT_TYPE_CONST,{.i64=3}, 0, 0, FLAGS, "mode" },
+ { "stereo", "stereo difference", 0, AV_OPT_TYPE_CONST,{.i64=4}, 0, 0, FLAGS, "mode" },
{ "slide", "set slide mode", OFFSET(slide), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_SLIDE-1, FLAGS, "slide" },
{ "replace", "replace", 0, AV_OPT_TYPE_CONST,{.i64=SLIDE_REPLACE},0, 0, FLAGS, "slide" },
{ "scroll", "scroll", 0, AV_OPT_TYPE_CONST,{.i64=SLIDE_SCROLL}, 0, 0, FLAGS, "slide" },
@@ -360,6 +361,29 @@ static int draw(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
}
switch (mode) {
+ case 4:
+ {
+ const AVComplexFloat *src2 = ((const AVComplexFloat *)s->ch_out->extended_data[FFMAX(1, s->nb_channels - 1)]) +
+ y * ihop_size + ihop_index;
+ float z, u, v;
+
+ z = hypotf(src[0].re + src2[0].re, src[0].im + src2[0].im);
+ u = hypotf(src[0].re, src[0].im);
+ v = hypotf(src2[0].re, src2[0].im);
+
+ z = remap_log(z, log_factor);
+ u = remap_log(u, log_factor);
+ v = remap_log(v, log_factor);
+
+ Y = z;
+ U = 0.5f + z * sinf((v - u) * M_PI_2);
+ V = 0.5f + z * sinf((u - v) * M_PI_2);
+
+ dstY[0] = av_clip_uint8(lrintf(Y * 255.f));
+ dstU[0] = av_clip_uint8(lrintf(U * 255.f));
+ dstV[0] = av_clip_uint8(lrintf(V * 255.f));
+ }
+ break;
case 3:
{
const int nb_channels = s->nb_channels;