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

39 Commits

Author SHA1 Message Date
Paul B Mahol
0dff278e5b avfilter/af_silenceremove: do not trim non-silence from start 2022-08-23 22:18:02 +02: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
9abb877362 avfilter/af_silenceremove: Use formats list instead of 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
6a1bda3df9 avfilter/af_silenceremove: improve trimming middle silence 2021-09-23 23:34:45 +02:00
Paul B Mahol
abd24eaf68 avfilter/af_silenceremove: fix regression in output frame pts 2021-09-09 20:22:02 +02:00
Paul B Mahol
38ab20e591 avfilter/af_silenceremove: fix stop_silence handling 2021-09-08 19:10:39 +02:00
Paul B Mahol
8a42ee6697 avfilter/af_silenceremove: avoid returning 1 sample duration frames 2021-09-08 19:10:39 +02:00
Paul B Mahol
3b331468da avfilter/af_silenceremove: fix processing of periods > 1 2021-09-08 19:10:39 +02:00
Paul B Mahol
5e7e2e5031 avfilter/af_silenceremove: guard against negative numbers 2021-09-08 10:45:53 +02:00
Paul B Mahol
c3e11e3092 avfilter/af_silenceremove: add asserts to check for NaNs 2021-09-08 10:45:53 +02:00
Paul B Mahol
4e1ee16cbb avfilter/af_silenceremove: use duration option for window option 2021-09-07 19:44:25 +02:00
Paul B Mahol
15e844ed9d avfilter/af_silenceremove: fix indentation 2021-09-07 19:44:25 +02:00
Paul B Mahol
1d1e8a47b7 avfilter/af_silenceremove: cover default case too 2021-09-07 19:44: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
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
da6975f022 avfilter/af_silenceremove: make window also depends on input sample format 2021-07-25 22:48:25 +02:00
Paul B Mahol
d08deb11d2 avfilter/af_silenceremove: add support for more sample formats 2021-07-25 16:42:58 +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
1b262004d3 avfilter/af_silenceremove: use input timestamp for timestamp recalculation 2019-07-02 19:01:42 +02:00
Paul B Mahol
936376f3f7 avfilter/af_silenceremove: use enum for threshold detection modes 2018-10-15 19:03:01 +02:00
Paul B Mahol
631994b62b avfilter/af_silenceremove: add enum for detection modes 2018-10-15 19:03:01 +02:00
Paul B Mahol
454ed32d56 avfilter/af_silenceremove: add options description 2018-10-15 19:03:01 +02:00
Paul B Mahol
a853623681 avfilter/af_silenceremove: prefer outlink instead of inlink 2018-10-15 19:03:01 +02:00
Paul B Mahol
346b23237b avfilter/af_silenceremove: add mode options
To control how threshold is calculated in multichannel audio.
2018-10-15 19:03:01 +02:00
Paul B Mahol
c07bc1d6ee avfilter/af_silenceremove: add options to keep min duration of silence 2018-10-15 19:03:01 +02:00
Paul B Mahol
3cbf37bf09 avfilter/af_silenceremove: fix max for duration options 2018-10-08 12:22:12 +02:00
Paul B Mahol
2d1594a8d6 avfilter/af_silenceremove: fix possible crash if supplied duration is negative
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-11-27 16:34:09 +01:00
Paul B Mahol
9152bda839 avfilter/af_silenceremove: fix logic error in EOF case
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-11-27 13:38:33 +01:00
Paul B Mahol
7760ed7e96 avfilter/af_silenceremove: set output timestamps
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-05-15 14:29:18 +02:00
Paul B Mahol
47aaebd63e avfilter/af_silenceremove: make size of window user configurable
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-28 12:23:59 +01:00
Paul B Mahol
b841fe002a avfilter/af_silenceremove: lower number of operations in for loop
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-28 12:23:59 +01:00
Paul B Mahol
1809894b2a avfilter/af_silenceremove: add peak detector
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-27 20:49:29 +01: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
5c64ae64bd avfilter/silenceremove: use AV_OPT_TYPE_BOOL for leave_silence option 2015-09-08 23:16:49 +02:00
Paul B Mahol
a0854c084e avfilter: handle error in query_formats() in bunch of filters
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-04-08 13:05:06 +00:00
Michael Niedermayer
1b2390e2bc avfilter/af_silenceremove: remove dead code
Fixes CID1237284

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-09-06 21:36:56 +02:00
Paul B Mahol
422619646e add silenceremove filter
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2014-09-05 17:30:57 +00:00