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

119894 Commits

Author SHA1 Message Date
6f452ad1ac fftools/textformat/avtextformat: Fix races when initializing formatters
Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-02 00:47:33 +02:00
4947e56974 fftools/resources/resman: Use proper logcontext
Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-02 00:47:16 +02:00
6d5e18b2f3 fftools/resources/resman: Use assert for always-false condition
Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-02 00:46:46 +02:00
06cd9086c3 fftools/resources/resman: Don't alloc ResourceManager, fix race
The resman_ctx pointer was accessed outside of its guarding
mutex.

Also make the ResourceManager static.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-02 00:45:18 +02:00
b4c5397642 fftools/textformat/avtextformat: Avoid relocations
Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-02 00:45:13 +02:00
0742239289 fftools/graph/graphprint: Fix races when initializing graphprint
Setting print_graphs_format (in case no -print_graphs_format
option was specified) is racy, as is using av_strtok()
to split it. Both have been removed.

Notice that using av_strtok() was destructive: In the absence
of races the options would only have been applied for the
first initialization.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-02 00:44:44 +02:00
6ede1e3fbf fftools/ffmpeg_filter: make InputFilterPriv and OutputFilterPriv private again
As the names imply, they are structs meant to be internal and private to the
filter handling code. If a field is required in other modules, then it can
be moved to the public facing structs, which is done in this commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-06-01 14:12:50 -03:00
1f034714f6 fftools/ffmpeg_filter: make FilterGraphPriv private again
As the name implies, it's a struct meant to be internal and private to the
filter handling code. If a field is required in other modules, then it can
be moved to the public facing struct, which is done in this commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-06-01 14:12:50 -03:00
8ea2b993fd avformat/movenc: Reduce loop iterations in mov_flush_fragment
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-06-01 16:37:00 +08:00
56cf1c084d avformat/movenc: Fix flush fragment
The follow cmd output corrupted file before the patch:

ffmpeg -f lavfi -i color=blue,trim=duration=0.04 \
	-f lavfi -i anullsrc,atrim=duration=2 \
	-movflags +empty_moov+hybrid_fragmented \
	-frag_duration 1000000 \
	-frag_interleave 1 \
	output.mp4

1. first_track is the first track with track->entry != 0. As in the
command above, video track (track index 0) has a single frame. When
flush the second fragment, first_track is 1, the audio track.

2. write_moof = i == first_track, so write_moof is false for i = 0.

3. When mov->frag_interleave != 0, mov->mdat_buf != NULL, because
it contains audio data. So avio_write is called before write_moof,
that is, the data write before moof, and mov_finish_fragment
executed with wrong mdat_start.

4. With normal fmp4 output, the error isn't obvious. With
hybrid_fragmented, ffplay output.mp4 shows a lot of error messages.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-06-01 16:36:54 +08:00
3d9b284ad1 tests: Add fate-hevc-color-reserved
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-06-01 16:35:23 +08:00
64116800be tests/fate/hevc: Fix dependancy for hevc-alpha
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-06-01 16:35:23 +08:00
9a19ba4067 tests/fate/cbs: Add hevc metadata set color test
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-06-01 16:35:23 +08:00
c80002aa81 avcodec/h2645_vui: Ensure color primaries/trc/space isn't reserved value
Fix error reported by swscaler:
Unsupported input (Operation not supported): fmt:yuv420p csp:unknown prim:reserved trc:bt709 -> fmt:yuv420p csp:bt709 prim:reserved trc:bt709

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-06-01 16:35:23 +08:00
6c291232cf avformat/movenc: fix VVC encoding with leading pictures
The default behavior for VVenC (since v1.10.0) is to create an IDR with
leading pictures for the first picture in decoding order (POC 32). This
leads to FFmpeg generating an edit list with an empty entry, skipping
the leading pictures.

This patch fixes the calculation for the start_pts, while the DTS is
negative (as produced by vvenc).

Signed-off-by: Gabriel Hege <g+ffmpeg@hege.cc>
2025-05-31 09:47:50 +08:00
a02e880e35 avcodec/vvc/sei: add decode_mastering_display_colour_volume
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
f6d2f38530 avcodec/vvc/sei: add decode_ambient_viewing_environment
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
761f75db74 avcodec/vvc: support fields
passed files:
    FIELD_A_Panasonic_4.bit
    FIELD_B_Panasonic_2.bit

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
870fa133af avcodec/vvc/sei: add decode_frame_field_info
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
299544bd0c avcodec/h274: add H274SEIFrameFieldInfo struct
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
33d511b581 avcodec/cbs_sei_syntax_template: add sei message frame_field_information
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
97137e38c1 avcodec/vvc/sei: add decode_content_light_level_info
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
40bc5e119e avcodec/vvc/sei: add decode_display_orientation
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
d140648c31 avcodec/cbs_sei_syntax_template: add sei message sei_display_orientation
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
23e9912315 avcodec/vvcdec: verify picture hash
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
9620c95edb avcodec/h274: add ff_h274_hash functions
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
8dfc24cdce avcodec/vvc/sei: add decode_decoded_picture_hash
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
942cf59e9d avcodec/h274: add H274SEIPictureHash struct
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
312f8ef2ca avcodec/vvc/dec: support removing film grain params from side data
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
a8d949bd96 avcodec/vvc/dec: support applying film grain by the decoder
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
1608d60001 avcodec/vvc/dec: export sei to the frame when the frame starts
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
1c87e3625a avcodec/vvc/sei: add decode_film_grain_characteristics
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
ab5df96cef avcodec/vvc: support decoding prefix and suffix nal units
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
bf3a7291db avcodec/cbs_sei_syntax_template: add sei message film_grain_characteristics
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
e618f7d5cf avcodec/cbs_h2645: add cbs_sei_h274_types
Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-05-31 09:35:54 +08:00
848ceb1329 Revert "ogg/vorbis: implement header packet skip in chained ogg bitstreams."
non flat extradata is problematic and was missed by reviewers

Found-by: Andreas Rheinhardt
This reverts commit 574f634e49.
2025-05-31 03:18:26 +02:00
0435cd5a62 avfilter/x86/vf_spp: Remove permutation-specific code
The MMX requantize functions have the MMX permutation
(i.e. FF_IDCT_PERM_SIMPLE) hardcoded and therefore
check for the used permutation (namely via a CRC).
Yet this is very ugly and could even lead to misdetection;
furthermore, since d7246ea9f2
the permutation used here is de-facto and since
bfb28b5ce8 definitely
impossible on x64, making this code dead on x64.
So remove it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-31 01:31:09 +02:00
23761c7acd avcodec/asvenc,dvenc: Optimize unaligned checks away if possible
For certain arches (AARCH64, x86, generic) get_pixels and
get_pixels_unaligned always coincide for 8 bit input.
In these cases it is possible to avoid checks for unaligned
input in asvenc, dvenc.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-31 01:28:51 +02:00
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