1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

68 Commits

Author SHA1 Message Date
Anton Khirnov
1e7d2007c3 all: use designated initializers for AVOption.unit
Makes it robust against adding fields before it, which will be useful in
following commits.

Majority of the patch generated by the following Coccinelle script:

@@
typedef AVOption;
identifier arr_name;
initializer list il;
initializer list[8] il1;
expression tail;
@@
AVOption arr_name[] = { il, { il1,
- tail
+ .unit = tail
}, ...  };

with some manual changes, as the script:
* has trouble with options defined inside macros
* sometimes does not handle options under an #else branch
* sometimes swallows whitespace
2024-02-14 14:53:41 +01:00
Paul B Mahol
fb05bc8eee avfilter/af_astats: extend and improve bit depth output 2023-09-25 19:07:11 +02:00
Paul B Mahol
a5b334e18e avfilter/af_astats: fix reporting of noise_floor for small number of samples 2023-08-13 14:38:28 +02:00
Paul B Mahol
90afcc2bfd avfilter/af_astats: drop usage of histogram for noise floor calculation 2023-08-13 14:24:47 +02:00
Paul B Mahol
a1838c59bb avfilter/af_astats: add abs_peak_count stat 2023-05-25 19:51:39 +02:00
Stefano Sabatini
abfe8456a2 lavfi/astats: sort measures keys by name 2023-02-11 17:30:20 +01:00
Paul B Mahol
754fa305fa avfilter/af_astats: accessing outlink in uninit is not valid 2022-12-03 17:32:07 +01:00
Paul B Mahol
4d38d4607c avfilter/af_astats: print stats in case nb_samples is 0
Happens with special function only.
2022-12-01 19:21:11 +01:00
Paul B Mahol
14e6ca17e1 avfilter/af_astats: do not give output for 0 samples 2022-11-30 21:19:49 +01: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
Limin Wang
571e8ca2dd avfilter/af_astats: improve options descriptions
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-14 22:36:50 +08:00
Anton Khirnov
b9c928a486 avfilter: add AVFILTER_FLAG_METADATA_ONLY
This flag allows distinguishing between filters that actually modify the
data and those that only modify metadata or gather some stream
information.
2021-12-04 14:07:19 +01:00
Andreas Rheinhardt
01d158d1c8 all: Remove unused-but-set variables
Newer versions of Clang detect this and emit warnings for it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:09:14 +01:00
Andreas Rheinhardt
2f51b80f0f avfilter/af_astats: Use formats list instead of query function
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-05 18:01:02 +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
Paul B Mahol
966fc3c070 avfilter/af_astats: add entropy stat 2021-09-11 10:54:20 +02:00
Paul B Mahol
5b258c2770 avfilter/af_astats: remove invalid 5x factor in window size calculation
Also allow smaller window sizes, and change histogram for noise
floor calculation to uint64_t type.
2021-08-21 22:05:08 +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
Andreas Rheinhardt
1b20853fb3 avfilter/internal: Factor out executing a filter's execute_func
The current way of doing it involves writing the ctx parameter twice.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-15 21:33:25 +02:00
Andreas Rheinhardt
18ec426a86 avfilter/formats: Factor common function combinations out
Several combinations of functions happen quite often in query_format
functions; e.g. ff_set_common_formats(ctx, ff_make_format_list(sample_fmts))
is very common. This commit therefore adds functions that are equivalent
to commonly used function combinations in order to reduce code
duplication.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-13 17:36:22 +02:00
Tobias Rapp
ca56299fb3 avfilter/af_astats: Only print header lines when values are to be printed
Avoids empty "Channel" or "Overall" header lines added to log output
when measurement is restricted to one scope using
"measure_perchannel=none" or "measure_overall=none".

Signed-off-by: Tobias Rapp <t.rapp@noa-archive.com>
2021-07-14 10:31:33 +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
Marton Balint
c8e1e56509 avfilter/af_astats: fix possible crash because of undefined float to integer rounding
Fixes ticket #9049.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-23 19:54:14 +01:00
Paul B Mahol
89c9c42c5b avfilter/af_astats: clip input value to prevent overflow 2021-01-04 11:14:50 +01:00
Paul B Mahol
24db9372eb avfilter/af_astats: add noise floor count stat 2020-04-17 13:28:01 +02:00
Paul B Mahol
715da29501 avfilter/af_astats: add slice threading support 2020-04-17 13:26:44 +02:00
Paul B Mahol
87b4fb65a8 avfilter/af_astats: measure noise floor 2020-04-17 13:26:30 +02:00
Paul B Mahol
bd6942b4c0 avfilter/af_astats: fix calculations involving last sample 2019-05-12 17:12:06 +02:00
Paul B Mahol
2a4a364f6a avfilter/af_astats: fix initial values of variables 2019-05-12 17:12:06 +02:00
Matthias Troffaes
90b21ae5b5 avfilter/af_astats: fix msvc compile error
MSVC requires an explicit cast from void * to void when applying the
ternary conditional operator to switch between methods that return
void.
2019-04-29 11:08:49 +02:00
Paul B Mahol
1e01f66822 avfilter/af_astats: count number of NaNs/Infs/denormals for floating-point audio too 2019-04-26 12:14:10 +02:00
Marton Balint
6af67dcc35 avfilter/af_astats: add support for optimized min/max/peak calculation
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-03-21 00:39:57 +01:00
Marton Balint
5cc4b79b29 avfilter/af_astats: rework sample loops
The channel loop is now the outer loop for both planar and interleaved. This is
needed by the next patch, and the speed difference is negligable if any.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-03-21 00:39:57 +01:00
Marton Balint
235228ea50 avfilter/af_astats: factorize sample loops
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-03-21 00:39:57 +01:00
Marton Balint
233fdd84c2 avfilter/af_astats: fix identation
Signed-off-by: Marton Balint <cus@passwd.hu>
2019-03-21 00:39:57 +01:00
Marton Balint
e85f37d51e avfilter/af_astats: add support for selecting measured statistics
set_metadata with many entries is not very efficient, and with small audio
frames the performance loss is noticable. Also with this very simple
calculations (like peak) can be even further optimized.

Unfoturnately there are some small differences in metadata and av_log info
output, so factorizing calculations and output might not worth the hassle.

Signed-off-by: Marton Balint <cus@passwd.hu>
2019-03-21 00:39:57 +01:00
Paul B Mahol
c4774c5474 avfilter/af_astats: count zero crossings 2018-09-17 12:12:54 +02:00
Paul B Mahol
12791ec5b0 avfilter/af_astats: measure dynamic range
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-07-19 21:07:45 +02:00
Paul B Mahol
a17fcd8e04 avfilter/af_astats: do not overwrite already set values when doing reset
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-07-19 20:11:43 +02:00
Paul B Mahol
ed93ed5ee3 avfilter: don't anonymously typedef structs
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-05-13 11:39:28 +02:00
Paul B Mahol
e312ed0504 avfilter/af_astats: add RMS difference too
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-05-12 18:14:45 +02:00
Muhammad Faiz
6af050d7d0 avfilter: do not use AVFrame accessor
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
2017-04-23 14:40:30 +07:00
Paul B Mahol
703ae350c2 avfilter/af_astats: fix flt(p) support 2016-08-18 15:30:05 +02:00
Paul B Mahol
81f7d07608 avfilter/af_astats: add support for s64(p) sample format 2016-08-18 15:30:05 +02:00
Paul B Mahol
4f226714f5 avfilter/af_astats: add support for other sample formats 2016-08-15 22:01:16 +02:00
Paul B Mahol
4be8ab70a6 avfilter/af_astats: extend bitdepth calculation 2016-08-03 20:32:43 +02:00
Paul B Mahol
2a7f056d88 avfilter/af_astats: do not clear previous sample value
Should help when using reset=1 and metadata=1

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-02-26 11:12:45 +01:00
Paul B Mahol
0d65a7d033 avfilter/af_astats: clear all stats
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-02-25 00:00:25 +01:00
Paul B Mahol
c09248aecd avfilter/af_astats: reset stats prior not after filtering
This way stats printed at uninit are also useful.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-02-24 22:32:26 +01:00
Ganesh Ajjanagadde
ac6b7c47cc avfilter/af_astats: replace FFABS with fabs 2015-10-13 09:34:39 +02:00