Commit Graph

25838 Commits

Author SHA1 Message Date
Derek Buitenhuis 2d5fa816fb avformat/http: Add support for Retry-After header
429 and 503 codes can, and often do (e.g. all Google Cloud
Storage URLs can), return a Retry-After header with the error,
indicating how long to wait, asd either a date, or in seconds,
before retrying again. If it is not respected by, for example,
using our default backoff stratetgy instead, chances of success
are very unlikely.

Some references:
    * https://datatracker.ietf.org/doc/html/rfc6585
    * https://datatracker.ietf.org/doc/html/rfc7231#section-7.1.3

This adds an AVOption to respect that header.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2024-04-25 15:21:25 +01:00
Derek Buitenhuis 6d89fd4c27 avformat/http: Rename parse_set_cookie_expiry_time to parse_http_date
That is what it actually does, and it will be needed for more
than the Expiry header soon.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2024-04-25 15:21:25 +01:00
Derek Buitenhuis 31de02cf31 avformat/http: Add option to limit total reconnect delay
The existing option only allows users to set the max delay for a
single attempt, rather than the total allowed delay, which is both
pretty unintitive, and only applicable when exponential backoff is
used.

The default for this option is set to 256, which is just above the
effective total delay accomplished by the the existing
reconnect_delay_max default of 120.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2024-04-25 14:19:50 +01:00
Derek Buitenhuis 10374ab5ed avformat/http: Add options to set the max number of connection retries
Not every use case benefits from setting retries in terms of the backoff.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2024-04-25 14:17:33 +01:00
Derek Buitenhuis a776d524e1 avformat/http: Rename attempts to auth_attempts
This accurately reflects what it does, as per
e75bbcf493.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2024-04-25 14:15:32 +01:00
Derek Buitenhuis fa00624693 avformat/http: Don't bail on parsing headers on "bad" HTTP codes
Many "bad" HTTP codes like 429 and 503 may include important info in
their headers.

Also, in general, there is no purpose in bailing here.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2024-04-25 14:15:08 +01:00
Derek Buitenhuis b79260550b avformat/http: Use AVERROR_HTTP_TOO_MANY_REQUESTS
Added in the previous commit.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2024-04-25 14:14:36 +01:00
James Almer 757367e068 avformat/demux: extract extradata from packets when context update is requested
If the demuxer doesn't set extradata in the stream's codecpar, a
need_context_update request will delete the previously extracted extradata in
the stream's internal AVCodecContext.
As we can't ensure the old extradata is valid for the stream in its post
context update request state, try to get extradata from the new packet instead
of attempting to preserve the old in some form.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-24 00:11:37 -03:00
James Almer ce33a5f16d avformat/movenc: remove one level of indentation
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-23 12:46:49 -03:00
Niklas Haas 69e45a627c avformat/movenc: warn if dovi cfg ignored
Since this is guarded behind strict unofficial, we should warn if the
user feeds a dolby vision stream to this muxer, as it will otherwise
result in a broken file.
2024-04-22 12:17:56 +02:00
Stefano Sabatini bba492dc9c lavf/matroskaenc: apply consistent style to options descriptions 2024-04-19 08:44:20 +02:00
James Almer 5b9db32ccc avformat/mov: ignore old infe box versions
Some files with no image items have them, and were working prior to the recent
HEIF parsing overhaul.
Ignore such boxes instead, to recover the old behavior.

Fixes a regression since d9fed9df2a.

Tested-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-18 13:00:11 -03:00
Gyan Doshi 38c322681e avformat/ivfenc: remove unused var
sum_delta_pts is unused since 3b358f151d
2024-04-17 18:31:06 +05:30
Andreas Rheinhardt 639013aafc avformat/lc3: Only allow AV_CODEC_ID_LC3 in muxer
Also check for the number of streams and the AVCodecID generically
using FF_OFMT_FLAGs.

Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-16 21:40:13 +02:00
James Almer 6b6a0fc53d avformat/iamf_writer: reject duplicated stream ids in a stream group
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-16 11:43:10 -03:00
Antoine SOULIER 257bc2a82a avformat/lc3: add file format for LC3/LC3plus transport
A file format is described in Bluetooth SIG LC3 and ETSI TS 103 634, for
test purpose.
2024-04-15 18:34:12 +02:00
Zhao Zhili 65c1c83ca4 avformat/tls_mbedtls: Pass FLAG_NONBLOCK to underlying transport
This fix rtmps failure since rtmps requires nonblocking read.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-04-12 15:24:17 +08:00
Martin Storsjö e4f5c2414b tests/movenc: Validate that normal muxer usage doesn't print warnings
We have test to make sure that certain configurations do print
warnings. However, the normal operation of the muxer within this
test always printed a warning, so those tests to check for
extra warnings didn't essentially guard anything.

The warning that always was printed, "track 1: codec frame size is
not set" was not present in the libav fork where this testcase
originated, it was removed in f234e8a32e.

Set the frame size for the audio stream to silence the warning,
and use this frame size in a couple later calculations, and check
that one test configuration doesn't print warnings.

Setting the frame size apparently changes the rounding of a timestamp
in the ismv muxing testcase.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-04-11 14:08:55 +03:00
Andreas Rheinhardt 497a0f839d avformat/img2: Avoid relocations for ff_img_tags
The strings here are so short that using a pointer is wasteful
(the longest string takes nine bytes; on 64 bit systems,
the pointer+padding already take 12 bytes). So avoid them
and add asserts to ensure that no one ever tries to use a too
long tag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-11 12:53:26 +02:00
Martin Storsjö fbd5e238d4 movenc: Allow writing timed ID3 metadata
This is based on a spec at https://aomediacodec.github.io/id3-emsg/,
further based on ISO/IEC 23009-1:2019.

Within libavformat, timed ID3 metadata (already supported by the
mpegts demuxer and muxer) is handled as a separate data AVStream
with codec type AV_CODEC_ID_TIMED_ID3. However, it doesn't
have a corresponding track in the mov file - instead, these events
are written as separate toplevel 'emsg' boxes.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-04-10 10:48:50 +03:00
Martin Storsjö e4e3d25d41 movenc: Remove a leftover commented out line
This line originates from 6f69f7a8bf.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-04-10 10:42:02 +03:00
Marton Balint c38f785be4 avformat/mov_chan: add support for omitted_channel bitmask in chnl atom
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-04-09 23:14:22 +02:00
Marton Balint 92e7a9a4d5 avformat/mov_chan: respect channel order when parsing and creating chnl atom
Previously we always assumed that the channels are in native order, even if
they were not. The new channel layout API allows us to signal the proper
channel order, so let's do so.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-04-09 23:14:22 +02:00
Marton Balint da0fe26379 avformat/mov_chan: factorize some layout map search functions
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-04-09 23:14:22 +02:00
Marton Balint c68dc3e5f1 avformat/mov_chan: check channel count of layout tags at compile time
We can do this by using an X-macro for channel map declaration and doing a
static_assert() in one pass for the check. Thanks for Andreas Rheinhardt for
the suggestion.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-04-09 23:14:21 +02:00
Marton Balint 7801451376 avformat/hlsenc: use a slash separator even in win32
We don't know if the protocol used is referring to a local file or a remote
resource, so it is better to simply use slash as separator which works all the
time. (well, except in very special cases when the user specified a \\?\ path)

Fixes ticket #9780.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-04-09 23:13:09 +02:00
Stefano Sabatini 1cb1f29a04 lavf/lrc: fix comments in headers 2024-04-06 12:59:56 +02:00
Leo Izen 7c338f470f avcodec, avformat/ffjni: fix duplicate JNI symbols
Use SHLIBOBJS and STLIBOBJS in the Makefiles for avcodec and avformat,
and add a stub ffjni.c to libavformat, which allows the symbols to be
duplicated for shared builds but not static builds.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com>
2024-04-04 21:51:21 +02:00
Michael Niedermayer bf3b74142e
avformat/pcm: Use 64bit in bitrate computation
Fixes: signed integer overflow: 65792 * 65312 cannot be represented in type 'int'
Fixes: 67819/clusterfuzz-testcase-minimized-ffmpeg_dem_WADY_fuzzer-5236100912185344

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-04 19:38:30 +02:00
Michael Niedermayer ed49391961
avformat/mxfdec: Check index_edit_rate
Fixes: Assertion b >=0 failed at libavutil/mathematics.c:62
Fixes: 67811/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5108429687422976

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-04 19:38:29 +02:00
Michael Niedermayer 4593cf7ab3
avformat/iamf_parse: Check sound_system
Fixes: index 13 out of bounds for type 'const struct IAMFSoundSystemMap [13]'
Fixes: 67796/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-4554553191104512

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-04 19:38:29 +02:00
Eugene Zemtsov 591e27d1e7 configure: Separate subsystem for Immersive Audio Model
This change allows users to build libavfomat without support
for Immersive Audio Model by specifying --disable-iamf.
It helps to save on binary size in cases where it's important.

Co-authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: Eugene Zemtsov <eugene@chromium.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-03 09:57:52 -03:00
James Almer 50458b7fa1 avformat/isom: don't drop the known layout when parsing AAC decSpecificInfo
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-02 20:21:13 -03:00
Michael Niedermayer d157725cf7 avformat/isom: Uninit layout in ff_mp4_read_dec_config_descr()
Fixes: memleak
Fixes: 67442/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-5068813261406208

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-02 20:20:04 -03:00
Marth64 58f04608c2 avformat/rcwtenc: remove repeated documentation
The high level summary of RCWT can be delegated doc/muxers, which
makes it easier to maintain and more consistent with the documentation
of the demuxer.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-04-02 20:09:05 +02:00
Marth64 536f0239c0 avformat/rcwtenc: don't assume .bin extension
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-04-02 20:09:05 +02:00
Marth64 15406f8377 avformat/rcwtdec: add RCWT Closed Captions demuxer
RCWT (Raw Captions With Time) is a format native to ccextractor,
a commonly used OSS tool for processing 608/708 Closed Captions (CC).
RCWT can be used to archive the original extracted CC bitstream.
The muxer was added in January 2024. In this commit, add the demuxer.

One can now demux RCWT files for rendering in ccaption_dec or interop
with ccextractor (which produces RCWT). Using the muxer/demuxer combo,
the CC bits can be kept for processing or rendering with either tool.
This can be an effective way to backup an original CC stream, including
format extensions like EIA-708 and overall original presentation.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-04-02 20:08:51 +02:00
Marth64 1c35333671 avformat/subtitles: extend ff_subtitles_queue_insert() to support not yet available events
If ff_subtitles_queue_insert() were given a NULL buffer
with 0 length, it would still attempt to grow the packet
or memcpy depending on if merge option is enabled.

In this commit, allow passing a NULL buffer with 0 length
without attempting to do such operations. This way, if a
subtitle demuxer happens to pass an empty cue or wants to
use av_get_packet() to read bytes, there are no unnecessary
operations on the packet after it is allocated.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-04-02 19:59:01 +02:00
Nicolas Gaullier ed9363052f avformat/demux: add duration_probesize AVOption
Yet another probesize used to get the durations when
estimate_timings_from_pts is required. It is aimed at users interested
in better durations probing for itself, or because using
avformat_find_stream_info indirectly and requiring exact values: for
concatdec for example, especially if streamcopying above it.
The current code is a performance trade-off that can fail to get video
stream durations in a scenario with high bitrates and buffering for
files ending cleanly (as opposed to live captures): the physical gap
between the last video packet and the last audio packet is very high in
such a case.

Default behaviour is unchanged: 250k up to 250k << 6 (step by step).
Setting this new option has two effects:
- override the maximum probesize (currently 250k << 6)
- reduce the number of steps to 1 instead of 6, this is to avoid
detecting the audio "too early" and failing to reach a video packet.
Even if a single audio stream duration is found but not the other
audio/video stream durations, there will be a retry, so at the end the
full user-overriden probesize will be used as expected by the user.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2024-04-02 19:53:40 +02:00
James Almer 8e294abd9d avformat/mov: simplify the entry count overflow check in the keys atom
Suggested-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-02 09:09:35 -03:00
James Almer 5a06d3810e avformat/mov: don't read key_size bytes twice in the keys atom
We only support mdta as type, yet we were not skipping other types,
but rather reading key_size worth of bytes twice per entry.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-02 00:16:31 -03:00
James Almer 3d12ba77d9 avformat/mov: take into account the first eight bytes in the keys atom
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-02 00:13:12 -03:00
Eugene Zemtsov 8a23a145d8 avformat/mov: Check if a key is longer than the atom containing it
Stop reading keys and return AVERROR_INVALIDDATA if key_size
is larger than the amount of space left in the atom.

Bug: https://crbug.com/41496983
Signed-off-by: Eugene Zemtsov <eugene@chromium.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-02 00:13:12 -03:00
Andreas Rheinhardt 9d219ff149 avformat/mov: Don't add attached pic if one is already present
Fixes: memleak
Fixes: 67714/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5671570999476224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-02 04:13:44 +02:00
James Almer f492f1ac23 avformat/mov: ensure all items id referenced by a grid are valid
Fixes: null pointer dereference
Fixes: 67494/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6528714521247744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Tested-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-01 21:13:04 -03:00
Michael Niedermayer cb9752d897
avformat/mpegts: Reset local nb_prg on add_program() failure
add_program() will deallocate the whole array on failure so
we must clear nb_prgs

Fixes: null pointer dereference
Fixes: crash-35a3b39ddcc5babeeb005b7399a3a1217c8781bc

Found-by: Catena cyber
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-01 19:03:06 +02:00
Michael Niedermayer 23b29f72ee
avformat/aiffdec: Check for previously set channels
Fixes: out of array access (av_channel_layout_copy())
Fixes: 67087/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-4920720268263424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-01 18:59:07 +02:00
Michael Niedermayer f30fe5e8d0
avformat/mxfdec: Make edit_unit_byte_count unsigned
Suggested-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-01 18:52:38 +02:00
Michael Niedermayer d88c284c18
avformat/movenc: Check that cts fits in 32bit
Fixes: Assertion av_rescale_rnd(start_dts, mov->movie_timescale, track->timescale, AV_ROUND_DOWN) <= 0 failed at libavformat/movenc.c:3694
Fixes: poc2

Found-by: Wang Dawei and Zhou Geng, from Zhongguancun Laboratory
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-01 18:51:59 +02:00
James Almer 0a693bce62
avformat/iamf_parse: keep count_label consistent on language_label allocation failure
Fixes: null pointer dereference
Fixes: 67023/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6011025237278720

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-04-01 18:17:28 +02:00