Commit Graph

12214 Commits

Author SHA1 Message Date
Niklas Haas
6f1ab828d3 libavfilter/vf_libplacebo: add temperature option 2025-10-09 20:45:09 +00:00
Baptiste Coudurier
ef60d5ac32 general: fix warning 'av_malloc_array' sizes specified with 'sizeof'
in the earlier argument and not in the later argument [-Wcalloc-transposed-args]

Fixes trac ticket #11620
2025-10-07 14:51:46 -07:00
Zhao Zhili
c7815a4b70 avfilter/vf_chromakey: specify alphamode of chromakey filter
Fix assert failure with:
ffmpeg -i input.mp4 \
	-vf chromakey=similarity=0.1,format=yuva420p,alphaextract \
	-f null -

Assertion frame->alpha_mode == link->alpha_mode failed at src/libavfilter/avfilter.c:1085
2025-10-07 16:00:27 +00:00
Zhao Zhili
ba9c635784 avfilter/vf_chromakey_cuda: specify alpha_mode of output
Fix assert failure with:

ffmpeg -init_hw_device cuda=gpu -filter_hw_device gpu \
	-i input.mp4 -an \
	-vf hwupload,format=cuda,chromakey_cuda=color=black,hwdownload,format=yuva420p,alphaextract \
	-f null -

Assertion frame->alpha_mode == link->alpha_mode failed at src/libavfilter/avfilter.c:1085
2025-10-07 16:00:27 +00:00
Zhao Zhili
027497891b avfilter/vf_chromakey_cuda: simplify frame management 2025-10-07 16:00:27 +00:00
Zhao Zhili
bb3a4de5a7 avfilter/vf_bilateral_cuda: remove a goto which has no effect 2025-10-07 16:00:27 +00:00
Zhao Zhili
4e27a4ba03 avfilter/vf_bilateral_cuda: remove some variables and redundant operations
Since output format is equal to input format, there is no point to
save two groups of fmt and desc.
2025-10-07 16:00:27 +00:00
Zhao Zhili
d5f0c55f3f avfilter/vf_bilateral_cuda: don't create a new hwframe_ctx
There is no change on properties, so just reference the input
link's hwframe ctx.
2025-10-07 16:00:27 +00:00
Zhao Zhili
adf51312ee avfilter/vf_bilateral_cuda: simplify frame management 2025-10-07 16:00:27 +00:00
Zhao Zhili
a91cf4f38f avfilter/vf_bilateral_cuda: simplify the checking of window_size 2025-10-07 16:00:27 +00:00
Zhao Zhili
2749f5f91e avfilter/vf_bilateral_cuda: remove write only variable 2025-10-07 16:00:27 +00:00
Andreas Rheinhardt
e05f8acabf avfilter/blend_modes: Don't build duplicate functions
Some of the blend mode functions only depend on the underlying type
and therefore need only one version for 9, 10, 12, 14, 16 bits.
This saved 35104B with GCC and 26880B with Clang.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 17:49:08 +02:00
Andreas Rheinhardt
ea346a23de avfilter/blend_modes: Use stride in bytes
The blend functions currently convert strides from bytes to elements
of the type by using the stride /= sizeof(pixel) idiom. Yet this has
several drawbacks:
1. It invokes undefined behavior that happens to work when stride is
negative: size_t is typically the unsigned type of ptrdiff_t and
therefore the division will be performed as size_t, i.e. use logical
right shifts, making stride very big when sizeof(pixel) is > 1. This
works, because pointer to pixel for accesses entails an implicit
factor of sizeof(pixel) so that everything is correct modulo SIZE_MAX.
Yet this is UB and UBSan complains about it.
2. It makes the compiler emit actual shifts/ands to discard the low bits
shifted away.
3. There may be systems where alignof(uint16_t) or alignof(float) is
strictly smaller than their sizeof, so that the stride (in bytes) is
not guaranteed to be multiple of these sizeofs. In this case, dividing
by sizeof(pixel) is simply wrong.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 17:49:08 +02:00
Niklas Haas
b80f28fcbc avfilter/vf_libplacebo: introduce fit_sense option
This allows choosing whether the `fit_mode` merely controls the placement
of the image within the output resolution, or whether the output resolution
is also adjusted according to the given `fit_mode`.
2025-09-30 15:39:39 +00:00
Niklas Haas
12d696cff4 avfilter/vf_libplacebo: introduce fit_mode option
The semantics of these keywords are well-defined by the CSS 'object-fit'
property. This is arguably more user-friendly and less obtuse than the
existing `normalize_sar` and `pad_crop_ratio` options. Additionally, this
comes with two new (useful) behaviors, `none` and `scale_down`, neither of
which map elegantly to the existing options.

One additional benefit of this option is that, unlike `normalize_sar`, it
does *not* also imply `reset_sar`; meaning that users can now choose to
have an anamorphic base layer and still have the overlay images scaled to fit
on top of it according to the chosen strategy.

See-Also: https://drafts.csswg.org/css-images/#the-object-fit
2025-09-30 15:39:39 +00:00
Niklas Haas
6ad839ff2e avfilter/vf_scale_*: add enum names for force_oar magic values 2025-09-30 15:39:39 +00:00
Kacper Michajłow
d6cb0d2c2b ALL: move av_unused to conform with standard requirement
This is required placement by standard [[maybe_unused]] attribute, works
the same for __attribute__((unused)).

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-26 16:15:46 +00:00
James Almer
b9cc8e3210 avfilter/vf_scale: don't attempt to rescale AV_NOPTS_VALUE
Finishes fixing issue #20589.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-26 12:24:04 -03:00
James Almer
5614672d1b avfilter/framesync: don't attempt to rescale AV_NOPTS_VALUE
Part of a fix for issue #20589.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-26 12:24:04 -03:00
Timo Rothenpieler
994a368451 configure: deprecate support for libnpp 2025-09-26 12:31:39 +00:00
Andreas Rheinhardt
4fc05c28f4 avfilter/x86/vf_gradfun: Remove MMXEXT func overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 version
of filter_line.
This commit therefore removes the overridden MMXEXT version
(which didn't abide by the ABI) which allows us to remove
an emms_c() from vf_gradfun.c, so that users with SSSE3 no longer
pay a price for the mere existence of an MMXEXT version.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:35 +02:00
Andreas Rheinhardt
baace56169 avfilter/vf_tonemap_opencl: Make array smaller
Also makes the code more independent of AVCOL_TRC_NB.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:00:43 +02:00
Andreas Rheinhardt
f0586ffa95 avfilter/vf_colorspace: Make array smaller
Also makes it more independent of AVCOL_TRC_NB.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:00:14 +02:00
Vittorio Palmisano
9970dc32bf avfilter/af_whisper: fix srt index
The srt index should be incremented for each segment.
2025-09-25 11:34:10 +00:00
Vittorio Palmisano
f18b1e2389 avfilter/af_whisper: fix int64 printf format
Use PRId64 for printing int64_t values in the SRT output.
2025-09-23 23:35:58 +00:00
Niklas Haas
899e497122 avfilter/vf_libplacebo: force premultiplied blending for linear texture
Blending onto independent alpha framebuffers is not possible under the
constraints of the supported blend operators. While we could handle
blending premul-onto-premul, this would break if the base layer is YUV,
since premultiplied alpha does not survive the (nonlinear) YUV conversion.

Fortunately, blending independent-onto-premul is just as easy, and works in
all cases. So just force this mode when using a linear intermediate blend
texture, which is always RGBA.
2025-09-23 18:50:03 +00:00
Niklas Haas
6f08ab6c4c avfilter/vf_libplacebo: use temporary params struct for per-pass params
Instead of directly mutating `opts->params`. Avoids any possible leak of
overriden params between invocations of this function, as well as the later
`pl_render_image` during the linear output pass.
2025-09-23 18:50:03 +00:00
Niklas Haas
0bd5a7d371 avfilter/vf_colordetect: only report detected properties on EOF
Instead of reporting them also when the filtergraph is suddenly destroyed
mid-stream, e.g. during the `ffmpeg` tool's early init.
2025-09-21 13:28:58 +02:00
Niklas Haas
843920d5d6 avfilter/x86/vf_idetdsp: add AVX2 and AVX512 implementations
The only thing that changes slightly is the horizontal sum at the end.
2025-09-21 11:02:41 +00:00
Niklas Haas
4c067d0778 avfilter/x86/vf_idetdsp: generalize 8-bit macro
This is mostly compatible with AVX as well, so turn it into a macro.
2025-09-21 11:02:41 +00:00
Niklas Haas
326abf359f avfilter/vf_idetdsp: use consistent uint8_t pointer type
Even for 16-bit DSP functions. Instead, cast the pointer inside the
function.
2025-09-21 11:02:41 +00:00
Niklas Haas
60dbcc5321 avfilter/vf_idetdsp: pass actual bit depth
More informative and IMO cleaner; some implementations may want to
differentiate by exact bit depth or support 32 bit down the line.
2025-09-21 11:02:41 +00:00
Niklas Haas
56bb187ca9 avfilter/vf_idet: correctly update dsp function on format change
Currently, this never updates on change from high bit depth to low bit depth.
2025-09-21 11:02:41 +00:00
Niklas Haas
2b67137daa avfilter/vf_idet: correctly reset pixdesc on format change 2025-09-21 11:02:41 +00:00
Niklas Haas
5830743363 avfilter/vf_idet: separate DSP parts
To avoid pulling in the entire libavfilter when using the DSP functions
from checkasm.

The rest of the struct is not needed outside vf_idet.c and was moved there.
2025-09-21 11:02:41 +00:00
Niklas Haas
367febc491 avfilter/vf_idet: expose DSP init function internally
For checkasm.
2025-09-21 11:02:41 +00:00
Kacper Michajłow
c373636f55 avfilter/vsrc_gfxcapture: fix string format specifier
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-18 03:55:54 +02:00
Timo Rothenpieler
61835e1d8b avfilter/vsrc_gfxcapture: keep cbdata object alive
Depending on the threading backend the stdlib uses, creating a
mutex/condvar can be quite expensive.
So keep this object alive in the ctx, on which we synchronize via the
uninit mutex anyway.
2025-09-18 01:04:59 +00:00
Timo Rothenpieler
c4e537793b avfilter/vsrc_gfxcapture: fix leaking all callback handlers
Fixes #20537
2025-09-18 01:04:59 +00:00
Timo Rothenpieler
1849068c65 avfilter/vsrc_gfxcapture: use free threaded capture frame pool
Apparently, using a normal frame pool in a multithreaded environment
leads to strange resource leaks on shutdown, which vanish when using a
free threaded pool.
2025-09-18 01:04:59 +00:00
Timo Rothenpieler
4879c9f4e2 avfilter/vsrc_gfxcapture: stop capture session before initializing capture thread shutdown
It might have things going on in the background that still need cleaned
up, and this gives it a chance to enqueue them on the dispatch queue.
2025-09-18 01:04:59 +00:00
Timo Rothenpieler
23d9412ff9 avfilter/vsrc_gfxcapture: fix re-using ret variable from outside of lambda scope 2025-09-18 01:04:59 +00:00
Timo Rothenpieler
983fed34f8 avfilter/vsrc_gfxcapture: don't pass pointer to ComPtr
While it does appear to work fine, with all the operator overloads, it
at least has potential for surprises, so pass it by reference instead.
2025-09-18 01:04:59 +00:00
Timo Rothenpieler
00ddb408c5 avfilter/vsrc_ddagrab: support rendering mouse cursor onto array textures 2025-09-17 14:50:41 +00:00
Andreas Rheinhardt
f47b270b41 avfilter/vf_colordetect: Move ff_color_detect_dsp_init() out of .c file
Otherwise checkasm pulls in vf_colordetect.o and then all of
libavfilter.

Reviewed-by: Martin Storsjö <martin@martin.st>
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-16 18:23:52 +02:00
Andreas Rheinhardt
fe0a313299 avfilter/vf_colordetect: Avoid sequentially consistent atomics
Reviewed-by: Martin Storsjö <martin@martin.st>
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-16 18:23:45 +02:00
Andreas Rheinhardt
a35c91dc14 avfilter/vf_colordetect: Rename header to vf_colordetectdsp.h
It is more in line with our naming conventions.

Reviewed-by: Martin Storsjö <martin@martin.st>
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-16 18:22:24 +02:00
Timo Rothenpieler
b8256b82f5 avfilter/vsrc_gfxcapture: remove needless use of atomics 2025-09-16 15:52:11 +00:00
Timo Rothenpieler
61378d6b91 avfilter/vsrc_gfxcapture: fix possible missed wakeup race in capture loop 2025-09-16 15:52:11 +00:00
Drew Dunne
76471fb143 vf_colorspace: Add an option to clamp trc LUT output
Add a new flag to the vf_colorspace filter which provides the user an
option to clamp the linear and delinear transfer characteristics LUT
values to the [0, 1] represented range. This helps constrain the
potential value range when converting between colorspaces.

Certain colors when going through the conversion can result in out of
gamut colors after the rotation. The colorspace filter allows that with
the extended range. The added clamping just keeps the colors within the
[0, 1) range rather than using that extended range. I'm not enough of a
color scientist to say which is correct, but there are certain
situations where we would prefer to keep the colors in gamut.

The example I have is:

A solid color image of 8-bit YUV: Y=157, U=164, V=98.

Specify the input as:

Input range: MPEG
In color matrix: BT470BG
In color primaries: BT470M
In color transfer characteristics: Gamma 28

Output as:
Out color range: JPEG
Out color matrix: BT.709
Out color primaries: BT.709
Out color transfer characteristics: BT.709

During the calculation you get:

Input YUV:                             y=157,      u=164,      v-98
Post-yuv2rgb BT.470BG:                 r=0.456055, g=0.684152, b=0.928606
Post-apply gamma28 linear LUT:         r=0.110979, g=0.345494, b=0.812709
Post-color rotation BT.470M to BT.709: r=-0.04161, g=0.384626, b=0.852400
Post-apply Rec.709 delinear LUT:       r=-0.16382, g=0.615932, b=0.923793
Post-rgb2yuv Rec.709 matrix:           y=120,      u=190,      v=25

Where with this change, the delinear LUT output would be clamped to 0,
so the result would be:
r=0.000000, g=0.612390, b=0.918807 and a final output of
y=129, u=185, v=46

As for the long and av_clip64, this was just because lrint returned a
long, so I left it as that and then used av_clip64 to the [0,1) range to
avoid overflow. But re-reading, it looks like av_clip_int16 would
downcast that long to int anyway so the possibility of overflow already
existed there. I've put it back to int just to match the existing
behavior.
2025-09-15 14:39:09 +00:00