Commit Graph

116 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
Andreas Rheinhardt 2f62a433f2 avfilter: Deduplicate default video inputs/outputs
Lots of video filters use a very simple input or output:
An array with a single AVFilterPad whose name is "default"
and whose type is AVMEDIA_TYPE_VIDEO; everything else is unset.

Given that we never use pointer equality for inputs or outputs*,
we can simply use a single AVFilterPad instead of dozens; this
even saves .data.rel.ro (8312B here) as well as relocations.

*: In fact, several filters (like the filters in vf_lut.c)
already use the same outputs; furthermore, ff_filter_alloc()
duplicates the input and output pads so that we do not even
work with the pads directly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-07 09:21:13 +02: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
Paul B Mahol 97b5b9dbea avfilter: split negate filter from lut filter
Using luts for negating is suboptimal.

FATE test changes because filter no longer clips values into limited color range.
2021-10-27 11:29:29 +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 412d645ba1 avfilter/vf_lut: Remove empty init function
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-19 04:31:03 +02:00
Andreas Rheinhardt b5be13255f avfilter/vf_lut: Deduplicate AVClasses
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-19 04:30:38 +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 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 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 a00ff56321 avfilter/vf_lut: add support for commands
While here remove excessive log and uninit() call in negate_init().
2021-02-08 16:37:23 +01:00
Paul B Mahol 0f39ef4db2 avfilter/vf_lut: fix regression with >8bit planar filtering 2019-07-05 12:55:02 +02:00
Jun Zhao bbad0bc5ff lavfi/lut: Add slice threading support
Used the command for 1080p h264 clip as follow:

a). ffmpeg -i input -vf lutyuv="u=128:v=128" -f null /dev/null
b). ffmpeg -i input -vf lutrgb="g=0:b=0" -f null /dev/null

after enabled the slice threading, the fps change from:

a). 144fps to 258fps (lutyuv)
b). 94fps  to 153fps (lutrgb)

in Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-06-03 09:38:28 +08:00
Paul B Mahol bd6c57d532 avfilter: add support for gray14 format 2018-09-09 19:10:44 +02:00
Paul B Mahol d2a2bc9a9f avfilter/vf_lut: add support for gray formats
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-12-22 10:57:12 +01:00
Paul B Mahol bac508fec1 avfilter: add support for GRAY9 and GBRAP10 2017-08-07 13:11:09 +02:00
Paul B Mahol aa234698e9 avfilter/vf_lut: make it possible to clip pixel values that are out of valid range
Previous behavior was not useful at all as such pixels where all mapped to 0.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-02-13 22:54:21 +01:00
Paul B Mahol 72864547f9 avfilter/vf_lut: do not always explicitly clip pixels
Old behaviour was not useful at all. New behaviour only emulate
old behaviour with default options.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-02-13 22:54:20 +01:00
Paul B Mahol 8175fb03f0 avfilter/vf_lut: unbreak planar rgb suppot on big-endian 2016-08-31 11:18:40 +02:00
Paul B Mahol 0edfd8e6f4 avfilter/vf_lut: add planar RGB support 2016-08-24 08:30:22 +02:00
Derek Buitenhuis 21f9468402 avutil: Rename FF_CEIL_COMPAT to AV_CEIL_COMPAT
Libav, for some reason, merged this as a public API function. This will
aid in future merges.

A define is left for backwards compat, just in case some person
used it, since it is in a public header.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-01-27 16:36:46 +00:00
Steven Robertson b38e685c05 vf_lut: Add support for RGB48 and RGBA64.
Signed-off-by: Steven Robertson <steven@strobe.cc>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-30 03:55:12 +01:00
Ganesh Ajjanagadde 4c96985af1 all: remove some casts of function pointer to void *
These casts are unnecessary, and may safely be removed.
Found by enabling -Wpedantic on clang 3.7.

Tested with FATE.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-24 15:14:59 -04:00
Paul B Mahol af24763400 avfilter/vf_lut: use AV_OPT_TYPE_BOOL for negate_alpha option
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-09-09 10:01:10 +00:00
Hendrik Leppkes 5d8e836d0e Replace all remaining occurances of step/depth_minus1 and offset_plus1 2015-09-08 17:10:48 +02:00
Paul B Mahol 866404df2d avfilter/vf_lut: fix oversight
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-07-03 16:58:56 +00:00
Michael Niedermayer 8f4cfda972 avutil: add missing bswap include
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-07-03 13:17:57 +02:00
Paul B Mahol b74ebd09c7 avfilter/vf_lut: >8 bit depth planar yuv support
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-07-03 09:29:06 +00:00
Clément Bœsch fd682b1892 avfilter: handle error in query_formats() of a bunch of random video filters 2015-03-16 23:43:12 +01:00
Stefano Sabatini afa3c996fe lavfi/lut: apply minor compute_gammaval709() doxy fix 2015-01-27 11:22:45 +01:00
Yayoi 0463df6f42 avfilter/lut: reduce dereference in the inner loop
For rgb, with a 1080p source, 69 to 74fps on core i5(2 core, 1.8GHz),
and 136 to 160 fps on an core i7(4770R, 3.2Ghz)
Changed the yuv code for consistency, even though the performance
increase is not as obvious as rgb

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-18 21:54:23 +01:00
Peter Ross b186b7131e avfilter/vf_lut: gammaval709()
See http://www.itu.int/rec/R-REC-BT.709
Item 1.2, overall opto-electronic transfer characteristics at source

Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-14 02:55:15 +01:00
Michael Niedermayer 74a8dbe1c4 Merge commit '58400ac133bcfb6bf8196b4e5208bc178307739b'
* commit '58400ac133bcfb6bf8196b4e5208bc178307739b':
  lavfi: name anonymous structs

Conflicts:
	libavfilter/buffersink.c
	libavfilter/f_select.c
	libavfilter/src_movie.c
	libavfilter/vf_drawbox.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_overlay.c
	libavfilter/vf_showinfo.c
	libavfilter/vf_unsharp.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-19 18:20:17 +02:00
Vittorio Giovara 58400ac133 lavfi: name anonymous structs 2014-04-19 16:20:57 +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
Anton Khirnov cd43ca0443 lavfi: do not export the filters from shared objects 2013-10-28 15:29:54 +01: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 67d7ea9825 Merge commit 'faa8245bd45c1a6dd220ba9407ea1c82132aa1ce'
* commit 'faa8245bd45c1a6dd220ba9407ea1c82132aa1ce':
  vf_lut: Constantize

Conflicts:
	libavfilter/vf_lut.c

See: d7e95ccd9f
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-01 13:10:07 +02:00
Diego Elio Pettenò faa8245bd4 vf_lut: Constantize
The pixel format tables are never modified, mark them as constant.

Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2013-08-31 16:13:42 +02:00
Michael Niedermayer e43a0a232d avfilter: fix plane validity checks
Fixes out of array accesses

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-08-03 19:15:46 +02:00
Michael Niedermayer d5e5e73c52 Merge commit 'd371c3c2e2830d9783465ecfe1ab7d93351083b7'
* commit 'd371c3c2e2830d9783465ecfe1ab7d93351083b7':
  vf_frei0r: make config_props work properly when called multiple times.
  vf_gradfun: make config_props work properly when called multiple times.
  vf_lut: make config_props work properly when called multiple times.

Conflicts:
	libavfilter/vf_lut.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-17 10:51:59 +02:00
Anton Khirnov b06848f4de vf_lut: make config_props work properly when called multiple times.
Do not leak the expressions.
2013-05-17 07:42:28 +02:00
Michael Niedermayer af00d68af0 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  vf_pad: use the name 's' for the pointer to the private context
  vf_overlay: use the name 's' for the pointer to the private context
  vf_lut: use the name 's' for the pointer to the private context

Conflicts:
	libavfilter/vf_lut.c
	libavfilter/vf_overlay.c
	libavfilter/vf_pad.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-16 17:03:52 +02:00
Anton Khirnov 8d2565c28b vf_lut: use the name 's' for the pointer to the private context
This is shorter and consistent across filters.
2013-05-16 07:35:59 +02:00
Clément Bœsch 1776177b7f lavfi: replace passthrough_filter_frame with a flag.
With the introduction of AVFilterContext->is_disabled, we can simplify
the custom passthrough mode in filters.

This commit is technically a small compat break, but the timeline was
introduced very recently.

Doxy by Stefano Sabatini.
2013-05-12 13:07:47 +02:00
Clément Bœsch 59d33eafd1 lavfi/lut: use FF_CEIL_RSHIFT for chroma w/h rounding. 2013-05-12 12:59:00 +02:00
Paul B Mahol 94ff68ccb3 lavfi/lut: add support for YUVA422P and YUVA444P
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-05-08 12:48:05 +00:00
Michael Niedermayer a8ff830b79 Merge commit '093804a93cc5da3f95f98265a5df116912443cec'
* commit '093804a93cc5da3f95f98265a5df116912443cec':
  avfilter: Add av_cold attributes to init/uninit functions

Conflicts:
	libavfilter/af_ashowinfo.c
	libavfilter/af_volume.c
	libavfilter/src_movie.c
	libavfilter/vf_lut.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-05 11:42:18 +02:00
Diego Biurrun 093804a93c avfilter: Add av_cold attributes to init/uninit functions 2013-05-04 21:10:05 +02:00