Fixes: A3O7F4s10WXJ
Fixes: EINVAL on a format change
EINVAL on a format change Replicated through UnModified FFmpeg with a plain output diff
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24765
libavfilter does not reconfigure a filter when the frames on its input
change size or format after the graph was configured; a scale filter
with eval=frame nevertheless rewrites its outlink per frame, and with
-reinit_filter 0 the ffmpeg tool feeds changed frames into the graph.
Most filters size their buffers from the link at configuration time
and then overrun them.
ff_filter_frame() now rejects a frame that differs from the format and
size ff_filter_config_links() recorded for its link, unless the filter
declares with FF_FILTER_FLAG_DYNAMIC_FRAME_PARAMS that it handles such
frames. The flag replaces the list of filter names exempt from the
consistency assertion. idet is not carried over, it reads across
frames of different sizes.
Fixes: out of array write
Fixes: RqgTntCAW2qN
Found-by: mzfr
Replicated through UnModified FFmpeg
The out of array reads in idet (frames of different sizes) and showinfo
(a smaller frame with -reinit_filter 0) were found during triage of
the same report.
ff_inlink_make_frame_writable() allocated the copy with the link's size,
so for a filter handling frames whose size differs from the link the
copy failed for a larger frame and blended a smaller one into a stale
size. Frames matching the link are unaffected.
Found during triage of the security report RqgTntCAW2qN.
A filter declares with FF_FILTER_FLAG_DYNAMIC_FRAME_SIZE or
FF_FILTER_FLAG_DYNAMIC_FRAME_PARAMS that it handles input frames whose
size, or size and pixel format, differ from what its input link was
configured with. ff_inlink_check_frame_params() checks a frame against
that configuration.
Chroma sample location is the last of the video colorimetry properties
without a negotiated link value, so nothing downstream can ask a filter for
a particular siting and no encoder can constrain the graph. Add it alongside
the existing color space, color range and alpha mode negotiation.
Merge conflicts are resolved by inserting a scale filter, the same way as
for color space and color range.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Currently, such filter graphs just fail with a nebulous:
[fc#0 @ 0x2a7b3c0] [error] Error while filtering: Cannot allocate memory
Sponsored-by: nxtedition AB
Signed-off-by: Niklas Haas <git@haasn.dev>
When ff_filter_alloc fails after the name has been allocated (via
av_strdup), the error handling code frees inputs and input_pads but
misses freeing ret->name, causing a memory leak.
Add av_freep(&ret->name) in the error path before freeing inputs.
Sinks without an activate callback have no means to request frames in their
input, therefore the default activate callback should do it for them.
Fixes ticket #11624.
Fixes ticket #10988.
Fixes ticket #10990.
Signed-off-by: Marton Balint <cus@passwd.hu>
Even if all inputs are blocked an activate callback should request a frame on
some if its inputs if a frame is requested on any of its outputs.
Signed-off-by: Marton Balint <cus@passwd.hu>
EOF only need to be forwarded back if all outputs have reached EOF.
Fixes infinte loop with ffprobe -f lavfi -i "smptebars=d=1,select=n=2:e=1[out0][out1]"
Regression since d9e41ead82.
Fixes ticket #10959.
Fixes ticket #11366.
Signed-off-by: Marton Balint <cus@passwd.hu>
Flipping can already be accomplished by setting the crop_w/h expressions to
their negative values, so together these options can implement any of the
common frame orientations.
This patch is analogous to 20f9727018:
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>
The ctxi_dst variable is unused outside of the av_assert1,
causing an unused variable warning. The simplest solution
for this is to avoid the intermediate variable here.
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.
GCC 9-13 do not emit warnings for this at all optimization
levels even when -Wmaybe-uninitialized is not disabled.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
The documentation for filter arguments states that short options must
precede long options (i.e. those of the form key=value). Yet if
process_options() encounters arguments not abiding by this, it simply
treats short options after a long option as if it were parsing short
options for the first time. In particular, it overwrites options already
set earlier, possibly via other short options. This is not how it is
intended (as a comment in the code indicates).
This commit modifies the code to reject further shorthand options
after a long option has been encountered. After all, avfilter_init_str()
errors out upon unrecognized options, so it is intended to be picky.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
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>
At present, consume_update evaluates timeline state on all links for
a multi-input filter. This can lead to the filter being incorrectly
en/dis-abled when evaluation on a frame on a secondary link leads to
a different result than the frame on the current main link next in
line for processing.
src/libavfilter/internal.h:255:45: note: passing argument to parameter 'filter' here
int ff_filter_config_links(AVFilterContext *filter);
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>