Commit Graph

85 Commits

Author SHA1 Message Date
Andreas Rheinhardt 790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
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 d295b6b693 avfilter: fix highshelf zdf coefficients 2023-08-07 11:57:28 +02:00
Andreas Rheinhardt 19af142d45 avfilter/internal: Don't include formats.h
internal.h doesn't rely on it; instead include it directly
in every user that needs it (a filter needing it is basically
equivalent to it using FILTER_QUERY_FUNC, i.e. a majority of
filters doesn't need it).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-07 09:21:13 +02:00
Andreas Rheinhardt 50ea7389ec avfilter: Deduplicate default audio inputs/outputs
Lots of audio filters use very simple inputs or outputs:
An array with a single AVFilterPad whose name is "default"
and whose type is AVMEDIA_TYPE_AUDIO; everything else is unset.

Given that we never use pointer equality for inputs or outputs*,
we can simply use a single AVFilterPad instead of dozens; this
even saves .data.rel.ro (4784B here) as well as relocations.

*: In fact, several filters (like the filters in af_biquads.c)
already use the same inputs; furthermore, ff_filter_alloc()
duplicates the input and output pads so that we do not even
work with the pads directly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-07 09:21:13 +02:00
Paul B Mahol 6f1c82fd5b avfilter/af_biquads: reduce double type usage 2023-05-05 17:20:13 +02:00
Paul B Mahol 3d6d127cd0 avfilter/af_biquads: fix bandpass for zdf 2022-10-07 14:05:31 +02:00
Paul B Mahol a7e0997324 avfilter/af_biquads: refactor some options 2022-05-29 12:38:37 +02:00
Paul B Mahol 525f83becd avfilter: add tiltshelf audio filter 2022-05-29 12:37:46 +02:00
Paul B Mahol 93b31dae1d avfilter/af_biquads: fix low/highshelf 'k' calculation 2022-05-27 09:39:53 +02:00
Paul B Mahol b5aa514bbb avfilter/af_biquads: always return same number of samples with block processing 2022-05-12 18:23:37 +02:00
Paul B Mahol cbc1b8adad avfilter/af_biquads: add zdf transform type 2022-05-11 22:14:58 +02:00
Paul B Mahol 38238b604f avfilter/af_biquads: use correct variables when reversing samples
Also silence initial block frames.
2022-05-10 09:27:10 +02:00
Paul B Mahol 1309867022 avfilter/af_biquads: add option for block based linear phase processing 2022-05-09 22:21:40 +02:00
Paul B Mahol d166317cdd avfilter/af_biquads: add tdi transform type 2022-05-08 18:27:11 +02:00
Martin Storsjö a78f136f3f configure: Use a separate config_components.h header for $ALL_COMPONENTS
This avoids unnecessary rebuilds of most source files if only the
list of enabled components has changed, but not the other properties
of the build, set in config.h.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-16 14:12:49 +02:00
Paul B Mahol 93a076db70 avfilter/af_biquads: fix possible leak on error
Recently introduced.
2022-03-15 16:22:56 +01:00
Paul B Mahol 5b59c072f5 avfilter/af_biquads: fix regression with channels option processing 2022-03-15 16:07:57 +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
Paul B Mahol e38551180e avfilter/af_biquads: add svf transform type 2021-11-26 00:55:32 +01: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 4ab80ac17e avfilter/af_biquads: Deduplicate AVClasses
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-19 04:04:12 +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
Andreas Rheinhardt 1be3d8a0cb avcodec/avcodec: Stop including channel_layout.h in avcodec.h
Also include channel_layout.h directly wherever used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 11:14:31 +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
Andreas Rheinhardt 6fed8a6cb0 avfilter/af_biquads: Don't redundantly set AVClass
It is already set generically in ff_filter_alloc().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:06:12 +01:00
Andreas Rheinhardt 2d48b69b3d avfilter/af_biquads: Deduplicate options
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:06:12 +01:00
Paul B Mahol 1eb751955e avfilter/af_biquads: fix error in ro calculation 2020-12-17 15:13:42 +01:00
Paul B Mahol 69be00aa61 avfilter/af_biquads: add one-pole shelf filters by adding pole option 2020-12-16 18:38:51 +01:00
Paul B Mahol 88b6ebdace avfilter/af_biquads: add shortcut to set internal precision 2020-12-06 14:51:21 +01:00
Paul B Mahol c6a7ca271b avfilter/af_biquads: make sure that biquad filter still works 2020-11-24 14:26:47 +01:00
Paul B Mahol 040e989223 avfilter/af_biquads: do not abort filtering on bogus options
Instead, continue returning unfiltered input.
2020-11-24 12:03:23 +01:00
Paul B Mahol 42ccef2846 avfilter/af_biquads: remove not needed code 2020-11-22 14:22:19 +01:00
Paul B Mahol 2ddd6afd30 avfilter/af_biquads: make commands work reliably within biquad filter
Previously changing single coefficient would give unexpected results.
2020-11-02 13:30:14 +01:00
Paul B Mahol 40ce4ad999 avfilter/af_biquads: add lattice-ladder form 2020-11-02 13:30:14 +01:00
Paul B Mahol 2459c3f8f0 avfilter/af_biquads: add different transform types 2020-08-21 22:46:07 +02:00
Paul B Mahol 1206a10d9c avfilter/af_biquads: implement 1st order allpass 2020-05-30 09:57:04 +02:00
Paul B Mahol f46b04c4c3 avfilter/af_biquads: add new normalize/n option 2019-11-22 21:10:43 +01:00
Paul B Mahol 015cbca444 avfilter/af_biquads: use ff_filter_process_command() 2019-10-14 11:40:17 +02:00
Paul B Mahol 034a9d2507 avfilter/af_biquads: clip gain picked from command to sane values 2019-07-08 16:29:15 +02:00
Paul B Mahol 7b2d39fc27 avfilter/af_biquads: implement mix option to all filters 2019-07-08 16:20:57 +02:00
Paul B Mahol 255feeccc5 avfilter/af_biquads: add timeline support 2019-05-01 12:59:54 +02:00
Michael Niedermayer 1b6695354d avfilter/af_biquads: minor simplification by using ff_exp10()
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-01 21:11:47 +01:00
Michael Niedermayer 6414415889 avfilter/af_biquads: Remove l from %lf in av_log environment
The l modifier does nothing in C99 and it was undefined in C89 for %f

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-10-07 03:03:09 +02:00
Paul B Mahol d176497cec avfilter/af_biquads: add slice threading
Helps with multi-channels audio. Otherwise use threads=1.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-05-01 16:00:19 +02:00
Paul B Mahol 2308a3c7e3 avfilter/af_biquads: change clipping detection from global to channel
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-05-01 15:26:20 +02:00
Paul B Mahol 2fc12f4971 avfilter: add lowshelf and highshelf filters
These are old bass and treble filters.
Make bass and treble filters better at boosting.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-04-17 12:40:27 +02:00
Paul B Mahol 50b3cd22dd avfilter/av_biquads: scale a0 too
Fixes bug when using commands to alter coefficients.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-01-06 14:58:00 +01:00