Commit Graph

64 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
Andreas Rheinhardt e2ec90cd0e avfilter/af_sofalizer: Remove unnecessary emms_c()
The floating point dsp code does not use MMX registers
since 2718a3be1f.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-04 11:04:45 +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 3bcec58535 avfilter: fix av_tx_fn stride usage for complex inputs 2022-11-19 00:25:47 +01:00
James Almer 55740299ef avfilter/af_sofalizer: fix getting speaker position
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 11:09:31 -03: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
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
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
Paul B Mahol f6aeb94d72 avfilter/af_sofalizer: switch to TX FFT from avutil 2021-07-24 12:24:40 +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 f7fd205f11 avfilter/af_sofalizer: allow up to 64 channels 2020-10-12 12:21:35 +02:00
Paul B Mahol aa125fd06a avfilter/af_sofalizer: allow to specify virtual speakers indetifier as number 2020-10-12 12:21:35 +02: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
Paul B Mahol 21d1bb00c4 avfilter/af_sofalizer: switch to activate 2019-04-29 13:35:04 +02:00
Paul B Mahol e1f7881d92 afilter/af_sofalizer: check explicitly other type 2019-01-01 12:29:19 +01:00
Paul B Mahol 51b356eef8 avfilter/af_sofalizer: stop allocating never used buffers 2018-12-31 19:40:18 +01:00
Paul B Mahol b5e0a0fe3a avfilter/af_sofalizer: use av_log2() 2018-12-27 12:31:01 +01:00
Paul B Mahol 92ed9316bb avfilter/af_sofalizer: fix regression after 7ea4b928a2 2018-12-26 10:18:19 +01:00
Paul B Mahol 60e9007be2 avfilter/af_sofalizer: fix typo in comments 2018-12-26 10:01:06 +01:00
Paul B Mahol 8e4e2c9e40 avfilter/af_sofalizer: use float constants 2018-12-26 10:01:06 +01:00
Paul B Mahol 530fc345ec avfilter/af_sofalizer: add fltp sample format support 2018-12-26 10:01:06 +01:00
Paul B Mahol 8d0b8c50bd avfilter/af_sofalizer: speed up fast convolution
Do inverse FFT only once per output channel.
2018-12-25 18:56:55 +01:00
Paul B Mahol 84d1adb118 avfilter/af_sofalizer: do not reduce LFE by 6dB
It is already reduced enough.
2018-12-24 15:24:20 +01:00
Paul B Mahol 7d5bb3a4d3 avfilter/af_sofalizer: fix memory leaks 2018-12-23 21:49:30 +01:00
Paul B Mahol ee64b64c02 avfilter/af_sofalizer: set delays when interpolation is disabled 2018-12-23 21:40:07 +01:00
Paul B Mahol 4096c670ab avfilter/af_sofalizer: stop using easy API
Easy API is not flexible enough for our needs.
2018-12-23 18:29:53 +01:00
Paul B Mahol d360a79c0a avfilter/af_sofalizer: reset FFT pointers back to NULL 2018-12-23 11:30:01 +01:00
Paul B Mahol 0c3481b43a avfilter/af_sofalizer: pick IR length after loading sofa
Instead of picking it in preloading stage.
2018-12-23 11:02:34 +01:00
Paul B Mahol b13fe6477d avfilter/af_sofalizer: increase range for lfegain
Fixes #7634.
2018-12-23 10:00:44 +01:00
Paul B Mahol 7ea4b928a2 avfilter/af_sofalizer: fix non-power of 2 IR length filtering in time domain 2018-12-22 16:19:21 +01:00
Paul B Mahol c49307e784 avfilter/af_sofalizer: use fabsf() instead of fabs() 2018-12-21 11:53:44 +01:00
Paul B Mahol d6951e595a avfilter/af_sofalizer: add framesize option 2018-12-20 20:30:07 +01:00
Paul B Mahol 1ead98ffd9 avfilter/af_sofalizer: increase max radius 2018-12-20 19:20:30 +01:00
Paul B Mahol 4b5977fc50 avfilter/af_sofalizer: add printing of license back 2018-12-20 13:46:49 +01:00
Paul B Mahol 9b2c325060 avfilter/af_sofalizer: use av_sscanf() 2018-11-18 21:21:18 +01:00
Paul B Mahol 2336c76b22 avfilter/af_sofalizer: switch to libmysofa
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-06-08 22:02:26 +02:00
Paul B Mahol f5e5c53117 avfilter/af_sofalizer: make lfe gain user configurable
Default settings have it too low.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-05-18 23:13:52 +02:00
Paul B Mahol 79bf4d1450 avfilter/af_sofalizer: avoid casting
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-05-18 22:49:04 +02:00
Michael Niedermayer 4064f3f0df avfilter/af_sofalizer: Fix bad shift
Fixes CID1396835

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-03-30 22:46:31 +02:00
Paul B Mahol 7aef56864c avfilter/af_sofalizer: speed and clean up fast convolution a little
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-01-09 18:38:25 +01:00
Paul B Mahol 458fbee221 avfilter/af_sofalizer: warn if user gives unknown channel names
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-12-14 22:47:38 +01:00
Paul B Mahol a55c953ef0 avfilter/af_sofalizer: allow user to setup custom virtual speakers positions
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-28 21:27:59 +02:00
Michael Niedermayer c34250178b avfilter/af_sofalizer: Fix "warning: ISO C90 forbids mixed declarations and code"
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-14 22:40:38 +01:00
Paul B Mahol 781195fa62 avfilter/af_sofalizer: check if filename was set.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-04 22:14:43 +01:00
Paul B Mahol 79a54f30c8 avfilter/af_sofalizer: fix crash when ir size is not aligned, usually when n_samples are not power of 2
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-04 10:38:40 +01:00
Paul B Mahol 21234c835d avfilter/af_sofalizer: fix crash with odd IR size
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-03 23:59:58 +01:00