Commit Graph

11369 Commits

Author SHA1 Message Date
Marton Balint 268062fa15 avfilter/yadif_common: factorize some part of the config_output and the uninit functions
This unifies slightly diverged code and ensures that cc_fifo is always initialized.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-04 20:04:18 +01:00
Gyan Doshi 94422871fc avfilter/buffersrc: limit link variance logs below debug loglevel
The video param change check will print loglines below debug level
for each frame which is different from the inlink parameters. This
can spam the console. It is now printed at warning level once for
each param change else it is kept at debug level.

Partially addresses #10823
2024-02-01 16:36:18 +05:30
Lynne 5860a966d2
lavfi/vsrc_testsrc_vulkan: fix -Wint-conversion
While VK_NULL_HANDLE is equivalent to NULL on 64-bit platforms, the same is not
true across all platforms.

Fixes building with gcc-14.
2024-01-31 14:26:26 +01:00
Anton Khirnov 0291b6f824 lavfi/vsrc_ddagrab: add an option to avoid duplicating frames
Tested-by: Jiří Eliášek, Misha Aizatulin
2024-01-30 09:32:39 +01:00
Wenbin Chen d52e8ed114 libavfilter/vf_dnn_detect: Use class confidence to filt boxes
Use class confidence instead of box_score to filt boxes, which is more
accurate. Class confidence is obtained by multiplying class probability
distribution and box_score.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2024-01-28 11:18:13 +08:00
Wenbin Chen 3de38b9da5 libavfilter/dnn_interface: use dims to represent shapes
For detect and classify output, width and height make no sence, so
change width, height to dims to represent the shape of tensor. Use
layout and dims to get width, height and channel.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2024-01-28 11:18:06 +08:00
Wenbin Chen c695de56b5 libavfilter/dnn_bakcend_openvino: Add automatic input/output detection
Now when using openvino backend, user doesn't need to set input/output
names in command line. Model ports will be automatically detected.

For example:
ffmpeg -i input.png -vf \
dnn_detect=dnn_backend=openvino:model=model.xml:input=image:\
output=detection_out -y output.png

can be simplified to:
ffmpeg -i input.png -vf dnn_detect=dnn_backend=openvino:model=model.xml\
 -y output.png

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2024-01-28 11:17:59 +08: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
Vladimir Petrov c915dc4c50
avfilter/vsrc_testsrc: fix colorchart black stripe
Fixed blackstripe on bottom or segmentation fault in case
when patch width and height differ.

Signed-off-by: Vladimir Petrov <vppetrovmms@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-01-12 23:35:40 +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
Marton Balint 363b3ec98a all: use av_channel_layout_describe_bprint instead of av_channel_layout_describe in a few places
Where an AVBPrint buffer is used later anyway.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-01-07 22:47:22 +01:00
Thilo Borgmann c03c675d89 avfilter/fsync: Fix memory leak
Fixes a leak if s->last_frame is still set at the end of filtering.

Found-by: James Almer
2024-01-07 13:59:02 +01:00
Thilo Borgmann 7ec4835386 avfilter: Add fsync filter 2024-01-05 09:29:05 +01:00
Mark Thompson 8b76bae896 avfilter: Temporary hack to fix format negotiation for hw formats
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.
2024-01-04 21:47:38 +00:00
Zhao Zhili 99debe5f82 avfilter/vf_codecview: fix heap buffer overflow
And improve the performance by a little bit.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-01-05 01:14:33 +08:00
Stefano Sabatini 59686eaf33 lavfi/drawtext: fix missed rename of is_newline
Fix fallout introduced in 732fb122e6, fix compilation with
--enable-libfribidi.
2024-01-03 16:49:16 +01:00
Stefano Sabatini 933c7ff0b9 lavfi/setpts: use macro to access variables array 2024-01-01 20:12:52 +01:00
Stefano Sabatini 030e140145 lavfi: add quirc filter 2024-01-01 20:12:52 +01:00
Stefano Sabatini 899302bb5f lavfi: add qrencode source and filter 2024-01-01 20:12:52 +01:00
Stefano Sabatini 732fb122e6 lavfi: introduce textutils
Generalize drawtext utilities to make them usable in other filters.
This will be needed to introduce the QR code source and filter without
duplicating functionality.
2024-01-01 20:12:52 +01:00
Stefano Sabatini c2ab41b7e0 lavfi/overlay: factorize definition of planar and packed blending functions 2024-01-01 20:12:52 +01:00
Niklas Haas 44a33fccd8 avfilter/vf_format: allow empty pix_fmts list
Which will impose no restriction. This makes sense when using e.g.
`color_ranges=pc` to limit the color range, without also limiting the
pixel format.
2023-12-31 13:36:22 -08:00
Niklas Haas 796669d483 avfilter/vf_format: add color_ranges/spaces
Needed for fftools/ffmpeg_filter to be able to force specific output
formats via the filter chain.
2023-12-31 13:36:22 -08:00
Niklas Haas 2a942b4b3a avfilter/vf_format: re-use AVFilterFormats for pix_fmt parsing
Rewrite the format parsing code to make it more easily generalizable. In
particular, `invert_formats` does not depend on the type of format list
passed to it, which allows me to re-use this helper in an upcoming
commit.

Slightly shortens the code, at the sole cost of doing several malloc
(ff_add_format) instead of a single malloc.
2023-12-31 13:36:22 -08:00
Niklas Haas 475a99628d avfilter/buffersink: add color space/range accessors
Needed for fftools.
2023-12-31 13:36:12 -08:00
Niklas Haas e82277b548 avfilter/vf_libplacebo: switch to colorspace negotiation API 2023-12-31 13:35:35 -08:00
Niklas Haas ff506b8d8f avfilter/vf_libplacebo: don't force dovi frames to bt.2020-ncl
This is at odds with the YUV matrix negotiation API, in which such
dynamic changes in YUV encoding are no longer easily possible. There is
also no really strong motivating reason to do this, since the choice of
YUV matrix is essentially arbitrary and not actually related to the
Dolby Vision decoding process.
2023-12-31 13:35:35 -08: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
Niklas Haas 45e09a3041 vf_scale: use colorspace negotiation API
This filter will always accept any input format, even if the user sets
a specific in_range/in_color_matrix. This is to preserve status quo with
current behavior, where passing a specific in_color_matrix merely
overrides the incoming frames' attributes. (Use `vf_format` to force
a specific input range)

Because changing colorspace and color_range now requires reconfiguring
the link, we can lift sws_setColorspaceDetails out of scale_frame and
into config_props. (This will also get re-called if the input frame
properties change)
2023-12-31 13:35:35 -08:00
Niklas Haas 2d555dc82d avfilter/buffersrc: add color_space/range parameters
To allow adding proper negotiation, in particular, to fftools.

These values will simply be negotiated downstream for YUV formats, and
ignored otherwise.
2023-12-31 13:35:17 -08: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
Niklas Haas e687a84854 avfilter/formats: set audio fmt lists for vaf filters
Currently, the logic inside the FF_FILTER_FORMATS_QUERY_FUNC branch
prevents this code from running in the event that we have a filter with
a single video input and a single audio output, as the resulting audio
output link will not have its channel counts / samplerates correctly
initialized to their default values, possibly triggering a segfault
downstream.

An example of such a filter is vaf_spectrumsynth. Although this
particular filter already sets up the channel counts and samplerates as
part of the query function and therefore avoids triggering this bug, the
bug still exists in principle. (And importantly, sets a wrong precedent)
2023-12-31 13:33:01 -08:00
Niklas Haas 0e9cf1abf5 avfilter: always call ff_default_query_formats
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.
2023-12-31 13:33:01 -08:00
Niklas Haas 1b0ca47707 avfilter/formats: document ff_default_query_formats
In particular, make it clear that this function will not touch format
lists which were already set by the caller before calling into this
function.
2023-12-31 13:32:29 -08:00
Michael Niedermayer 68146f06f8
avfilter/vf_minterpolate: Check pts before division
Fixes: FPE
Fixes: tickets/10758/poc20ffmpeg

Discovered by Zeng Yunxiang

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-30 21:50:04 +01:00
Michael Niedermayer 08bd2cbfeb
avfilter/avf_showwaves: Check history_nb_samples
Fixes: out of array access
Fixes: tickets/10756/poc18ffmpeg

Discovered by Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-30 21:50:04 +01:00
Wenbin Chen 56c5930ec3 libavfilter/vf_dnn_detect: Add two outputs ssd support
For this kind of model, we can directly use its output as final result
just like ssd model. The difference is that it splits output into two
tensors. [x_min, y_min, x_max, y_max, confidence] and [lable_id].

Model example refer to: https://github.com/openvinotoolkit/open_model_zoo/tree/master/models/intel/person-detection-0106

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2023-12-30 12:12:58 +08:00
Wenbin Chen 86435582a6 libavfilter/dnn_backend_openvino: Add dynamic output support
Add dynamic outputs support. Some models don't have fixed output size.
Its size changes according to result. Now openvino can run these kinds of
models.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2023-12-30 12:12:51 +08:00
Michael Niedermayer bb04235d72
avfilter/vf_vidstabdetect: Avoid double AVERRORS
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-29 21:36:03 +01:00
Michael Niedermayer 7deaca71b3
avfilter/vf_swaprect: round coordinates down
Fixes: out of array access:
Fixes: tickets/10745/poc12ffmpeg

Found-by: Li Zeyuan and Zeng Yunxiang.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-29 21:07:59 +01:00
Michael Niedermayer 9f4c5bd7d2
avfilter/vf_swaprect: Use height for vertical variables
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-29 21:07:58 +01:00
Michael Niedermayer 9d1ba698d2
avfilter/vf_swaprect: assert that rectangles are within memory
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-29 21:07:58 +01:00
Michael Niedermayer a88b06f9ee
avfilter/af_alimiter: Check nextpos before use
Fixes: out of array read
Fixes: tickets/10744/poc11ffmpeg

Found-by: Li Zeyuan and Zeng Yunxiang.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-29 21:07:57 +01:00
Michael Niedermayer 61e73851a3
avfilter/f_reverse: Apply PTS compensation only when pts is available
Fixes: out of array access
Fixes: tickets/10753/poc16ffmpeg

Regression since: 45dc668aea
Found-by: Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-29 19:29:07 +01:00
Michael Niedermayer 50f0f8c53c
avfilter/af_stereowiden: Check length
Fixes: out of array access
Fixes: tickets/10746/poc13ffmpeg

Found-by: Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-29 19:29:06 +01:00
Michael Niedermayer 0ecc1f0e48
avfilter/vf_weave: Fix odd height handling
Fixes: out of array access
Fixes: tickets/10743/poc10ffmpeg

Found-by: Zeng Yunxiang and Li Zeyuan
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-29 01:28:11 +01:00
Michael Niedermayer c443658d26
avfilter/edge_template: Fix small inputs with gaussian_blur()
Fixes: out of array access
Fixes: Ticket10699
Fixes: poc5ffmpeg

Found-by: Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-29 01:28:10 +01:00
Paul B Mahol e6459abfad
avfilter/af_stereotools: round-up max size of buffer
Fixes: out of array access
Fixes: tickets/10747/poc14ffmpeg

Found-by: Zeng Yunxiang and Song Jiaxuan
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-29 01:19:06 +01:00
Michael Niedermayer e4d2666bdc
avfilter/vf_gradfun: Do not overread last line
The code works in steps of 2 lines and lacks support for odd height
Implementing odd height support is better but for now this fixes the
out of array access

Fixes: out of array access
Fixes: tickets/10702/poc6ffmpe

Found-by: Zeng Yunxiang
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-12-29 01:19:05 +01:00