Commit Graph

43 Commits

Author SHA1 Message Date
Anton Khirnov 06758370aa lavfi/avf_showfreqs: set frame durations
The filter is supposed to produce CFR output.
2022-10-04 11:55:03 +02:00
Steven Liu 90007e0b4e avfilter/avf_showfreqs: fix memleak in plot_freqs
plot_freqs should free colors before return error when
ff_get_video_buffer failed

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2022-05-23 15:07:50 +08:00
Paul B Mahol d8e8aa944a avfilter/avf_showfreqs: add rate option
Fix possible buffer overflow.
2022-04-30 15:41:45 +02:00
Paul B Mahol 0b6e801d4a avfilter/avf_showfreqs: add option to draw subset of channels 2022-04-22 01:20:21 +02:00
Paul B Mahol fd834924d7 avfilter/avf_showfreqs: filter support all channel counts 2022-04-22 01:20:21 +02:00
James Almer 1f96db959c avfilter: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:46 -03:00
Paul B Mahol d27e1cb633 avfilter/avf_showfreqs: stop using audio fifo
Also stop rewriting pts.
2022-02-23 17:01:36 +01:00
Paul B Mahol 767f162432 avfilter/window_func: unify all filters win_func option that use this header 2021-10-15 10:45:50 +02:00
Andreas Rheinhardt b4f5201967 avfilter: Replace query_formats callback with union of list and callback
If one looks at the many query_formats callbacks in existence,
one will immediately recognize that there is one type of default
callback for video and a slightly different default callback for
audio: It is "return ff_set_common_formats_from_list(ctx, pix_fmts);"
for video with a filter-specific pix_fmts list. For audio, it is
the same with a filter-specific sample_fmts list together with
ff_set_common_all_samplerates() and ff_set_common_all_channel_counts().

This commit allows to remove the boilerplate query_formats callbacks
by replacing said callback with a union consisting the old callback
and pointers for pixel and sample format arrays. For the not uncommon
case in which these lists only contain a single entry (besides the
sentinel) enum AVPixelFormat and enum AVSampleFormat fields are also
added to the union to store them directly in the AVFilter,
thereby avoiding a relocation.

The state of said union will be contained in a new, dedicated AVFilter
field (the nb_inputs and nb_outputs fields have been shrunk to uint8_t
in order to create a hole for this new field; this is no problem, as
the maximum of all the nb_inputs is four; for nb_outputs it is only
two).

The state's default value coincides with the earlier default of
query_formats being unset, namely that the filter accepts all formats
(and also sample rates and channel counts/layouts for audio)
provided that these properties agree coincide for all inputs and
outputs.

By using different union members for audio and video filters
the type-unsafety of using the same functions for audio and video
lists will furthermore be more confined to formats.c than before.

When the new fields are used, they will also avoid allocations:
Currently something nearly equivalent to ff_default_query_formats()
is called after every successful call to a query_formats callback;
yet in the common case that the newly allocated AVFilterFormats
are not used at all (namely if there are no free links) these newly
allocated AVFilterFormats are freed again without ever being used.
Filters no longer using the callback will not exhibit this any more.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-05 17:48:25 +02:00
Andreas Rheinhardt 8be701d9f7 avfilter/avfilter: Add numbers of (in|out)pads directly to AVFilter
Up until now, an AVFilter's lists of input and output AVFilterPads
were terminated by a sentinel and the only way to get the length
of these lists was by using avfilter_pad_count(). This has two
drawbacks: first, sizeof(AVFilterPad) is not negligible
(i.e. 64B on 64bit systems); second, getting the size involves
a function call instead of just reading the data.

This commit therefore changes this. The sentinels are removed and new
private fields nb_inputs and nb_outputs are added to AVFilter that
contain the number of elements of the respective AVFilterPad array.

Given that AVFilter.(in|out)puts are the only arrays of zero-terminated
AVFilterPads an API user has access to (AVFilterContext.(in|out)put_pads
are not zero-terminated and they already have a size field) the argument
to avfilter_pad_count() is always one of these lists, so it just has to
find the filter the list belongs to and read said number. This is slower
than before, but a replacement function that just reads the internal numbers
that users are expected to switch to will be added soon; and furthermore,
avfilter_pad_count() is probably never called in hot loops anyway.

This saves about 49KiB from the binary; notice that these sentinels are
not in .bss despite being zeroed: they are in .data.rel.ro due to the
non-sentinels.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-20 12:53:58 +02:00
Paul B Mahol ae94868a57 avfilter/avf_showfreqs: switch to TX FFT from avutil 2021-07-30 09:44:51 +02:00
Andreas Rheinhardt a04ad248a0 avfilter: Constify all AVFilters
This is possible now that the next-API is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:48:05 -03:00
Paul B Mahol a01b037c90 avfilter/avf_showfreqs: add group delay data mode 2020-11-28 20:57:41 +01:00
Paul B Mahol 3864896017 avfilter/avf_showfreqs: implement phase display 2020-11-27 12:52:21 +01:00
Nicolas George 2f76476549 lavfi: regroup formats lists in a single structure.
It will allow to refernce it as a whole without clunky macros.

Most of the changes have been automatically made with sed:

sed -i '
  s/-> *in_formats/->incfg.formats/g;
  s/-> *out_formats/->outcfg.formats/g;
  s/-> *in_channel_layouts/->incfg.channel_layouts/g;
  s/-> *out_channel_layouts/->outcfg.channel_layouts/g;
  s/-> *in_samplerates/->incfg.samplerates/g;
  s/-> *out_samplerates/->outcfg.samplerates/g;
  ' src/libavfilter/*(.)
2020-09-08 14:02:40 +02:00
James Almer 1aa4fc1ec2 avfilter/avf_showfreqs: free input frame after using it
Fixes ticket #8336.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-10-26 10:16:02 -03:00
Paul B Mahol a46ee096d1 avfilter/avf_showfreqs: fix check for failed allocation 2019-09-21 19:09:29 +02:00
Paul B Mahol 74d4fd0822 avfilter/avf_showfreqs: make selecting window size simpler
The previous solution was very bad.
2019-07-10 16:03:34 +02:00
Paul B Mahol fc0de1c04b avfilter/avf_showfreqs: switch to activate 2019-05-26 17:11:17 +02:00
Paul B Mahol 40ac622460 avfilter/window_func: add bohman window 2018-10-27 13:36:00 +02:00
Rostislav Pehlivanov 039ebaa5f3 lavfi: make window_func an inline function
Eliminate lavc->lavfi dependency. The function isn't big and doesn't
deserve its own file.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-09-23 14:35:06 +01:00
Paul B Mahol f85cad799b avfilter: properly set SAR for A->V filters
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-06-13 15:10:58 +02:00
Nicolas George 183ce55b0d lavfi: split frame_count between input and output.
AVFilterLink.frame_count is supposed to count the number of frames
that were passed on the link, but with min_samples, that number is
not always the same for the source and destination filters.
With the addition of a FIFO on the link, the difference will become
more significant.

Split the variable in two: frame_count_in counts the number of
frames that entered the link, frame_count_out counts the number
of frames that were sent to the destination filter.
2016-11-13 10:41:16 +01:00
Paul B Mahol 5ee5f4b13c avfilter/avf_showfreqs: make minimum amplitude for log scaler configurable 2016-08-17 22:02:29 +02:00
Paul B Mahol b438c2025c avfilter/window_func: add cauchy, parzen and poisson window function 2016-08-16 18:09:50 +02:00
Paul B Mahol ea58dd2beb avfilter/window_func: add dolph window 2016-08-16 15:56:12 +02:00
Michael Niedermayer 43bf15d1a4 avfilter/avf_showfreqs: assert that variables are initialized by switch()
Silences: CID1351396

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-12 00:37:11 +01:00
Paul B Mahol 4ab4793c15 avfilter/avf_showfreqs: properly handle pts
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-01-31 22:18:12 +01:00
Paul B Mahol 4e17efd852 avfilter/avf_showfreqs/showspectrum: rename skip_samples to hop_size
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-01-18 19:38:14 +01:00
Paul B Mahol b7b4d99a18 avfilter/avf_showfreqs: fix possible null pointer dereference
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-01-08 14:58:43 +01:00
Paul B Mahol c13216ac08 avfilter/window_func: add tukey window function
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-01-05 11:37:11 +01:00
Paul B Mahol 45b3e6e04e avfilter: move window function generation into separate file
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-28 18:54:55 +01:00
Paul B Mahol 9e569abe99 avfilter/avf_showfreqs: make it possible to split channels
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-20 19:52:51 +01:00
Ganesh Ajjanagadde e5d771c84d avfilter/avf_showfreqs: avoid wasteful pow
pow is a ridiculous function for computing a simple Gaussian.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-09 20:07:49 -05:00
Ganesh Ajjanagadde 8507b98c10 avfilter,swresample,swscale: use fabs, fabsf instead of FFABS
It is well known that fabs and fabsf are at least as fast and sometimes
faster than the FFABS macro, at least on the gcc+glibc combination.
For instance, see the reference:
http://patchwork.sourceware.org/patch/6735/.
This was a patch to glibc in order to remove their usages of a macro.

The reason essentially boils down to fabs using the __builtin_fabs of
the compiler, while FFABS needs to infer to not use a branch and to
simply change the sign bit. Usually the inference works, but sometimes
it does not. This may be easily checked by looking at the asm.

This also has the added benefit of reducing macro usage, which has
problems with side-effects.

Note that avcodec is not handled here, as it is huge and
most things there are integer arithmetic anyway.

Tested with FATE.

Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-22 16:13:26 -04:00
Ganesh Ajjanagadde 6aaac24d72 avfilter/all: propagate errors of functions from avfilter/formats
Many of the functions from avfilter/formats can return errors, usually AVERROR(ENOMEM).
This propagates the return values.

All of these were found by using av_warn_unused_result, demonstrating its utility.

Tested with FATE. I am least sure of the changes to avfilter/filtergraph,
since I don't know what/how reduce_format is intended to behave and how it should
react to errors.

Fixes: CID 1325680, 1325679, 1325678.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Previous version Reviewed-by: Nicolas George <george@nsup.org>
Previous version Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-14 10:04:01 -04:00
Nicolas George 44f660e7e7 lavfi: remove FF_LINK_FLAG_REQUEST_LOOP.
It has no longer any effect.
2015-09-20 19:02:33 +02:00
Paul B Mahol f2b1df735e avfilter/avf_showfreqs: add lanczos and gauss windowing functions
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-09-15 09:28:40 +00:00
Michael Niedermayer 8ca97b5e4f avfilter/avf_showfreqs: Fix memleak of out frame
Fixes CID1322344

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-05 15:46:18 +02:00
Michael Niedermayer 0ada8ec1a5 avfilter/avf_showfreqs: Fix "may be used uninitialized in this function" warning
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-05 15:34:35 +02:00
Michael Niedermayer 7213d3fbf3 avfilter/avf_showfreqs: Free fin
Fixes CID1322345

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-05 15:32:00 +02:00
Michael Niedermayer 629fcda4da avfilter/avf_showfreqs: Use floating point division in WFUNC_BHANN
Fixes: CID1322365

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-03 18:54:14 +02:00
Paul B Mahol 2fa019958b avfilter: add showfreqs filter 2015-08-19 16:15:13 +00:00