Commit Graph

25854 Commits

Author SHA1 Message Date
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