Commit graph

11890 commits

Author SHA1 Message Date
66e9888bf4
avfilter/vf_v360: Fix NULL pointer use
Fixes: applying zero offset to null pointer
partly Fixes: verysmall.flv

Found-by: Elias Myllymäki <elias.myllymaki04p@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-01-15 01:27:46 +01:00
Andreas Rheinhardt
e540381f91 avfilter/vf_xpsnr: Avoid array only one of whose elements is used
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-01-12 15:41:40 +01:00
Andreas Rheinhardt
7822beed85 avfilter/vf_xpsnr: Fix leaks
This filter uses the AVBuffer API to allocate buffers that are never
shared at all and frees them via av_freep() (actually, it passes
pointers to AVBufferRefs to av_freep, so that only the AVBuffer
structures are freed at all (because AVBufferRef has a AVBuffer* as its
first member), not the AVBufferRef and not the underlying buffers;
and due to a wrong check the AVBuffers corresponding
to buf_org[c] with c>0 were never freed at all). This is a violation
of the AVBuffer API and causes a memleak. Fix this by avoiding the
AVBuffer API altogether.
(The FATE tests don't catch this, because they use piping to awk,
so that the error code from ffmpeg is ignored.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-01-12 15:41:40 +01:00
Andreas Rheinhardt
7ab7d9c3c0 avfilter/avfilter: Add FFFilter, hide internals of AVFilter
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>
2025-01-12 15:41:40 +01:00
Andreas Rheinhardt
9bbab3255b avfilter/vf_overlay: Remove spec-incompliant ';'
Fixes warnings with -pedantic with GCC and Clang.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-01-12 15:41:40 +01:00
b5b6391d64
avfilter/af_pan: Fix sscanf() use
Fixes: Memory Data Leak

Found-by: Simcha Kosman <simcha.kosman@cyberark.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-01-08 23:23:24 +01:00
9ffa127aa6
avfilter/vf_grayworld: Use the correct pointer for av_log()
Fixes: crash

Found-by: Elias Myllymäki <elias.myllymaki04p@gmail.com>
Reviewed-by: Alexander Strasser <eclipse7@gmx.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-01-08 23:23:24 +01:00
b72de49295
avfilter/vf_addroi: Add missing NULL termination to addroi_var_names[]()
Fixes: out of array read

Found-by: Elias Myllymäki <elias.myllymaki04p@gmail.com>
Reviewed-by: Alexander Strasser <eclipse7@gmx.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-01-08 23:23:23 +01:00
Koushik Dutta
252fc2e047 avfilter/scale_vulkan: add dynamic crop region and aspect ratio match
The scale_vulkan filter initializes the shader once, with the crop
region set by the original frame. However, subsequent frames may
specify a different crop region than the first frame. This change
updates the cropping to match the behavior present on the other
hardware frame scale filters.

The scale filter should also allow negative values
that respect aspect ratio, similar to other scale filters.

Signed-off-by: Koushik Dutta <koushd@gmail.com>
2025-01-07 08:34:59 +09:00
James Almer
cd174c7c7c avfilter/aeval: don't leak the strdup'd expression string
Signed-off-by: James Almer <jamrial@gmail.com>
2025-01-04 20:45:10 -03:00
James Almer
e262411f32 avfilter/aeval: tighten the check for empty expression
Fixes ticket #11395

Signed-off-by: James Almer <jamrial@gmail.com>
2025-01-04 20:45:10 -03:00
Leandro Santiago
9d9ac8e2ca avfilter/vf_dnn_detect: fix loading anchors when labels file is set
References https://trac.ffmpeg.org/ticket/11387

Defining anchors is needed, even when a filename with the labels is set.
The issue was identified when using yolov4-tiny model using openvino.

More information about how to reproduce the bug can be found on the trac
issue referenced by this commit.

Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com>
2025-01-04 20:12:12 +08:00
James Almer
dd5696c197 avfilter/buffersrc: make channel_layout a CHLAYOUT type AVOption
The string type is a remnant of the old channel layout API implementation.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-01-02 12:11:08 -03:00
James Almer
041a6c3614 avfilter/buffersink: don't leak the reallocated channel layouts array
And ensure the last element is the zeroed terminator.

Fixes ticket #11392.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-01-01 19:42:11 -03:00
James Almer
1446e37d3d avfilter/buffersrc: check for valid sample rate
A sample rate <= 0 is invalid.

Fixes an assert in ffmpeg_enc.c that assumed a valid sample rate would be set.
Fixes ticket #11385.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-31 11:54:12 -03:00
Niklas Haas
d23f443dfc avfilter/vf_lut*: strip color volume metadata
These filters, in general, will apply some arbitrary color volume
transformation. Strip corresponding metadata to be conservative/safe.
2024-12-23 14:23:13 +01:00
Niklas Haas
eecdc25d4b avfilter/vf_colorspace: strip color volume metadata 2024-12-23 14:23:13 +01:00
Niklas Haas
0d468730bc avfilter/vf_libplacebo: update metadata stripping logic
Switches to av_frame_side_data_remove_by_props(), covering a number of
cases that we previously ignored. Additionally, stop stripping metadata
when merely changing colorspace or color range, since these do not
affect the actual color volume of the image data, only the encoding.
2024-12-23 14:23:13 +01:00
Niklas Haas
d1eadc43b9 avfilter/vf_zscale: strip metadata on change
Required for both size changes and color volume changes (as a result of
changing primaries/transfer).
2024-12-23 14:23:13 +01:00
Niklas Haas
f22965b882 avfilter/vf_scale*: strip metadata on size change 2024-12-23 14:23:13 +01:00
Niklas Haas
01ce9d7963 avfilter/vf_scale: strip metadata when changing colorspace
This is no longer relevant after a change in color space.
2024-12-23 12:33:43 +01:00
Niklas Haas
4315cc943a avfilter/vf_scale: make options alignment consistent (cosmetic) 2024-12-23 12:33:43 +01:00
Niklas Haas
b7a2333357 avfilter/vf_scale: add colorspace and transfer property options
In the long run, it would be ideal if we could add these to the avfilter
negotiation as well, but for now, this is a good start.
2024-12-23 12:33:43 +01:00
2e06b84e27
vulkan: do not reinvent a queue context struct
We recently introduced a public field which was a superset
of the queue context we used to have.

Switch to using it entirely.

This also allows us to get rid of the NIH function which was
valid only for video queues.
2024-12-23 04:25:09 +09:00
Kacper Michajłow
7902702762
avfilter/af_ashowinfo: fix scaling factor of replaygain peak values
Commit 8542f9c4f1 changed replaygain peak
values to use 100k instead of UINT32_MAX as peak, with possibility of
overflow. af_ashowinfo was never updated to reflect this, so we update
it now.

Fixes: 8542f9c4f1
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2024-12-07 12:03:53 -05:00
Marton Balint
8d6f3bcb96 avfilter/asrc_sine: increase frequency accuracy
Previously the delta phase was fixed point fractional with 2^32 fractions,
which caused inaccuracies in the output frequency, unless the input
frequency*2^32 was divisable by the sample rate.

This patch improves frequency accuracy by tracking subfractions of the delta
phase fractions. For this we are using a denominator which is a multiple of the
sample rate, making sure that integer frequencies are always accurately
represented.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-11-29 21:16:22 +01:00
Marton Balint
06247ae746 avfilter/asrc_sine: factorize sampling to a separate context
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-11-29 21:16:22 +01:00
Zhao Zhili
82c208b653 avfilter/textutils: Add missing time_internal.h
This fix build error on Windows with MSVC. We need time_internal.h
for gmtime_r and localtime_r.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-11-29 12:30:48 +08:00
Fei Wang
bc991ca048 lavfi/qsvvpp: Copy frame props before modify it
The changes to output frame props in query_frame overlapped since
578ac59887. Move the copy frame props before the changes.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
2024-11-28 11:13:25 +08:00
Koushik Dutta
ac3f69a4b9 avfilter/scale_vt: implement frame crop
The crop filter has no effect on scale_vt:

-vf crop=100:100,scale_vt=300x300

Hardware frames (AV_PIX_FMT_FLAG_HWACCEL) are expected to use the crop_* properties,
as seen in the implementation vf_crop.c.

Signed-off-by: Koushik Dutta <koushd@gmail.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-11-26 11:54:28 +08:00
Koushik Dutta
352333543c avfilter/scale_vt: implement negative width/height aspect ratio sizing
Signed-off-by: Koushik Dutta <koushd@gmail.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-11-26 11:26:38 +08:00
Niklas Haas
bcbf3a5630 avfilter/vf_scale: fix off-by-one in loop bounds
Results in over-read of the array. Fortunately, the excess element was
never actually used, but it still triggers ASAN (and could in theory trigger
a segfault).

Fixes: 04ce01df0b
2024-11-25 14:40:49 +01:00
Niklas Haas
04ce01df0b avfilter/vf_scale: switch to new swscale API
Most logic from this filter has been co-opted into swscale itself,
allowing the resulting filter to be substantially simpler as it no
longer has to worry about context initialization, interlacing, etc.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2024-11-25 11:03:54 +01:00
ecb7232bac avfilter: fix unused variable warning
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.
2024-11-24 22:11:12 +01:00
Leandro Santiago
69cbda5770 lavfi/vf_drawtext: fix memory management when destroying font face
Ref https://trac.ffmpeg.org/ticket/11152

According to harfbuzz docs, hb_ft_font_set_funcs() does not need to be
called, as, quoted:

```
An #hb_font_t object created with hb_ft_font_create()
is preconfigured for FreeType font functions and does not
require this function to be used.
```

Using this function seems to cause memory management issues between
harfbuzz and freetype, and could be eliminated.

This commit also call hb_ft_font_changed() when the underlying FC_Face
changes size, as stated on hardbuzz:

```
HarfBuzz also provides a utility function called hb_ft_font_changed() that you should call
whenever you have altered the properties of your underlying FT_Face, as well as a hb_ft_get_face()
that you can call on an hb_font_t font object to fetch its underlying FT_Face.
```

Finally, the execution order between hb_font_destroy() and
hb_buffer_destroy() is flipped to match the order of creation of
the respective objects.

Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-11-19 23:50:49 +01:00
Marton Balint
fe18ed3f2a avfilter/f_loop: fix aloop activate logic
The logic did not follow the documented behaviour and that caused skipping of
some audio in the loop and in the leftover buffer.

Example command line which should produce a smooth sine wave for the whole
duration of the output:

ffmpeg -f lavfi -i "sine=r=48000:f=480:d=4" -af "aloop=loop=4:start=48000:size=48000" out.wav

Fixes ticket #11283.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-11-11 21:56:34 +01:00
Marton Balint
b33a594160 avfilter/f_loop: fix length of aloop leftover buffer
If the audio loop stops inside an audio frame, the leftover buffer contains the
end of the frame, which is not looped. The length supposed to be the part which
was not written to the loop buffer, so we need to drain exactly that number of
bytes from the leftover buffer.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-11-11 21:56:34 +01:00
James Almer
10c02deccb avfilter/vf_zscale: extend the configuration log message with color space info
And print it in DEBUG level, not TRACE, as it's useful information.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-11-09 19:33:57 -03:00
James Almer
5c8268ac56 avfilter/vf_zscale: remove unecessary argument from realign_frame
Possible since the previous commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-11-09 19:33:56 -03:00
James Almer
c8e5c684b3 avfilter/vf_zscale: align the frame buffers
Signed-off-by: James Almer <jamrial@gmail.com>
2024-11-09 19:33:56 -03:00
Pavel Koshevoy
00cf3df03f lavfi/vf_zscale: fix call to av_pix_fmt_count_planes
realign_frame called av_pix_fmt_count_planes with incorrect parameter.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-11-09 19:33:56 -03:00
Pavel Koshevoy
7b302f4db7 lavfi/vf_zscale: fix tmp buffer ptr alignment for zimg_filter_graph_process
Signed-off-by: James Almer <jamrial@gmail.com>
2024-11-09 19:33:56 -03:00
James Almer
f15fc27db5 avfilter/framepool: align the frame buffers
And not just the linesizes. Use the extra align bytes allocated for this purpose.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-11-09 19:33:56 -03:00
Anton Khirnov
3e9b0f7c01 lavfi/vf_libplacebo: eliminate LibplaceboInput.link
Setting it was broken in 8160178dfc, since
links are not yet set up during init. It is also redundant, as the
struct also stores the input index.

Reported-By: llyyr <llyyr.public@gmail.com>
2024-11-09 02:45:58 +01:00
James Almer
c8438546ff avfilter/vsrc_testsrc: add support for RGB48/RGBA64
Signed-off-by: James Almer <jamrial@gmail.com>
2024-11-06 17:34:32 -03:00
James Almer
165f124129 vsrc_testsrc: add support for x2rgb10le to rgbtestsrc
Signed-off-by: James Almer <jamrial@gmail.com>
2024-11-02 15:01:31 -03:00
Koushik Dutta
0cdcbab9e9 avfilter/scale_cuda: frame crop support
The crop filter has no effect on scale_cuda:

-vf crop=100:100,scale_cuda=100x100

Hardware frames (AV_PIX_FMT_FLAG_HWACCEL) are expected to use the crop_* properties,
as seen in the implementation vf_crop.c.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2024-11-01 17:10:34 +01:00
James Almer
42b748f738 avfilter/vsrc_testsrc: add support for XV48
Signed-off-by: James Almer <jamrial@gmail.com>
2024-10-26 00:04:55 -03:00
James Almer
dfd7acf3ed avfilter/vf_pixdesctest: also take into account undefined alpha components
Ensure those bits are copied, which will result in the output being the same as
the input, where swscale set them to the equivalent of fully opaque.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-10-21 09:52:58 -03:00
James Almer
8debc5aa41 avfilter/vsrc_testsrc: use the alpha component information for XV3{0,6} and V30X
And add a few more tests to ensure all the pixfmts affected by this change
are tested.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-10-21 09:52:58 -03:00