1
0
Fork 0
Commit Graph

26021 Commits

Author SHA1 Message Date
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
Michael Niedermayer f26ee6e066
avformat/iamf_reader: Check len before summing
Fixes: integer overflow
Fixes: 67275/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-5438920751906816
Fixes: 67688/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-5970342318243840

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
Michael Niedermayer d6ed6f6e8d
avformat/mxfdec: Check first case of offset_temp computation for overflow
This is kind of ugly
Fixes: signed integer overflow: 255 * 1157565362826411919 cannot be represented in type 'long'
Fixes: 67313/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6250434245230592

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
Andreas Rheinhardt 0e5f71230a avutil/internal: Move avpriv_set_systematic_pal2 decl to imgutils_internal.h
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
Andreas Rheinhardt 790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
Andreas Rheinhardt b616be1649 lib*/version: Use static_assert for static asserts
Also update the checks that guard against inserting
a new enum entry in the middle of a range.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:42 +01:00
James Almer e37b233ee2 Revert "avformat/mov: ignore item boxes for animated heif"
This reverts commit f6b7b473d4.
The image in the item boxes and the animation in the trak box are not
necessarely the same, so both should be exported.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-30 12:25:59 -03:00
James Almer e54591369f avformat/flac_picture: print a warning when mimetype is unknown
It's not an error since bba6df9ac7.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-28 18:00:34 -03:00
Dale Curtis bba6df9ac7
Don't throw an error when attached picture isn't recognized.
The MIME type field is required per the FLAC standard, but it's
not an error just because ffmpeg doesn't recognize it.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-28 18:07:13 +01:00
Andreas Rheinhardt 5d71f97e0e all: Don't use ATOMIC_VAR_INIT
C11 required to use ATOMIC_VAR_INIT to statically initialize
atomic objects with static storage duration. Yet this macro
was unsuitable for initializing structures [1] and was actually
unneeded for all known implementations (this includes our
compatibility fallback implementations which simply wrap the value
in parentheses: #define ATOMIC_VAR_INIT(value) (value)).
Therefore C17 deprecated the macro and C23 actually removed it [2].

Since commit 5ff0eb34d2 we default
to C17 if the compiler supports it; Clang warns about ATOMIC_VAR_INIT
in this mode. Given that no implementation ever needed this macro,
this commit stops using it to avoid this warning.

[1]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2396.htm#dr_485
[2]: https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-28 09:12:48 +01:00
James Almer 189c32f536 avformat/mov: don't abort on duplicate Mastering Display Metadata boxes
The VP9 spec defines a SmDm box for this information, and the ISOBMFF spec defines a
mdvc one. If both are present, just ignore one of them.
This is in line with clli and CoLL boxes.

Fixes ticket #10711.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-27 13:51:28 -03:00
Michael Niedermayer 6b213175c9
Bump after 7.0 branch point
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-27 01:04:54 +01:00
Michael Niedermayer 872980ace6
Bump prior release/7.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-27 01:04:53 +01:00
Michael Niedermayer 86f73277bf
avformat/westwood_vqa: Fix 2g packets
Fixes: signed integer overflow: 2147483424 * 2 cannot be represented in type 'int'
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_WSVQA_fuzzer-4576211411795968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 23:25:43 +01:00
Michael Niedermayer e849eb2343
avformat/matroskadec: Check timescale
Fixes: 3.82046e+18 is outside the range of representable values of type 'unsigned int'
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6381436594421760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 23:25:42 +01:00
Michael Niedermayer 61dca9e150
avformat/wavdec: satuarte next_tag_ofs, data_end
Fixes: signed integer overflow: 5053074104798691550 + 5053074104259715104 cannot be represented in type 'long'
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-6515315309936640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 23:25:41 +01:00
Michael Niedermayer 75317ec442
avformat/wavdec: sanity check channels and bps before using them for block_align
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-4704044498944000
Fixes: signed integer overflow: 520464 * 8224 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>
2024-03-26 23:25:40 +01:00
Michael Niedermayer 0bed22d597
avformat/sbgdec: Check for negative duration
Fixes: signed integer overflow: 9223372036854775807 - -8000000 cannot be represented in type 'long'
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-5133181743136768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 23:25:40 +01:00
Michael Niedermayer 878625812f
avformat/rpl: Use 64bit for total_audio_size and check it
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_RPL_fuzzer-4677434693517312
Fixes: signed integer overflow: 5555555555555555556 * 8 cannot be represented in type 'long long'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 23:25:39 +01:00
Michael Niedermayer f01a89c5a3
avformat/mov: use 64bit for intermediate for rounding
Fixes: signed integer overflow: 1768972133 + 968491058 cannot be represented in type 'int'
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4802790784303104

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 23:25:37 +01:00
Michael Niedermayer 746203af31
avformat/jacosubdec: Use 64bit for abs
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-5401294942371840

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 23:25:36 +01:00
Michael Niedermayer 007486058c
avformat/concatdec: Check user_duration sum
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-6434245599690752
Fixes: signed integer overflow: 9223372026773000000 + 22337000000 cannot be represented in type 'long'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 23:25:35 +01:00
Michael Niedermayer 0a114d7318
avformat/mov: Do not deallocate heif_item in a input dependant way
Fixes: out of array access
Fixes: 67070/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5685384082161664

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-03-26 23:19:49 +01:00
Marth64 9df1182065
avformat/dvdvideodec: add explicit inttypes.h include
Since log statements printing int64 were made portable in
4464b7eeb1, let us include
inttypes.h explicitly (as it is unclear where PRId64 and
such are coming from now).

Reported-by: Leo Izen <leo.izen@gmail.com>
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-03-26 11:40:12 -04:00
James Almer 1e7ba76562 avformat/mov: free HEIFItem.name when cleaning items in mov_read_trak
Fixes memleaks.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-26 10:43:45 -03:00
Andreas Rheinhardt 4a4dcde339 avformat/internal: Move FF_FMT_INIT_CLEANUP to demux.h
and rename it to FF_INFMT_INIT_CLEANUP. This flag is demuxer-only,
so this is the more appropriate place for it.
This does not preclude adding internal flags common to both
demuxer and muxer in the future.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt 27af88fb7f avformat/vqf: Return 0 on success in read_packet
Demuxers are not supposed to return the size of the packet read.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt 29aa499fc9 avformat/cdg: Don't store avio_size() return value in int
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt cee70b9f1b avformat/lafdec: Fix shadowing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt aa8c7dc3d8 avformat/argo_cvg: Avoid relocations for ArgoCVGOverride
The average length of the strings used here does not differ much
from the length of the longest string; therefore it makes sense
to use an array big enough for the longest string and not
a pointer to a string. This also moves this array into .rodata
(from .data.rel.ro).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt 69b85a69bd avformat/wady: Combine skips
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt cdff5a2c0c avformat/avr: Combine skips
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt 56ba83ff2d avformat/fsb: Don't set data_offset manually
It is set generically to the value that it is to here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt 88f803cf64 avformat/wvedec: Inline constant
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt 8768188581 avformat/g722: Inline constants
Forgotten in 5f0e161dd6.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt b93ed5c28e avformat/fitsdec: Don't use AVBPrint for temporary storage
Most of the data in the temporary storage ends up being
returned to the user as AVPacket.data, so it makes sense
to avoid using the AVBPrint for temporary storage altogether
(in particular in light of the fact that the blocks read here
are too big for the small-string optimization anyway) and
read the data directly into AVPacket.data. This also avoids
another memcpy() from a stack buffer to the AVBPrint in ts_image()
(that could always have been avoided with av_bprint_get_buffer()).

These changes also allow to use av_append_packet(), which
greatly simplifies the code; furthermore, one can avoid cleanup
code on error as the packet is already unreferenced generically
on error.

There are two user-visible changes from this patch:
1. Truncated packets are now marked as corrupt.
2. AVPacket.pos is set (it corresponds to the discarded header
line, 80 bytes before the position corresponding to the
actual packet data).

Furthermore, this patch also removes code that triggered
a -Wtautological-constant-out-of-range-compare warning
from Clang (namely a comparison of an unsigned and INT64_MAX
in an assert).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt 5144455c20 avformat/hls: Don't access FFInputFormat.raw_codec_id
It is an implementation detail of other input formats whether
they use raw_codec_id or not. The HLS demuxer should not rely
on this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt a990e6fa01 avformat/mux: Remove check for AVFMT_ALLOW_FLUSH
Due to the bump it is now certain that all devices
that support flushing have the proper internal flag set.
(Notice that the check for LIBAVFORMAT_VERSION was wrong.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:32:52 +01:00
Andreas Rheinhardt e95dd6f53e avformat/file: Combine all CONFIG_ANDROID_CONTENT_PROTOCOL blocks
Besides improving readability this also ensures that
a developer who has the android content protocol enabled
and works on the other parts of the file will not
forget to add necessary inclusions just because of
(indirect) inclusions from the files included only
when said protocol is enabled.

Reviewed-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:31:58 +01:00
Andreas Rheinhardt ebe8326409 avformat/file: Constify android content protocol
(The discrepancy between the definition and the declaration
in protocols.c is actually UB.)

Reviewed-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:31:40 +01:00
James Almer abcdd3aed7 avformat/mov: don't use cur_item_id as array index
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-25 23:20:51 -03:00
Michael Niedermayer dd733b2be4
avformat/concatdec: clip outpoint - inpoint overflow in get_best_effort_duration()
An alternative would be to limit all time/duration fields to below 64bit

Fixes: signed integer overflow: -93000000 - 9223372036839000000 cannot be represented in type 'long long'
Fixes: 64546/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5110813828186112

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 01:19:17 +01:00
Michael Niedermayer e83e8d443b
avformat/jacosubdec: clarify code
add comments, rename variables and indent things differently

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 01:19:16 +01:00
Jun Zhao 5ebcca4e08 lavf/movenc: small cleanup for style
Small cleanup for style, indent, switch case lables.
BTW, the preferred way to ease multiple indentation levels in a
switch statement is to align the switch and its subordinate
case labels in the same column

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2024-03-26 07:52:53 +08:00
Michael Niedermayer b792e4d4c7
avformat/cafdec: Check that data chunk end fits within 64bit
Fixes: signed integer overflow: 64 + 9223372036854775803 cannot be represented in type 'long long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6536881135550464
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6536881135550464

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 00:08:25 +01:00
Michael Niedermayer b8e754525c
avformat/iff: Saturate avio_tell() + 12
Fixes: signed integer overflow: 9223372036854775796 + 12 cannot be represented in type 'long long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-4898373660704768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 00:08:25 +01:00
Michael Niedermayer 50d8e4f273
avformat/dxa: Adjust order of operations around block align
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_DXA_fuzzer-5730576523198464
Fixes: signed integer overflow: 2147483566 + 82 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>
2024-03-26 00:08:25 +01:00
Michael Niedermayer d973fcbcc2
avformat/cafdec: dont seek beyond 64bit
Fixes: signed integer overflow: 64 + 9223372036854775807 cannot be represented in type 'long long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6418242730328064
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6418242730328064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 00:08:25 +01:00
Michael Niedermayer d384af5226
avformat/avidec: support huge durations
Fixes: signed integer overflow: 109817402400 * 301990077 cannot be represented in type 'long long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6706191715139584
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6706191715139584

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 00:08:25 +01:00
Michael Niedermayer c0f4abe2aa
avformat/id3v2: read_uslt() check for the amount read
Fixes: timeout
Fixes: 66783/clusterfuzz-testcase-minimized-ffmpeg_dem_GENH_fuzzer-5356884892647424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-25 21:41:26 +01:00
Michael Niedermayer 3c43299e9e
avformat/mov: Check sample_count and auxiliary_info_default_size to be 0
This combination causes 0 size arrays to be allocated and to leak later

Fixes: memleak
Fixes: 64342/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4520993686945792

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-25 21:41:25 +01:00
Michael Niedermayer 6f9e90ab0b
avformat/wady: Check >0 samplerate and channels 1 || 2.
The WADY decoder only supports mono and stereo

This fixes a probetest failure

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-25 21:41:25 +01:00
Andreas Rheinhardt 316239096b avformat/mov_chan: Use anonymous enum
Fixes many -Wenum-conversion warnings with Clang caused by
e6c2c87037.
See e.g.
https://fate.ffmpeg.org/log.cgi?time=20240325033545&slot=aarch64-linux-clang-10&log=compile

Reviewed-by: Henrik Gramner <henrik@gramner.com>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-25 17:40:19 +01:00
Marton Balint e6c2c87037 avformat/mov_chan: respect channel order when parsing and creating chan 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.

Fixes ticket #98.
2024-03-24 21:14:54 +01:00
Andreas Rheinhardt ccd2b7f858 avformat/demux: Combine "Packet corrupt" logmessages
Otherwise these statements might be torn apart by
av_logs from other threads.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-24 19:02:41 +01:00
Andreas Rheinhardt 07064f9bda avformat/demux: Restore pkt->stream_index assert check
It has been moved after "st  = s->streams[pkt->stream_index]"
in b140b8332c.
Deduplicate ff_read_packet() and ff_buffer_packet()
while fixing this.
This also fixes shadowing in ff_read_packet().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-24 19:02:41 +01:00
Leo Izen 83ed18a3ca
avformat/jpegxl_anim_dec: set pos for generic index
avpkt->pos needs to be set for generic indexing or features such as the
stream_loop option will not work.

Co-authored-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Leo Izen <leo.izen@gmail.com>
2024-03-23 07:29:18 -04:00
Stefano Sabatini 5c60be3ab6 lavf/gxfenc: return proper error codes in case of failure 2024-03-23 11:42:13 +01:00
Stefano Sabatini 3733aa7b17 lavf/gxfenc: consistently use snake_case in function names 2024-03-23 11:42:13 +01:00
Matthieu Bouron 6567516a5e avformat: add Android content resolver protocol support
Handles Android content URIs starting with content://.
2024-03-23 11:37:29 +01:00
Andreas Rheinhardt 073251316e avformat: Make init function out of write_header functions if possible
Also mark them as av_cold while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:20 +01:00
Andreas Rheinhardt 37f0dbbc39 avformat: Enforce codec_id where appropriate
E.g. chromaprint expects to be fed 16bit signed PCM
in native endianness, yet there was no check for this.
Similarly for other muxers. Use the new
FF_OFMT_FLAG_ONLY_DEFAULT_CODECS to enfore this where
appropriate, e.g. for pcm/raw muxers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:20 +01:00
Andreas Rheinhardt 2ccb45511f avformat/ttmlenc: Avoid unnecessary block
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:20 +01:00
Andreas Rheinhardt a24bccc238 avformat/mux: Add flag for "only default codecs allowed"
AVOutputFormat has default codecs for audio, video and subtitle
and often these are the only codecs of this type allowed.
So add a flag to AVOutputFormat so that this can be checked generically.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:19 +01:00
Andreas Rheinhardt 03b04eef72 avformat: Enforce one-stream limit where appropriate
Several muxers (e.g. pcm muxers) did not check the number
of streams even though the individual streams were not
recoverable from the muxed files. This commit changes
this by using the FF_OFMT_MAX_ONE_OF_EACH flag
where appropriate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:19 +01:00
Andreas Rheinhardt f4167842c1 avformat/mux: Add flag for "not more than one stream of each type"
More exactly: Not more than one stream of each type for which
a default codec (i.e. AVOutputFormat.(audio|video|subtitle)_codec)
is set; for those types for which no such codec is set (or for
which no designated default codec in AVOutputFormat exists at all)
no streams are permitted.

Given that with this flag set the default codecs become more important,
they are now set explicitly to AV_CODEC_ID_NONE for "unset";
the earlier code relied on AV_CODEC_ID_NONE being equal to zero,
so that default static initialization set it accordingly;
but this is not how one is supposed to use an enum.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:19 +01:00
Andreas Rheinhardt a48e839a22 avformat/mux_utils: Don't report that AV_CODEC_ID_NONE can be muxed
If AVOutputFormat.video_codec, audio_codec or subtitle_codec
is AV_CODEC_ID_NONE, it means that there is no default codec
for this format and not that it is supported to mux AV_CODEC_ID_NONE.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:19 +01:00
Andreas Rheinhardt 789c5b03db avformat/amr: Move write_header closer to muxer definition
Avoids one #if.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:19 +01:00
Andreas Rheinhardt 233e13f285 avformat/mux: Rename FF_FMT_ALLOW_FLUSH->FF_OFMT_FLAG_ALLOW_FLUSH
It better reflects that this is a muxer-only flag.
Also document the flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:19 +01:00
Andreas Rheinhardt b8124fe35e libavformat/westwood_audenc: Use proper logcontext
(AVStream did not have an AVClass when this muxer was added.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:19 +01:00
Andreas Rheinhardt eb3ee7f141 avformat/mp3enc: Improve query_codec
Signal that anything except MP3 and the ID3V2 attached pic types
are forbidden.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 23:57:19 +01:00
Andreas Rheinhardt ee736ff80e avformat/flvenc: Avoid avio_write(pb, "", 0)
When the compiler chooses to inline put_amf_string(pb, ""),
the avio_write(pb, "", 0) can be avoided. Happens with
Clang-17 with -O1 and higher and GCC 13 with -O2 and higher
here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-22 12:59:50 +01:00
James Almer 97d2990ea6 avformat/iamf_reader: propagate avio_skip() error values
Fixes: null pointer derference
Fixes: 67007/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6522819204677632

Tested-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-21 09:08:22 -03:00
James Almer e04c638f5f avformat/movenc: only compile avif_write_trailer() when the avif muxer is enabled
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-20 23:50:55 -03:00
Andreas Rheinhardt 0b7d4fccce avformat/codec2: Don't allocate Codec2Context for muxer
Only the demuxers use it.

Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-20 12:46:23 +01:00
Andreas Rheinhardt cd8cc3d1b3 avformat/iamfenc: Remove unused headers
Forgotten in c95c8a0158.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-20 10:17:59 +01:00
Andreas Rheinhardt 6a9ddfcd96 avformat/iamfenc: Align check and error message
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-20 10:17:52 +01:00
Andreas Rheinhardt a7ad5d4d10 avformat/iamfenc: Remove always-false check
This muxer does not have the AVFMT_NOSTREAMS flag; therefore
it is checked generically that there is at least a stream.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-20 10:17:37 +01:00
James Almer 53dd31497b avformat/matroska: use named constants for ITU-T T.35 metadata
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-19 10:49:20 -03:00
Andreas Rheinhardt 7e41a658f5 avformat/aeadec: Use sample rate as time base
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-19 02:54:24 +01:00
Andreas Rheinhardt 103965053b avformat/aeadec: Export title
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-19 02:54:13 +01:00
Zhu Pengfei 85e047e7cd avformat/flvenc: support enhanced flv PacketTypeMetadata
Signed-off-by: Zhu Pengfei <411294962@qq.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2024-03-18 15:41:54 +08:00
Zhu Pengfei 4e5b1882d6 avformat/flvdec: support enhanced flv PacketTypeMetadata
Signed-off-by: Zhu Pengfei <411294962@qq.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2024-03-18 15:41:48 +08:00
Andreas Rheinhardt 6e63295d41 avformat/crypto: Avoid cast, use proper printf specifier
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-18 01:53:32 +01:00
Andreas Rheinhardt 7b48cc61be avformat/aeaenc: Fix printf-specifier
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-18 01:53:26 +01:00
Andreas Rheinhardt 95a6788314 avformat/aiffenc: Usw avio_wb32() where possible
AIFF is a big-endian format, so this is more natural.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-17 16:09:15 +01:00
Andreas Rheinhardt 0230792bc8 avformat/aiffenc: Simplify padding tag
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-17 16:09:15 +01:00
Andreas Rheinhardt 62412cd75d avformat/iamf: Mark symbols as hidden
Avoids .got entries for ff_iamf_scalable_ch_layouts and
ff_iamf_sound_system_map (whether they would have been
created otherwise depends upon the compiler and compiler
options).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-17 15:10:05 +01:00
Marton Balint d35b6fda45 avformat/mxfdec: signal channel layouts using the new channel layout api
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-16 19:49:39 +01:00
Marton Balint 26e0454cad avformat/mov_chan: simplify channel layout canonicalization
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-16 19:49:39 +01:00
Marton Balint 44b2769619 avformat/pcm: decrease target audio frame per sec to 10
This makes the wav and pcm demuxer demux bigger packets, which is more
efficient.

As a side effect of the bigger packets, audio durations can become less exact
for command lines such as "ffmpeg -i $INPUT -c:a copy -t 1.0 $OUTPUT".

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-16 19:19:42 +01:00
Marton Balint 05936403f9 avformat/wavdec: use ff_pcm_default_packet_size for the default packet size
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-16 19:19:42 +01:00
Marton Balint 9c2c0c37f8 avformat/pcm: factorize and improve determining the default packet size
- Remove the 1024 cap on the number of samples, for high sample rate audio it
  was suboptimal, calculate the low neighbour power of two for the number of
  samples (audio blocks) instead.
- Make the function work correctly also for non-pcm codecs by using the stream
  bitrate to estimate the target packet size. A previous version of this patch
  used av_get_audio_frame_duration2() the estimate the desired packet size, but
  for some codecs that returns the duration of a single audio frame regardless
  of frame_bytes.
- Fallback to 4096/block_align*block_align if bitrate is not available.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-16 19:19:42 +01:00
Gyan Doshi f5441e441f avformat/mpegtsenc: correct bitstream check
8559cce3c3 made the bitstream check generic using a LUT.
However, one of the comparisons which involves a bitwise AND
and equality check is faulty due to operator precedence.

First reported and analysed at
https://github.com/streamlink/streamlink/issues/5876

Fixes #10908
2024-03-16 14:30:05 +05:30
Marth64 4464b7eeb1 avformat/dvdvideodec: use int64_t for menu blocks_read and make format expressions portable
Signed-off-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-15 15:50:35 +01:00
Andreas Rheinhardt c00cd007e8 configure: Remove av_restrict
All versions of MSVC that support C11 (namely >= v19.27)
also support the restrict keyword, therefore av_restrict
is no longer necessary since 75697836b1.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-15 12:51:15 +01:00
Andreas Rheinhardt 53a51e70f2 avformat/internal: Remove declaration for ff_format_io_close_default()
Forgotten in d6799ee0e4.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-14 22:53:50 +01:00
Andreas Rheinhardt 7a089ed8e0 avformat/avidec: Fix integer overflow iff ULONG_MAX < INT64_MAX
Affects many FATE-tests, see
https://fate.ffmpeg.org/report.cgi?time=20240312011016&slot=ppc-linux-gcc-13.2-ubsan-altivec-qemu

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-14 20:48:20 +01:00
Marton Balint 7196b12b2b avformat/daudenc: force 2000 sample packet size with a bsf
The samples I found all have 2000 sample packets, and by forcing the packet
size with a bsf we could automagically make muxing work for packets containing
more than 3640 samples.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-14 01:37:31 +01:00
Christian Lee Seibold 384cc270d2 avformat/gopher: Add audio and video itemtypes
The 's', ';', and '<' itemtypes are used for audio and video by
Gophernicus and Gopher+.

Signed-off-by: Christian Lee Seibold <christian.seibold32@outlook.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-12 23:01:46 +01:00
Kristoffer Brånemyr 51d303e20c avformat/webvttdec: Skip more parts of header to let parsing continue
Signed-off-by: Kristoffer Brånemyr <ztion1@yahoo.se>
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-12 23:01:46 +01:00
Andreas Rheinhardt 41ab25cb2d avformat/fifo_test: Move into tests/fifo_muxer.c
This muxer solely exists to test the fifo muxer via a dedicated
test tool in libavformat/tests/fifo_muxer.c. It fulfills no
other role and it is only designed with this role in mind.

The latter can be seen in two facts: The muxer uses printf
for logging and it simply presumes the packets' data to contain
a FailingMuxerPacketData (a struct duplicated in fifo_test.c
and tests/fifo_muxer.c.); in particular, it presumes packets
to have data at all, but this need not be true with side-data
only packets and a segfault can easily be triggered by e.g.
encoding flac (our native encoder sends a side-data only packet
with updated extradata at the end of encoding).

This patch fixes this by moving the test muxer into the fifo
test tool, making it inaccessible via the API (and actually
removing it from libavformat.so and libavformat.a).
While this muxer was accessible via e.g. av_guess_format(),
it was not really usable for an API user as FailingMuxerPacketData
was not public. Therefore this is not considered a breaking change.

In order to continue to use the test muxer in the test tool,
the ordinary fifo muxer had to be overridden: fifo_muxer.c
includes lavf/fifo.c but with FIFO_TEST defined which makes
it support the fifo_test muxer. This is possible because
test tools are always linked statically to their respective
library.

Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-12 22:39:54 +01:00
Marth64 b3d87fb0c4 avformat/sccdec: remove unused bprint.h include
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-03-12 14:54:54 +01:00
Marth64 9b981e3112 avcodec/rcwtenc: canonize name and refresh documentation
The formal title of the muxer according to the specification
is "RCWT (Raw Captions With Time)", so canonize this
in the long name of the codec and docs.

In the documentation section, point #2 was wrong: ccextractor
extracts the Closed Captions data and stores normalized bits
similarly to this muxer.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-03-12 14:54:54 +01:00
asivery 9124d807dc avformat/aea: add aea muxer
Signed-off-by: asivery <asivery@protonmail.com>
2024-03-12 11:26:13 +01:00
Marth64 275877b981 avformat/dvdvideodec: add menu demuxing support
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-03-12 11:14:16 +01:00
Marth64 b8cbaad2ac avformat/dvdvideodec: add CLUT utilities and subtitle color support
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-03-12 11:14:16 +01:00
Stefano Sabatini 5828aaa2b5 lavf/fifo: sort options by name 2024-03-12 11:05:01 +01:00
Stefano Sabatini 53a952a731 lavf/fifo: fix typo 2024-03-11 16:52:42 +01:00
Stefano Sabatini bce9234f10 lavf/dvenc: improve error messaging
Provide useful information about the failure in the error message, do
not let the user guess.
2024-03-11 16:52:42 +01:00
Michael Niedermayer b2d7cbc378
avformat/concatdec: Check in and outpoints to be to produce a positive representable duration
Fixes: signed integer overflow: -93000000 - 9223372036839000000 cannot be represented in type 'long'
Fixes: 64546/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5110813828186112

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-10 19:49:04 +01:00
Marth64 ffc3f2a350 avformat/dvdvideodec: assign mono channel layout explicitly
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-03-10 15:01:11 +01:00
Marton Balint 64634e809f avformat/mxfenc: add h264_mp4toannexb bitstream filter if needed when muxing h264
Partially fixes ticket #10395.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-08 20:22:32 +01:00
Andreas Rheinhardt 93178c6c1a avformat/tests/movenc: Constify write functions
Forgotten in 2a68d945cd.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-08 03:30:57 +01:00
Anton Khirnov 384a207ea9 lavf/matroskadec: add missing linebreaks in error messages 2024-03-07 15:59:31 +01:00
James Almer 783d00b203 libs: bump major version for all libraries
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 11:29:43 -03:00
James Almer c8db1006ef avformat/avformat: Reorder AVFormatContext fields
Move related fields closer together.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:32 -03:00
James Almer 53cdf94653 avformat/avformat: remove AVFormatContext.ts_id
It's been replaced by a demuxer exported private option.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:32 -03:00
Andreas Rheinhardt cd93ba6531 avformat/demux: Use enum AVCodecID for raw_codec_id
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-07 08:53:31 -03:00
Andreas Rheinhardt b800327f4c avformat/avformat: Add FFInputFormat, hide internals of AVInputFormat
This commit does for AVInputFormat what commit
59c9dc82f4 did for AVOutputFormat:
It adds a new type FFInputFormat, moves all the internals
of AVInputFormat to it and adds a now reduced AVInputFormat
as first member.

This does not affect/improve extensibility of both public
or private fields for demuxers (it is still a mess due to lavd).

This is possible since 50f34172e0
(which removed the last usage of an internal field of AVInputFormat
in fftools).

(Hint: tools/probetest.c accesses the internals of FFInputFormat
as well, but given that it is a testing tool this is not considered
a problem.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-07 08:53:31 -03:00
James Almer d4574a9b64 avformat/version_major: postpone some deprecations until the next bump
They are either too recent, or are not trivial to remove.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
James Almer b8fef7e9c5 avutil: remove deprecated FF_API_PKT_DURATION
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
James Almer 65ddc74988 avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUT
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
James Almer 02aea61d69 avformat: remove deprecated FF_API_AVIO_WRITE_NONCONST
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
James Almer d6799ee0e4 avformat: remove deprecated FF_API_AVFORMAT_IO_CLOSE
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
James Almer aaefe47913 avformat: remove deprecated FF_API_AVIODIRCONTEXT
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
James Almer c4c6c9e9d2 avformat: remove deprecated FF_API_GET_END_PTS
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
Andreas Rheinhardt 49707b0590 avformat/options: Deprecate av_fmt_ctx_get_duration_estimation_method()
Forgotten in b7785d10b0.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-06 13:27:52 +01:00
James Almer 1a34eb3ffc avformat/mov: fix setting dependent disposition on ambisonic IAMF streams
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-05 13:26:04 -03:00
James Almer ab15c04dee avformat/avformat: add a function to return the name of stream groups
Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-05 11:54:27 -03:00
James Almer 79c6ba9007 avformat/iamf_writer: constify some variables
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-05 11:39:17 -03:00
James Almer 988e3a061a avformat/iamf_writer: clear extradata_size on extradata allocation failure
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-05 11:23:41 -03:00
Andreas Rheinhardt 440f8186ef avformat/dashenc, hlsenc: Return 0 on succes from write_header
Do not propagate the return value of avformat_write_header(),
as it contains the information whether the output had
already been initialized in avformat_init_output(),
but this is set generically; the return value of
FFOutputFormat.write_header is not documented at all
(and is currently ignored if >= 0), but it is more future-proof
to simply return 0 on success.

Reviewed-by: Liu Steven <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-05 15:15:31 +01:00
Andreas Rheinhardt d085f341d6 avformat/hlsenc: Redo checking for strftime %s support to avoid warnings
This is intended to avoid -Wformat= warnings on systems
where %s might not be supported (and also generally emitted
by GCC with -pedantic).

Reviewed-by: Liu Steven <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-05 15:15:06 +01:00
Andreas Rheinhardt fed46d7706 avformat/avio: Avoid av_strdup(NULL)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-05 12:08:18 +01:00
Andreas Rheinhardt c856e4c546 avformat/avio: Avoid indirection in ffio_fdopen()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-05 12:08:18 +01:00
Andreas Rheinhardt 57e20dd6b6 avformat/avio: Avoid function pointer casts
It is undefined behaviour to use a different type for a call
than the actual type of the function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-05 12:08:18 +01:00
Andreas Rheinhardt f0abb44fbf avformat/aviobuf: Move code specific to URLContexts to avio.c
This separates the URL-layer adjacent parts of the code
from the parts that are also usable with custom IO.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-05 12:08:18 +01:00
James Almer 44e5749462 avformat/iamfenc: ensure updated extradata is written
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-04 21:14:17 -03:00
James Almer 56d630e6c2 avformat/iamf_writer: update extradata from packet side data
Some encoders, like flac, propagate updated extradata at the end of encoding
as packet side data. Use it to update the relevant codec_config.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-04 21:14:05 -03:00
James Almer 97e1480c8c avformat/mov: set stream index field in tile grids
It was forgotten for grid type derived images.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-04 20:17:52 -03:00
James Almer 8f33d8fa9b avformat/mov: don't mark an item referenced by a grid as dependent if it's the primary item
If it's the primary item, then it's expected to be ready for presentation even
outside of the grid it belongs to.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-04 20:17:41 -03:00
James Almer d78c75fe49 avformat/mov: fix setting disposition for the first iamf stream
st->disposition will be overwritten with disposition later in the function.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-04 20:17:41 -03:00
Andrew Sayers 6096c244bb fix /// comments that should be ///<
Actual command: sed -i -e "s/\([;,] *\)<* *\/\/\/ *<* */\1\/\/\/< /" $( git grep -l "[;,] */// " )

Signed-off-by: Andrew Sayers <ffmpeg-devel@pileofstuff.org>
2024-03-04 17:38:57 +01:00
Marth64 01476f752a avformat/dvdvideodec: fix -pgc and -pg options
Rebased on top of recently merged fixes (should apply correctly now).

In merged DVD patch, -pgc and -pg options were broken. While these are
rather advanced options, they are the only means to get content for
some strangely authored discs.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-03-04 10:47:57 +01:00
Marton Balint 0aaee4741c avformat/mpegts: detect synchronous metadata KLV more reliably
The mpegts code historically tries to strip (the first) metadata access unit
header from synchronous KLV metadata, but the detection for such streams was
unreliable causing strips of asynchronous metadata or ID3 as well.

MISB ST 1402 specifies required stream type, stream id and registration
descriptor (which eventually maps to the codec ID) so let's use all of these
for reliable detection.

Fixes a regression caused by 468615f204.

Fixes ticket #10828, #10883.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-04 00:33:20 +01:00
Andreas Rheinhardt 1a4e0eb374 avformat/dvdvideodec: Reorder allocations to simplify freeing
Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 09:20:36 +01:00
Andreas Rheinhardt 77b26bf4b6 avformat/dvdvideodec: Only free allocated buffers
Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 09:20:23 +01:00
Andreas Rheinhardt e30dd9bbac avformat/dvdvideodec: Don't store AVInputFormat*
The inner AVInputFormat* of the inner mpegps-demuxer
is only used once (in avformat_open_input()), so
don't even store it. In fact, just use ff_mpegps_demuxer
directly, as this demuxer has a configure dependency
on it.

Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 09:20:13 +01:00
Andreas Rheinhardt 0b8f7a7859 avformat/dvdvideodec: Explicitly return 0 on success
Don't "return ret" even when ret is zero on success.

Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-03 09:19:51 +01:00
James Almer f8caf388fb avformat/iamf_writer: constify some function parameters
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-02 21:41:09 -03:00
Marton Balint 3a09c2122d avformat/wavdec: dynamically set max_size by default
The wav demuxer by default tried to demux 4096-byte packets which caused
packets with very few number of samples for files with high channel count.
This caused a significant overhead especially since the latest ffmpeg.c
threading changes.

So let's use a similar approach for selecting audio frame size which is already
used in the PCM demuxer, which is to read 25 times per second but at most 1024
samples.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-02 19:13:03 +01:00
Marton Balint 4ebf478f4c avformat/mxfdec: track metadata sets by their type
We typically are only interesed in a single type of metadata set, so it is
better to keep them separated instead of always filtering for them.

Also use av_dynarray_add for increasing their array.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-02 18:49:31 +01:00
Marton Balint aa299faa9a avformat/mxfdec: remove resolve_strong_ref usage with AnyType
UUIDs do not have to be unique if their type sets them apart, so avoid using
AnyType, since we are only interested in specific types.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-03-02 18:49:31 +01:00
Marth64 a1304272c3 libavformat/dvdvideo: add DVD-Video demuxer, powered by libdvdread and libdvdnav
Signed-off-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-03-02 08:12:29 +01:00
Andreas Rheinhardt dfb9d8a5a2 avformat/avio: Make avio_print_string_array() accept const pointers
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-02 02:49:48 +01:00
Zhao Zhili b56b343e43 avformat/mov: Update bits_per_coded_sample after read pcmC
Fix #10878
2024-03-01 17:23:18 +08:00
James Almer ec7937f4a5 avformat/iamf: remove duplicated function
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-29 12:57:25 -03:00
Andreas Rheinhardt 1bb7d5ca9f avformat/mov: Don't use entry[-1] in pointer arithmetic
It is undefined behaviour.
Fixes many failed tests with UBSan and GCC 13 like
"src/libavformat/mov.c:4229:44: runtime error: store to address
0x5572abe20f80 with insufficient space for an object of type 'struct
MOVIndexRange'"
(The line number does not refer to the line where &entry[-1]
is assigned.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-27 10:27:42 +01:00
Andreas Rheinhardt 9d7d03ea45 Revert "avformat/mov: zero initialize the index ranges buffer"
This reverts commit eee3b7e2fb.
It has been made in an attempt to fix UBSan test failures with
GCC 13 (see e.g. [1]), but it did not help at all. So revert it,
but use av_malloc_array() instead of going back to av_malloc().

[1]: https://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-ubsan&time=20240226182430

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-27 00:17:39 +01:00
James Almer 41e349c24a avformat/mov: add support for tile HEIF still images
Export each tile as its own stream, and the grid information as a Stream Group
of type TILE_GRID.
This also enables exporting other stream items like thumbnails, which may be
present in non tiled HEIF images too. For those, the primary stream will be
tagged with the default disposition.

Based on a patch by Swaraj Hota

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-26 12:21:12 -03:00
James Almer 25a10677d1 avformat: add a Tile Grid stream group type
This will be used to support tiled image formats like HEIF.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-26 12:21:12 -03:00
Marton Balint 87677c2195 avformat/libsrt: use SRT_EPOLL_IN for waiting for an incoming connection
This is the proper poll mode for waiting for an incoming connection according
to the SRT API docs.

Fixes ticket #9142.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-25 00:35:02 +01:00
Zhao Zhili 4ea2b271eb avformat/libsrt: Remove manually free AV_OPT_TYPE_STRING
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-02-22 19:13:36 +08:00
Dale Curtis 6ef32ea574
Avoid OOM for invalid STCO / CO64 constructions.
The `entries` value is read directly from the stream and used to
allocate memory. This change clamps `entries` to however many are
possible in the remaining atom or file size (whichever is smallest).

Fixes https://crbug.com/1429357

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-02-21 18:23:41 +01:00
Andreas Rheinhardt cffadfe99a avformat/movenc: Make check actually check what is intended
Also fixes a Clang warning:
"overlapping comparisons always evaluate to false
[-Wtautological-overlap-compare]"

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-20 19:00:23 +01:00
Martin Storsjö 58ffe0db4d flvdec: Honor the "flv_metadata" option for the "datastream" metadata field
By default the option "flv_metadata" (internally using the field
name "trust_metadata") is set to 0, meaning that we don't allocate
streams based on information in the metadata, only based on
actual streams we encounter. However the "datastream" metadata field
still would allocate a subtitle stream.

When muxing, the "datastream" field is added if either a data stream
or subtitle stream is present - but the same metadata field is used
to preemtively create a subtitle stream only. Thus, if the field
was added due to a data stream, not a subtitle stream, the demuxer
would create a stream which won't get any actual packets.

If there was such an extra, empty subtitle stream, running
avformat_find_stream_info still used to terminate within reasonable
time before 3749eede66. After that
commit, it no longer would terminate until it reaches the max
analyze duration, which is 90 seconds for flv streams (see
e6a084641a,
24fdf7334d and
f58e011a1f).

Before that commit (which removed the deprecated AVStream.codec), the
"st->codecpar->codec_id = AV_CODEC_ID_TEXT", set within the demuxer,
would get propagated into st->codec->codec_id by numerous
avcodec_parameters_to_context(st->codec, st->codecpar), then further
into st->internal->avctx->codec_id by update_stream_avctx within
read_frame_internal in libavformat/utils.c (demux.c these days).

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-02-20 16:49:51 +02:00
James Almer dbfa8381f6 avformat/movenc: add support for Immersive Audio Model and Formats in ISOBMFF
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-20 11:45:11 -03:00
James Almer fe637161db avformat/mov: add support for Immersive Audio Model and Formats in ISOBMFF
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-20 11:24:19 -03:00
James Almer 9ba327e70f avformat/mov: make MOVStreamContext refcounted
This will be useful in the next commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-20 11:24:19 -03:00
James Almer ce7b519ab7 avformat/mov: factorize out setting the output packet properties
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-20 11:24:19 -03:00
James Almer b140b8332c avformat/demux: allow demuxers to output more than one packet per read_packet() call
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-20 11:24:19 -03:00
James Almer 80131321c4 avformat/iamfdec: set disposition flags to output streams
if there's an audio layer with a single stream that can be rendered alone, mark it
as default. Otherwise, mark every stream as dependent.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-19 20:53:36 -03:00
James Almer c95c8a0158 avformat/iamfenc: further split into shareable modules
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-19 20:53:36 -03:00
James Almer c7266ad60f avformat/iamfdec: further split into shareable modules
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-19 20:53:36 -03:00
Marton Balint 68f2b32ef2 avformat/mxfdec: do not use AnyType when resolving Descriptors and MultipleDescriptors
By using AnyType for resolving a strong reference we searched among all types,
not just the ones which can be the target of the reference, which in some cases
caused to find the wrong type, if the metadata set UUIDs were not unique.

UUIDs do not have to be unique if their type sets them apart, SMPTE 377M says:

> StrongRef: 'One to One’ relationship between sets and implemented in MXF
> with UUIDs. Strong References are typed which means that the definition
> identifies the kind of set which is the target of the reference.

Fixes ticket #10865.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-20 00:04:40 +01:00
Marton Balint 41672f5586 avformat/mxfdec: move resolving Descriptors to the multi descriptor resolve function
Also remove unused descriptor member from MXFPackage.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-20 00:04:40 +01:00
Andreas Rheinhardt 1f7cd5d434 avformat/iamf_writer: Fix leaks on error
Fixes Coverity issues #1559544 and #1559547.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-19 23:30:18 +01:00
Andreas Rheinhardt c5845afd09 avformat/iamf_writer: Return proper error codes
Surprisingly the return value of add_param_definition()
(a pointer) has only been used to check for success
and not to actually access the pointee; nonsuccess
was equated with ENOMEM, although there is a non-enomem
error path in this function.

Change this by returning an int.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-19 23:30:06 +01:00
Andreas Rheinhardt 18af922c53 avformat/iamf: Don't mix ownership and non-ownership pointers
IAMFAudioElement and IAMFMixPresentation currently contain
pointers to independently allocated objects that are sometimes
owned by said structures and sometimes not.

More precisely, upon success the demuxer transfers ownership
of these other objects newly created AVStreamGroups, but it
keeps its pointers. iamf_read_close() therefore always resets
these pointers (because the cleanup code always treats them
as ownership pointers). This leads to memory leaks in case
iamf_read_header() without having attached all of these
objects to stream groups.

The muxer has a similar issue: It also clears these pointers
(pointing to objects owned by stream groups created by the user)
in its deinit function.

This commit fixes this memleak by explicitly adding non-ownership
pointers; this also allows to remove the code to reset the
ownership pointers.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-19 23:30:00 +01:00
Andreas Rheinhardt e7c33c92d1 avformat/iamf_writer: Don't memset twice
This has been allocated via av_calloc() a few lines above.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-19 23:29:57 +01:00
Andreas Rheinhardt 840f192540 avformat/iamf_writer: Remove nonsense check
Checking whether a pointer to an element of an array is NULL
makes no sense, as the pointer addition involved in getting
the address would be undefined behaviour already if the array
were NULL.
In this case the array allocation has already been checked
a few lines before.
Fixes Coverity issue #1559548.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-19 23:29:49 +01:00
Andreas Rheinhardt 94fadd335b avformat/iamf_writer: Don't leak on error when adding ParamDefinition
Fix this by postponing the allocation.
Fixes Coverity issue #1559545.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-19 23:29:25 +01:00
James Almer 4b8be3616d avformat/mpegts: remove decoding param from ts_packetsize option
It's a read only exported option, and not meant to be set by the user.
Also, move it to MPEGTS_OPTIONS while at it to avoid duplication.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-19 11:25:21 -03:00
James Almer f9f56fdc37 avformat/mpegts: add a ts_id exported option
It will replace AVFormatContext.ts_id in the coming bump.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-19 11:25:15 -03:00
Marton Balint b81ed729ec avformat/mov_chan: rework ff_mov_read_chnl
A lot of changes and fixes to channel layout parsing, notably
- get rid of dynamic allocation of channel positions
- signal unimplemented speaker positions as unknown instead of failure, but
  warn the user about it
- native order, and that a single channel only appears once was always assumed
  for less than 64 channels, obviously this was incorrect

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-18 10:54:24 +01:00
Marton Balint f8f2142d61 avformat/mov: factorize reading the main part of the chnl atom to mov_chan
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-18 10:54:24 +01:00
Ingo Oppermann 86128bd07a avformat/libsrt: Fix srt:// URL query string parsing
Add missing NULL check and use ff_urldecode for string query
parameters.

Signed-off-by: Ingo Oppermann <ingo@datarhei.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-15 00:34:16 +01:00
Anton Khirnov 1e7d2007c3 all: use designated initializers for AVOption.unit
Makes it robust against adding fields before it, which will be useful in
following commits.

Majority of the patch generated by the following Coccinelle script:

@@
typedef AVOption;
identifier arr_name;
initializer list il;
initializer list[8] il1;
expression tail;
@@
AVOption arr_name[] = { il, { il1,
- tail
+ .unit = tail
}, ...  };

with some manual changes, as the script:
* has trouble with options defined inside macros
* sometimes does not handle options under an #else branch
* sometimes swallows whitespace
2024-02-14 14:53:41 +01:00
Andreas Rheinhardt 964693324a avformat/avformat: Remove reference to removed setter
Removed in 704017d91e.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-14 13:18:41 +01:00
asivery 7f4abe7c37 avformat/matroska: Add support for A_ATRAC/AT1
Signed-off-by: asivery <asivery@protonmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-13 15:27:29 +01:00
Andreas Rheinhardt 568645f087 avformat/dump: Fix use of undeclared variables
Broken in ec2036454b.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-13 14:17:38 +01:00
James Almer ec2036454b avformat: add a disposition field to AVStreamGroup
The existing (and upcoming) available group types are meant to combine several
streams for presentation, with the result being treated as if it was a stream
itself.
For example, a file could export two stream groups of the same type with one of
them as the "default".

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-13 09:51:28 -03:00
Marton Balint 106527d2e5 avformat/mov_chan: add support for reading custom channel layouts when layout_tag == 0
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-12 21:04:11 +01:00
rcombs 7bf1b9b357 lavf/assenc: normalize line endings to \n
Previously, we produced output with either \r\n or mixed line endings.
This was undesirable unto itself, but also made working with patches affecting
FATE output particularly challenging, especially via the mailing list.

Everything that consumes the SSA/ASS format is line-ending-agnostic,
so \n is selected to simplify git/ML usage in FATE.

Extra \r characters at the end of a packet are dropped. These are always
ignored by the renderer anyway.
2024-02-11 17:01:07 -08:00
rcombs 98eeef44aa lavf/avio_internal: add ffio_write_lines for line ending normalization 2024-02-11 17:01:07 -08:00
Marton Balint dc9d64f794 avformat/mov_chan: never override number of channels based on chan atom
The channel designation metadata should not override the number of channels.
Let's warn the user if it is inconsistent, and keep the channel layout
unspecified.

Before the conversion to the channel layout API the code only set the mask, but
never overridden the channel count, so this restores the old behaviour.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-09 23:47:24 +01:00
Marton Balint 3d3cad7483 avformat/mov_chan: do not assume channels are in native order
Existing code could have caused wrong channel order signalling or reduced
channel count if a channel designation appeared multiple times. This is
actually an old bug, but the conversion to the new channel layout API made it
visible, because now the code overrides the proper channel count with the one
calculated from the mask.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-09 23:47:24 +01:00
Anton Khirnov ca18bb5972 lavf/demux: stop calling avcodec_close()
Replace it with recreating the codec context.

This is the last remaining blocker for deprecating avcodec_close().
2024-02-09 16:14:56 +01:00
Anton Khirnov 88ba22009e lavf/flacdec: stop accessing FFStream.avctx
The demuxer opens an internal parser instance in read_timestamp(), which
requires a codec context. There is no need for it to access the FFStream
one which is used for other purposes, it can allocate its own internal
one.
2024-02-09 16:14:56 +01:00
Anton Khirnov 0d54ae4012 lavf/mpegts: drop a cargo-culted check
This check has survived the transition to AVCodecParameters, but is no
longer relevant after it, since the codec context is no longer updated
or accessed at all from the demuxer.
2024-02-09 16:14:56 +01:00
Andreas Rheinhardt 3371250c32 avformat/rcwtenc: Pass RCWTContext directly in rcwt_init_cluster()
It does not use the AVFormatContext at all.

Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 10:20:42 +01:00
Andreas Rheinhardt a8e55cf118 avformat/rcwtenc: Remove redundant zeroing of buffer
Resetting the counter of used elements is enough as nothing is
ever read from the currently unused elements.

Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 10:20:35 +01:00
Andreas Rheinhardt d30fe36b88 avformat/rcwtenc: Fix potential out-of-bounds write
The rcwt muxer uses several counters for how much data
it has already cached: One byte counter and one counter
for how many complete blocks (of three bytes each).
These counters can become inconsistent when the muxer is
fed incomplete blocks as the muxer presumes that it is
about to write a new block at the start of each write_packet
call. E.g. sending 65535*3+1 1-byte packets (with data[0] e.g. 0x03)
will trigger an out-of-bounds write.

This patch fixes this by processing the data in complete blocks
only. This also allows to simplify the code, e.g. to remove one of
the counters.

Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-09 10:20:21 +01:00
Andreas Rheinhardt 8b83b52d0f avformat/nutenc: Fix indentation
Forgotten after 82beb46e65.
Also use loop-scope for iterators while at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:22:19 +01:00
Andreas Rheinhardt 71e1da4522 avformat/mux: Don't allocate priv_pts separately
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:22:18 +01:00
Andreas Rheinhardt ad9f644505 avformat/avformat: Avoid av_strdup(NULL)
It is not documented to be safe.
Also copy these lists in a more generic manner.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:22:18 +01:00
Andreas Rheinhardt 569ad285a5 avformat/options: Only allocate AVCodecContext for demuxers
The muxer's AVCodecContext is currently used for exactly one thing:
To store a time base in it that has been derived via heuristics
in avformat_transfer_internal_stream_timing_info(); said time base
can then be read back via av_stream_get_codec_timebase().
But one does not need a whole AVCodecContext for that, a simple
AVRational is enough.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:22:18 +01:00
Andreas Rheinhardt 76ef2b9337 avformat/avformat: Remove obsolete comment
Forgotten in 3f991325b5,
obsolete since 3749eede66.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:22:18 +01:00
Andreas Rheinhardt 1d5ba34249 avformat/avformat: Remove dead check, write-only assignment
For muxers, the internal AVCodecContext is basically unused
except in avformat_transfer_internal_stream_timing_info()
(which sets time_base and ticks_per_frame) and
av_stream_get_codec_timebase() (a getter for time_base).
This makes ticks_per_frame write-only, so don't set it.

Also remove an always-false check for the AVCodecContext's
codec_tag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-07 10:22:18 +01:00
Alessandro Ros 49ab7f8997 avformat/flvenc: fix stereo flag when writing PCMA/PCMU
Currently, when writing PCMA or PCMU tracks with FLV or RTMP, the
stereo flag and sample rate flag inside RTMP audio messages are
overridden, making impossible to distinguish between mono and stereo
tracks. This patch fixes the issue by restoring the same flag mechanism
of all other codecs, that takes into consideration the right channel
count and sample rate.

Signed-off-by: Alessandro Ros <aler9.dev@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-02-04 20:28:47 +01:00
Damiano Galassi 112d3618ca avformat/mov: add support for 'amve' ambient viewing environment box
As defined in ISOBMFF (ISO/IEC 14496-12) document.

Co-Authored-By: Cosmin Stejerean <cosmin@cosmin.at>
2024-02-04 13:36:25 -03:00
Cosmin Stejerean dda4b25e2d avformat/mov: rename rescale_mdcv
It's not specific to the mdcv box.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-04 13:36:25 -03:00
Gyan Doshi 7375a6ca7b avformat/wavenc: use strtoull for UMID conversion
Existing use of strtoll can lead to ERANGE errors leading to incorrect
storage of UMID.
2024-02-04 14:44:32 +05:30
James Almer b94b3eac0e avformat/mov: use a more descriptive name for variables of type HEIFItem
Other HEIF related structs will be introduced, so lets be more specific about what
this one defines.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-03 23:08:42 -03:00
Marth64 01388936a8 avformat/avlanguage: add the 6 deprecated DVD languages
There are 6 deprecated ISO language codes that are still valid for DVDs.
This patch allows avlanguage to recognize them correctly. The codes are:
(1) "in" - legacy code for Indonesian, mapped to the modern code
(2) "iw" - legacy code for Hebrew, mapped to the modern code
(3) "ji" - legacy code for Yiddish, mapped to the modern code
(4) "jw" - legacy code for Javanese, published and used as a typoed version of "jv"
(5) "mo" - legacy code for Moldavian, mapped to the inclusive code
(6) "sh" - legacy code for Serbo-Croatian, no modern inclusive code so it is left alone

All of this can be verified from several sources including:
https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-02-03 12:52:47 +01:00
Andreas Rheinhardt d50a246687 avformat/iamf*: Improve included headers
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-03 00:26:10 +01:00
Andreas Rheinhardt 8d4b22edc7 avformat/iamf_writer, iamfenc: Avoid allocations when using dyn buffers
Use avio_get_dyn_buf()+ffio_free_dyn_buf() instead of
avio_close_dyn_buf()+av_free(). This saves an allocation
(and memcpy) in case all the data fits in the AVIOContext's
write buffer.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-03 00:26:02 +01:00