1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

25877 Commits

Author SHA1 Message Date
James Almer
2d84ee3745 avformat/vvc: fix parsing sps_subpic_id
The length of the sps_subpic_id[i] syntax element is sps_subpic_id_len_minus1 + 1 bits.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-22 17:46:49 -03:00
James Almer
3bd7e3a336 avformat/vvc: initialize some ptl flags
Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-22 17:46:49 -03:00
llyyr
d1b96c3808 avformat/mov: avoid seeking back to 0 on HEVC open GOP files
ab77b878f1 attempted to fix the issue of broken packets being sent to
the decoder by implementing logic that kept attempting to PTS-step
backwards until it reached a valid point, however applying this
heuristic meant that in files that had no valid points (such as HEVC
videos shot on iPhones), we'd seek back to sample 0 on every seek
attempt. This meant that files that were previously seekable, albeit
with some skipped frames, were not seekable at all now.

Relax this heuristic a bit by giving up on seeking to a valid point if
we've tried a different sample and we still don't have a valid point to
seek to. This may some frames to be skipped on seeking but it's better
than not being able to seek at all in such files.

Fixes: ab77b878f1 ("avformat/mov: fix seeking with HEVC open GOP files")
Fixes: #10585
Signed-off-by: Philip Langdale <philipl@overt.org>
2024-05-21 18:57:44 -07:00
Marton Balint
49e018d6fe avformat/mp3dec: change bogus error message if read_header encounters EOF
Because of ffio_ensure_seekback() a seek error normally should only happen if
the end of file is reached during checking for the junk run-in. Also use proper
error code.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-05-21 08:28:09 +02:00
Marton Balint
b75e604fe5 avformat/mp3dec: simplify inner frame size check in mp3_read_header
We are protecting the checked buffer with ffio_ensure_seekback(), so if the
inner check fails with a seek error, that likely means the end of file was
reached when checking for the next frame. This could also be the result of a
wrongly guessed (larger than normal) frame size, so let's continue the loop
instead of breaking out early. It will end sooner or later anyway.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-05-21 08:28:09 +02:00
Marton Balint
b005317219 avformat/mp3dec: only call ffio_ensure_seekback once
Otherwise the subsequent ffio_ensure_seekback calls destroy the buffer of the
earlier. The worst case ~66kB seekback is so small it is easier to request it
entirely.

Fixes ticket #10837, a regression since
0d17f5228f.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-05-21 08:28:09 +02:00
LuMingYin
14f9e47314 libavformat/rtsp: fix a memory leak on error path
Signed-off-by: LuMingYin <lumingyindetect@163.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-05-20 23:57:05 +08:00
LuMingYin
9481b7d932 libavformat/hlsenc: fix a memory leak on error path
Signed-off-by: LuMingYin <lumingyindetect@163.com>
Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-05-20 23:56:58 +08:00
Andreas Rheinhardt
b50c5d0290 avformat/flacdec: Reorder allocations to avoid leak on error
Fixes Coverity issue #1591795.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-20 14:15:18 +02:00
Andreas Rheinhardt
f3d206d25f fftools, avfilter, avformat: Simplify check for "is dictionary empty?"
Reviewed-by: epirat07@gmail.com
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-20 13:52:41 +02:00
Andreas Rheinhardt
482afe8f3f avcodec/lib*, avformat/tee: Simplify iterating over AVDictionary
Reviewed-by: epirat07@gmail.com
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-20 13:51:55 +02:00
Andreas Rheinhardt
ce22e7ab28 avformat/tee: Use smaller scope for variables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-20 13:49:58 +02:00
Andreas Rheinhardt
26f3e79114 avformat/tee: Constify AVDictionaryEntry* pointee where possible
This is in preparation for using av_dict_iterate().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-20 13:33:38 +02:00
Andreas Rheinhardt
583c3d45fa avformat/tls_openssl: #if ff_openssl_init/deinit() away if possible
These functions do nothing useful when used with a non-ancient
version of openssl (namely 1.1.0 or above).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-20 12:37:42 +02:00
Andreas Rheinhardt
8b48b0adab avformat/utils: Use static mutexes instead of ff_lock_avformat()
Its existence is a remnant of (libavcodec's) lock-manager API
which has been removed in a04c2c707d.
There is no need to use the same lock for avisynth, chromaprint
or tls, so switch to ordinary static mutexes instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-20 12:28:28 +02:00
Marcus B Spencer
8b8b555de0 avformat/aacdec: strictly conform to K&R style
In the K&R style, a single-statement block does not have braces.
Edit the code to conform to this rule.

It is FFmpeg's code formatting convention to use K&R style.

Signed-off-by: Marcus B Spencer <marcus@marcusspencer.xyz>
2024-05-19 01:26:40 +02:00
James Almer
3765305928 configure: split ISOBMFF writer helpers into a separate component
Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-18 13:21:35 -03:00
James Almer
9ab8dddf1f avformat/vvc: use align_get_bits() where useful
Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-18 13:21:35 -03:00
James Almer
f00b23453c avformat/vvc: reduce the scope of some variables
Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-18 13:21:24 -03:00
James Almer
a48203d51a avformat/vvc: fix parsing some early VPS bitstream values
vps_default_ptl_dpb_hrd_max_tid_flag needs to always be set, and
vps_direct_ref_layer_flag needs to be read even when
vps_max_tid_ref_present_flag is false.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-18 11:35:27 -03:00
James Almer
f121d52b35 avformat/vvc: remove duplicate struct
VVCCProfileTierLevel is the same as VVCPTLRecord since the previous commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-18 11:33:46 -03:00
James Almer
cba15ca0ec avformat/vvc: generalize calculating num_bytes_constraint_info
Will be useful for when the aditional bits are supported, as well as for the
next commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-18 11:33:46 -03:00
James Almer
415dfa89e2 avformat/vvc: fix writing general_constraint_info bytes
The existing implementation was completely broken.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-18 11:33:46 -03:00
Michael Niedermayer
a5d1497f33
avformat/concatdec: Check file
Fixes: null pointer dereference
Fixes: -stream_loop 1 -ss 00:00:05 -i zgclab/ffmpeg_crash/poc2 -codec:v copy -codec:a aac -y output.mp4

Found-by: Wang Dawei and Zhou Geng, from Zhongguancun Laboratory
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-09 16:17:39 +02:00
Dawid Kozinski
e4da96c6b2 avformat/evc: Small fixes in documentation
Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com>
2024-05-09 10:06:38 -03:00
Dawid Kozinski
73d338d47c avformat/avi: Added EVC codec tag to the list of supported codec_id-codec_tag pairs for AVI muxer
Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com>
2024-05-08 21:15:05 -03:00
Andreas Rheinhardt
5de78958e4 avformat/Makefile: Add asf_muxer->asf_tags.o dependency
Forgotten in 493356cc0b.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-07 23:53:26 +02:00
Marton Balint
8d92f59d11 avformat/file: fail for non-numerical arguments to pipe:
Before this patch, the implementation of pipe: inputs/outputs would
silently fall back to stdin/stdout for any argument not successfully
parsed by strtol().

This patch introduces an explicit error for any non-numerical arguments,
which should avoid user confusion as in #10977.

New behavior:

$ cat /tmp/video.mkv | ./ffmpeg -i pipe:aa -acodec copy -vcodec copy -f matroska pipe:1 | cat >/tmp/out.mkv

[pipe @ 0x5618c7bcf740] Non-numerical argument "aa" to pipe:
[in#0 @ 0x5618c7bced00] Error opening input: Invalid argument
Error opening input file pipe:aa.
Error opening input files: Invalid argument

Based on the patch of Nils Goroll <nils.goroll@uplex.de>.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-05-07 23:38:05 +02:00
James Almer
2e16285fe8 avformat/iamf_reader: split "if ((ret = ...) < 0)" line
Cosmetic change.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-05 21:37:07 -03:00
James Almer
0ec8f3c55a avformat/mov: don't use stream duration to calculate bitrate with fragmented input
sc->data_size may contain the size of a single fragment after probing, and
using it alongside the duration of the entire stream to calculate bitrate
will result in a bogus small value.

Before:
  Duration: 00:00:05.00, start: 0.000000, bitrate: 586 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 640x360 [SAR 1:1 DAR 16:9], 112 kb/s, 60 fps, 60 tbr, 15360 tbn (default)

After:
  Duration: 00:00:05.00, start: 0.000000, bitrate: 586 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 640x360 [SAR 1:1 DAR 16:9], 561 kb/s, 60 fps, 60 tbr, 15360 tbn (default)

Signed-off-by: James Almer <jamrial@gmail.com>
2024-05-05 21:37:07 -03:00
Andreas Rheinhardt
2c77dc5aad avformat/movenc: Avoid loop for writing array
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-04 16:30:22 +02:00
Andreas Rheinhardt
601873263e avformat/movenc: Check av_malloc()
Fixes Coverity issue #1596735.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-05-04 16:29:58 +02:00
Michael Niedermayer
9f54c13bc4
avformat/iamfdec: check nb_streams in header read
Fixes: Assertion pkt->stream_index < (unsigned)s->nb_streams && "Invalid stream index.\n" failed at libavformat/demux.c:572
Fixes: 67890/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-5166340789829632.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-01 02:57:12 +02:00
Michael Niedermayer
20a6bfda0f
avformat/mxfdec: Check body_offset
Fixes: signed integer overflow: 538976288 - -9223372036315799520 cannot be represented in type 'long'
Fixes: 68060/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5523457266745344

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>
2024-05-01 02:57:12 +02:00
Michael Niedermayer
c26a762ea1
avformat/kvag: Check sample_rate
Fixes: Division by 0
Fixes: -copyts -start_at_zero -itsoffset 00:00:01 -itsscale 1 -ss 00:00:02  -i zgclab/ffmpeg_crash/poc1 output.mp4

Found-by: Wang Dawei and Zhou Geng, from Zhongguancun Laboratory
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-01 02:57:12 +02:00
James Almer
e09164940e avformat/mov: free the infe allocated item data on failure
Fixes: memleak
Fixes: 68212/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4963488540721152

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-30 18:29:38 -03:00
James Almer
b7debef3cc avformat/mov: support SpatialAudioBox ambisonic layouts with non-diegetic channels
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-30 11:15:13 -03:00
James Almer
37c8d93e56 avformat/mov: support SpatialAudioBox ambisonic layouts with arbitrary channel mapping
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-30 11:15:13 -03:00
James Almer
31327c2d07 avformat/mov: fix the check for the heif item parsing loop
Fixes: Null pointer dereference
Fixes: 67861/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5352628142800896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-27 19:39:23 -03:00
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