From 13d26716fb58ff705b9896bb80f26756245d2648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Sun, 21 Oct 2012 21:01:18 +0200 Subject: [PATCH] lavfi/showspectrum: add sliding mode. --- doc/filters.texi | 3 +++ libavfilter/avf_showspectrum.c | 17 +++++++++++++---- libavfilter/version.h | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 93fdcec39f..c4e29c30f1 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -4704,6 +4704,9 @@ The filter accepts the following named parameters: @table @option @item size, s Specify the video size for the output. Default value is @code{640x480}. +@item slide +Specify if the spectrum should slide along the window. Default value is +@code{0}. @end table The usage is very similar to the showwaves filter; see the examples in that diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 641c27f9bf..1600265415 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -37,6 +37,7 @@ typedef struct { int w, h; AVFilterBufferRef *outpicref; int req_fullfilled; + int sliding; ///< 1 if sliding mode, 0 otherwise int xpos; ///< x position (current column) RDFTContext *rdft; ///< Real Discrete Fourier Transform context int rdft_bits; ///< number of bits (RDFT window size = 1<h; y++) { // FIXME: bin[0] contains first and last bins - const int pos = showspectrum->xpos * 3 + (outlink->h - y - 1) * outpicref->linesize[0]; + uint8_t *p = outpicref->data[0] + (outlink->h - y - 1) * outpicref->linesize[0]; const double w = 1. / sqrt(nb_freq); int a = sqrt(w * MAGNITUDE(RE(0), IM(0))); int b = nb_display_channels > 1 ? sqrt(w * MAGNITUDE(RE(1), IM(1))) : a; + if (showspectrum->sliding) { + memmove(p, p + 3, (outlink->w - 1) * 3); + p += (outlink->w - 1) * 3; + } else { + p += showspectrum->xpos * 3; + } + a = FFMIN(a, 255); b = FFMIN(b, 255); - outpicref->data[0][pos] = a; - outpicref->data[0][pos+1] = b; - outpicref->data[0][pos+2] = (a + b) / 2; + p[0] = a; + p[1] = b; + p[2] = (a + b) / 2; } outpicref->pts = insamples->pts + av_rescale_q(showspectrum->consumed, diff --git a/libavfilter/version.h b/libavfilter/version.h index 672472bd89..7b559031be 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,7 +30,7 @@ #define LIBAVFILTER_VERSION_MAJOR 3 #define LIBAVFILTER_VERSION_MINOR 20 -#define LIBAVFILTER_VERSION_MICRO 105 +#define LIBAVFILTER_VERSION_MICRO 106 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \