summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-08-04 22:42:44 +0200
committerPaul B Mahol <onemda@gmail.com>2021-08-04 22:42:44 +0200
commit82123e133db6d556f3366a1cbb4f0439d70539d4 (patch)
tree3092ddde8de9c7cdb64a1ad097912ca56db8f0e1 /libavfilter
parentb1388cd6c53a101425f33f427ac890d42d03e107 (diff)
avfilter/avf_showspectrum: add lreplace sliding mode
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/avf_showspectrum.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c
index b9391a6efb..c9cdccad11 100644
--- a/libavfilter/avf_showspectrum.c
+++ b/libavfilter/avf_showspectrum.c
@@ -49,7 +49,7 @@ enum DataMode { D_MAGNITUDE, D_PHASE, NB_DMODES };
enum FrequencyScale { F_LINEAR, F_LOG, NB_FSCALES };
enum DisplayScale { LINEAR, SQRT, CBRT, LOG, FOURTHRT, FIFTHRT, NB_SCALES };
enum ColorMode { CHANNEL, INTENSITY, RAINBOW, MORELAND, NEBULAE, FIRE, FIERY, FRUIT, COOL, MAGMA, GREEN, VIRIDIS, PLASMA, CIVIDIS, TERRAIN, NB_CLMODES };
-enum SlideMode { REPLACE, SCROLL, FULLFRAME, RSCROLL, NB_SLIDES };
+enum SlideMode { REPLACE, SCROLL, FULLFRAME, RSCROLL, LREPLACE, NB_SLIDES };
enum Orientation { VERTICAL, HORIZONTAL, NB_ORIENTATIONS };
typedef struct ShowSpectrumContext {
@@ -115,6 +115,7 @@ static const AVOption showspectrum_options[] = {
{ "scroll", "scroll from right to left", 0, AV_OPT_TYPE_CONST, {.i64=SCROLL}, 0, 0, FLAGS, "slide" },
{ "fullframe", "return full frames", 0, AV_OPT_TYPE_CONST, {.i64=FULLFRAME}, 0, 0, FLAGS, "slide" },
{ "rscroll", "scroll from left to right", 0, AV_OPT_TYPE_CONST, {.i64=RSCROLL}, 0, 0, FLAGS, "slide" },
+ { "lreplace", "replace from right to left", 0, AV_OPT_TYPE_CONST, {.i64=LREPLACE}, 0, 0, FLAGS, "slide" },
{ "mode", "set channel display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=COMBINED}, COMBINED, NB_MODES-1, FLAGS, "mode" },
{ "combined", "combined mode", 0, AV_OPT_TYPE_CONST, {.i64=COMBINED}, 0, 0, FLAGS, "mode" },
{ "separate", "separate mode", 0, AV_OPT_TYPE_CONST, {.i64=SEPARATE}, 0, 0, FLAGS, "mode" },
@@ -1187,6 +1188,13 @@ static int config_output(AVFilterLink *outlink)
(s->orientation == HORIZONTAL && s->xpos >= s->h))
s->xpos = 0;
+ if (s->sliding == LREPLACE) {
+ if (s->orientation == VERTICAL)
+ s->xpos = s->w - 1;
+ if (s->orientation == HORIZONTAL)
+ s->xpos = s->h - 1;
+ }
+
s->auto_frame_rate = av_make_q(inlink->sample_rate, s->hop_size);
if (s->orientation == VERTICAL && s->sliding == FULLFRAME)
s->auto_frame_rate = av_mul_q(s->auto_frame_rate, av_make_q(1, s->w));
@@ -1377,11 +1385,20 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples)
if (s->sliding != FULLFRAME || s->xpos == 0)
outpicref->pts = av_rescale_q(insamples->pts, inlink->time_base, outlink->time_base);
- s->xpos++;
- if (s->orientation == VERTICAL && s->xpos >= s->w)
- s->xpos = 0;
- if (s->orientation == HORIZONTAL && s->xpos >= s->h)
- s->xpos = 0;
+ if (s->sliding == LREPLACE) {
+ s->xpos--;
+ if (s->orientation == VERTICAL && s->xpos < 0)
+ s->xpos = s->w - 1;
+ if (s->orientation == HORIZONTAL && s->xpos < 0)
+ s->xpos = s->h - 1;
+ } else {
+ s->xpos++;
+ if (s->orientation == VERTICAL && s->xpos >= s->w)
+ s->xpos = 0;
+ if (s->orientation == HORIZONTAL && s->xpos >= s->h)
+ s->xpos = 0;
+ }
+
if (!s->single_pic && (s->sliding != FULLFRAME || s->xpos == 0)) {
if (s->old_pts < outpicref->pts) {
AVFrame *clone;