Commit Graph

44 Commits

Author SHA1 Message Date
Anton Khirnov 1e7d2007c3 all: use designated initializers for AVOption.unit
Makes it robust against adding fields before it, which will be useful in
following commits.

Majority of the patch generated by the following Coccinelle script:

@@
typedef AVOption;
identifier arr_name;
initializer list il;
initializer list[8] il1;
expression tail;
@@
AVOption arr_name[] = { il, { il1,
- tail
+ .unit = tail
}, ...  };

with some manual changes, as the script:
* has trouble with options defined inside macros
* sometimes does not handle options under an #else branch
* sometimes swallows whitespace
2024-02-14 14:53:41 +01:00
Paul B Mahol e506ea3ce1 avfilter: use ff_inlink_make_frame_writable() 2023-02-12 13:32:00 +01:00
Paul B Mahol 5d3f0226ad avfilter/avf_avectorscope: add anti-aliased line drawing mode 2023-01-09 18:07:05 +01:00
Paul B Mahol 2324b917fc avfilter/avf_avectorscope: simplify code a little 2022-11-27 19:53:16 +01:00
Paul B Mahol 9c8b977c1e avfilter/avf_avectorscope: fix crash when using vflip filter 2022-11-25 19:40:11 +01:00
Anton Khirnov 7d13c5dff0 lavfi/avf_avectorscope: set frame durations
The filter is supposed to produce CFR output.
2022-10-04 11:55:03 +02:00
Paul B Mahol 3ce4e08089 avfilter/avf_avectorscope: request new frames only when needed 2022-04-30 16:20:38 +02:00
Paul B Mahol d41f85235d avfilter/avf_avectorscope: set time_base to outlink
And rescale timestamps.
2022-04-18 20:24:54 +02: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
Paul B Mahol faac31cc86 avfilter/avf_avectorscope: make frame writable before writing to it 2022-03-04 13:54:12 +01: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
Paul B Mahol 0b150e4f61 avfilter/avf_avectorscope: fix zoom 0 mode with nonlinear scale 2021-09-19 13:49:55 +02:00
Paul B Mahol 7747ab7ded avfilter/avf_avectorscope: add support for commands 2021-09-19 13:49:55 +02:00
Paul B Mahol 99d71c28d4 avfilter/avf_avectorscope: add slice threading for fade function 2021-09-19 13:14:11 +02:00
Paul B Mahol 4f7f046683 avfilter/avf_avectorscope: add ultra fast path when slow fading is disabled 2021-09-19 12:34:45 +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 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
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
Paul B Mahol f9897eda43 avfilter/avf_avectorscope: check if clone frame is set 2020-01-14 16:52:07 +01:00
Paul B Mahol b16806b09d avfilter/avf_avectorscope: make use of av_rescale 2019-05-28 10:43:25 +02:00
Paul B Mahol 21b1f08ea2 avfilter/avf_avectorscope: switch to activate 2019-04-29 12:52:50 +02:00
Paul B Mahol 396c019795 avfilter/avf_avectorscope: disable mirroring
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-04-18 18:14:35 +02:00
Michael Niedermayer 173939259a avfilter/avf_avectorscope: Fix ;;
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-02-15 13:48:25 +01:00
Paul B Mahol afd2bf54c3 avfilter/avf_avectorscope: add swap and mirror options
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-11-21 12:27:03 +01:00
Paul B Mahol a5e6cd79ec avfilter/avf_avectorscope: fix mistake in previous commit
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-09-05 11:55:23 +02:00
Paul B Mahol 2c10f054c2 avfilter/avf_avectorscope: add possibility to auto zoom
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-09-05 11:43:49 +02:00
Paul B Mahol f85cad799b avfilter: properly set SAR for A->V filters
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-06-13 15:10:58 +02:00
Michael Niedermayer 362f6c91e4 avfilter/avf_avectorscope: Assert that format is valid
This should help coverity realize that src[] is inited

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-04-22 20:08:45 +02:00
Paul B Mahol eb3137255f avfilter/avf_avectorscope: fix initialization for prev_y in polar mode 2016-08-11 17:30:32 +02:00
Paul B Mahol a130165ed9 avfilter/avf_avectorscope: add scale option 2016-08-11 17:21:54 +02:00
Michael Niedermayer f2c8b666be avfilter: Fix max value of AV_OPT_TYPE_VIDEO_RATE
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-09 10:35:13 +02:00
Michael Niedermayer 62eb935bf9 avfilter/avf_avectorscope: assert that variables are initialized by switch()
Silences: CID1351390
Silences: CID1351391

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-11 23:09:39 +01:00
Paul B Mahol 206f65b06d avfilter/avf_avectorscope: add line drawing support
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-01-05 15:01:55 +01: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
Ganesh Ajjanagadde 6aaac24d72 avfilter/all: propagate errors of functions from avfilter/formats
Many of the functions from avfilter/formats can return errors, usually AVERROR(ENOMEM).
This propagates the return values.

All of these were found by using av_warn_unused_result, demonstrating its utility.

Tested with FATE. I am least sure of the changes to avfilter/filtergraph,
since I don't know what/how reduce_format is intended to behave and how it should
react to errors.

Fixes: CID 1325680, 1325679, 1325678.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Previous version Reviewed-by: Nicolas George <george@nsup.org>
Previous version Reviewed-by: Clément Bœsch <u@pkh.me>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-14 10:04:01 -04:00
Paul B Mahol 4b0e112442 avfilter/avf_avectorscope: add polar mode 2015-08-14 17:27:56 +02:00
Paul B Mahol 2bdd026b26 avfilter/avf_avectorscope: stop making output fully transparent 2015-08-07 16:44:19 +02:00
Michael Niedermayer 27a5d09c6a avfilter/avf_avectorscope: Change enums to int, which are accessed via AVOption as int
This fixes depending on implementation defined behavior

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-02 04:08:18 +01:00
Paul B Mahol 67aaa7056d avfilter/avf_avectorscope: use the name 's' for the pointer to the private context
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2015-01-28 14:34:11 +00:00
Clément Bœsch ec73bd1fe8 avfilter/avectorscope: fix {} mistake in alloc check. 2013-12-26 13:49:15 +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
Paul B Mahol 7d8939a0ff avfilter/avf_avectorscope: improve description
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-09-14 12:11:22 +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
Paul B Mahol 005ee7a586 lavfi: avectorscope filter
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-05-10 17:11:54 +00:00