Commit Graph

57 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
Niklas Haas bfa1b7577d avfilter/vf_zscale: fix query_formats
Wrong field assignment as a result of copy/paste error.
2024-01-12 14:12:44 +01:00
Niklas Haas 2ebcbe97fc avfilter/vf_zscale: switch to colorspace negotiation API
Following the same design as vf_scale.
2023-12-31 13:35:35 -08:00
Niklas Haas 3f2c49acfb avfilter/vf_zscale: remove unused variables
Only assigned, never read.
2023-12-31 13:35:35 -08:00
Paul B Mahol 0aa75a85e6 avfilter/vf_zscale: fix adding >8 bit alpha plane 2023-09-28 22:46:56 +02:00
Paul B Mahol 086c280901 avfilter/vf_zscale: add more planar formats with alpha 2023-09-28 22:46:55 +02:00
Mattias Wadman 1ec1a48458 avfilter/vf_zscale: Add smpte240m transfer option and fix matrix option typo
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-07-28 16:17:23 +02:00
Marton Balint 846488cca8 avfilter/vf_zscale: enable AVX512 zimg functions
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-10 22:35:20 +02:00
Marton Balint a6f0e641bc avfilter/vf_zscale: simplify and fix slice_params calculations
Do not insist on a fixed slice height, because that can still cause overflows
in corner cases as described in this comment:

https://github.com/sekrit-twc/zimg/issues/177#issuecomment-1157734233

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-10 22:35:20 +02:00
Marton Balint 68fdc9de84 avfilter/vf_zscale: remove some unneeded initializations
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-07-10 22:35:20 +02:00
Paul B Mahol 42289d5eaf avfilter/vf_zscale: dissallow too small slices
Also change rounding type when calculating slices size.
2022-06-16 10:23:30 +02:00
Paul B Mahol 710dce131f avfilter/vf_zscale: active region use doubles so use that type here too 2022-05-13 15:18:43 +02:00
Paul B Mahol 52a14b8505 avfilter/vf_zscale: improve slice processing 2022-05-13 10:22:51 +02:00
Paul B Mahol e5189b1382 avfilter/vf_zscale: fix regression with src/dst_format initialization 2022-04-05 10:33:14 +02:00
Marton Balint ea887ef876 avfilter/vf_zscale: realign output buffer if needed
Output buffer alignment might be different to ZIMG_ALIGNMENT or it may not be
aligned at all if a downstream filter (e.g. vf_pad) intentionally misaligns it.

Or maybe we should unconditionally always allocate output with
av_frame_get_buffer() instead of ff_get_video_buffer()?

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-03-16 20:20:56 +01:00
Marton Balint d5722d578e avfilter/vf_zscale: properly check return value of slice threads
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-03-16 20:20:56 +01:00
Marton Balint c0351ee5c5 avfilter/vf_zscale: fix number of threads
Make sure it is between [1, MAX_THERADS] and also take into account the outlink
size in order not to request zero height output from zscale.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-03-16 20:20:56 +01:00
Paul B Mahol a0724328a8 avfilter/vf_zscale: do not attempt to continue filtering if there is no graph 2022-03-11 09:34:04 +01:00
Paul B Mahol 4ac85ae448 avfilter/vf_zscale: also check formats 2022-03-11 01:54:03 +01:00
Paul B Mahol 779ae049b2 avfilter/vf_zscale: fix leaks in fast/bypass path 2022-03-04 14:07:20 +01:00
Paul B Mahol 837c55da3d avfilter/vf_zscale: fix several issues in previous commit 2022-03-03 17:35:48 +01:00
Victoria Zhislina d0aefc3706 avfilter/vf_zscale: add slice threading support
By ffmpeg threading support implementation via frame slicing and doing
zimg_filter_graph_build that used to take 30-60% of each frame processig
only if necessary (some parameters changed)
the performance increase vs original version
in video downscale and color conversion  >4x is seen
on 64 cores Intel Xeon, 3x on i7-6700K (4 cores with HT)

Signed-off-by: Victoria Zhislina <Victoria.Zhislina@intel.com>
2022-03-03 17:35:48 +01:00
Jan Ekström 27c0dd5560 avfilter/vf_zscale: fix mapping of zimg_chroma_location_e to AVChromaLocation
The AVChromaLocation values are one higher than zimg's, not one
lower as the undefined value is set to zero (as opposed to zimg's
-1).
2021-10-28 23:13:51 +03:00
Jan Ekström cd1d09e81b avfilter/vf_zscale: deduplicate output color information setting
This way a piece of logic is not missed in one location or the other,
such as the case with chroma location outside the if.
2021-10-28 23:13:51 +03: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 73a59ed1cb avfilter/vf_zscale: Use init instead of init_dict
The AVDictionary was unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-19 04:48:58 +02:00
Andreas Rheinhardt 6556146aa0 avfilter/vf_zscale: Don't make assumptions about zimg's range enums
zimg's color range enum values are off-by-one compared to ours;
therefore the code just adds one when converting from theirs to ours.
Yet this is not how one should deal with enums; use a switch instead.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-18 23:16:44 +02:00
Pavel Koshevoy 4fc0b75973 avfilter/vf_zscale: fix output color_range discrepancy
This filter chain was supposed to convert from narrow range
to full range yuv444p, but didn't:

buffer=width=1280:height=720:pix_fmt=yuv444p:frame_rate=25/1:\
time_base=1/25:sar=1/1,zscale=min=709:rin=limited:pin=709:\
tin=709:t=linear,format=gbrpf32le,zscale=tin=linear:p=709:m=709:\
r=full:t=709,format=pix_fmts=yuv444p,buffersink
2021-09-17 13:35:59 -06: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 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
Jan Ekström 58e59396f5 avfilter/vf_zscale: add support for setting scaling filter parameters
param_a/b are utilized for this.
2021-02-11 20:45:56 +02:00
Paul B Mahol 8e027ca817 avfilter/vf_zscale: switch verbose log to trace
Not needed in verbose mode.
2021-02-09 10:37:42 +01: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
Jacob Ruiz ba2581adb2 avfilter/vf_zscale: fix crash on unaligned input 2020-02-25 19:52:26 +01:00
Jun Zhao b5cea39190 lavfi/zscale: enable runtime change flag
enable runtime change flag

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-01-13 09:25:18 +08:00
Paul B Mahol 22f3b6286e avfilter: add av_cold where it is missing 2019-10-03 12:09:07 +02:00
Raphaël Zumer 08dfd57fd8 avfilter: Support EBU Tech. 3213-E primaries values
Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2019-09-01 20:00:53 -03:00
Jun Zhao 26dbe88ea3 lavfi/zscale: make use of AVFILTER_DEFINE_CLASS
use AVFILTER_DEFINE_CLASS for defining the filter classes

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-03-08 09:38:09 +08:00
Vittorio Giovara bc38c8f442 vf_zscale: Fix alpha destination graph for floating point pixel formats
This was setting the input pixel type instead of the output one,
leading to incorrect data being fed to the library.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2017-12-08 10:11:50 -05:00
Vittorio Giovara 002db7d49a vf_zscale: Add more supported input properties
Bump the minimum version necessary in the configure file.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2017-11-28 14:51:45 -05:00
Vittorio Giovara 3e0560b054 vf_zscale: Relax color properties maximum bounds
This simplifies adding new values, which are already validated elsewhere.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2017-11-28 13:55:47 -05:00
dxfhgwet ff763351e7 avfilter/zscale: fix memory leak 2017-10-28 19:38:12 +02:00
dxfhgwet b43d13144b avfilter/zscale: fix segfault on library error 2017-10-28 19:32:45 +02:00
Vittorio Giovara 8b9ae9a8e0 zscale: Enable single precision input/ouput filtering
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2017-08-15 15:27:40 +02:00
Vittorio Giovara 2e91a96d7b zscale: Factor out graph building 2017-07-21 20:07:40 +02:00
Vittorio Giovara 0a243bedec zscale: Factor out format initialization 2017-07-21 20:07:40 +02:00
Vittorio Giovara 1f4454230d zscale: Add range options aliases to match scale ones
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2017-05-26 10:29:32 -04:00
Vittorio Giovara 6aafe56421 zscale: Add pixdesc-API compatible color names to filter options
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2017-05-26 10:28:50 -04:00