Commit Graph

59 Commits

Author SHA1 Message Date
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 52ebb15ec1 avfilter/af_afade: add 4 more curves 2023-08-24 22:20:06 +02:00
Paul B Mahol c44fe10160 avfilter/af_afade: stop using ff_outlink_get_status on inputs 2023-06-17 22:36:31 +02:00
Paul B Mahol 2a74826b02 avfilter/*xfade: reduce memory consumption
There is no always need for new buffers.
2023-05-14 23:35:50 +02:00
Paul B Mahol c94988a781 avfilter/af_afade: add options to control unity/silence gains 2023-01-03 10:25:06 +01: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
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 ba90e306c2 avfilter/af_afade: Use formats list instead of query function
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-05 18:01:02 +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
Andreas Rheinhardt 1f387ae4cb avfilter/af_afade: Remove impossible branch
Also don't call ff_inlink_queued_samples() unnecessarily often.

Fixes Coverity issue 1427665.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-02 16:29:11 +02:00
Andreas Rheinhardt 9985ea7651 avfilter/af_afade: Remove redundant checks and assignments
The acrossfade filter uses the ff_set_common_* functions in its
query_formats(), so that the formats, the sample rates as well as
the channel layouts and counts of all links coincide.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:55:47 +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 a2f9270f1c avfilter/af_afade: remove uneeded '.' from durations in options 2021-02-21 13:42:40 +01:00
Paul B Mahol fc50a8de55 avfilter/af_afade: add support for commands to afade filter 2020-12-11 23:02:03 +01:00
Paul B Mahol e3081d6f4f avfilter/af_afade: add sinc curve types 2020-11-18 11:36:53 +01:00
Paul B Mahol 86a42e954e avfilter/af_afade: start crossfading only when first stream reached end 2019-10-31 10:23:59 +01:00
Paul B Mahol 89389b7ed4 avfilter/af_afade: check for eof after crossfade later
Fixes memleaks and #8346
2019-10-30 19:07:19 +01:00
Paul B Mahol 29dac2927f avfilter/af_afade: make sure that in is available 2019-10-16 00:59:30 +02:00
Paul B Mahol e1b89c76f6 avfilter/af_afade: fix heap-buffer overflow
Fixes #8276
2019-10-15 16:55:13 +02:00
Gyan Doshi 3224d6691c avfilter/afade+acrossfade: allow skipping fade on inputs
New fade curve value 'nofade' passes audio samples as-is.
Primarily useful in carrying out acrossfade without fades.
2019-01-24 22:08:34 +05:30
Marton Balint aecd63b926 avfilter/af_afade: fix duration maximum
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-11-15 22:16:32 +01:00
Paul B Mahol 63fbec7477 avfilter/af_afade: remove unused code 2018-11-04 15:01:56 +01:00
Paul B Mahol c8625e5c6f avfilter/af_afade: do not use framequeue directly 2018-11-03 18:24:35 +01:00
Marton Balint 0e9a09793a avfilter/af_afade: fix crossfade duration maximum value
Signed-off-by: Marton Balint <cus@passwd.hu>
2018-10-07 20:26:28 +02:00
Paul B Mahol 3d308746eb avfilter/af_afade: add logistic sigmoid curve 2018-10-07 17:38:22 +02:00
Paul B Mahol 20a3c4f606 avfilter: forward status back in some filters that missed it
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-05-05 21:32:33 +02:00
Paul B Mahol 8088b5d69c avfilter/af_afade: acrossfade: switch to activate
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-01-18 16:26:14 +01:00
Paul B Mahol 88cbd25b19 avfilter: pass outlink to ff_get_audio_buffer()
This is more correct.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-01-03 22:52:47 +01:00
Paul B Mahol 6111ac73d9 avfilter/af_afade: fix fading very long durations
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-05-17 22:59:11 +02:00
Paul B Mahol ed93ed5ee3 avfilter: don't anonymously typedef structs
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-05-13 11:39:28 +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
Paul B Mahol ce404b4d7c avfilter/af_afade: do not duplicate curve option
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-01-27 11:11:51 +01:00
Ganesh Ajjanagadde 9ee1feaa7c avfilter/af_afade: improve accuracy and speed of gain computation
Gain computation for various curves was being done in a needlessly
inaccurate fashion. Of course these are all subjective curves, but when
a curve is advertised to the user, it should be matched as closely as
possible within the limitations of libm. In particular, the constants
kept here were pretty inaccurate for double precision.

Speed improvements are mainly due to the avoidance of pow, the most
notorious of the libm functions in terms of performance. To be fair, it
is the GNU libm that is among the worst, but it is not really GNU libm's fault
since others simply yield a higher error as measured in ULP.

"Magic" constants are also accordingly documented, since they take at
least a minute of thought for a casual reader.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-26 09:20:46 -05:00
Paul B Mahol 04a7ce1a8c avfilter/af_afade: add missing fifo write for second stream
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-11-23 10:37:51 +01:00
Justin Greer 9c168f9a22 avfilter/af_afade: fix start of fade out
Fixes #4919
2015-10-08 23:09:25 +02: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 1435587373 avfilter/acrossfade: use AV_OPT_TYPE_BOOL for overlap option 2015-09-09 01:32:30 +02:00
Paul B Mahol 4a2836eaf3 avfilter: add acrossfade filter
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-07-26 21:54:13 +00:00
Paul B Mahol eb85060b84 avfilter/af_afade: add couple of more curves
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-06-15 20:55:05 +00:00
Paul B Mahol 20ee65ef73 avfilter/af_afade: use av_clipd() instead of nested FFMAX & FFMIN
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-06-14 17:08:43 +00: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
Stefano Sabatini 7ba2e134fb lavfi/afade: fix cur_sample computation
Use the correct timebase conversion.
2014-10-21 13:28:08 +02:00
Michael Niedermayer 325f6e0a97 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  lavfi: do not export the filters from shared objects

Conflicts:
	libavfilter/af_amix.c
	libavfilter/af_anull.c
	libavfilter/asrc_anullsrc.c
	libavfilter/f_select.c
	libavfilter/f_settb.c
	libavfilter/split.c
	libavfilter/src_movie.c
	libavfilter/vf_aspect.c
	libavfilter/vf_blackframe.c
	libavfilter/vf_colorbalance.c
	libavfilter/vf_copy.c
	libavfilter/vf_crop.c
	libavfilter/vf_cropdetect.c
	libavfilter/vf_drawbox.c
	libavfilter/vf_format.c
	libavfilter/vf_framestep.c
	libavfilter/vf_frei0r.c
	libavfilter/vf_hflip.c
	libavfilter/vf_libopencv.c
	libavfilter/vf_lut.c
	libavfilter/vf_null.c
	libavfilter/vf_overlay.c
	libavfilter/vf_scale.c
	libavfilter/vf_transpose.c
	libavfilter/vf_unsharp.c
	libavfilter/vf_vflip.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-29 11:58:11 +01:00
Paul B Mahol 848a1e6738 avfilter/af_afade: use the name 's' for the pointer to the private context
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-10-02 11:37:52 +00:00
Paul B Mahol b211607b5c avfilter: various cosmetics
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-12 14:01:43 +00:00
Paul B Mahol 1e89f74902 lavfi/afade: use av_rescale()
Should not make a difference, but its good idea.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-07-10 19:13:28 +00:00
Paul B Mahol 8caf2da320 lavfi/afade: add timeline support
For correct precision one may need to use asetnsamples.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-05-25 13:20:27 +00:00