Commit Graph

9523 Commits

Author SHA1 Message Date
Paul B Mahol e2d40cd1d5 avfilter/vf_blend: add softdifference blend mode 2021-09-26 23:34:47 +02:00
Paul B Mahol 53f8a03123 avfilter/vf_colorchannelmixer: add extended preserve color support 2021-09-26 20:27:24 +02:00
Paul B Mahol e4327f97b1 avfilter/vf_colorchannelmixer: simplify code a little 2021-09-26 20:27:24 +02:00
Paul B Mahol 34102f8c07 avfilter/vf_colorlevels: add preserve color option 2021-09-26 20:27:23 +02:00
Paul B Mahol 4727e30ec3 avfilter/vf_colorlevels: refactor code so all components are processed in same loop
This is also faster.
2021-09-26 20:27:23 +02:00
Soft Works 8983c3d7e4 avfilter/elbg: Extend filter to include alpha values in the quantization procedure
Usage example:

ffmpeg -y -loglevel verbose -i "..\fate-suite\apng\o_sample.png" -filter_complex "elbg=pal8=1:use_alpha=1" -frames:v 1 out.png

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-09-26 17:34:08 +02:00
Andreas Rheinhardt f348a967a3 avfilter/formats: Avoid reallocations for video in ff_all_formats()
Up until now, the list of pixfmts is reallocated every time an entry
is added to it; there are currently 196 pixel formats, so this matters:
It causes 5541704 calls to av_realloc_array() in a typical FATE run,
which is the majority for said function (8095768 calls) and even
a large chunk of the calls to av_realloc() itself (12589508 calls).

Fix this by using ff_formats_pixdesc_filter() instead.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-26 12:42:36 +02:00
Andreas Rheinhardt 99feb59cf7 avfilter/formats: Make ff_formats_pixdesc_filter return AVFilterFormats*
Up until now, it has returned the AVFilterFormats list via
an AVFilterFormats** parameter; the actual return value was an int
that was always AVERROR(ENOMEM) on error. The AVFilterFormats**
argument was a pure output parameter which was only documented
by naming the parameter rfmts. Yet nevertheless all callers
initialized the underlying AVFilterFormats* to NULL.

This commit changes this to return a pointer to AVFilterFormats
directly. This is more in line with the API in general, as it
allows to avoid checks for intermediate values.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-26 12:41:33 +02:00
Andreas Rheinhardt aff855148a avfilter/vf_swaprect: Use ff_formats_pixdesc_filter()
Reviewed-by: Nicolas George <george@nsup.org>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-26 12:29:59 +02:00
Paul B Mahol 7b5df3b545 avfilter/vf_colorbalance: fix min/max check that can never be true
While here change doubles to floats.
2021-09-26 11:20:45 +02:00
Paul B Mahol 314ee127f3 avfilter/vf_selectivecolor: reduce number of operations with r/g/b/a pointers 2021-09-26 10:17:17 +02:00
Paul B Mahol 69f4fdd10d avfilter/vf_selectivecolor: refactor some repeating calculations 2021-09-26 10:17:17 +02:00
Paul B Mahol d098e16f09 avfilter/vf_v360: refactor uf/vf scaling 2021-09-24 22:30:37 +02:00
Andreas Rheinhardt 6b2c1d1018 avcodec/elbg: Add flags to avpriv_elbg_do()
This is currently unused and it is only added to enable changes
while maintaining ABI compatibility. The type is uintptr_t in order
to potentially accept a pointer argument.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-24 00:01:27 +02:00
Andreas Rheinhardt 6afad4c7e9 avfilter/vf_elbg: Check call to avpriv_elbg_do()
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-24 00:01:08 +02:00
Paul B Mahol 6a1bda3df9 avfilter/af_silenceremove: improve trimming middle silence 2021-09-23 23:34:45 +02:00
Andreas Rheinhardt d6f4b91ba5 avfilter/framesync: Remove redundant setting of AVClass
Every filter exposing the framesync options via its child_next
callback already calls framesync_preinit() in its preinit callback.
So the filter is already preinited whenever its child_next is called.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-23 21:13:00 +02:00
Andreas Rheinhardt c1b6165b73 avfilter/vf_convolve: Deduplicate framesync auxiliary functions
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-23 21:12:58 +02:00
Andreas Rheinhardt 5e9c7f1355 avfilter/vf_lut3d: Deduplicate options
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-23 21:12:58 +02:00
Andreas Rheinhardt b368a774dd avfilter/framesync: Separate framesync AVClass and auxiliary functions
Will be useful for deduplication.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-23 21:12:37 +02:00
Andreas Rheinhardt 467c6a9146 avfilter/vf_geq: Simplify creating string
Also fixes a Wformat-truncation warning from GCC.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:57:35 +02:00
Andreas Rheinhardt 04a5ffa75f avfilter/vf_xfade: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:57:32 +02:00
Andreas Rheinhardt c87d7c8a81 avfilter/vf_vif: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:57:30 +02:00
Andreas Rheinhardt 2a18ee752d avfilter/vf_threshold: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:57:27 +02:00
Andreas Rheinhardt d1a92cd06f avfilter/vf_ssim: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:57:23 +02:00
Andreas Rheinhardt 63cc7077c1 avfilter/vf_psnr: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:57:20 +02:00
Andreas Rheinhardt b6de483cb4 avfilter/vf_premultiply: Remove always-false format check
These filters use ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:57:17 +02:00
Andreas Rheinhardt 71285daba9 avfilter/vf_midequalizer: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:57:14 +02:00
Andreas Rheinhardt 0fc1abe031 avfilter/vf_maskedthreshold: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:57:09 +02:00
Andreas Rheinhardt e2cd1b3c06 avfilter/vf_maskedminmax: Remove always-false format check
These filters use ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:57:05 +02:00
Andreas Rheinhardt 406552155a avfilter/vf_maskedmerge: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:57:02 +02:00
Andreas Rheinhardt 15778ccce6 avfilter/vf_maskedclamp: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:58 +02:00
Andreas Rheinhardt 095d88d7ca avfilter/vf_libvmaf: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:55 +02:00
Andreas Rheinhardt 14488c26bb avfilter/vf_identity: Remove always-false format check
These filters use ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:52 +02:00
Andreas Rheinhardt 0d3841b59b avfilter/vf_hysteresis: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:49 +02:00
Andreas Rheinhardt bd98d125c8 avfilter/vf_guided: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:46 +02:00
Andreas Rheinhardt caef1172ea avfilter/vf_displace: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:43 +02:00
Andreas Rheinhardt 97454352cd avfilter/vf_convolve: Remove always-false format check
These filters use ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:40 +02:00
Andreas Rheinhardt 9cffffd795 avfilter/vf_bm3d: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:37 +02:00
Andreas Rheinhardt ef09bd65e2 avfilter/vf_blend: Remove always-false format check
This filter uses ff_set_common_formats_from_list().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:33 +02:00
Andreas Rheinhardt 910215b4db avfilter/af_sidechaincompress: Remove always-false samplerate check
This filter uses ff_set_common_all_samplerates().
Also don't overwrite outlink->sample_rate in config_output;
it is harmless, because it is overwritten with the value it already
had, but it is an API violation.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:30 +02:00
Andreas Rheinhardt e1487deb19 avfilter/af_amerge: Remove always-false samplerate check
This filter uses ff_set_common_all_samplerates().
Also don't overwrite outlink->sample_rate in config_output;
it is harmless, because it is overwritten with the value it already
had, but it is an API violation.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:25 +02:00
Andreas Rheinhardt 789de76e21 avfilter/af_agate: Remove always-false samplerate check
This filter uses ff_set_common_all_samplerates().
Also don't overwrite outlink->sample_rate in config_output;
it is harmless, because it is overwritten with the value it already
had, but it is an API violation.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:21 +02:00
Andreas Rheinhardt 7d99507838 avfilter/af_sidechaincompress: Honour query_formats API, fix segfault
Just like the sidechaingate filter, the sidechaincompress filter
overwrote the channel layout and channel count of its output in
its config_output callback to match the channel layout of its main
input instead of linking the main input and its output together
in its query_formats callback.

This is an API violation that can lead to segfaults, as in the
following filtergraph, where stereotools rightly expects stereo,
yet receives only mono:
[in]aformat=channel_layouts=mono,aformat=channel_layouts=stereo|mono[out];\
[out][in2]sidechaincompress,stereotools

Fix this by linking the channel layouts of the main input and the output
in query_formats and remove the code overwriting it in config_output.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56:17 +02:00
Andreas Rheinhardt 80d32e0f7e avfilter/af_agate: Honour query_formats API, fix segfault
The sidechaingate filter wants its main input and its (only) output
to have the same channel layout and number of channels; yet it does
not link them in its query_formats callback. Instead it sets the
outlink to only accept the first offered choice for the main input's
channel layout and then sets both inputs to independently accept
any channel counts. The config_output callback then overwrote the
outlink's channel layout and channels properties with the main input's,
even though they may differ in case the first offered choice for
the main input's channel layout turns out not to be the final one.

Consider e.g. the following filtergraph:
[in]aformat=channel_layouts=mono,aformat=channel_layouts=stereo|mono[out];\
[out][in2]sidechaingate,stereotools
The two aformats ensure that the first offered channel layout (stereo)
will not be chosen for the input; yet it is the only offered channel
layout for the output of sidechaingate and will therefore be chosen
by the query_formats framework. Because the sidechaingate outputs
interleaved doubles which stereotools expects the output of
sidechaingate appears to be suitable as input for stereotools without
further conversions. Yet stereotools actually only receives a mono frame
and therefore overreads its input buffer which leads to segfaults;
it can also lead to heap corruption because there can be writes beyond
the end of the buffer, too.

Fix this by linking the channel layouts of the main input and the output
in query_formats and remove the code overwriting it in config_output.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-21 17:56: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
Paul B Mahol 59719a905c avfilter/avf_showspectrum: rewrite frequency log axis/bin scaling 2021-09-20 11:14:53 +02:00
Andreas Rheinhardt 896c11687e avcodec/elbg: Add persistent ELBGContext
It will be used in future commits to avoid having to allocate and free
all the buffers used.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 04:38:45 +02:00
Andreas Rheinhardt 8bfd466c9e avfilter/vf_elbg: Rename ELBGContext->ELBGFilterContext
The former name will be used for a context for avpriv_do_elbg().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 04:38:12 +02:00
Andreas Rheinhardt 05ccfcb7b0 avcodec/elbg: Merge avpriv_init_elbg() into avpriv_do_elbg()
These functions are always called directly after another with
the exact same arguments. This avoids exporting a symbol;
it also avoids having to perform two calls for every caller.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 04:09:22 +02:00