aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/avfiltergraph.c
Commit message (Collapse)AuthorAgeFilesLines
* avfilter/avfilter: add AVFilterGraph->max_buffered_frames to limit buffered ↵Marton Balint24 hours1-0/+4
| | | | | | frames Signed-off-by: Marton Balint <cus@passwd.hu>
* avfilter: signal an empty buffersrc with an explicit activate error codeMarton Balint12 days1-0/+2
| | | | | | No change in functionality. Signed-off-by: Marton Balint <cus@passwd.hu>
* avfilter/avfiltergraph: fix regression in picking channel layoutPaul B Mahol2025-05-221-2/+2
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avfilter/avfilter: Add FFFilter, hide internals of AVFilterAndreas Rheinhardt2025-01-121-8/+9
| | | | | | | | | | This patch is analogous to 20f972701806be20a77f808db332d9489343bb78: It hides the internal part of AVFilter by adding a new internal structure FFFilter (declared in filters.h) that has an AVFilter as its first member; the internal part of AVFilter is moved to this new structure. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavfi/avfilter: move AVFilterContext.command_queue to FFFilterContextAnton Khirnov2024-10-071-1/+2
| | | | It is private to generic filtering code.
* lavfi/avfilter: move AVFilterContext.ready to FFFilterContextAnton Khirnov2024-10-071-7/+11
| | | | This field is private to the generic filtering code.
* avfilter: fix YUV colorspace negotiation for YUVJNiklas Haas2024-09-121-12/+19
| | | | | | | | | | | | | | | Ironically, despite being introduced to make YUVJ unnecessary, the new YUV negotiation logic failed to actually negotiate YUVJ formats themselves correctly, leading to errors when passing YUVJ frames into a filter graph. (They were effectively treated like RGB or Grayscale formats, rather than as forced-full-range YUV, and hence did not have their colorspace matrix correctly negotiated) Fix this by splitting off the YUVJ check from ff_fmt_is_regular_yuv(). Obviously, we can trivially undo this change again once YUVJ is actually deleted from the codebase. Fixes: #11179
* lavfi/avfiltergraph: fix leak on errorMarvin Scholz2024-09-091-1/+3
| | | | | | | Introduced in eddffbedb3443d5a4fe642de6e35b9e6a35cfda7 Fixes: CID1618897 Resource leak Signed-off-by: Anton Khirnov <anton@khirnov.net>
* lavfi: add query_func2()Anton Khirnov2024-09-021-0/+43
| | | | | | | | It differs from query_func() in accepting arrays of input/output format configurations to be filled as callback parameters. This allows to mark the filter context as const, ensuring it is not modified by this function, as it is not supposed to have any side effects beyond returning the supported formats.
* lavfi: drop internal.hAnton Khirnov2024-08-191-1/+0
| | | | | | All that remains in it are things that belong in avfilter_internal.h. Move them there and remove internal.h
* lavfi/inernal: move ff_fmt_is_regular_yuv() declaration to video.hAnton Khirnov2024-08-191-0/+1
|
* lavfi/internal: move functions used by filters to filters.hAnton Khirnov2024-08-191-0/+1
| | | | | | internal.h currently mixes interfaces intended to be used by filters with those that should be limited to generic filter- or graph-level code.
* lavfi: move AVFilterLink.graph to FilterLinkAnton Khirnov2024-08-151-1/+1
|
* lavfi: move AVFilterLink.frame_wanted_out to FilterLinkInternalAnton Khirnov2024-08-151-1/+1
|
* lavfi: move AVFilterLink.{frame,sample}_count_{in,out} to FilterLinkAnton Khirnov2024-08-151-2/+2
|
* lavfi: move AVFilterLink.current_pts(_us) to FilterLinkAnton Khirnov2024-08-151-3/+3
|
* lavfi: add a new struct for private link propertiesAnton Khirnov2024-08-151-5/+5
| | | | | | | | | | | Specifically those that should be visible to filters, but hidden from API callers. Such properties are currently located at the end of the public AVFilterLink struct, demarcated by a comment marking them as private. However it is generally better to hide them explicitly, using the same pattern already employed in avformat or avcodec. The new struct is currently trivial, but will become more useful in following commits.
* lavfi: set AVFilterLink.graph on link creationAnton Khirnov2024-08-151-2/+0
| | | | There is no reason to delay this.
* avfilter/avfiltergraph: return value of ff_request_frame() is unusedMichael Niedermayer2024-05-011-1/+1
| | | | | | | Fixes: CID1397741 Unchecked return value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-311-1/+1
| | | | | | | | | | | 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>
* avfilter: properly reduce YUV colorspace format listsNiklas Haas2024-03-271-80/+4
| | | | | | | | | | | | Doing this with REDUCE_FORMATS() instead of swap_color_*() is not only shorter, but more importantly comes with the benefit of being done inside a loop, allowing us to correctly propagate complex graphs involving multiple conversion filters (e.g. -vf scale,zscale). The latter family of swapping functions is only used to settle the best *remaining* entry if no exact match was found, and as such was never the correct solution to YUV colorspaces, which only care about exact matches.
* lavfi: deprecate avfilter_config_links()Anton Khirnov2024-03-081-1/+1
| | | | It never makes sense for this function to be called by users.
* avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUTJames Almer2024-03-071-6/+0
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avfilter/avfilter: Move age_index to FilterLinkInternalAndreas Rheinhardt2024-02-181-29/+32
| | | | | | | | Also make FFFilterGraph.sink_links a FilterLinkInternal** because sink_links is used to access FilterLinkInternal fields. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/avfilter: Move AVFilterGraph private fields to FFFilterGraphAndreas Rheinhardt2024-02-181-15/+17
| | | | | | | (These fields were in AVFilterGraph although AVFilterGraphInternal existed for years.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/avfiltergraph: Avoid allocation for AVFilterGraphInternalAndreas Rheinhardt2024-02-181-17/+15
| | | | | | | | | | To do this, allocate AVFilterGraphInternal jointly with AVFilterGraph and rename it to FFFilterGraph in the process (similarly to AVStream/FFStream). The AVFilterGraphInternal* will be removed on the next major version bump. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/avfiltergraph: Avoid indirection when freeing filtergraphAndreas Rheinhardt2024-02-181-10/+12
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter: Add a header for internal generic-layer APIsAndreas Rheinhardt2024-02-181-2/+1
| | | | | | | | | This commit moves the generic-layer stuff (that is not used by filters) to a new header of its own, similarly to 5e7b5b0090bdf68e0897fe55ee657fdccc0cbca2 for libavcodec. thread.h and link_internal.h are merged into this header. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavfi: get rid of FF_INTERNAL_FIELDSAnton Khirnov2024-02-141-4/+5
| | | | | | | This hack is used to limit the visibility of some AVFilterLink fields to only certain files. Replace it with the same pattern that is used e.g. in lavf AVStream/FFStream and avoid exposing these internal fields in a public header completely.
* all: use designated initializers for AVOption.unitAnton Khirnov2024-02-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-201-0/+1
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* avfilter: Temporary hack to fix format negotiation for hw formatsMark Thompson2024-01-041-2/+6
| | | | | | | hw_frames_ctx on the input link is only set when the input link is configured, which hasn't happened yet. This temporarily hacks around the problem (in a way no worse than before the format negotiation changes) until a proper fix can be applied.
* avfilter: add negotiation API for color space/rangeNiklas Haas2023-12-311-3/+170
| | | | | | | | | | | | | | | | | | | 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.
* avfilter: always call ff_default_query_formatsNiklas Haas2023-12-311-27/+12
| | | | | | | | | | | | | | | Even if a query func is set. This is safe to do, because ff_default_query_formats is documented not to touch any filter lists that were already set by the query func. The reason to do this is because it allows us to extend AVFilterFormatsConfig without having to touch every filter in existence. An alternative implementation of this commit would be to explicitly add a `ff_default_query_formats` call at the end of every query_formats function, but that would end up functionally equivalent to this change while touching a whole lot more code paths for no reason. As a bonus, eliminates some code/logic duplication from this function.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-221-1/+0
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/avfiltergraph: remove no longer valid commentPaul B Mahol2023-05-141-1/+0
|
* avfilter/formats: fix format negotiation when multiple channel_layouts are ↵James Almer2023-05-131-1/+1
| | | | | | | | | | provided For example ffmpeg -f lavfi -i sine -af "aformat=cl=stereo|5.1|7.1,lowpass,aformat=cl=7.1|5.1|stereo" -f null - Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avfilter/avfiltergraph: fix check for negative returnPaul B Mahol2023-05-131-2/+4
| | | | | | | | | | | | Before this commit if allocation would fail in ff_add_channel_layout() function, function would return negative error code and this would cause wrong format pick up later. If allocation would not fail return code would be 0 and then format negotiation would simply fail as code would break from the loop but with wrong return code. Error was introduced in 6aaac24d72a7da commit. Fixes #6638
* avfilter/avfiltergraph: remove unnecessary channel layout copyJames Almer2022-08-061-7/+8
| | | | | | | | It's not modified, so we can simply use a const pointer to it. Also check the return value of the other copy in the function while at it. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: James Almer <jamrial@gmail.com>
* avfilter: convert to new channel layout APIJames Almer2022-03-151-36/+48
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* Remove unnecessary libavutil/(avutil|common|internal).h inclusionsAndreas Rheinhardt2022-02-241-2/+0
| | | | | | | | | | Some of these were made possible by moving several common macros to libavutil/macros.h. While just at it, also improve the other headers a bit. Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/avfiltergraph: Fix use-after-free when inserting auto-converterAndreas Rheinhardt2021-10-081-6/+5
| | | | | | | | | | | | | | | | | | | | When inserting an auto-resampler, it may be that the configuration of the filters that the auto-resampler is supposed to connect is already partially merged, i.e. converter->inputs[0].incfg.foo and converter->outputs[0].outcfg.foo (where foo is one of formats, samplerates, channel_layouts) can coincide. Therefore merging the converter filter's input link might modify the outcfg of the converter' outlink. Yet the current code in avfiltergraph.c used pointers from before merging the inlink for merging the outlink, leading to a use-after-free in command lines like: $ ffmpeg -f lavfi -i anullsrc=cl=stereo -lavfi channelsplit,axcorrelate -f null - Fix this by not using outdated values when merging the outlink. This is a regression since 85a6404d7e6c759ddf71d6374812d7ff719728ec. Found-by: Paul B Mahol <onemda@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter: Replace query_formats callback with union of list and callbackAndreas Rheinhardt2021-10-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* avfilter/avfiltergraph: Remove always-true checkAndreas Rheinhardt2021-10-021-2/+1
| | | | | | Always true since bc1a985ba030e9861d24965d42792850b43a43ea. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/avfiltergraph: Free AVFilterGraph options properlyAndreas Rheinhardt2021-10-021-2/+2
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/avfiltergraph: Simplify adding filter to graphAndreas Rheinhardt2021-10-021-7/+5
| | | | | | | | | | By reallocating the array of pointers to the AVFilterContexts before allocating the new AVFilterContext one can avoid freeing the new AVFilterContext in case the array could not be reallocated. Also switch to av_realloc_array() while just at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/avfiltergraph: add an "auto" constant to the threads optionJames Almer2021-09-041-2/+3
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avfilter/avfiltergraph: Remove dead checksAndreas Rheinhardt2021-08-201-21/+1
| | | | | | | | | These checks emit warnings in case the channel layouts lists are inconsistent; yet since 69f5f6ea375950b4845b241ee27054bfc8f00343 a function that is called earlier errors out if they are inconsistent. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avfilter/avfiltergraph: Don't use AVClass * for logcontextAndreas Rheinhardt2021-08-201-7/+6
| | | | | | | Forgotten in 57fa314090ab006808911fd790053b534749aa53. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavfi/formats: rename AVFilterNegotiation.nb to nb_mergersNicolas George2021-08-201-3/+3
|