Commit graph

26384 commits

Author SHA1 Message Date
Andreas Rheinhardt
a6c58450da all: Fix doxy comments wrongly designated as trailing ///<
The ///< or /**< form of doxygen comments are only to be used
when the documentation follows the member and the comment
block starts on the same line as the member. This commit
fixes wrong uses of them; in particular, this fixes the comment
for mb_height in H.264 SPS's structure which was wrongly added
to mb_width.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-12 17:00:24 +01:00
Zhao Zhili
0f7d77fc42 avformat/flvdec: Use appropriate error code
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:07:20 +08:00
Zhao Zhili
fa5a100ed2 avformat/flvdec: Fix error handling of parse_video_color_info
Some error should not be ignored.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:07:09 +08:00
Zhao Zhili
291fdc96ab avformat/flvdec: Use float for FLVMasteringMeta
The precision should be enough for primaries and luminance.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:04:00 +08:00
Zhao Zhili
888f5ea72b avformat/flvdec: Use appropriate types in FLVMetaVideoColor
This also reduce memory usage.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:03:56 +08:00
Zhao Zhili
f0cf122cf4 avformat/flvdec: Remove one level of indentation
Also remove the condition of AMF_DATA_TYPE_BOOL when parse color
info. There is no AMF_DATA_TYPE_BOOL type in color info.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:03:38 +08:00
Zhao Zhili
4f53ecf114 avformat/flvdec: Put FLVMetaVideoColor inside FLVContext directly
1. Rename metaVideoColor to meta_color_info
2. Allocated FLVMetaVideoColor together with FLVContext
3. Improve the use of meta_color_info_flag. Do a sequence of strcmp
only if meta_color_info_flag is FLV_COLOR_INFO_FLAG_PARSING.
4. Check return value of amf_parse_object().

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
2025-03-12 16:03:15 +08:00
Zhao Zhili
f34294897f avformat/flvdec: Fix use sizeof(AVMasteringDisplayMetadata)
sizeof AVMasteringDisplayMetadata isn't part of ABI.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: James Almer <jamrial@gmail.com>
2025-03-12 16:02:12 +08:00
Andreas Rheinhardt
ede2b391cc avcodec/put_bits: Add and use put_bits63()
When using a 64bit PutBitContext (i.e. on x64), put_bits_no_assert()
can naturally write up to 63 bits. So one can avoid treating the
cases <32bits, 32 bits and <63 bits differently.

As it turns out, no user actually wants to write 64 bit at once
(maybe except testprograms).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-11 04:37:21 +01:00
Andreas Rheinhardt
b98beb3704 all: Use put_bytes_output() instead of put_bits_ptr - pb->buf
Avoids accessing internals of PutBitContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-10 04:51:57 +01:00
Andreas Rheinhardt
56cfbe3c9f avformat/mpegenc, mpegts. mxfenc: Mark (de)muxers declarations as internal
Otherwise compilers might emit code that presumes there to be
a GOT which can't be fixed by the linker.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-05 00:24:54 +01:00
Andreas Rheinhardt
9e2773034b avformat/rtp_av1: Add necessary headers
Also use a void* instead of an AVFormatContext as logctx in parse_leb.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-04 15:34:38 +01:00
Zhao Zhili
2d7966aee1 avformat/isom_tags: Add tag for AVS3
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-04 17:01:58 +08:00
Zhao Zhili
a053516e64 avformat/movenc: Add AVS3 support
'avs3' is registered at mp4ra.org. The Avs3ConfigurationBox 'av3c'
inside 'avs3' hasn't been registered yet, but is specified by the
AVS3 spec.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-04 17:01:58 +08:00
Viraaj Raulgaonkar
081c865867
avformat/riffdec: change declaration of ff_get_wav_header()
Change the type of logctx from void* to AVFormatContext*. This is in
preparation for the next commit.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-04 02:07:01 +01:00
James Almer
25c439296b avformat/mov: fix overflow in corrected_dts calculation
Fixes: Integer-overflow
Fixes: 400093647/clusterfuzz-testcase-minimized-media_metadata_parser_fuzzer-4794341562187776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-03 18:10:10 -03:00
softworkz
ace9f03a6c
avformat/hls: Partially revert "reduce default max reload to 3"
(setting to 100 as a reasonable compromise)

The change has caused regressions for many users and consumers.
Playlist reloads only happen when a playlist doesn't indicate that it
has ended (via #EXT-X-ENDLIST), which means that the addition of future
segments is still expected.
It is well possible that an HLS server is temporarily unable to serve
further segments but resumes after some time, either indicating a
discontinuity or even by fully catching up.
With a segment length of 3s, a max_reload value of 1000 corresponds to
a duration of 50 minutes which appears to be a reasonable default.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-01 02:47:20 +01:00
Chris Hodges
330c8f8b93 avformat: add AV1 RTP depacketizer and packetizer
Add RTP packetizer and depacketizer according to (most)
of the official AV1 RTP specification. This enables
streaming via RTSP between ffmpeg and ffmpeg and has
also been tested to work with AV1 RTSP streams via
GStreamer.

It also adds the required SDP attributes for AV1.

AV1 RTP encoding is marked as experimental due to
draft specification status, debug amount reduced
and other changes suggested by Tristan.

Added optional code for searching the sequence
header to determine the first packet for broken
AV1 encoders / parsers.

Stops depacketizing on corruption until next keyframe,
no longer prematurely issues packet on decoding if
temporal unit was not complete yet.

Change-Id: I90f5c5b9d577908a0d713606706b5654fde5f910
Signed-off-by: Chris Hodges <chrishod@axis.com>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2025-02-26 12:32:22 -05:00
Peter Zebühr
e24920375c Make mime-type award a bonus probe score
This changes the default behaviour of ffmpeg where content-type headers
on an input gives an absolut probe score (of 75) to instead give a bonus
score (of 30). This gives the probe a better chance to arrive at the
correct format by (hopefully) giving a large enough bonus to push edge
cases in the right direction (MPEG-PS vs MP3, I am looking at you) while
also not adversly punishing clearer cases (raw ADTS marked as
"audio/mpeg" for example).

This patch was regression tested against 20 million recent podcast
submissions (after content-type propagation was added to
original-storage), and 50k Juno vodcasts submissions (dito). No adverse
effects observed (but the bonus may still need tweaking if other edge
cases are detected in production).
2025-02-26 14:52:34 +01:00
Ulrik Mikaelsson
5a526fdad0 avformat/mp3dec: Subtract known padding from duration
When an Info-tag is present, marking initial and trailing samples as
padding, those samples should not be included in the calculation of track
duration.

This solves a surprising user experience where converting a WAV->MP3->WAV,
ffprobe will show the duration of the mp3 as slightly longer than both the
input and the output.

As a result, the estimated duration and imprecise seek-results of some
FATE-tests have been updated.
2025-02-26 14:52:34 +01:00
ekir
da5353cf05 GOL-1361: Remove invalid CTTS sample_offset check
We checked in this places:
* In 8.6.1.3 of ISO/IEC 14496-12 about the CTTS box
* In Apples MOV spec: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-SW19
2025-02-26 14:52:34 +01:00
Jonathan Murray
98d97bb33b rtmp: Set correct message stream id when writing as server
rtmp_write is used both for writing outputs as a server. The
rt->listen flag determines which mode we're running in.

Previously, when running as a server, the message stream id would
always be set to 0 for media/metadata messages. This is surprising
given that we have both responded to "createStream()" with a value
of 1 and sent a "Stream Begin 1" to the client. Furthermore, some
client libraries (Red5) seem to trip up on receiving
"@setDataFrame" on stream 0 (and may be correct to assume that
this message would be sent on stream 1).
2025-02-26 14:52:34 +01:00
Ulrik
95314cd7c5 avformat/flacdec: Return correct error-codes on read-failure
Forward errors from `avio_read` directly. When `avio_read` sees EOF before
expected bytes can be read, consistently return `AVERROR_INVALIDDATA`

We used to return `AVERROR(AVERROR_INVALIDDATA)` when failing to read
metadata block headers. `AVERROR_INVALIDDATA` is already negative, so
wrapping in `AVERROR` leads to double-negation.

We used to return `AVERROR(EIO)` when failing to read extended metadata.
However, many times, the IO-layer is not at fault, the input data is simply
corrupted (truncated), so we return `AVERROR_INVALIDDATA` here as well.

---

Tomas: changed to use AVERROR_EOF
2025-02-26 14:52:34 +01:00
Ulrik
1306e5c7d3 avformat/http: Return EIO for prematurely broken connection
Currently, a prematurely broken connection normally leads to the same
EOF, as a completed successful transfer. However, enabling reconnect
changes this logic, and leads to the return of EIO.

This patch unifies that logic, leading to the return of EIO for premature
disconnect, regardless of setting of "reconnect".
2025-02-26 14:52:15 +01:00
Pavel Koshevoy
5021764413 avformat/mov: (v4) fix get_eia608_packet
The problem is reproducible with "Test for Quicktime 608 CC file.mov"
from https://samples.ffmpeg.org/MPEG2/subcc/

ffmpeg -i "Test for Quicktime 608 CC file.mov" -map 0 -c copy -y remuxed.mov

See https://trac.ffmpeg.org/ticket/11470
2025-02-23 09:43:56 -07:00
James Almer
5470d024e1 avformat/iamf_parse: ensure there's at most one of each parameter types in audio elements
Should prevent potential memory leaks on invalid files.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-19 19:51:21 -03:00
James Almer
0526535cd5 avformat/iamf_parse: add missing constrains for num_parameters in audio_element_oub()
Fixes ticket #11475.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-19 19:51:21 -03:00
James Almer
6e26f57f67 avformat/demux: don't discard empty Theora packets
Theora signals "Output last frame again" with an empty packet.

Finishes fixing ticket #11451.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-19 19:51:21 -03:00
James Almer
84d85e7ad4 avformat/oggenc: don't discard empty packets with no side data
Theora signals "Output last frame again" with an empty packet.
To keep the behaviour of 18f24527eb of ignoring side data only packets, as
generated by the FLAC encoder to propagate updated extradata, also check for
pkt->side_data_size to choose wheter to mux the paket or not.

Fixes part of ticket #11451.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-19 19:51:21 -03:00
James Almer
261ec6c35e avformat/mov: further ensure mov_build_index isn't run twice
If sc->tts_count is not 0, then the sample index has already been built.

Fixes: Null-dereference READ
Fixes: 396192874/clusterfuzz-testcase-minimized-audio_decoder_fuzzer-4589309789143040

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-19 19:51:21 -03:00
Michael Niedermayer
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
Michael Niedermayer
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
Michael Niedermayer
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
Rémi Bernon
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
Scott Theisen
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
James Almer
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
James Almer
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
dank074
e945142df3
avformat/unix: set is_streamed to true
Currently when a Unix Domain Socket is used as input there is a loss
of data when data is consumed from the stream. Setting is_streamed to
true fixes this, since the unix domain socket is now treated like a
consumable stream.

Fixes: #9346
Signed-off-by: dank074 <torresefrain10@gmail.com>
Reviewed-by: Leo Izen <leo.izen@gmail.com>
2025-02-07 10:13:50 -05:00
Michael Niedermayer
8a6ad9eab2
avformat/mxfdec: Check edit unit for overflow in mxf_set_current_edit_unit()
Fixes: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long'
Fixes: 392672068/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6232335892152320

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-06 22:04:12 +01:00
Michael Niedermayer
cef3422b48
avformat/hls: Fix twitter
Allow mp4 with all mpegts extensions

Fixes: Ticket11435
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-06 22:04:11 +01:00
Kacper Michajłow
c17774a9ae
avformat/mov: fix eof check in mov_read_iinf()
This fix ensures that the loop stops early on EOF. The issue occurs
because mov_read_infe() performs a version check and skips unsupported
versions. The problem is that seeking within the stream clears the EOF
flag, causing avio_feof() to not function as expected. This is resolved
by moving the EOF check after reading the size and type, ensuring the
EOF flag is set when necessary.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-06 22:04:11 +01:00
Tomas Härdin
9729444c7d lavf/mxfenc: Return AVERROR(EINVAL) in mxf_write_jpeg2000_subdesc() is pixfmt not set 2025-02-05 15:48:22 +01:00
Tomas Härdin
0202c7cc2e lavf/mxfenc: Make write_desc return int
This enables returning AVERRORs
2025-02-05 15:48:22 +01:00
Zhao Zhili
4307008b9a avformat/matroskaenc: log unsupported subtitle codec name
It's more user friendly than codec ID.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Marth64 <marth64@proxyid.net>
2025-02-04 13:42:43 +08:00
Zhao Zhili
1c5961e4b4 avformat/seek: Remove always true condition
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-02-04 01:24:23 +08:00
Zhao Zhili
ef3ffd8c5c avformat/seek: Remove dead code
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Marth64 <marth64@proxyid.net>
2025-02-04 01:22:57 +08:00
Michael Niedermayer
0113e30806
libavformat/hls: Be more restrictive on mpegts extensions
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-02 02:42:03 +01:00
Michael Niedermayer
9e12572933
avformat/hls: .ts is always ok even if its a mov/mp4
Maybe fixes: 11435

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-02 02:42:02 +01:00
Michael Niedermayer
d845533130
avformat/hls: Print input format in error message
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-01-31 23:10:02 +01:00
James Almer
02958ab715 avformat/mov: fix overflow in drift timestamp calculation
Fixes: signed integer overflow: 7803923888585309955 - -3407677434275325337 cannot be represented in type 'int64_t' (aka 'long')
Fixes: 377736723/clusterfuzz-testcase-minimized-media_pipeline_integration_fuzzer-5052449500889088

Signed-off-by: James Almer <jamrial@gmail.com>
2025-01-30 10:56:59 -03:00