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

119156 Commits

Author SHA1 Message Date
3f30ae823e avutil/aes_ctr: simplify incrementing the counter
Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-05 20:46:40 -03:00
fe73b84879 avutil/aes_ctr: simplify and optimize av_aes_ctr_crypt()
Process data in chunks of four or eight bytes, depending on host, instead of
one at a time.

before:
55561 decicycles in av_aes_ctr_crypt

after:
52204 decicycles in av_aes_ctr_crypt

Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-05 20:46:40 -03:00
2ea3c51795 lavu/aes: add x86 AESNI optimizations
crypto_bench comparison for AES-128-ECB:

lavu_aesni AES-128-ECB  size: 1048576  runs:   1024  time:    0.596 +- 0.081
lavu_c     AES-128-ECB  size: 1048576  runs:   1024  time:   17.007 +- 2.131
crypto     AES-128-ECB  size: 1048576  runs:   1024  time:    0.612 +- 1.857
gcrypt     AES-128-ECB  size: 1048576  runs:   1024  time:    1.123 +- 0.224
tomcrypt   AES-128-ECB  size: 1048576  runs:   1024  time:    9.038 +- 0.790

Improved-By: Henrik Gramner <henrik@gramner.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-05 20:46:40 -03:00
2daaafafc6 avutil/tests/aes_ctr: also randomize the encryption key
And not just the IV.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-05 20:46:40 -03:00
462d35dc72 avutil/tests/aes_ctr: reindent after the previous commit
Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-05 20:46:40 -03:00
19085287b4 avutil/tests/aes_ctr: also check the encrypted buffer
The test in its current form is just ensuring the plain text output is the same
as the plain text input, not bothering to check if anything was done with the
latter. av_aes_ctr_crypt() could be a simple memcpy under the hood and this
test would still succeed.

To check the integrity of the encrypted buffer, both the IV and the key need to
be fixed. As such, and in order to not remove the existing randomization of the
input IV, do two runs, one with random initialization data, and one with static
data.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-05 20:46:40 -03:00
0a34f009aa avutil/tests/aes_ctr: test more than a single block worth of data
This should exercise the implementation more thoroughly after an upcoming
change.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-05 20:46:39 -03:00
ccf073e772 avcodec/d3d12va_decode: enable reference-only mode
The Reference-Only feature in DirectX 12 is a memory optimization
technique designed for video decoding scenarios.
This feature requires that reference resources must be allocated with
the D3D12_RESOURCE_FLAG_VIDEO_DECODE_REFERENCE_ONLY resource flag.
Reference textures must also be separated from output textures.
This feature is not supported in the current version of ffmpeg.
Since AMD GPU uses this feature in Direct 12 decoder,
ffmpeg does not support AMD GPU Direct 12 decoding.

Signed-off-by: Tong Wu <wutong1208@outlook.com>
2025-04-05 11:57:49 +08:00
37a319fb95 avcodec/ffv1enc: Consider 2s x s slice configurations
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-04 20:30:42 +02:00
2d9c9dae14 avcodec/ffv1dec: Limit size of fltmap* to pixel number
This reduces needed memory and also removes the 65536 maximum for remap
on the decoder side

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-04 20:30:42 +02:00
06c00f9355 avcodec/ffv1: Only allocate fltmap* and bitmap when needed
This reduces memory requirements

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-04 20:30:42 +02:00
b67cf79683 avcodec/ffv1: Allocate unit only when needed and only as large as needed
That is instead of a fixed 65536, we now allocate only as many as there
are pixels.
We also allocate only for the encoder and only when remapping is enabled
and only for 32bit per sample

This should reduce memory consumption, the 2nd array will be
dealt with in a future commit

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-04 20:30:41 +02:00
f1235f4bc1 avcodec/ffv1enc: run1start variables should fit in 32bit
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-04 20:30:41 +02:00
4ebc1f06e9 avcodec: remove remaining references to avcodec_close()
Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-04 14:03:21 -03:00
1c17061397 avcodec/decode: Fix avcodec parameters when bsfs are enable by decoder
BSF can update extradata, e.g., vvc_mp4toannexb. If we don't copy
bsf->par_out back to avcodec context, decoder can get extradata in
mp4 format, while packets are in annexb format.
2025-04-05 00:28:20 +08:00
c05ed36b56 libavcodec/amfenc: Setting the VBAQ property before the init call. 2025-04-04 17:57:49 +02:00
8284ba2a21 configure: Check for AVCaptureSession as dependency to avfoundation
This class is unavailable on tvOS before 17.0 (and macOS before 10.7
and iOS before 4.0, but those are fairly ancient). This makes sure
that we don't try to build the avfoundation indevice for such
OSes.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-04 17:12:34 +03:00
69bab4e74f avfoundation: Fix compilation for OSes other than macOS and iOS
E.g. tvOS doesn't have devicesWithMediaType.

In principle, we could probably disable building the whole
input device on such OSes, but that would either require
testing explicitly for the OS type in configure (which we don't
do anywhere so far), or test for individual objective C methods.

This approach allows the code to compile, but no input devices
will be found at runtime.

Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-04 17:12:33 +03:00
46762c8b82 avfilter/vf_libplacebo: don't explode on zero FPS information
While technically not specifiad as valid by the AVFilterLink documentation,
it is currently possible to get an FPS of zero from various sources inside
libavfilter (notably vf_buffersrc).

Avoid a division by zero and resulting infinity when this happens.
2025-04-03 17:17:42 +02:00
68b105341c avformat: Fix AV1 RTP wrong log condition
Fixed warning about OBU count being wrong, which can only be
determined when the number of OBUs in the header is non-zero,
not the other way round.

Signed-off-by: Chris Hodges <chris.hodges@axis.com>
2025-04-03 16:08:41 +02:00
1722f08acf avutil/Makefile: Only include half2float, float2half when needed
They are not needed for shared builds (and because --gc-sections
is not the default for shared builds, they were included by default
included in libavutil since bf22c4cc3e).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
52d766e5c2 avcodec/vdpau: Only include mpegvideodec.h when used
mpegvideodec.h includes mpegvideodata.h which in turn contains
a "static const uint8_t *const ff_mpeg1_dc_scale_table =
ff_mpeg12_dc_scale_table[0]"; yet if mpegvideo is disabled,
ff_mpeg12_dc_scale_table is not available, yet a non-optimizing
compiler (like GCC with -O0) may emit ff_mpeg1_dc_scale_table
and therefore a reference to ff_mpeg12_dc_scale_table nevertheless.

Fix this by only including mpegvideodec.h if it is needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
1479c2ec27 doc/{in,out}devs: Remove documentation for removed devices
Namely bktr, opengl and sdl2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
265e0d3e24 avfilter/palette: Remove unused ff_srgb_u8_to_linear_int()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
3693acb855 avcodec/x86/h26x/h265dsp: Remove unused functions
The ff_h2656_put_{uni_,}8tap_hv{32,64,128}_8_avx2
and ff_h2656_put_{uni_,}4tap_hv{64,128}_8_avx2
functions were unused and have been removed.
This saved 3712B of .text here.

(ff_h2656_put_{uni_,}4tap_hv32_8_avx2 are now only
called from exactly one callsite (in
ff_hevc_put_{uni_,}epel_hv32_8_avx2) and could be inlined.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
2e962fb080 avcodec/vulkan_video: Remove unused ff_vk_h26[45]_profile_to_av()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
664aef361a avcodec/aactab: Remove unused arrays
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
f5007a07d8 avcodec/aac/aacdec_lpd: Remove dead code
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
2b9b4dde93 avcodec/aac/aacdec_lpd: Make ff_aac_lpd_mode_tab static
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
132a55fd7c postproc/postprocess_template: Use immediate instead of memory load
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
5e947cc320 postproc/postprocess: Remove unused b02
The line which appears to be using it was always commented out
(since it has been added in 70c5ae870b).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
435be31ef5 swscale/csputils: Remove unused ff_sws_matrix3x3_rmul()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
4d2e38b376 avutil/hwcontext_vulkan: Remove unused variable
Forgotten in 8c7b00ba3a.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:57 +02:00
9d543273fe fftools/ffprobe: Fix hypothetical stack buffer overflow
It can't really happen, because no currently used pixel format
has a name exceeding the size of the buffer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:51 +02:00
2a2b5aec5b tools/target_swr_fuzzer: fix memory leak on av_samples_fill_arrays() error
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-03 01:58:07 +02:00
d5ad860cd8 tests/checkasm/checkasm.c: Assert that aligned_w/h do not overflow
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-03 01:58:07 +02:00
4aeaee1f4e avcodec/ffv1enc: replace the remaining log2() by magic
big secret, reading a float as the corresponding integer is a good
approximation of log2() for numbers not too close to 1.0. At the same
time it maintains strict monotonicity

this reduces run time from 19sec to 17sec for the slowest of my testcases
(with default remap_optimizer 3)

Compression is about the same:

-rw-r----- 1 michael michael  497603370 Mar 30 15:23 float-303503-fixed-40-optim-3-1log2F.nut
-rw-r----- 1 michael michael  497603374 Mar 28 11:27 float-303503-fixed-40-optim-3b.nut
-rw-r----- 1 michael michael  549938852 Mar 28 11:27 float-303503-float16-40-optim-3b.nut
-rw-r----- 1 michael michael  549938857 Mar 30 15:23 float-303503-float16-40-optim-3-1log2F.nut
-rw-r----- 1 michael michael 1150827841 Mar 28 11:28 float-303503-float-40-optim-3b.nut
-rw-r----- 1 michael michael 1150832913 Mar 30 15:22 float-303503-float-40-optim-3ref-log2F2.nut

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-03 01:58:07 +02:00
98c1788370 avcodec/ffv1enc: replace 3 double precision log2() by 1 single precision log2()
This makes the remap finding heuristic much faster

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-03 01:58:06 +02:00
b4d165c68f doc: replace http/git by https urls
These are more secure

Reviewed-by: Gyan Doshi <ffmpeg@gyani.pro>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-03 01:57:46 +02:00
efa0c6252f fftools/cmdutils: fix error message for "ffmpeg -init_hw_device list"
When running 'ffmpeg -init_hw_device list' to display available hardware
devices, it incorrectly shows an error message:
"Failed to set value 'list' for option 'init_hw_device': Immediate exit requested"

This is a regression introduced by commit a50f90f1c2. The command is
actually working as intended - it should exit after listing devices, but
shouldn't display an error message.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2025-04-03 06:29:12 +08:00
976c16109b doc/ffmpeg: document videotoolbox in -hwaccel option
Add videotoolbox to the list of supported hardware acceleration methods
in the -hwaccel option documentation. This option allows users to utilize
Apple's VideoToolbox framework for hardware-accelerated video decoding
on macOS and iOS devices.

The videotoolbox acceleration has been supported for a while, but was
missing from the documentation.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2025-04-03 06:28:51 +08:00
d1f2f8eee0 tests/filter-video: add rgbtestsrc tests for gbrap
Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-02 09:32:08 -03:00
67c4891311 tests/filter-video: add yuvtestsrc tests for yuva444p
Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-02 09:32:08 -03:00
cd1ec359c4 avfilter/vsrc_testsrc: also fill alpha planes with a test pattern in {rgb,yuv}testsrc
And add support for more formats.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-04-02 09:32:08 -03:00
ca48e7bb70 avcodec/sbcdsp_data: Make data static
This data is only used by sbcdsp.c, so delete sbcdsp_data.h,
make a header out of sbcdsp_data.c and make the data contained
therein static.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-02 09:25:46 +02:00
0ce8868878 avcodec/hevc/hevcdec: Use bitfield instead of array of flags
It is simpler, avoids several loops and also makes GCC no longer
emit bogus -Wstringop-overflow= warnings.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-02 09:25:38 +02:00
ffa56f73a9 avcodec/ac3dec: Read spx flags at once, not one bit at a time
Doing so gets rid of a stupid GCC -Wstringop-overflow= warning
(GCC somehow believes that fbw_channels can be 7 with the old
form of the code, so that channel_uses_spx[7] would be written
to, but now it no longer believes so).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-02 09:25:30 +02:00
2204efc2a6 avcodec/dct: Make declarations and definitions match
GCC considers declarations using a parameter of pointer
type (or equivalently a parameter using an array of unspecified
dimensions) to be inconsistent with a declaration using
a known-length array type and emits a -Warray-parameter warning
for several ff_j_rev_dct* functions for this.

This patch makes the declarations match the actual definitions
to suppress these (IMO nonsensical) warnings.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-02 09:25:24 +02:00
839b41991d avcodec/nvenc: unify CBR filler data insertion for all codecs
Previously, AV1 used filler data with CBR by default while H.264
and HEVC may or may not depending on driver version. Make this
consistent by using not filler data in CBR mode for all codecs.

Since there are valid reasons to use CBR with or without filler,
also add a cbr_padding option to allow users to override this.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-04-01 19:13:38 +02:00
c1a2da72cc checkasm: vp8dsp: Use checkasm_check_padded in check_mc
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-04-01 18:34:53 +03:00