Commit Graph

150 Commits

Author SHA1 Message Date
Anton Khirnov abd7da0af9 lavfi: deprecate avfilter_config_links()
It never makes sense for this function to be called by users.
2024-03-08 09:29:54 +01:00
Andreas Rheinhardt a272c9cffa avfilter: Add a header for internal generic-layer APIs
This commit moves the generic-layer stuff (that is not used
by filters) to a new header of its own, similarly to
5e7b5b0090 for libavcodec.
thread.h and link_internal.h are merged into this header.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-18 16:38:09 +01:00
Andreas Rheinhardt db98b0e04e avfilter/avfilter: Avoid allocation for AVFilterInternal
To do this, allocate AVFilterInternal jointly with AVFilterContext
and rename it to FFFilterContext in the process (similarly to
AVStream/FFStream).
The AVFilterInternal* will be removed from AVFilterContext
on the next major bump.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-18 16:38:09 +01:00
Anton Khirnov 08bebeb1be Revert "all: Don't set AVClass.item_name to its default value"
Some callers assume that item_name is always set, so this may be
considered an API break.

This reverts commit 0c6203c97a.
2024-01-20 10:34:48 +01:00
Niklas Haas 8c7934f73a avfilter: add negotiation API for color space/range
Motivated by YUVJ removal. This change will allow full negotiation
between color ranges and matrices as needed. By default, all ranges and
matrices are marked as supported.

Because grayscale formats are currently handled very inconsistently (and
in particular, assumed as forced full-range by swscale), we exclude them
from negotiation altogether for the time being, to get this API merged.

After filter negotiation is available, we can relax the
grayscale-is-forced-jpeg restriction again, when it will be more
feasible to do so without breaking a million test cases.

Note that this commit updates one FATE test as a consequence of the
sanity fallback for non-YUV formats. In particular, the test case now
writes rgb24(pc, gbr/unspecified/unspecified) to the matroska file,
instead of rgb24(unspecified/unspecified/unspecified) as before.
2023-12-31 13:35:03 -08:00
Andreas Rheinhardt 0c6203c97a all: Don't set AVClass.item_name to its default value
Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9;
also avoids relocations.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-12-22 15:12:33 +01:00
Andreas Rheinhardt 19af142d45 avfilter/internal: Don't include formats.h
internal.h doesn't rely on it; instead include it directly
in every user that needs it (a filter needing it is basically
equivalent to it using FILTER_QUERY_FUNC, i.e. a majority of
filters doesn't need it).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-07 09:21:13 +02:00
Andreas Rheinhardt 6d15643173 avfilter/internal: Don't include video.h
internal.h does not depend on video.h (and should not depend on it)
and therefore should not include video.h at all; instead all users
of video.h should include it directly.

Doing so also avoids unnecessary video.h inclusions in files that
don't need it, like most audio filters.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-07 09:21:13 +02:00
Andreas Rheinhardt 1062a6d6c4 avfilter/avfilter: Make functions only used here static
Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-04 11:49:26 +02:00
Anton Khirnov 4310b66b98 lavfi/avfilter: track whether a filter has been initialized
Refuse to link uninitialized filters or initialize a filter twice.
2023-02-12 10:17:26 +01:00
Anton Khirnov 80cf509e73 lavfi/avfilter: export process_options()
Also, replace an AVFilterContext argument with a logging context+private
class, as those are the only things needed in this function.

Will be useful in future commits.
2023-02-12 10:16:41 +01:00
Andreas Rheinhardt 5a7978a694 avfilter/avfilter: Make ff_command_queue_pop() static
Only used here.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-21 13:01:20 +02:00
Andreas Rheinhardt 55c35d84eb avfilter/internal: Remove declaration of inexistent function
ff_get_ref_perms_string() has been removed in
7e350379f8.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-21 13:00:52 +02:00
Andreas Rheinhardt e10774a8cc avfilter/avfilter: #if ff_tlog_link() away when empty
It is currently calling av_channel_layout_describe()
unnecessarily.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-14 21:48:48 +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
Andreas Rheinhardt 155cd6baa4 Remove obsolete version.h inclusions
Forgotten in e7bd47e657.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-24 12:56:49 +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 2761a7403b avfilter/avfilter: Make ff_tlog_ref() static
It allows compilers to inline the one and only call to this function
in its caller or even to optimize it away completely (this function
is empty in case TRACE is not defined).

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-03 22:54:54 +02:00
Andreas Rheinhardt 441b292592 avfilter/internal: Add AVFILTER_DEFINE_CLASS_EXT
This macro will allow to share options between AVClasses without
having to redefine the option name (as is currently done) and will
also allow to share the AVClasses itself (which is possible now
that AVClass.child_class_next is gone).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-13 16:08:29 +02:00
Andreas Rheinhardt f308f37441 avfilter/avfilter: Allow to free non-static pads generically
This can be enabled/disabled on a per-pad basis by setting
the AVFILTERPAD_FLAG_FREE_NAME flag; variants of ff_append_(in|out)pads
that do this for you have been added and will be put to use in the
following commits.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-22 16:13:25 +02:00
Andreas Rheinhardt dff1709eb2 avfilter/internal: Uninline ff_insert_(in|out)pad()
These functions are not hot at all.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-22 16:12:06 +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 515e7fbce1 avfilter/avfilter: Remove unused feature to add pads in the middle
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-17 21:20:59 +02:00
Andreas Rheinhardt 1e35744a4c avfilter/internal: Replace AVFilterPad.needs_writable by flags
It will be useful in the future when more flags are added.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-17 21:10:45 +02:00
Andreas Rheinhardt 1aa640c7d7 avfilter/internal: Combine get_(audio|video)_buffer into union
These fields are mutually exclusive, so putting them in a union
is possible and makes AVFilterPad smaller.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-17 19:13:16 +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 ef54590f83 avfilter/internal: Don't include libavcodec/(avcodec|internal).h
The reasons for including them don't exist any longer: ff_tlog() has
been moved to libavutil/internal.h and FF_QSCALE_TYPE_* has been moved
to qp_table.h.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-05 21:15:25 +02:00
Andreas Rheinhardt 2b6e008577 avfilter/internal: Move ff_norm_qscale() to qp_table.h
It is the natural header for it.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-05 19:59:00 +02:00
Andreas Rheinhardt 6e66e2c321 avfilter/internal: Don't include framepool.h, thread.h
They are not used by the header at all and only used by very few files;
so include the headers in their users instead of in internal.h.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-04 03:03:25 +02:00
Andreas Rheinhardt b76f9bcfd0 avfilter/internal: Mark ff_filter_get_nb_threads() as av_pure
It does not modify anything; it only returns a value, so it fulfills
the requirements for av_pure.
The deeper rationale behind this change is that this function is called
quite often inside arguments to FFMIN which may lead to two calls to it;
declaring this function as av_pure allows the compiler to optimize the
second call away.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-18 22:33:34 +02:00
Paul B Mahol b4ad669a42 avfilter/avfilter: mark enable as runtime option too 2021-02-03 15:51:40 +01:00
Andreas Rheinhardt 242ba4d74c avfilter/formats: Remove unused functions
This commit removes ff_parse_sample_format(), ff_parse_time_base() and
ff_query_formats_all_layouts() from libavfilter/formats.c. All of these
functions were completely unused. ff_parse_time_base() has not been used
at all since it had been added in 3448404a707b6e236a2ffa7b0453b3300de41b7b;
the last caller of ff_parse_sample_format has been removed in commit
d1c49bcae9. And the one and only caller of
ff_query_formats_all_layouts() (the asyncts filter) has been removed in
commit a8fe8d6b4a.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-21 18:28:40 +02:00
Nicolas George 4ca1fb9d2a lavfi: remove needs_fifo. 2020-08-20 18:55:19 +02:00
Limin Wang 548ef7a12b avfilter: add D2TS, TS2D, TS2T as a common macro in internal.h
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-06-19 23:12:49 +08:00
Nicolas George 02daafb45c lavfi: remove AVFilterPad.poll_frame().
This design is no longer used and was replaced a long time ago.
2019-12-23 13:03:38 +01:00
Nicolas George 65e6850c56 lavfi: remove ff_poll_frame().
It is never used.
2019-12-23 13:03:38 +01:00
Paul B Mahol a918b833a5 avfilter/avfilter: add ff_filter_process_command() 2019-10-14 11:28:54 +02:00
Mark Thompson bcab11a1a2 Merge commit '6d86cef06ba36c0ed591e14a2382e9630059fc5d'
* commit '6d86cef06ba36c0ed591e14a2382e9630059fc5d':
  lavfi: Add support for increasing hardware frame pool sizes

Merged-by: Mark Thompson <sw@jkqxz.net>
2018-02-12 22:28:12 +00:00
Mark Thompson 6d86cef06b lavfi: Add support for increasing hardware frame pool sizes
AVFilterContext.extra_hw_frames functions identically to the field of
the same name in AVCodecContext.
2018-02-11 22:11:06 +00:00
James Almer 3ec6d9c6b2 avfilter: remove duplicate and disabled trace log function
It's already defined and actually enabled depending on compiler options
elsewhere.

Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-01 14:06:14 -03:00
Paul B Mahol e9510dc032 avfilter: remove usage of empty header
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-06-26 19:43:41 +02:00
Matthieu Bouron b5e1ec5660 Merge commit 'e3fb74f7f9a8f1895381355f40c92cac3c1023d9'
* commit 'e3fb74f7f9a8f1895381355f40c92cac3c1023d9':
  lavfi: Always propagate hw_frames_ctx through links

Merged-by: Matthieu Bouron <matthieu.bouron@gmail.com>
2017-03-30 00:02:08 +02:00
Nicolas George c619a4e525 lavfi: make two functions static.
ff_request_frame_to_filter() and ff_filter_frame_to_filter()
are only used in avfilter.c.
2017-01-12 14:06:16 +01:00
Nicolas George ae4650f0b9 lavfi: disallow ff_request_frame for filters using activate.
Having two different functions allows to have stricter tests
and detect errors earlier.
2017-01-12 14:06:16 +01:00
Nicolas George 02aa0701ae lavfi: make filter_frame non-recursive.
A lot of changes happen at the same time:

- Add a framequeue fifo to AVFilterLink.

- split AVFilterLink.status into status_in and status_out: requires
  changes to the few filters and programs that use it directly
  (f_interleave, split, filtfmts).

- Add a field ready to AVFilterContext, marking when the filter is ready
  and its activation priority.

- Add flags to mark blocked links.

- Change ff_filter_frame() to enqueue the frame.

- Change all filtering functions to update the ready field and the
  blocked flags.

- Update ff_filter_graph_run_once() to use the ready field.

- buffersrc: always push the frame immediately.
2016-12-18 10:38:52 +01:00
Mark Thompson e3fb74f7f9 lavfi: Always propagate hw_frames_ctx through links
Also adds a new flag to mark filters which are aware of hwframes and
will perform this task themselves, and marks all appropriate filters
with this flag.

This is required to allow software-mapped hardware frames to work,
because we need to have the frames context available for any later
mapping operation in the filter graph.

The output from the filter graph should only propagate further to an
encoder if the hardware format actually matches the visible format
(mapped frames are valid here and have an hw_frames_ctx, but this
should not be given to the encoder as its hardware context).
2016-11-02 20:29:05 +00:00
Paul B Mahol 5b1907142d avfilter: add ff_filter_get_nb_threads() 2016-08-29 16:27:09 +02:00
Paul B Mahol 547d412078 avfilter: update some comments
start_frame is no more, samplesref argument is now frame argument.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2016-01-24 14:32:14 +01:00
Nicolas George 1655788712 lavfi: make request_frame() non-recursive.
Instead of calling the input filter request_frame() method,
ff_request_frame() now marks the link and returns immediately.
buffersink is changed to activate the marked filters until
a frame is obtained.
2015-12-22 16:04:30 +01:00
Nicolas George 108b4de552 lavfi: replace link.closed by link.status.
The status field can carry any error code instead of just EOF.
Also only update it through a wrapper function and provide a timestamp.
Update the few filters that used it directly.
2015-12-22 16:04:30 +01:00