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

61 Commits

Author SHA1 Message Date
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
c54c8836cf avfilter/af_afir: Free inpads' names generically
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-22 16:13:34 +02:00
Andreas Rheinhardt
515e7fbce1 avfilter/avfilter: Remove unused feature to add pads in the middle
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-17 21:20:59 +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
Andreas Rheinhardt
1be3d8a0cb avcodec/avcodec: Stop including channel_layout.h in avcodec.h
Also include channel_layout.h directly wherever used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 11:14:31 +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
9860777516 avfilter/af_aiir: remove unused variable 2020-10-18 22:56:23 +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
Andreas Rheinhardt
4c5d6e87ac avfilter/af_afir: Avoid allocating AVFilterPad names
If the names are always the same, they need not be duplicated; doing so
saves allocations, checks for the allocations as well as frees.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-26 23:52:56 +02:00
Paul B Mahol
e2589ac650 avfilter/af_afir: make use of vector_fmac_scalar() too 2020-08-23 17:52:58 +02:00
Andreas Rheinhardt
3a0f080ffa avfilter/af_afir: Fix leak of AVFilterChannelLayout in case of error
If an error happens between the allocation of an AVFilterChannelLayout
and its usage (which involves attaching said object to a more permanent
object), the channel layout array leaks. This can simply be fixed by
making sure that nothing is between the allocation and the
aforementioned usage.

Fixes Coverity issue #1250334.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-20 00:24:03 +02:00
Jun Zhao
ff8329a730 lavfi/afir: fix vpad.name leak
Fix vpad.name leak in error path, move the vpad related operation
only if enabled show IR frequency response.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-05-30 19:02:34 +08:00
Paul B Mahol
2a9a52b913 avfilter/af_afir: check if frame clone is set 2020-01-14 16:52:07 +01:00
Paul B Mahol
52bf43eb49 avfilter/af_afir: add support for switching impulse response streams at runtime
Currently, switching is not free of artifacts, to be resolved later.
2020-01-10 13:14:54 +01:00
Paul B Mahol
03a7240a73 avfilter/af_afir: add support for even smaller partition sizes 2020-01-10 13:05:21 +01:00
Paul B Mahol
e364fe4cca avfilter/af_afir: split input frames from impulse response frames 2020-01-10 12:43:18 +01:00
Paul B Mahol
f2e2456294 avfilter/af_afir: adjust min partition size
Minimal value allowed by our FFT is 16 thus min partition size is 8.
2019-01-05 09:40:41 +01:00
James Almer
82043dfd2e avfilter/af_afir: split off fcmul_add into a DSP context
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-01-03 10:12:18 -03:00
Paul B Mahol
86555a2fbf avfilter/af_afir: fix overhead for small partitions 2018-12-31 18:07:46 +01:00
Paul B Mahol
ea3a980a61 avfilter/af_afir: do not over allocate fft buffer 2018-12-30 22:11:46 +01:00
Paul B Mahol
ba3d983c95 avfilter/af_afir: stop using as much threads as stream have it 2018-12-30 17:50:44 +01:00
Paul B Mahol
72270d5bd0 avfilter/af_afir: optimize code a little more
Avoid memset.
2018-12-30 17:50:44 +01:00
Paul B Mahol
a53a9f1c8d avfilter/af_afir: implement non-uniform partitioned convolution
Using multiple frequency delay lines.
2018-12-30 13:40:29 +01:00
Paul B Mahol
300dc45fdc avfilter/af_afir: properly split IR into multiple segments 2018-12-29 10:57:58 +01:00
Paul B Mahol
3c3eb4930e avfilter/af_afir: make part_index values per channel 2018-12-29 10:46:25 +01:00
Paul B Mahol
31c9d693aa avfilter/af_afir: make number of segments extendable 2018-12-29 10:39:19 +01:00
Paul B Mahol
6095356d5b avfilter/af_afir: use AVFrame for coeff too 2018-12-29 10:17:39 +01:00
Paul B Mahol
1ba909fabe avfilter/af_afir: use segment pointer 2018-12-29 08:35:23 +01:00
Paul B Mahol
30bf54b9f3 avfilter/af_afir: introduce uninit_segment() and use it 2018-12-29 08:35:23 +01:00
Paul B Mahol
8007e8fc67 avfilter/af_afir: fix minp/maxp range and change default value for maxp 2018-12-29 08:35:23 +01:00
Paul B Mahol
c343e81ffd avfilter/af_afir: introduce init_segment() and use it 2018-12-29 08:35:23 +01:00
Paul B Mahol
e57053417a avfilter/af_afir: move allocation stuff where it belongs 2018-12-29 08:35:23 +01:00
Paul B Mahol
7312e027d6 avfilter/af_afir: introduce AudioFIRSegment structure and use it 2018-12-29 08:35:23 +01:00
Paul B Mahol
dbf43ace21 afilter/af_afir: remove invalid delay 2018-12-27 18:02:31 +01:00
Paul B Mahol
f266d2ac90 avfilter/af_afir: remove not needed nb_samples from filter context 2018-12-27 14:11:12 +01:00
Paul B Mahol
ff0b4d5af7 avfilter/af_afir: remove not needed operations 2018-12-27 12:55:07 +01:00
Paul B Mahol
d702600350 avfilter/af_afir: remove dead store variable 2018-12-26 22:30:10 +01:00
Paul B Mahol
8443462e4a avfilter/af_afir: remove unused variable 2018-12-26 21:57:59 +01:00
Paul B Mahol
29fdaaa80d avfilter/af_afir: fix hang because video is first requested 2018-11-09 18:51:21 +01:00
Paul B Mahol
16d91b7e99 avfilter/af_afir: kill useless code which increases latency for no reason 2018-11-09 10:40:16 +01:00
Paul B Mahol
36348d77b8 avfilter/af_afir: add minp/maxp options to control latency and speed 2018-11-08 22:07:14 +01:00
Paul B Mahol
698e67bef2 avfilter/af_afir: do not leak frame and clear pointer to freed frame 2018-11-08 21:34:49 +01:00
Paul B Mahol
1d9fe1fdf6 avfilter/af_afir: implement rate option 2018-11-08 13:05:08 +01:00
Paul B Mahol
8dc5eb43b0 avfilter/af_afir: return early when giving video frame 2018-11-08 13:05:08 +01:00
Paul B Mahol
fcbde5e6a4 avfilter/af_afir: remove redundant code 2018-11-08 11:14:04 +01:00
Paul B Mahol
0939c33b54 avfilter/af_afir: calculate group delay too 2018-10-21 12:47:07 +02:00
Paul B Mahol
7a6d88ee62 avfilter/af_afir: remove again option, merge it with gtype 2018-10-10 20:04:25 +02:00
Paul B Mahol
0baca07759 avilter/af_afir: add irfmt option 2018-10-04 23:51:22 +02:00
Paul B Mahol
4901fa1fb8 avfilter/af_afir: use internal lavfi queue 2018-10-04 12:10:20 +02:00