Commit Graph

110 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 f8503b4c33 avutil/internal: Don't auto-include emms.h
Instead include emms.h wherever it is needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-04 11:04:45 +02:00
Andreas Rheinhardt 19ffa2ff2d avfilter: Remove unnecessary formats.h inclusions
A filter needs formats.h iff it uses FILTER_QUERY_FUNC();
since lots of filters have been switched to use something
else than FILTER_QUERY_FUNC, they don't need it any more,
but removing this header has been forgotten.
This commit does this; files with formats.h inclusion went down
from 304 to 139 here (it were 449 before the preceding commit).

While just at it, also improve the other headers a bit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-07 09:21:13 +02: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
Andreas Rheinhardt a7ccfdc0d7 avfilter/vf_hqdn3d: Fix left-shift of negative numbers
Affected filter-hqdn3d and filter-hqdn3d-sample FATE-tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-11-09 17:39:00 +01:00
Andreas Rheinhardt 40e6575aa3 all: Replace if (ARCH_FOO) checks by #if ARCH_FOO
This is more spec-compliant because it does not rely
on dead-code elimination by the compiler. Especially
MSVC has problems with this, as can be seen in
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/296373.html
or
https://ffmpeg.org/pipermail/ffmpeg-devel/2022-May/297022.html

This commit does not eliminate every instance where we rely
on dead code elimination: It only tackles branching to
the initialization of arch-specific dsp code, not e.g. all
uses of CONFIG_ and HAVE_ checks. But maybe it is already
enough to compile FFmpeg with MSVC with whole-programm-optimizations
enabled (if one does not disable too many components).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-06-15 04:56:37 +02:00
Andreas Rheinhardt 31a373ce71 avfilter: Reindentation after query_formats changes
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-05 18:58:29 +02:00
Andreas Rheinhardt 315e9e121c avfilter/vf_hqdn3d: Use formats list instead of query function
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-05 18:58:27 +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 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
Valerii Zapodovnikov ff0d70c8a9 avfilter/vf_hqdn3d: fix left shift of negative numbers
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-06-05 16:59:37 +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 8c2f81a17a avfilter/vf_hqdn3d: add support for commands 2019-11-29 17:28:59 +01:00
Paul B Mahol 3a61297a67 avfilter/vf_hqdn3d: add support for 12bit and 14bit yuv formats 2019-11-29 17:28:59 +01:00
Jun Zhao da0c0c7247 lavfi/hqdn3d: add slice thread optimization
Enabled one thread per plane, used the test command for 1080P video
(YUV420P format) as follow:

ffmpeg -i 1080p.mp4 -an -vf hqdn3d -f null /dev/nul

This optimization improved the performance about 30% in 1080P YUV420P
case (from 110fps to 143fps), also pass the framemd5 check and FATE.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Moritz Barsnick <barsnick@gmx.net>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-10-10 09:33:09 +08:00
Clément Bœsch 8ef57a0d61 Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb':
  cosmetics: Fix spelling mistakes

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +02:00
Vittorio Giovara 41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +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
Ganesh Ajjanagadde 8507b98c10 avfilter,swresample,swscale: use fabs, fabsf instead of FFABS
It is well known that fabs and fabsf are at least as fast and sometimes
faster than the FFABS macro, at least on the gcc+glibc combination.
For instance, see the reference:
http://patchwork.sourceware.org/patch/6735/.
This was a patch to glibc in order to remove their usages of a macro.

The reason essentially boils down to fabs using the __builtin_fabs of
the compiler, while FFABS needs to infer to not use a branch and to
simply change the sign bit. Usually the inference works, but sometimes
it does not. This may be easily checked by looking at the asm.

This also has the added benefit of reducing macro usage, which has
problems with side-effects.

Note that avcodec is not handled here, as it is huge and
most things there are integer arithmetic anyway.

Tested with FATE.

Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-22 16:13:26 -04:00
Hendrik Leppkes 151aa2ebff Merge commit '2268db2cd052674fde55c7d48b7a5098ce89b4ba'
* commit '2268db2cd052674fde55c7d48b7a5098ce89b4ba':
  lavu: Drop the {minus,plus}1 suffix from AVComponentDescriptor fields

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-09-08 16:35:28 +02:00
Vittorio Giovara 2268db2cd0 lavu: Drop the {minus,plus}1 suffix from AVComponentDescriptor fields
The new fields can be accessed directly and are more intelligible.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-09-07 12:37:47 +02:00
Michael Niedermayer 4240e6a921 avfilter/vf_hqdn3d: Initialize the whole LUT
With bps > 8 more than 255..255 are used
The initialized table content is left unchanged,
But it could also be adjusted for the slight difference of
the maximum

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-27 05:18:55 +02: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
Clément Bœsch 55feff57ce avfilter/hqdn3d: an invalid bit depth means a bug, not invalid read data
This code looks clumsy, and an assert would probably be more welcome.
2015-02-08 17:16:51 +01:00
Michael Niedermayer ccccfb59b1 Merge commit '22b985d59c007c4422aefe3ef3fca0aa0daafa9f'
* commit '22b985d59c007c4422aefe3ef3fca0aa0daafa9f':
  hqdn3d: check memory allocations and propagate errors

Conflicts:
	libavfilter/vf_hqdn3d.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-29 22:43:36 +01:00
Vittorio Giovara 22b985d59c hqdn3d: check memory allocations and propagate errors 2015-01-29 17:33:38 +00:00
Michael Niedermayer 14e2e40f3b avfilter/vf_hqdn3: use av_malloc_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-14 06:17:05 +02:00
Michael Niedermayer e3c93f1f84 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  avfilter: Add missing emms_c when needed

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-03-05 13:51:44 +01:00
Luca Barbato e995cf1bcc avfilter: Add missing emms_c when needed
Arch specific calls should have an emms_c following to keep the cpu
state consistent.

Reported-By: wm4
CC: libav-stable@libav.org
2014-03-05 11:00:05 +01: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
Paul B Mahol a8e00cf926 avfilter: remove redundant use of AV_NE() macro
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-11 15:05:21 +00:00
Paul B Mahol 622c977437 lavfi/hqdn3d: make use of AVFILTER_DEFINE_CLASS
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-05-27 10:58:45 +00:00
Michael Niedermayer 1e9a050bc0 Merge commit '16a645adeb758207346a4bbf66766f02734c461e'
* commit '16a645adeb758207346a4bbf66766f02734c461e':
  vf_pixdesctest: make config_props work properly when called multiple times.
  vf_hqdn3d: make config_props work properly when called multiple times.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-17 11:41:14 +02:00
Anton Khirnov 3ba35a346c vf_hqdn3d: make config_props work properly when called multiple times.
Do not leak all the temp buffers.
2013-05-17 07:44:12 +02:00
Michael Niedermayer df003cbb56 Merge commit '4753f802c00853859b7b4b8fdb79c35e082cb7f8'
* commit '4753f802c00853859b7b4b8fdb79c35e082cb7f8':
  vf_libopencv: use the name 's' for the pointer to the private context
  vf_hqdn3d: use the name 's' for the pointer to the private context
  vf_hflip: use the name 's' for the pointer to the private context
  vf_gradfun: use the name 's' for the pointer to the private context

Conflicts:
	libavfilter/vf_gradfun.c
	libavfilter/vf_hflip.c
	libavfilter/vf_hqdn3d.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-05-16 16:45:43 +02:00
Anton Khirnov 56e4ce0d13 vf_hqdn3d: use the name 's' for the pointer to the private context
This is shorter and consistent across filters.
2013-05-16 07:35:48 +02:00
Clément Bœsch 0122300c86 lavfi/hqdn3d: restore timeline feature. 2013-05-12 13:07:47 +02:00
Clément Bœsch 0652111833 lavfi/hqdn3d: use macros instead of hardcoded indexes. 2013-05-12 13:07:47 +02:00
Clément Bœsch 50e66726a2 lavfi: use ceil right shift for chroma width/height.
This should fix several issues with odd dimensions inputs.

lut, vflip, pad and crop video filters also need to be checked for such
issues. It's possible sws is also affected.
2013-05-10 17:20:06 +02: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
Clément Bœsch 039c2b7828 lavfi/hqdn3d: remove timeline flag.
The filter stores some temporal data, which needs to be done with the
passthrough callback system when timeline is enabled. Until then,
timeline support is disabled.
2013-04-26 21:27:02 +02:00
Clément Bœsch fdd93eabfb lavfi: add timeline support.
Flag added in a few simple filters. A bunch of other filters can likely
use the feature as well.
2013-04-23 01:02:27 +02:00
Michael Niedermayer 3dedcef8b8 avfilter: add missing AV_OPT_FLAG_FILTERING_PARAM
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-12 15:47:16 +02:00
Anton Khirnov d69a4177b9 lavfi: remove now unused args parameter from AVFilter.init
Conflicts:

	libavfilter/avfilter.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_lut.c
	libavfilter/vf_select.c
	libavfilter/vf_setpts.c
	libavfilter/vsrc_color.c
	libavfilter/vsrc_movie.c

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-12 11:54:39 +02:00
Michael Niedermayer f780a90355 Merge commit '8c747d46f721cffa8ea51990805ad1d3a3a4fd0a'
* commit '8c747d46f721cffa8ea51990805ad1d3a3a4fd0a':
  vf_hqdn3d: switch to an AVOptions-based system.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-04-10 21:14:30 +02:00