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

119806 Commits

Author SHA1 Message Date
fbf5cfaed5 avcodec/pixblockdsp: Fix get_pixels alignment documentation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-31 01:28:35 +02:00
17d5f30dd5 avcodec/pixblockdsp: Pass bits_per_raw_sample directly
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-31 01:27:09 +02:00
20ddada2a3 avcodec/pixblockdsp: Improve 8 vs 16 bit check
Before this commit, the input in get_pixels and get_pixels_unaligned
has been treated inconsistenly:
- The generic code treated 9, 10, 12 and 14 bits as 16bit input
(these bits correspond to what FFmpeg's dsputils supported),
everything with <= 8 bits as 8 bit and everything else as 8 bit
when used via AVDCT (which exposes these functions and purports
to support up to 14 bits).
- AARCH64, ARM, PPC and RISC-V, x86 ignore this AVDCT special case.
- RISC-V also ignored the restriction to 9, 10, 12 and 14 for its
16bit check and treated everything > 8 bits as 16bit.
- The mmi MIPS code treats everything as 8 bit when used via
AVDCT (this is certainly broken); otherwise it checks for <= 8 bits.
The msa MIPS code behaves like the generic code.

This commit changes this to treat 9..16 bits as 16 bit input,
everything else as 8 bit (the former because it makes sense,
the latter to preserve the behaviour for external users*).

*: The only internal user of AVDCT (the spp filter) always
uses 8, 9 or 10 bits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-31 01:25:27 +02:00
61a70e8e9e avcodec/dvenc: Check for unaligned pointers, strides
Fixes segfaults on systems where PixblockDSPContext.get_pixels
really requires to be properly aligned (e.g. ARMv7).
Before this commit input created by
-filter_complex nullsrc=s=740x576:r=25,format=yuv420p,crop=w=720:x=2
led to crashes.

(The unaligned strides are in violation of the AVFrame.linesize
documentation, unaligned pointers itself do not seem to be
prohibited for encoders.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-31 01:12:47 +02:00
1a7e802c8f avformat/demux: use io_close2 when closing avfromat
It's not valid to call avio_close() on context that has not been open
with avio_open().

This fixes use of custom IO. (io_open / io_close2 callbacks)

Note that by default io_close2 is set to io_close2_default() which calls
avio_close(), so default case will work the same as before.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-31 00:08:25 +02:00
5030564376 libavformat/oggdec.h: Change paket function documentation to return 1 on header packets only.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-30 22:07:11 +02:00
574f634e49 ogg/vorbis: implement header packet skip in chained ogg bitstreams.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-30 22:07:10 +02:00
c9cc61d620 ogg/vorbis: factor out header processing logic.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-30 22:07:10 +02:00
ba3d4c2ba2 libavformat/oggdec.{c, h}: Add new_extradata, use it to pass extradata to the next decoded packet.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-30 22:07:10 +02:00
791a333a0e avcodec/hevc/hevcdec: Check num_entry_point_offsets
The code uses int, unsigned int and uint16_t to store num_entry_point_offsets
This limits it to the smallest of the 3.
Alternatively uint16_t can be changed and then a larger limit used.
A Check will still be needed.

Fixes: 391974932/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5966648879677440
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-30 22:07:09 +02:00
f6986e75be avcodec/speexdec: Pass and check remaining packets to decode functions
Fixes: out of array access
Fixes: 394638693/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEX_fuzzer-4868142996455424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-30 22:07:09 +02:00
67040773dc avcodec/ffv1enc_template: Fix remaining space check
Fixes: Assertion sc->slice_coding_mode == 0 failed at libavcodec/ffv1enc.c:1667
Fixes: 408838118/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-6493138204295168

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-30 22:07:09 +02:00
27c5e4b39a avcodec/libaomenc: Increase code locality
Reviewed-by: Niklas Haas <ffmpeg@haasn.xyz>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-30 19:35:32 +02:00
1b5a291dcc avcodec/dovi_rpuenc: Use av_unreachable() instead of av_assert0(0)
Reviewed-by: Niklas Haas <ffmpeg@haasn.xyz>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-30 19:35:27 +02:00
0adfe15829 avcodec/dovi_rpuenc: Use av_cold for ff_dovi_configure init functions
Reviewed-by: Niklas Haas <ffmpeg@haasn.xyz>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-30 19:35:21 +02:00
8d45dc858e avcodec/dovi_rpuenc: Avoid intermediate codec par in ff_dovi_configure()
It invalidates (removes by duplicates)  AVCodecContext.extradata
and AVCodecContext.coded_side_data which is quite surprising
and leads to bugs like #11617 where an AVCPBProperties
is used after it has been freed in ff_dovi_configure().

Reported-by: Ayose
Reviewed-by: Niklas Haas <ffmpeg@haasn.xyz>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-30 19:35:06 +02:00
ab37c7e49f ffv1enc: do not hardcode 1024 slices
Instead use a field where possible and the defined constant when not.

Tested by using 4096 slices.
2025-05-30 01:45:58 +09:00
75960ac270 avcodec/asvenc: Fix crash with unaligned pointers/linesizes
This happens on systems where get_pixels really needs
to be properly aligned, like ARMV7 or RISC-V. For these
systems, 0401ca714a caused
a bus error for the vsynth3-asv[12] tests, because
the stride in these tests is unaligned. See e.g.
https://fate.ffmpeg.org/report.cgi?slot=armv7-linux-gcc-13&time=20250527020548
https://fate.ffmpeg.org/report.cgi?slot=rv64gcvb-linux-gnu-gcc&time=20250527001827

It can also happen (even before said commit) if the pointers
itself are unaligned, e.g. by using the crop filter:
ffmpeg -filter_complex nullsrc=s=740x576:r=25,format=yuv420p,crop=w=720:x=2 \
-c:v asv2 -f null -

The alignment requirements for the frames passed to encoders are
mostly undocumented; the only thing I could find is the documentation
of AVFrame.linesize: "For video the linesizes should be multiples
of the CPUs alignment preference". This means that the FFmpeg cli
violates our API.

Yet as the above command line shows, it can also happen with
unaligned pointers and there does not seem to be a prohibition
of this, so we need to handle this case. This commit does so
by using get_pixels_unaligned when needed.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-29 08:00:21 +02:00
9568e40aeb avutil/vf_scdet_vulkan: add new filter
Carbon copy of vf_scdet.

Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: nxtedition
2025-05-28 12:21:27 +02:00
0894cfb168 avfilter/blackdetect_vulkan: add hw accelerated blackdetect filter
Like vf_blackdetect but better, faster, stronger, harder.

Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: nxtedition
2025-05-28 12:21:27 +02:00
7e783fac5b avfilter/vf_blackdetect: add alpha option
Check the alpha plane for (almost) transparent frames, instead of checking
the luma channel for almost black frames.

Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: nxtedition
2025-05-28 12:21:27 +02:00
02f45a7f3f avfilter/vf_gblur_vulkan: omit unnecessary buffer usage flag
Implied internally now when needed.
2025-05-28 12:21:27 +02:00
0a4cdf8822 avutil/vulkan: automatically enable shader device address usage bit
We require this internally when using descriptor buffers, so it makes sense
to enable it internally, also.
2025-05-28 12:21:20 +02:00
c2521c0cd2 avutil/vulkan: add YUVA pixel formats support
Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: nxtedition
2025-05-28 12:14:54 +02:00
96d4bcbcd8 avformat/matroskaenc: Use native id V_FFV1 instead of V_MS/VFW/FOURCC
Up until now, our muxer wrote FFV1 in video-for-windows
compatibility mode out of concern for old demuxers that
only support that (whereas the demuxer accepts V_FFV1).
This commit switches to using native mode, because
a) V_FFV1 is around long enough so that old demuxers
should not be an issue (support in FFmpeg has been added
in commit 9ae762da7e
in March 2017/FFmpeg 3.3),
b) using native mode uses fewer bytes for the CodecPrivate,
c) the VfW extradata is zero-padded to an even length
if necessary, but our demuxer forgot to undo the padding
until very recently (92e310eb82),
so that there are many versions of our demuxer around that
are buggy wrt VFW, but not V_FFV1.
This affects the FFV1 extradata checksums, specifically
the (experimental) version 4 files with error check version 2*
as created by
ffmpeg -i ../fate-suite/mpeg2/sony-ct3.bs -c:v ffv1 \
-slices 16 -frames 1 -level 4 -strict experimental ffv1.mkv
VFW files like the above created by this muxer before this patch
would not work with an old demuxer.

*: Without error check version 2, the CRC for the whole extradata
is zero, which is not changed by appending a zero byte.

Reviewed-by: compn <ff@hawaiiantel.net>
Reviewed-by: Dave Rice <dave@dericed.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-28 02:42:36 +02:00
8a936b8726 avformat/matroska: Support JPEG2000 for demuxing
Legal since commit 1cd0a9be4b2d1e7c60184ec68404e00e46e3123e
(Jan 4) in the Cellar Matroska specification git repo.
We still hold out on muxing it due to compatibility with
old demuxers.

Reviewed-by: compn <ff@hawaiiantel.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-28 02:09:28 +02:00
b7d44dde3b fftools/tf_mermaid: Add missing uninit and fix leaks
- merge forgotten uninit from work branch
- add set_str() function to free before overwriting
- fix some other leaks

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-28 01:02:55 +02:00
a0ac89e46c fftools/graphprint: Fix memory leaks
- uninit resource manager
- free strings before overwriting
- unref hw_frames_context

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-28 01:02:55 +02:00
75a5e0959f fftools/ffmpeg: Free print_graph option variables
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-28 01:02:55 +02:00
aa38270630 fftools/makefile: Remove resources from ffprobe
Even though it doesn't have any effect, that line is not needed (yet).

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-28 01:02:55 +02:00
af94383124 ffbuild: correctly silence and tag new css/html steps
Reviewed-by: softworkz <softworkz@hotmail.com>
2025-05-28 01:02:55 +02:00
4cb42551d4 fftools/resources: add missing extensions to .gitignore
Reviewed-by: softworkz <softworkz@hotmail.com>
2025-05-28 01:02:55 +02:00
92e310eb82 avformat/matroskadec: Fix VfW extradata size
The structure is padded to an even length with an internal
size field to indicate the real size.
The matroska-matroska-display-metadata test (writing FFV1
in VFW mode) was affected by this.
It should also fix ticket #11613.

Reviewed-by: compn <ff@hawaiiantel.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-27 22:07:35 +02:00
bf6d3dc339 ffv1enc_vulkan: allow slicecrc=2
For parity with the software encoder.
2025-05-27 21:50:35 +09:00
54c865fbec swscale/utils: Fix potential race when initializing xyz tables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-27 13:49:26 +02:00
1c78db8ffc avcodec/vc2enc: Use LUT to avoid repeated av_log2()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-27 13:49:26 +02:00
a6bcc773b5 avcodec/ffv1enc: Fix explicitly set -slicecrc 2
crcref needs to be set properly iff ec is two, regardless
of whether it has been explicitly set by the user or set
by default based on level/version.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-27 13:45:21 +02:00
3cbe3418b2 vulkan_ffv1: fix golomb coding for non-RGB streams
The run_index is reset on each plane, unlike with RGB, where
its reset once per slice.
2025-05-27 06:40:33 +09:00
c395ad7c2c vulkan_ffv1: small cleanup for golomb
Split up computation of the offset in the same way that
the range coder version does it.
2025-05-27 06:40:29 +09:00
9d229440ac Makefile: Split ALLFFLIBS
This matches other lists and reduces conflicts between patches

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-26 20:33:10 +02:00
c79bce92b8 avformat/movenc: disallow buggy flags combination
Use of hybrid_fragmented and faststart together can result in files with
loss of sync and bitstream parsing errors upon playback.
2025-05-26 22:44:17 +05:30
eda0ac7e5f avcodec/x86/vp9: Add AVX-512ICL for 16x16 and 32x32 10bpc inverse transforms 2025-05-26 15:26:11 +02:00
df967d095a configure: Use MSYSTEM_CARCH for default arch on msys2
On msys2, `uname -m` returns the architecture of the base msys2
layer. On Windows on arm64, the base msys2 layer itself is still
x86_64 only, even if running with e.g. the clangarm64 where the
windows native applications are built as aarch64.

If MSYSTEM_CARCH is set, use this instead of `uname -m` for
the default architecture. This gives the correct behaviour
for the clangarm64 environments. It also gives the correct
default for the 32 bit x86 environments such as `mingw32`.

(On `mingw32`, the fact that `uname -m` returned `x86_64`
hasn't been an issue, as both that and `i686` gets normalized
into `x86` internally in ffmpeg's configure.)

Signed-off-by: Coia Prant <coiaprant@gmail.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2025-05-26 14:46:29 +03:00
43a69886b2 avcodec/mpeg4videodec: Use union to save space
At most one of block32 and dpcm_macroblock is used at any given time.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-26 05:03:43 +02:00
ac1e6d2171 avcodec/mpegvideo: Remove h263_plus
It is only used to indicate to ff_h263_show_pict_info()
that we are decoding H.263+; pass this information
via a function parameter instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-26 05:03:29 +02:00
da5c2a419b avcodec/ituh263enc: Don't use h263_plus field
It is equal to codec_id == AV_CODEC_ID_H263P, check for that instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-26 05:03:15 +02:00
8987c29390 avcodec/mpegvideo: Check h263_aic, not h263_plus for allocating dc_val
This means that these buffers won't be allocated any more
for H.263+ with AIC disabled.
Also remove setting h263_plus for the RV20 encoder,
as it has only been done to force allocating dc_val.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-26 04:59:11 +02:00
ed73675832 avcodec/mpegvideo: Move mpeg_quant to {Mpeg4Dec,MPVEnc}Context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-26 04:58:42 +02:00
778c0a48fa avcodec/mpegvideo_dec: Simplify check for unquantizing inter blocks
Just ensure that dct_unquantize_inter is set iff it is used
and check for the function pointer instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-26 04:53:32 +02:00
f2c04fd587 avcodec/mpegvideo_dec: Document which codecs take which codepath
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-26 04:52:57 +02:00