Commit Graph

59 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
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 8e96319674 avfilter/af_dynaudnorm: add curve option 2022-11-10 19:16:05 +01:00
Paul B Mahol 369b7f2654 avfilter/af_dynaudnorm: add slice threading support 2022-11-04 18:32:13 +01:00
Paul B Mahol 4a672f1c0e avfilter/af_dynaudnorm: process also short durations 2022-11-04 18:32:13 +01:00
Paul B Mahol 9ac777234e avfilter/af_dynaudnorm: fix parameter for copy samples function 2022-09-18 19:43:41 +02:00
Paul B Mahol 9f81d12f87 avfilter/af_dynaudnorm: 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 178d8036dc avfilter/af_dynaudnorm: reduce number of lines by using for (int ... 2022-02-28 22:00:02 +01:00
Paul B Mahol aa6b9066b9 avfilter/af_dynaudnorm: use fmin/fmax for doubles 2022-02-28 22:00:02 +01:00
Paul B Mahol 456d48c752 avfilter/af_dynaudnorm: add support for overlapping frames 2022-02-28 22:00:02 +01:00
Paul B Mahol 9a86e5338c avfilter/af_dynaudnorm: do not leak frame on error 2022-02-28 22:00:02 +01:00
Paul B Mahol a2dbd17788 avfilter/af_dynaudnorm: allocate new frame instead of making it writable
Later case does not use frame pool at all.
2022-02-27 20:05:57 +01:00
Paul B Mahol a9124a75b0 avfilter/af_dynaudnorm: allow to filter subset of channels 2022-02-27 20:05:57 +01:00
Paul B Mahol b9f91a7cbc avfilter/af_dynaudnorm: make frame writable if it may be changed 2022-02-27 18:48:24 +01:00
Paul B Mahol e845c41c94 avfilter/af_dynaudnorm: cleanup gaussian_filter() function 2022-02-25 18:15:26 +01:00
Andreas Rheinhardt e74acd5771 avfilter/af_dynaudnorm: Store format in filter, remove query function
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-05 18:01:03 +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 38b9dc98a8 avfilter/af_dynaudnorm: add support for filtering non-writable frames
Previously it would continue processing frame even if call
to make frame writable failed.
2021-10-05 16:28:47 +02:00
Paul B Mahol fcbaeefb45 avfilter/af_dynaudnorm: fix possible clipping at start when alt-boundary mode is disabled 2021-10-05 15:40:45 +02:00
Paul B Mahol f78d0f67be avfilter/af_dynaudnorm: improve EOF timestamp precision 2021-09-12 23:47:32 +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 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 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 3e3c408e3f avfilter/af_dynaudnorm: make better check for available samples
Also report more correct EOF timestamp.
2021-03-10 23:52:07 +01:00
Paul B Mahol b650046860 avfilter/af_dynaudnorm: use better limits for maximal amplification
Fixes regression in smoothness of amplification.
2020-01-11 14:08:52 +01:00
Paul B Mahol 27ec72db06 avfilter/af_dynaudnorm: add support for commands 2020-01-06 14:23:53 +01:00
Paul B Mahol e26d66daaa avfilter/af_dynaudnorm: use already available pointer
Instead of dereferencing same thing again.
2020-01-05 10:22:57 +01:00
Paul B Mahol 1187dbb7e9 avfilter/af_dynaudnorm: move channels variable setup first 2020-01-05 10:20:27 +01:00
Paul B Mahol 389865352d avfilter/af_dynaudnorm: fix another clipping with custom peak value
This always happened at start with alternative boundary mode disabled.
The clipping only occurred if starting samples where high enough.
2020-01-04 19:34:50 +01:00
Paul B Mahol c8253cb332 avfilter/af_dynaudnorm: implement threshold option 2020-01-04 18:17:32 +01:00
Paul B Mahol 6a1305e8b7 avfilter/af_dynaudnorm: do not clip audio
Clipping can happen when smoothed gain is higher than maximum
allowed gain factor for current frame and peak value option is
set to enough low value.
2020-01-04 10:27:46 +01:00
Paul B Mahol 81172b5e3a avfilter/af_dynaudnorm: fix previous commit
We still need to analyze frame for amplification at EOF.
2020-01-02 17:24:01 +01:00
Paul B Mahol ed02563ce0 avfilter/af_dynaudnorm: do not enqueue flush buffers 2020-01-02 16:28:38 +01:00
Paul B Mahol d4d6280ab2 avfilter/af_dynaudnorm: do not hang forever if only EOF is received 2020-01-01 13:44:22 +01:00
Paul B Mahol 7bb09e57e0 avfilter/af_dynaudnorm: do not error out if even filter size was given
Instead issue a warning and make filter size odd number.
2020-01-01 13:44:22 +01:00
Paul B Mahol 73afea3ccc avfilter/af_dynaudnorm: add more descriptive aliases for options 2019-07-24 15:20:47 +01:00
Paul B Mahol 9cc10418b3 avfilter/af_dynaudnorm: add timeline support 2019-04-30 10:56:39 +02:00
Paul B Mahol c82d81ba42 avfilter/af_dynaudnorm: always update delay when flushing 2019-04-30 10:05:23 +02:00
Paul B Mahol d7fead80ad avfilter/af_dynaudnorm: switch to activate 2019-04-29 15:12:42 +02:00
Andy 448c88e1a5 avfilter/dynaudnorm: increment input outside of the FFMIN macro so it doesn't get double incremented 2017-08-09 10:21:36 +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
Clément Bœsch 8f9edf89d5 lavfi/dynaudnorm: rename pow2 to pow_2
This conflict with the DJGPP libc which includes a pow2 function¹

We cannot make DJGPP POSIX only (using -D_POSIX_SOURCE) to avoid this
kind of symbols conflicts due to the lack of both posix_memalign and
memalign (DJGPP non standard function) in that POSIX mode. We currently
rely on memalign for aligned heap allocation.

[1]: http://www.delorie.com/djgpp/doc/libc-2.02/libc_536.html
2017-03-29 14:49:29 +02:00
Paul B Mahol 0ddc24d232 avfilter/af_dynaudnorm: fix hang with too short input
The only thing we can do at such point is return samples unchanged.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-01-08 20:42:17 +01:00
Paul B Mahol 22d13e4290 avfilter/af_dynaudnorm: use better check for infinite loop
Apparently due to rounding this happens.
2016-08-07 23:47:04 +02:00
LoRd_MuldeR 8ab200fb8a avfilter/af_dynaudnorm: improve pre-filling code
In order to avoid possible clipping at the very
beginning. Especially apparent when "alternative"
boundary mode is used.

Adopted from original commit by committer.
2016-08-02 20:00:44 +02:00
Paul B Mahol 307b848218 avfilter/af_dynaudnorm: call uninit() from config_input()
Should help dynamic filtergraph reconfiguration.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-01-19 20:14:14 +01:00
Paul B Mahol 70df51112c avfilter/af_dynaudnorm: fix possible null pointer dereference
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-01-14 14:30:36 +01:00
Ganesh Ajjanagadde ad795f6394 lavfi/af_dynaudnorm: replace round by lrint
lrint is at least as fast, uses a superior rounding mode, and avoids an
implicit cast.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-21 08:22:23 -08:00
Paul B Mahol 7caf381a95 avfilter/af_dynaudnorm: use av_malloc_array()
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-19 22:46:10 +01:00