Commit Graph

40 Commits

Author SHA1 Message Date
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
Ganesh Ajjanagadde 352bd18dff avfilter/af_dynaudnorm: remove wasteful pow
This removes wasteful pow(x, 2.0) that although not terribly important
for speed, is still useless.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-26 09:20:46 -05:00
Ganesh Ajjanagadde 7769e6602d avfilter/af_dynaudnorm: use M_PI
The ad-hoc pi constant has a ludicrous number of digits that offer no
value whatsoever. M_PI is more consistent and readable across the
codebase.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-20 08:29:56 -05: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 494b792441 avfilter: use ff_all_channel_counts() instead of ff_all_channel_layouts()
Fixes playback of some files with ffplay.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-09-12 01:43:06 +00:00
Clément Bœsch 266997504d avfilter/dynaudnorm: use AV_OPT_TYPE_BOOL 2015-09-08 22:39:24 +02:00
Michael Niedermayer 92b3c486b0 avfilter/af_dynaudnorm: Fix typo in assert
Fixes: CID1322303

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-09-03 18:55:06 +02:00
Michael Niedermayer 2927b61c55 avfilter/af_dynaudnorm: Use av_frame_get_channels()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-18 10:45:29 +02:00
Michael Niedermayer 4c7c0d37e5 avfilter/af_dynaudnorm: Fix "ISO C90 forbids mixed declarations and code" warnings
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-17 21:13:56 +02:00
LoRd_MuldeR 21436b95dc avfilter: add Dynamic Audio Normalizer filter 2015-07-17 10:58:24 +00:00