[FFmpeg-devel] [PATCH] lavfi/showspectrum: add sliding mode.
Clément Bœsch
ubitux at gmail.com
Thu Oct 25 22:19:25 CEST 2012
On Mon, Oct 22, 2012 at 12:15:33AM +0200, Stefano Sabatini wrote:
> On date Sunday 2012-10-21 21:02:18 +0200, Clément Bœsch encoded:
> > ---
> > doc/filters.texi | 3 +++
> > libavfilter/avf_showspectrum.c | 17 +++++++++++++----
> > 2 files changed, 16 insertions(+), 4 deletions(-)
> >
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index 916655a..72bf0a1 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -4675,6 +4675,9 @@ spectrum.
> >
> > The filter accepts the following named parameters:
> > @table @option
> > + at item sliding
> > +Specify if the spectrum should slide along the window. Default value is
> > + at code{0}.
>
> I prefer "slide" for consistency with other similar options
> (e.g. "stitch"), also shorter.
>
Renamed, but kept sliding internally since the code makes more sense that
way IMO.
> > @item size, s
> > Specify the video size for the output. Default value is @code{640x480}.
> > @end table
> > diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c
> > index 641c27f..55bf260 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<<rdft_bits)
> > @@ -52,6 +53,7 @@ typedef struct {
> > static const AVOption showspectrum_options[] = {
> > { "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x480"}, 0, 0, FLAGS },
> > { "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "640x480"}, 0, 0, FLAGS },
> > + { "sliding", "set sliding mode", OFFSET(sliding), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS },
> > { NULL },
> > };
> >
> > @@ -247,16 +249,23 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFilterBufferRef *insampl
> >
> > for (y = 0; y < outlink->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) {
> > + p += showspectrum->xpos * 3;
> > + } else {
> > + memmove(p, p + 3, (outlink->w - 1) * 3);
> > + p += (outlink->w - 1) * 3;
> > + }
>
> Nit+: avoid negative logic when avoidable
>
Sure whatever, toggled
> > +
> > 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,
>
> LGTM, also bump micro so people/programs know when the feature was
> added, thanks.
lavfi micro bumped, and applied.
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121025/ea49d828/attachment.asc>
More information about the ffmpeg-devel
mailing list