Commit Graph

50 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
Paul B Mahol 7e1d474021 avfilter/af_compand: simplify frame allocation 2023-02-08 18:56: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
Andreas Rheinhardt 4bcb75ebae avfilter/af_compand: 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
Andreas Rheinhardt 1ea3650823 Replace all occurences of av_mallocz_array() by av_calloc()
They do the same.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 01:03:52 +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
Anton Khirnov f30a41a608 Stop hardcoding align=32 in av_frame_get_buffer() calls.
Use 0, which selects the alignment automatically.
2020-05-22 14:38:57 +02:00
Paul B Mahol 1232e67b16 avfilter/af_compand: change error condition into warning 2019-08-28 15:28:53 +02: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 13f4d077ed avfilter/af_compand: change default attack to 0
Fixes many distortions.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-05-15 14:29:18 +02:00
Paul B Mahol 69b83f5992 avfilter/af_compand: fix default companding to avoid clipping
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-05-14 11:59:04 +02:00
Michael Niedermayer 88612f8db3 avfilter/af_compand: Check av_strtok() for failure
Fixes CID1396256

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-04-20 02:19:21 +02:00
Ganesh Ajjanagadde db1a642cd2 all: move ff_exp10, ff_exp10f, ff_fast_powf to lavu/ffmath.h
The idea is to use ffmath.h for internal implementations of math functions.
Currently, it is used for variants of libm functions, but is by no means
limited to such things.

Note that this is not exported; use lavu/mathematics for such purposes.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanag@gmail.com>
2016-03-22 10:15:31 -07:00
Ganesh Ajjanagadde 421679dbf7 lavfi/af_compand: replace pow(10,x) by ff_exp10(x)
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-12-25 10:48:18 -08:00
Paul B Mahol b2517b02d9 avfilter/af_compand: do not clip; allow >0dB curve points
Do not clip output samples, so that clipping can be handled by other filters.
Alow setting curve points above 0dB. This is useful when operating with floats.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-12-02 23:41:26 +01:00
Ganesh Ajjanagadde 5a41a5a4f5 avfilter/af_compand: use hypot()
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-11-30 18:29:29 -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
Paul B Mahol 297df52f30 avfilter/af_compand: fix clipping with default options
Decays and attacks where by default set only for first channel
which caused poor defaults to be used which produced clipping
on any higher channel.

Reported-by: lachs0r
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-07-17 11:29:29 +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
Michael Niedermayer e1f729d977 Merge commit 'd3cfd7aff86ee3d449ca68aba21d67b9b2136a9b'
* commit 'd3cfd7aff86ee3d449ca68aba21d67b9b2136a9b':
  af_compand: make sure request_frame always outputs at least one frame

See: 6b68e2a43b
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-08 13:48:26 +02:00
Andrew Kelley d3cfd7aff8 af_compand: make sure request_frame always outputs at least one frame
This fixes a segmentation fault because request_frame in fifo.c assumes
that the call to ff_request_frame will populate fifo->root.next.
Before, it was possible for request_frame in af_compand to not do this,
resulting in a null pointer access. Now, request_frame in af_compand
always will return at least one frame or an error, as per the API
specifications in avfilter.h for request_frame.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2014-07-08 07:54:00 +00:00
Michael Niedermayer 6c23a85000 avfilter/af_compand: Silence "may be used uninitialized" warning
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-08 06:53:16 +02:00
Anton Khirnov bc6461c286 af_compand: replace strtok_r() with av_get_token() 2014-02-28 21:55:46 +01:00
Paul B Mahol 9f2a3bcee7 avfilter: remove superflous lines
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2014-02-26 16:37:59 +00:00
Paul B Mahol a2e4b4e968 avfilter/af_compand: some more cosmetics to decrease difference with qatar
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2014-02-26 15:03:09 +00:00
Michael Niedermayer c62d83a5e7 avfilter/af_compand: more cosmetics from libavfilter/af_compand_fork.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 13:12:38 +01:00
Michael Niedermayer 05412f4cd4 avfilter/af_compand: cosmetics from libavfilter/af_compand_fork.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 13:00:09 +01:00
Michael Niedermayer 5e02ff3e3d avfilter/af_compand: switch defaults to libavfilter/af_compand_fork.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 13:00:09 +01:00
Michael Niedermayer 619d6b8f55 avfilter/af_compand: "use local variable for channels" from libavfilter/af_compand_fork.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 13:00:09 +01:00
Michael Niedermayer e509df4bc8 avfilter/af_compand: error checks from libavfilter/af_compand_fork.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 13:00:09 +01:00
Michael Niedermayer 4b87975147 avfilter/af_compand: pts init code from libavfilter/af_compand_fork.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 12:46:04 +01:00
Michael Niedermayer 5c78fe08b0 avfilter/af_compand: cosmetics and doxy comment from libavfilter/af_compand_fork.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 12:42:47 +01:00
Michael Niedermayer 66ad3292eb avfilter/af_compand: add Andrew Kelley to the copyright
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 12:40:33 +01:00
Michael Niedermayer 86a191e25b avfilter/af_compand: merge avframe code from af_compand_fork
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 12:33:28 +01:00
Michael Niedermayer 27ba05adbc avfilter/af_compand: merge uninit() calls on error from af_compand_fork.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 12:11:33 +01:00
Michael Niedermayer 8b80485960 avfilter/af_compand: also support '|' as seperator
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 12:04:00 +01:00
Michael Niedermayer 22307f170f avfilter/af_compand: whitespace changes from af_compand_fork
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-02-26 11:41:36 +01:00
Andrew Kelley 738f83582a lavfi: add compand audio filter
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2014-02-26 08:09:58 +01:00
Andrew Kelley 9e329185d7 avfilter/af_compand: fix invalid read
Fixes #3383.
2014-02-25 19:00:14 +00:00
Paul B Mahol 709746b6af avfilter/af_compand: do not leak frames on error
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2014-02-15 11:38:32 +00: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 60abdb6c17 avfilter/af_aecho & af_compand: use extended_data
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-15 12:10:12 +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
Michael Niedermayer 64c54f8333 avfilter/af_compand: silence "maybe uninitialized" warnings
if channels is 0 it actually would be uninitialized, thus an assert with comment is added

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-07 03:49:01 +02:00
Michael Niedermayer 1bbf94d84f avfilter/af_compand: %f is for printing doubles
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-07-30 22:24:42 +02:00
Paul B Mahol 6b68e2a43b lavfi: add compand filter
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-07-29 19:11:50 +00:00