Commit Graph

11473 Commits

Author SHA1 Message Date
Michael Niedermayer e757726e89
avfilter/avfiltergraph: return value of ff_request_frame() is unused
Fixes: CID1397741 Unchecked return value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-01 02:57:13 +02:00
Haihao Xiang 578ac59887 lavfi/qsv: Copy metadata fields from the given input
Currently it always copies the metadata fields from the last input when
there are multiple inputs for the filter. For example, the metadata
fields from input1 are copied to the output for overlay_qsv filter,
however for regular overlay filters, the metadata fields from input0 are
copied to the output. With this fix, we may copy the metadata fields
from input0 to the ouput as well.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2024-04-29 11:08:41 +08:00
Niklas Haas a2cdb2f5be avfilter/f_sidedata: synchronize with side data list
Add all recently added frame data types, as well as the more consistent
name DETECTION_BBOXES as an alias to DETECTION_BOUNDING_BOXES.
2024-04-26 21:02:46 +02:00
Michael Niedermayer 02301017d2
avfilter/vf_thumbnail_cuda: Set ret before checking it
Fixes: CID1418336 Logically dead code

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-24 02:52:17 +02:00
Michael Niedermayer e7174e66ac
avfilter/signature_lookup: Dont copy uninitialized stuff around
Fixes: CID1403238 Uninitialized pointer read
Fixes: CID1403239 Uninitialized pointer read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-24 02:52:16 +02:00
Michael Niedermayer 25cb66369e
avfilter/signature_lookup: Fix 2 differences to the refernce SW
Fixes: CID1403227 Division or modulo by float zero

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-24 02:52:16 +02:00
Xinpeng Sun 35ae44c615 lavfi/tonemap_vaapi: Add support for HDR to HDR tone mapping
Usage example:
ffmpeg -y -hwaccel vaapi -hwaccel_output_format vaapi -i hdr.mp4 \
-vf "tonemap_vaapi=display=7500 3000|34000 16000|13250 34500|15635 16450|500 10000000:extra_hw_frames=64" \
-c:v hevc_vaapi output.mp4

Signed-off-by: Xinpeng Sun <xinpeng.sun@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2024-04-18 14:43:07 +08:00
Haihao Xiang db22804145 lavfi/tonemap_vaapi: Update the log
demote the message to AV_LOG_VERBOSE.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2024-04-18 14:43:07 +08:00
Haihao Xiang 3172a6722e lavfi/tonemap_vaapi: By default use bt709 for output frame
By default don't use the color properties from input frame as output
frame properties when performing HDR to SDR conversion

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2024-04-18 14:43:07 +08:00
Haihao Xiang 5c55e4e297 lavfi: Add drawbox_vaapi filter
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2024-04-18 14:43:07 +08:00
Haihao Xiang 42eb10ecc6 lavfi: Add pad_vaapi filter
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2024-04-18 14:43:07 +08:00
Haihao Xiang 16616a3d1b lavfi/vaapi_vpp: Use dynamic frame pool in outlink if possible
This can avoid to exhaust the buffers within outlink when libva2 is
available.

For example:
$ ffmpeg -hwaccel_output_format vaapi -hwaccel vaapi -i input.mp4 \
-vf 'scale_vaapi=w=720:h=480' -c:v hevc_vaapi -f null -
...
[vf#0:0 @ 0x55acad91f400] Error while filtering: Cannot allocate memory
[vf#0:0 @ 0x55acad91f400] Task finished with error code: -12 (Cannot
allocate memory)
[vf#0:0 @ 0x55acad91f400] Terminating thread with return code -12
(Cannot allocate memory)

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2024-04-18 14:43:07 +08:00
Nicolas Gaullier 376b3d53c5 avfilter/vf_colorspace: use colorspace negotiation API
Fixes a regression due to the fact that the colorspace filter does
not use the new API introduced by 8c7934f73a.
The scale filter uses it since 45e09a3041, and the setparams
filter since 3bf80df3cc.

Example:
ffprobe -f lavfi yuvtestsrc,setparams=color_primaries=bt470bg:color_trc=
bt470bg:colorspace=bt470bg,colorspace=bt709:range=tv,scale,showinfo

Before:
  color_range:unknown color_space:bt470bg ...
After:
  color_range:tv color_space:bt709 ...

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: Niklas Haas <git@haasn.dev>
2024-04-17 22:17:56 +02:00
LuMingYin 5e380bcdb1 avfilter/af_channelsplit: fix memory leak
Signed-off-by: LuMingYin <lumingyindetect@163.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-04-15 10:30:46 +08:00
Fei Wang 0534d2ac84 lavfi/dnn_backend_torch: Include mem.h
Fix build fail since 790f793844.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2024-04-10 18:18:49 +08:00
Marton Balint 4721b9f15f avfilter/buffersrc: never override channel count in av_buffersrc_add_frame_flags
Overriding unknown layouts with the negotiated layout is OK, but the number of
channels should match with what was negotiated.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-04-09 23:12:46 +02:00
Anton Khirnov d7cde009ce lavfi/avfilter: add an "auto" constant to the threads option
Analogous to the same constant in avfiltergraph and avcodec.
Cf. f599ae88c2.
2024-04-09 10:34:18 +02:00
Anton Khirnov b0e1bc6298 lavfi/vf_scale: fix AVOption flags for "size"/"s" 2024-04-09 10:34:18 +02:00
Wenbin Chen 478d97f303 libavfilter/dnn_io_proc: Take step into consideration when crop frame
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2024-04-04 14:26:57 +08:00
Wenbin Chen 8869f5ce86 libavfilter/dnn_backend_openvino: Check bbox's height
Check bbox's height with frame's height rather than frame's width.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2024-04-04 14:26:52 +08:00
Jan Ekström 23d1b50175 avfilter/{buffersrc,vf_setparams}: map IPT-C2, YCgCo-R variants 2024-04-03 21:31:35 +03:00
Andreas Rheinhardt 7895d1860f avfilter/avfilter: Don't use av_uninit
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>
2024-04-03 19:14:12 +02:00
Andreas Rheinhardt 8d3fdb42c0 avfilter/vf_grayworld: Remove empty options and AVClass
This filter only had an AVClass and empty options because up until
recently, avfilter_init_str() errored out when options were provided
for a filter without an AVClass. But setting (generic) options is
necessary to take advantage of timeline support. So with
avfilter_init_str() fixed, the AVClass and the options can be removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-03 19:14:12 +02:00
Andreas Rheinhardt de288e406a avfilter/vf_hflip: Remove empty options and AVClass
This filter only had an AVClass and empty options because up until
recently, avfilter_init_str() errored out when options were provided
for a filter without an AVClass. But setting (generic) options is
necessary to take advantage of timeline support. So with
avfilter_init_str() fixed, the AVClass and the options can be removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-03 19:14:12 +02:00
Andreas Rheinhardt 99a200cad8 avfilter/vf_vflip: Remove empty options and AVClass
This filter only had an AVClass and empty options because up until
recently, avfilter_init_str() errored out when options were provided
for a filter without an AVClass. But setting (generic) options is
necessary to take advantage of timeline support. So with
avfilter_init_str() fixed, the AVClass and the options can be removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-03 19:14:12 +02:00
Andreas Rheinhardt 6260d4f770 avfilter/vf_swapuv: Remove empty options and AVClass
This filter only had an AVClass and empty options because up until
recently, avfilter_init_str() errored out when options were provided
for a filter without an AVClass. But setting (generic) options is
necessary to take advantage of timeline support. So with
avfilter_init_str() fixed, the AVClass and the options can be removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-03 19:14:12 +02:00
Andreas Rheinhardt 0c800c0b48 avfilter/avfilter: Honour the short options documentation
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>
2024-04-03 19:14:12 +02:00
Andreas Rheinhardt c96d0a0b85 avfilter/avfilter: Use AV_DICT_DONT_STRDUP_(KEY|VAL) when possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-03 19:14:12 +02:00
Andreas Rheinhardt 3ed23dab98 avfilter/vf_spp: Fix left-shift of negative value
Affected the vf-spp FATE-test (on x86 only when MMX
is disabled).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-02 00:21:58 +02:00
Andreas Rheinhardt 0e5f71230a avutil/internal: Move avpriv_set_systematic_pal2 decl to imgutils_internal.h
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
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
Andreas Rheinhardt b616be1649 lib*/version: Use static_assert for static asserts
Also update the checks that guard against inserting
a new enum entry in the middle of a range.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:42 +01:00
Andreas Rheinhardt a265e8ca92 avcodec, avfilter: Don't use "" for system headers
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:42 +01:00
Marton Balint 2df2b4067e avfilter/buffersrc: fix overriding unknown channel layouts with negotiated one
Fixes ffplay playback of unknown layouts, when SDL directly supports the audio
format, such as:

ffplay -f lavfi anullsrc=cl=2C,aformat=s16

Without the patch, "Channel layout change is not supported" errors are
generated because buffersrc (unknown 2 channel) and buffersink (stereo)
negotiated a stereo layout, but the stereo layout was never stored in the
BufferSourceContext.

This fixes a regression of 7251f90972, but this
is more of a regression of the avfilter channel layout conversion
(1f96db959c).

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-30 20:59:15 +01:00
Anton Khirnov fa110c32b5 lavfi/setpts: unset frame durations
Actual frame durations are, in general, not computable without buffering
a frame.

FIxes #10886
2024-03-29 09:09:40 +01:00
Anton Khirnov f121d954ac lavf/vf_setpts: unset output framerate
This filter produces VFR output in general.

Avoids dropping frames in the setpts test.
2024-03-29 09:07:13 +01:00
Michael Niedermayer 3d5f03bbc8
avfilter/vf_signature: Dont crash on no frames
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-28 18:07:13 +01:00
Niklas Haas b89ee26539 avfilter: properly reduce YUV colorspace format lists
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.
2024-03-27 19:11:27 +01:00
Michael Niedermayer 6b213175c9
Bump after 7.0 branch point
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-27 01:04:54 +01:00
Michael Niedermayer 872980ace6
Bump prior release/7.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-27 01:04:53 +01:00
Marton Balint eaca78eff8 avfilter/af_channelmap: add some additional checks for the mappings
- Properly initialize all the mappings to -1 by default.
- Make sure every output channel is assigned exactly once
- Autodetect a native layout when only native channels are present
- Always honor the user specified layout, but make sure the mapping is
  compatible with it

The last item is a regression from 4af412be71.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-24 21:27:55 +01:00
Marton Balint bba6dd391f avfilter/af_channelmap: factorize checking indexes against a channel layout
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-24 21:27:55 +01:00
Marton Balint 2f754a96bd avfilter/af_channelmap: disallow channel index 64
MAX_CH is 64, therefore the maximum index is 63.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-24 21:27:55 +01:00
Marton Balint 1bea3e9ee2 avfilter/af_channelmap: fix mapping if in_channel was a string but out_channel was not specified
In this case in_channel_idx was never set and the default 0 was used.
Suprisingly no one noticed that the respective fate test output was wrong.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-24 21:27:55 +01:00
Marton Balint 9a5627ea9a avfilter/af_channelmap: fix error message if FL source channel was missing
FL channel ID is 0, so for an unset value we must check for ID < 0.

Regression since 1f96db959c.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-24 21:27:55 +01:00
Henrik Gramner 782c4df28d x86: Avoid using 'd' as an argument name
x86inc.asm adds defines for <argument_name>{b,w,d,q} which clashes with
the nasm d{b,w,d,q} pseudo-instructions for writing initialized data.
2024-03-24 14:53:57 +01:00
Niklas Haas 25cd0e0913 avfilter/vf_showinfo: adapt to new AVFilmGrainParams 2024-03-23 18:54:36 +01:00
Wenbin Chen f4e0664fd1 libavfi/dnn: add LibTorch as one of DNN backend
PyTorch is an open source machine learning framework that accelerates
the path from research prototyping to production deployment. Official
website: https://pytorch.org/. We call the C++ library of PyTorch as
LibTorch, the same below.

To build FFmpeg with LibTorch, please take following steps as
reference:
1. download LibTorch C++ library in
 https://pytorch.org/get-started/locally/,
please select C++/Java for language, and other options as your need.
Please download cxx11 ABI version:
 (libtorch-cxx11-abi-shared-with-deps-*.zip).
2. unzip the file to your own dir, with command
unzip libtorch-shared-with-deps-latest.zip -d your_dir
3. export libtorch_root/libtorch/include and
libtorch_root/libtorch/include/torch/csrc/api/include to $PATH
export libtorch_root/libtorch/lib/ to $LD_LIBRARY_PATH
4. config FFmpeg with ../configure --enable-libtorch \
 --extra-cflag=-I/libtorch_root/libtorch/include \
 --extra-cflag=-I/libtorch_root/libtorch/include/torch/csrc/api/include \
 --extra-ldflags=-L/libtorch_root/libtorch/lib/
5. make

To run FFmpeg DNN inference with LibTorch backend:
./ffmpeg -i input.jpg -vf \
dnn_processing=dnn_backend=torch:model=LibTorch_model.pt -y output.jpg

The LibTorch_model.pt can be generated by Python with torch.jit.script()
api. https://pytorch.org/tutorials/advanced/cpp_export.html. This is
pytorch official guide about how to convert and load torchscript model.
Please note, torch.jit.trace() is not recommanded, since it does
not support ambiguous input size.

Signed-off-by: Ting Fu <ting.fu@intel.com>
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2024-03-19 14:48:58 +08:00
Timo Rothenpieler b47abd5737 avfilter/vsrc_ddagrab: clear all flags of buffer texture
One some system, one some displays, for unknown reasons,
these contain rather bad flags that cause all kinds of weird
behaviour.
2024-03-16 00:44:58 +01:00
Andreas Rheinhardt c00cd007e8 configure: Remove av_restrict
All versions of MSVC that support C11 (namely >= v19.27)
also support the restrict keyword, therefore av_restrict
is no longer necessary since 75697836b1.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-15 12:51:15 +01:00