Commit Graph

74 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
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 28a73506df avfilter/vf_waveform: add input option
For finer control of selected formats for filtering.
2023-05-14 00:13:59 +02:00
Paul B Mahol eaf15b5882 avfilter/vf_waveform: cc2b3201e7 missed same for >8 bits 2023-05-01 14:55:32 +02:00
Paul B Mahol 5a9de38e54 avfilter/vf_waveform: copy props from input frame 2022-04-08 18:54:00 +02:00
Paul B Mahol a700dc3735 avfilter/vf_waveform: add some support for commands 2022-04-08 18:54:00 +02:00
Paul B Mahol cc2b3201e7 avfilter/vf_waveform: do not add tint if output format is gray 2022-02-17 23:05:13 +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
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
Paul B Mahol ca788d184c avfilter/vf_waveform: add option to control strechness of waveform 2021-08-16 01:19:19 +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 2934a4b9a5 Remove unnecessary avassert.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:30 +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
Peter Ross 5d8e86d15a avfilter/vf_waveform: flat_pix_fmts never used
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-24 09:35:36 +11: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 26eba8ca61 avfilter/vf_waveform: add support for 12bit yuva formats 2019-12-29 15:33:55 +01:00
Paul B Mahol 6399eed48a avfilter/vf_waveform: implement tint options 2019-12-28 21:51:40 +01:00
Paul B Mahol 4f4334bcbc avfilter/vf_waveform: fix typos which caused crash 2019-10-13 11:51:11 +02:00
Paul B Mahol e923e6205e avfilter/vf_waveform: add yflat filter 2019-10-12 18:46:13 +02:00
Paul B Mahol 33fd82ae9e avfilter/vf_waveform: allow different cb for new modes 2019-10-12 17:57:23 +02:00
Paul B Mahol 42974eb13a avfilter/vf_waveform: add invert graticule 2019-10-12 17:44:52 +02:00
Paul B Mahol ecc1675368 avfilter/vf_waveform: add graticule enum 2019-10-12 16:02:34 +02:00
Paul B Mahol 7ad69a73f3 avfilter/vf_waveform: better guard against picking wrong pixel format
Fixes #8252
2019-10-11 12:07:54 +02:00
Paul B Mahol 22d6d91649 avfilter/vf_waveform: abort early if there are no components to show 2018-10-24 18:33:52 +02:00
Paul B Mahol d94d252731 avfilter/vf_waveform: add gratcicule to rgb input 2018-10-24 18:33:52 +02:00
Paul B Mahol e9dd5b4f5e avfilter/vf_waveform: add slice threading
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-05-18 13:15:09 +02:00
Paul B Mahol 36cf3eb76a avfilter/vf_waveform: add orange graticule
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-03-21 12:21:42 +01:00
Paul B Mahol caef95737e avfilter/vf_waveform: add xflat mode
Also use macros for xflat and aflat mode.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2018-03-21 12:21:42 +01:00
Paul B Mahol 299a622297 avfilter/vf_waveform: add default case when picking input formats
Should silence compiler warnings.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-12-08 12:31:01 +01:00
Paul B Mahol 86222a7ea0 avfilter/vf_waveform: add support for 9 bit depth lowpass 2017-08-07 13:09:57 +02:00
Paul B Mahol 8a14374ab3 avfilter/vf_waveform: allow alpha output for >8 depth planar rgb inputs
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-06-25 13:14:22 +02:00
Muhammad Faiz 6af050d7d0 avfilter: do not use AVFrame accessor
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
2017-04-23 14:40:30 +07:00
Paul B Mahol 57ef0f0f17 avfilter/vf_waveform: add gray10 and gray12 support
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-11-29 11:34:48 +01:00
Paul B Mahol 4fb6f9de0c avfilter/vf_waveform: make possible to change background opacity
Only useful if output pixel format have alpha.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-09-07 22:38:14 +02:00
Paul B Mahol 5b174dd3f1 avfilter/vf_waveform: fix order of graticule scale items
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-05-05 10:38:37 +02:00
Paul B Mahol 4a80a6ad21 avfilter/vf_waveform: optimize lowpass filter even more
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-29 22:02:48 +02:00
Paul B Mahol c2bbcf1607 avfilter/vf_waveform: optimize 16bit lowpass filter
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-28 12:28:03 +02:00
Paul B Mahol 48be92e5b6 avfilter/vf_waveform: optimize lowpass 8bit filter
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-27 23:29:38 +02:00
Paul B Mahol 0b9957c301 avfilter/vf_waveform: move mirror variable into function argument
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-27 22:50:04 +02:00
Paul B Mahol 50f4b64c54 avfilter/vf_waveform: set color range for output frames
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-20 10:00:53 +01:00
Paul B Mahol 959c7dad88 avfilter/vf_waveform: add graticule to aflat filter
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-19 21:47:15 +01:00
Paul B Mahol c91b20c464 avfilter/vf_waveform: add subsampling input support for remaining filters
Remove achroma filter, as same output can be done with lowpass filter
and multiple components with overlay display.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-19 21:18:35 +01:00
Paul B Mahol 93c6c52ad7 avfilter/vf_waveform: add subsampled input support for (a)color filter
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-18 11:08:32 +01:00
Paul B Mahol a68d4bf235 avfilter/vf_waveform: add forgotten color and acolor filter to switch case
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-15 09:16:18 +01:00
Paul B Mahol af5559ab67 avfilter/vf_waveform: add graticule for chroma and flat filter
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-14 23:12:43 +01:00
Paul B Mahol 29d106e751 avfilter/vf_waveform: remove mirroring from chroma filter
It is not really useful.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-14 13:25:10 +01:00
Paul B Mahol 9f6e63f6f2 avfilter/vf_waveform: add >8 bit support for other filters
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-14 13:25:10 +01:00
Paul B Mahol 912fec3e54 avfilter/vf_waveform: add acolor filter
Useful in combination with color filter.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-13 11:24:39 +01:00
Paul B Mahol 817d0c6da2 avfilter/vf_waveform: add parade display mode
Rename old parade display mode to stacked.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-11 23:08:38 +01:00
Paul B Mahol 867637caea avfilter/vf_waveform: fix and extend millivolts grat lines
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-03-11 10:24:51 +01:00