[FFmpeg-cvslog] avfilter/avf_showspectrum: add color rotation feature
Paul B Mahol
git at videolan.org
Fri Aug 5 13:20:33 EEST 2016
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Aug 5 12:14:38 2016 +0200| [04a8bbca9289a4ee203f90bb8d48166bf53015e6] | committer: Paul B Mahol
avfilter/avf_showspectrum: add color rotation feature
Mostly useful with channel color scheme.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=04a8bbca9289a4ee203f90bb8d48166bf53015e6
---
doc/filters.texi | 8 ++++++++
libavfilter/avf_showspectrum.c | 15 +++++++++++----
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index e950c14..7e042e4 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16500,6 +16500,10 @@ Default value is @code{1}.
@item data
Set which data to display. Can be @code{magnitude}, default or @code{phase}.
+
+ at item rotation
+Set color rotation, must be in [-1.0, 1.0] range.
+Default value is @code{0}.
@end table
The usage is very similar to the showwaves filter; see the examples in that
@@ -16633,6 +16637,10 @@ Default value is @code{1}.
@item legend
Draw time and frequency axes and legends. Default is enabled.
+
+ at item rotation
+Set color rotation, must be in [-1.0, 1.0] range.
+Default value is @code{0}.
@end table
@subsection Examples
diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c
index 6be97af..648901f 100644
--- a/libavfilter/avf_showspectrum.c
+++ b/libavfilter/avf_showspectrum.c
@@ -61,6 +61,7 @@ typedef struct {
int color_mode; ///< display color scheme
int scale;
float saturation; ///< color saturation multiplier
+ float rotation; ///< color rotation
int data;
int xpos; ///< x position (current column)
FFTContext *fft; ///< Fast Fourier Transform context
@@ -140,6 +141,7 @@ static const AVOption showspectrum_options[] = {
{ "data", "set data mode", OFFSET(data), AV_OPT_TYPE_INT, {.i64 = 0}, 0, NB_DMODES-1, FLAGS, "data" },
{ "magnitude", NULL, 0, AV_OPT_TYPE_CONST, {.i64=D_MAGNITUDE}, 0, 0, FLAGS, "data" },
{ "phase", NULL, 0, AV_OPT_TYPE_CONST, {.i64=D_PHASE}, 0, 0, FLAGS, "data" },
+ { "rotation", "color rotation", OFFSET(rotation), AV_OPT_TYPE_FLOAT, {.dbl = 0}, -1, 1, FLAGS },
{ NULL }
};
@@ -542,13 +544,17 @@ static void color_range(ShowSpectrumContext *s, int ch,
if (s->color_mode == CHANNEL) {
if (s->nb_display_channels > 1) {
- *uf *= 0.5 * sin((2 * M_PI * ch) / s->nb_display_channels);
- *vf *= 0.5 * cos((2 * M_PI * ch) / s->nb_display_channels);
+ *uf *= 0.5 * sin((2 * M_PI * ch) / s->nb_display_channels + M_PI * s->rotation);
+ *vf *= 0.5 * cos((2 * M_PI * ch) / s->nb_display_channels + M_PI * s->rotation);
} else {
- *uf = 0.0f;
- *vf = 0.0f;
+ *uf *= 0.5 * sin(M_PI * s->rotation);
+ *vf *= 0.5 * cos(M_PI * s->rotation + M_PI_2);
}
+ } else {
+ *uf += *uf * sin(M_PI * s->rotation);
+ *vf += *vf * cos(M_PI * s->rotation + M_PI_2);
}
+
*uf *= s->saturation;
*vf *= s->saturation;
}
@@ -913,6 +919,7 @@ static const AVOption showspectrumpic_options[] = {
{ "horizontal", NULL, 0, AV_OPT_TYPE_CONST, {.i64=HORIZONTAL}, 0, 0, FLAGS, "orientation" },
{ "gain", "set scale gain", OFFSET(gain), AV_OPT_TYPE_FLOAT, {.dbl = 1}, 0, 128, FLAGS },
{ "legend", "draw legend", OFFSET(legend), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS },
+ { "rotation", "color rotation", OFFSET(rotation), AV_OPT_TYPE_FLOAT, {.dbl = 0}, -1, 1, FLAGS },
{ NULL }
};
More information about the ffmpeg-cvslog
mailing list