Commit Graph

11481 Commits

Author SHA1 Message Date
James Almer 82397084a9 avfilter/vf_scale: properly reinitialize framesync
Fixes leaks as reported by ASAN and Valgrind.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-05 21:37:07 -03:00
James Almer ccf395e8bd avfilter/framesync: reset nb_in on allocation failure
Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-05 21:37:07 -03:00
James Almer eb392e4100 avfilter/vf_scale: don't expose framesync options in vf_scale2ref
It doesn't use them.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-05 21:37:07 -03:00
Niklas Haas 6a5b021e35 avfilter/vf_scale: fix input declaration
This filter needs to be marked as having only one input by default, with
AVFILTER_FLAG_DYNAMIC_INPUTS allowing the extra input to be added at
init() time.

Fixes: bb80445813
2024-05-04 13:07:27 +02:00
Niklas Haas 95568c4e31 avfilter/scale2ref: deprecate in favor of scale=rw:rh
And remove it from the documentation.
2024-05-03 14:23:23 +02:00
Niklas Haas bb80445813 avfilter/vf_scale: add optional "ref" input
This is automatically enabled if the width/height expressions reference
any ref_* variable. This will ultimately serve as a more principled
replacement for the fundamentally broken scale2ref.

See-Also: https://trac.ffmpeg.org/ticket/10795
2024-05-03 14:23:23 +02:00
Niklas Haas e82a3997cd avfilter/vf_scale: switch to FFFrameSync
Preliminary commit, in anticipation of adding support for multiple
inputs (with proper synchronization and activate() callback).
2024-05-03 14:23:23 +02:00
Niklas Haas a5032dc12a avfilter/framesync: make framesync_class un-static
And rename to ff_framesync_class. More convenient for downstream users.
2024-05-03 14:23:22 +02:00
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