1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00
Commit Graph

118895 Commits

Author SHA1 Message Date
9c4a26d9b0 avgblur_vulkan: fix duplicated variable error when planes=0 2025-02-18 10:44:54 +01:00
389fb36f92 avgblur_vulkan: port to imageLoad() 2025-02-18 10:44:53 +01:00
779763181f bwdif_vulkan: convert to storage images
texture() uses bilinear scaling; imageLoad() accesses the image directly.
The reason why texture() was used throughout Vulkan filters is that
back when they were written, they were targetting old Intel hardware,
which had a texel cache only for sampled images.

These days, GPUs have a generic cache that doesn't care what source it
gets populated with. Additionally, bypassing the sampling circuitry saves
us some performance.

Finally, all the old texture() code had an issue where unnormalized
coordinates were used, but an offset of 0.5 was not added, hence each
pixel ended up being interpolated. This fixes this.
2025-02-18 10:44:53 +01:00
042ed96d0a vulkan_filter: use GENERAL image layout when no sampler is given
This allows using the generic filter code with STORAGE image inputs.
2025-02-18 10:44:53 +01:00
1029f51285 vulkan: fix crash in ff_vk_shader_free
The issue is if a shader fails to compile, shd->desc_layout would
not exist, but nb_descriptor_sets would.
2025-02-18 10:44:49 +01:00
4dc2ae69e7 avfilter/interlace_vulkan: add interlace_vulkan filter
This is a Vulkan-accelerated version of the existing interlace filter.
2025-02-17 17:16:25 +01:00
0e7c2a6287 fftools/ffmpeg: use an int for nb_threads
Removes unnecessary allocations.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-17 09:40:13 -03:00
b92577405b swscale/aarch64/rgb2rgb_neon: Implemented {yuyv, uyvy}toyuv{420, 422}
A78:
uyvytoyuv420_neon:                                    6112.5 ( 6.96x)
uyvytoyuv422_neon:                                    6696.0 ( 6.32x)
yuyvtoyuv420_neon:                                    6113.0 ( 6.95x)
yuyvtoyuv422_neon:                                    6695.2 ( 6.31x)

A72:
uyvytoyuv420_neon:                                    9512.1 ( 6.09x)
uyvytoyuv422_neon:                                    9766.8 ( 6.32x)
yuyvtoyuv420_neon:                                    9639.1 ( 6.00x)
yuyvtoyuv422_neon:                                    9779.0 ( 6.03x)

A53:
uyvytoyuv420_neon:                                   12720.1 ( 9.10x)
uyvytoyuv422_neon:                                   14282.9 ( 6.71x)
yuyvtoyuv420_neon:                                   12637.4 ( 9.15x)
yuyvtoyuv422_neon:                                   14127.6 ( 6.77x)

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-17 11:39:42 +02:00
64107e22f5 swscale/aarch64/rgb24toyv12: skip early right shift by 2
It's a minor improvement that shaves off 5-8% from the execution time.
Instead of shifting by 2 right away and by 7 soon after, shift by 9 one
time.

Times before and after:

A78:
rgb24toyv12_16_200_neon:                              5366.8 ( 3.62x)
rgb24toyv12_128_60_neon:                             13574.0 ( 3.34x)
rgb24toyv12_512_16_neon:                             14463.8 ( 3.33x)
rgb24toyv12_1920_4_neon:                             13508.2 ( 3.34x)
rgb24toyv12_1920_4_negstride_neon:                   13525.0 ( 3.34x)

rgb24toyv12_16_200_neon:                              5293.8 ( 3.66x)
rgb24toyv12_128_60_neon:                             12955.0 ( 3.50x)
rgb24toyv12_512_16_neon:                             13784.0 ( 3.50x)
rgb24toyv12_1920_4_neon:                             12900.8 ( 3.49x)
rgb24toyv12_1920_4_negstride_neon:                   12902.8 ( 3.49x)

A72:
rgb24toyv12_16_200_neon:                              9695.8 ( 2.50x)
rgb24toyv12_128_60_neon:                             20286.6 ( 2.70x)
rgb24toyv12_512_16_neon:                             22276.6 ( 2.57x)
rgb24toyv12_1920_4_neon:                             19154.1 ( 2.77x)
rgb24toyv12_1920_4_negstride_neon:                   19055.1 ( 2.78x)

rgb24toyv12_16_200_neon:                              9214.8 ( 2.65x)
rgb24toyv12_128_60_neon:                             20731.5 ( 2.65x)
rgb24toyv12_512_16_neon:                             21145.0 ( 2.70x)
rgb24toyv12_1920_4_neon:                             17586.5 ( 2.99x)
rgb24toyv12_1920_4_negstride_neon:                   17571.0 ( 2.98x)

A53:
rgb24toyv12_16_200_neon:                             12880.4 ( 3.76x)
rgb24toyv12_128_60_neon:                             27776.3 ( 3.94x)
rgb24toyv12_512_16_neon:                             29411.3 ( 3.94x)
rgb24toyv12_1920_4_neon:                             27253.1 ( 3.98x)
rgb24toyv12_1920_4_negstride_neon:                   27474.3 ( 3.95x)

rgb24toyv12_16_200_neon:                             12196.3 ( 3.95x)
rgb24toyv12_128_60_neon:                             26943.1 ( 4.07x)
rgb24toyv12_512_16_neon:                             28642.3 ( 4.07x)
rgb24toyv12_1920_4_neon:                             26676.6 ( 4.08x)
rgb24toyv12_1920_4_negstride_neon:                   26713.8 ( 4.07x)

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-17 10:49:41 +02:00
88d9ecaa7b avutil/frame: Fix direct pointer compare between different array
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-02-17 15:09:52 +08:00
f926b60455 avcodec/hevc: Add alpha layer support
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-02-17 15:09:41 +08:00
d367016d3c avcodec/hevc/ps: Add basic HEVC_SCALABILITY_AUXILIARY support
Only implementing what's needed for HEVC with alpha.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-02-17 15:08:42 +08:00
d3220ed818 avcodec/hevc: Rewrite scalability_mask_flag parse in decode_vps_ext
Remove a for loop and make it easy to extend to support other types
of scalability. Move ScalabilityMask to hevc header file so it can
be used in hevc decoder.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-02-17 15:08:33 +08:00
01f74bfaa2 avcodec/rv60dec: Initialize slice gb with actually allocated size
Fixes: out of array access
Fixes: 385170375/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-4710055187906560

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-16 15:41:43 +01:00
8668957ef6 avformat/iff: Check that we have a stream in read_dst_frame()
Fixes: null pointer dereference
Fixes: 385644864/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-4551049565765632

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-16 15:41:42 +01:00
464fb861b1 avcodec/aac/aacdec_lpd: Limit get_unary()
The limit is based on later code storing 32bits

Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 393164866/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-4606798354513920

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-16 15:41:42 +01:00
41cd72d76e avcodec/aac/aacdec_usac: Simplify decode_usac_scale_factors()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-16 15:41:42 +01:00
d1be369af6 avcodec/aac/aacdec: Clear SFO on error
types and SFO become confused for a USAC stream

Fixes: out of array access
Fixes: 383854203/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-4996677847547904.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-16 15:41:41 +01:00
251d43aef0 avformat/mlvdec: fix size checks
Fixes: heap-buffer-overflow
Fixes: 391962476/clusterfuzz-testcase-minimized-ffmpeg_dem_MLV_fuzzer-5746746587676672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-16 15:41:41 +01:00
1afbc40875 avformat/wavdec: Fix overflow of intermediate in block_align check
Fixes: signed integer overflow: -251517880 * 32 cannot be represented in type 'int'
Fixes: 385224934/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-4909298151915520

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-16 15:41:41 +01:00
9fd23f712a fftools/opt_common: add time and datetime log flags
This commit adds two logging flags: 'time' and 'datetime'.

Usage:

ffmpeg -loglevel +time

or

ffmpeg -loglevel +datetime

Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-16 15:41:40 +01:00
c79cdae377 avutil/log: support logging of date and time information
Signed-off-by: softworkz <softworkz@hotmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-16 15:41:40 +01:00
e417f939da lavc/vvc: Set fc->ref to NULL at top of decode_nal_units
In the fail: block of decode_nal_units, a check as to whether fc->ref is
nonzero is used.  Before this patch, fc->ref was set to NULL in
frame_context_setup.  The issue is that, by the time frame_context_setup
is called, falliable functions (namely slices_realloc and
ff_vvc_decode_frame_ps) have already been called.  Therefore, there
could arise a situation in which the fc->ref test of decode_nal_units'
fail: block is performed while fc->ref has an invalid value.  This seems
to be particularly prevalent in situations where the FrameContexts are
being reused.  The patch resolves the issue by moving the assignment of
fc->ref to NULL to the very top of decode_nal_units, before any falliable
functions are called.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2025-02-16 11:54:55 +08:00
a50d36b5fd avcodec/vvc/refs: Check content_ref in set_pict_type()
Fixes: 390565846/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-4990028521996288
Fixes: Null pointer dereference

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-15 11:25:12 +08:00
3698570442 avcodec/amfenc: Fix max rate control log message 2025-02-14 17:21:11 +01:00
75ade2dd49 avcodec/hevc_mp4toannexb: prepend extradata before the leading PS for an IRAP
Parameter sets may be coded in the packet before an IRAP (as is the case for
the hev1 ISO-BMFF brand), and they should have priority as they may override
the extradata ones.
As such, prepend the extradata PS NALUs to the packet PS NALUs if they are
present before an IRAP, instead of prepending them to the IRAP slice.

Should fix ticket #11458.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-14 00:21:19 -03:00
19a2d26177 random_seed: Improve behaviour with small timer increments with high precision timers
On a Zen 5, on Ubuntu 24.04 (with CLOCKS_PER_SEC 1000000), the
value of clock() in this loop increments by 0 most of the time,
and when it does increment, it usually increments by 1 compared
to the previous round.

Due to the "last_t + 2*last_td + (CLOCKS_PER_SEC > 1000) >= t"
expression, we only manage to take one step forward in this loop
(incrementing i) if clock() increments by 2, while it incremented
by 0 in the previous iteration (last_td).

This is similar to the change done in
c4152fc42e, to speed it up on
systems with very small CLOCKS_PER_SEC. However in this case,
CLOCKS_PER_SEC is still very large, but the machine is fast enough
to hit every clock increment repeatedly.

For this case, use the number of repetitions of each timer value
as entropy source; require a change in the number of repetitions
in order to proceed to the next buffer index.

This helps the fate-random-seed test to actually terminate within
a reasonable time on such a system (where it previously could hang,
running for many minutes).

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-13 11:41:51 +02:00
b053f1173d random_seed: Reorder if clauses for gathering entropy
Make it easier to add more cases.

This should be a pure refactoring, with no functional changes.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-13 11:41:47 +02:00
dc7964a862 avcodec/version: bump micro after the previous change
Useful to know if a given library build has the flush() callback or not.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-12 21:09:52 -03:00
045a8b15b1 avcodec/ac3dec: add a flush callback for the ac3 and eac3 decoders
Fixes ticket #10732

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-12 19:12:22 -03:00
a9e8586e3f avcodec/ac3dec: move some fields up in AC3DecodeContext
Needed for the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-12 19:12:13 -03:00
22aa71d4da avcodec/libtheora: fix setting keyframe_mask
t_info.keyframe_granule_shift is set to the library default of 6, which is ok
for gop sizes up to 63. Since there's apparently no way to query the updated
value after having forced a gop value with TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE,
calculate it manually instead.

Fixes ticket #11454.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-12 18:53:25 -03:00
eb3d507b7f avdevice/alsa: simplify passing ff_alsa_open a channel layout
This also ensures the layout set during the indev init is used instead of the
blank one in st->codecpar.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-12 18:49:07 -03:00
d62fd6e9c8 avformat/mov: Store trak > udta metadata on each stream
Some files keep extra metadata such as 'name' fields within udta, and
it is useful for Wine to access them with the "export_all" option so
they can then be exposed to Windows applications.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-11 15:22:59 +02:00
78ff3782af lavc/videotoolboxenc: Add spatial_aq option
Added in macOS 15 "Sequoia".

Signed-off-by: Dennis Sädtler <dennis@obsproject.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-11 11:33:27 +02:00
586de322ab threadprogress: reorder instructions to fix race.
Fixes #11456.
2025-02-10 11:00:07 -05:00
7ee4936e0a avfilter/vpp_amf: add option reset_sar
4b77a0a681 added a new consumer of ff_scale_adjust_dimensions
which was recently modified to allow for square pixel output.

This commit extends the new option to vpp_amf, and unbreaks the building
of vf_amf_common.c
2025-02-10 19:59:26 +05:30
d6a364e7c3 avfilter/vf_amf_common: fix build
AMF was forgotten in a28dc06869
2025-02-10 14:32:25 +01:00
9fb97215df avcodec/aarch64/opusdsp_neon: Simplify opus_postfilter_neon
This change removes one extra floating point operation and simplifies
load operations at the beginning of the loop by using dedicated register
for each of the 5 pointers and interleaving it with calculations. The
first case seems to be a bit slower, but the performance increase is
substantial in the other two.

A78 before:
postfilter_15_neon:                                   1684.8 ( 4.23x)
postfilter_512_neon:                                  1395.5 ( 5.10x)
postfilter_1022_neon:                                 1357.0 ( 5.25x)

After:
postfilter_15_neon:                                   1742.2 ( 4.09x)
postfilter_512_neon:                                  1169.8 ( 6.09x)
postfilter_1022_neon:                                 1160.0 ( 6.12x)

A72 before:
postfilter_15_neon:                                   3144.8 ( 2.39x)
postfilter_512_neon:                                  3141.2 ( 2.39x)
postfilter_1022_neon:                                 3230.0 ( 2.33x)

After:
postfilter_15_neon:                                   2847.8 ( 2.64x)
postfilter_512_neon:                                  2877.8 ( 2.61x)
postfilter_1022_neon:                                 2837.2 ( 2.65x)

x13s before:
postfilter_15_neon:                                   1615.4 ( 2.61x)
postfilter_512_neon:                                   963.1 ( 4.39x)
postfilter_1022_neon:                                  963.6 ( 4.39x)

After:
postfilter_15_neon:                                   1749.6 ( 2.41x)
postfilter_512_neon:                                   707.1 ( 5.97x)
postfilter_1022_neon:                                  706.1 ( 5.99x)

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-10 14:55:16 +02:00
e75a0f3c75 checkasm: aacencdsp: Actually test nonzero values in quant_bands
Previously, we read elements from ff_aac_pow34sf_tab; however
that table is initialized to zero; one needs to call
ff_aac_float_common_init() to make sure that the table is
initialized.

However, given the range of the input values, a large number of
entries in ff_aac_pow34sf_tab would give results outside of the
range for signed 32 bit integers. As the largest aac_cb_maxval
entry is 16, it seems more reasonable to produce values within
an order of mangitude of that value.

(When hitting INT_MIN, implementations may end up with different
results depending on whether the value is negated as a float or
as an int. This corner case is irrelevant in practice as this
is way outside of the expected value range here.)

Coincidentally, this fixes linking checkasm with Apple's older
linker. (In Xcode 15, Apple switched to a new linker. The one in
older toolchains seems to have a bug where it won't figure out to
load object files from a static library, if the only symbol
referenced in the object file is a "common" symbol, i.e. one for
a zero-initialized variable. This issue can also be reproduced with
newer Apple toolchains by passing -Wl,-ld_classic to the linker.)

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-10 14:03:25 +02:00
8b3e0061e1 x86: aacencdsp: Fix negating signed values in aac_quantize_bands
Previously, we would do OR with the sign bit, forcing the output
to a negative value, while we want to negate it, by inverting the
sign bit.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-02-10 14:03:24 +02:00
a28dc06869 avfilter/scale*: add option reset_sar
For anamorphic videos, enabling this option leads to adjustment of
output dimensions to obtain square pixels when the user requests
proportional scaling through either of the w/h expressions or
force_original_aspect_ratio.

Output SAR is always reset to 1.

Option added to scale, scale_cuda, scale_npp & scale_vaapi.

libplacebo already has a similar option with different semantics,
scale_vt and scale_vulkan don't implement force_oar, so for these
three filters, I've made minimal changes needed to not break building
or change output.
2025-02-10 16:25:23 +05:30
e838e6cbe2 avformat/mpeg: demux ivtv captions
The packets start 'IVT0' or 'ivt0'
('I' = 0x49, 'i' = 0x69).

Signed-off-by: Marth64 <marth64@proxyid.net>
2025-02-09 20:28:11 -06:00
9fb806fa57 avcodec: add AV_CODEC_ID_IVTV_VBI
IVTV, a Linux driver for TV tuners, and V4L2 utilize
a coding named after IVTV to carry sliced VBI data
in MPEG streams produced by tuner cards with
VBI capture capability and an MPEG-2 encoder SoC.

IVTV or V4L2 driver will transport the coded data into a
MPEG-PS private stream ("IVTV") that can be captured
from the card alongside the video/audio.

The data could include:
EIA-608, Teletext, WSS (PAL widescreen signaling),
or VPS (PAL VCR signaling).

Signed-off-by: Marth64 <marth64@proxyid.net>
2025-02-09 20:27:49 -06:00
0ae5b1bfcc avcodec/hw_base_encode: log the readable error message on failure
Currently, if there is a hardware encode failure, the numeric
error code will be printed making it somewhat hard to get to
the root cause of the issue. Print the readable message generated
by av_err2str() instead.

Signed-off-by: Marth64 <marth64@proxyid.net>
2025-02-09 20:27:49 -06:00
3fca5877d0 avcodec/pngdec: avoid hard failure on illegal sBIT chunks
If a malformed chunk like sBIT appears but otherwise the stream
is still parseable, we should print a warning and skip it rather
than failing with an error.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-02-09 19:06:42 -05:00
43be8d0728 avformat/mov: check for tts_count before deferencing tts_data
Fixes ticket #11460.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-07 23:00:34 -03:00
16f9cfcf4b avcodec/leaddec: support format 0x1006
Fixes ticket #10658.
2025-02-08 10:59:05 +11:00
a8f2374507 avformat/mov: add an offset to IAMF streams
Using audio_substream_id for AVStream ids is not ideal give that in containers
like mp4, the IAMF structure is opaque to the outside and other streams may
share such id values.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-07 19:44:13 -03:00
268d0b6527 swscale/graph: copy scaler_params to the legacy subpass context
Fixes ticket #11448.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-07 13:17:37 -03:00