Commit Graph

22957 Commits

Author SHA1 Message Date
Zane van Iperen 101ac40f69
avformat/argo_asf: fix enforcement of chunk count
Enforcing num_chunks == 1 only makes sense when demuxing from an ASF
file. When embedded in a BRP file, an ASF stream can have multiple chunks.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-20 19:20:53 +10:00
Andreas Rheinhardt ef29e5bf42 avformat/swfdec: Avoid unnecessary skip
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-20 11:14:26 +02:00
Andreas Rheinhardt d554aabdaf avformat/swfenc: Fix memleak upon write_header error
The SWF muxer accepts at most one mp3 audio and at most one VP6F, FLV1
or MJPEG stream. Upon encountering an mp3 stream, a fifo is allocated
that leaks if one of the subsequent streams is incompliant with the
restrictions mentioned above or if the framerate or samplerate are
invalid. This is fixed by adding a deinit function to free said fifo.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-20 11:14:11 +02:00
Andreas Rheinhardt 5aafdb4e5f avformat/rmdec: Fix potential crash on allocation failure
The RealMedia demuxer uses the priv_data of its streams to store a
structure containing an AVPacket. These packets are unreferenced in the
read_close function, yet said function simply presumed that the
priv_data has been successfully allocated. This implies that it mustn't
be called when an allocation of priv_data fails; but this can happen
since commit 35bbc1955a if one has a
stream with multiple substreams (also exported as AVStream) and if
allocating the priv_data for one of these substreams fails.

This has been fixed by making sure that read_close can handle the case
in which priv_data has not been successfully allocated.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-19 20:26:53 +02:00
Andreas Rheinhardt 4cc43d30c3 avformat/rmdec: Actually return value < 0 on read_header failure
The RealMedia demuxer's read_header function initially initializes ret,
the variable designated for the return variable to -1. Afterwards, chunks
of the file are parsed in a loop until an error happens or until the actual
frame data is encountered. If the first function whose return
value is put into ret doesn't fail, then ret contains a value >= 0
(actually == 0) and this is what will be returned if an error is
encountered afterwards.

This is a regression since 35bbc1955a.
Before that, ret had never been overwritten with a nonnegative value.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-19 20:26:50 +02:00
Andreas Rheinhardt ea45d6e61a avformat/avidec: Fix memleak when error happens after creating DV stream
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-19 20:26:19 +02:00
Zane van Iperen 52d362c6e0
avformat/argo_{asf,brp}: use variable frame sizes when (de)muxing adpcm_argo
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-19 15:55:00 +10:00
Michael Niedermayer 624f6df19f avformat/3dostr: Check remaining buffer in probe before 8 byte step
Fixes: segfault
Fixes: signal_sigabrt_7ffff6ae7cc9_7213_0d6457b9d6897fa7c78507fa5de53510.ts
Regression since: 3ac45bf665

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-19 00:55:04 +02:00
Paul B Mahol 92396cee60 avformat: add CRI AAX demuxer 2020-09-18 11:34:11 +02:00
Paul B Mahol 0ea6ec3d00 avformat: add DAT CCTV demuxer 2020-09-18 11:30:03 +02:00
Paul B Mahol 3ac45bf665 avformat/3dostr: make probing more robust 2020-09-17 23:47:10 +02:00
Harry Mallon fe3a57f4ca avformat/mxfdec: Read Apple private Content Light Level from MXF
* As embedded by Apple Compressor

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
2020-09-17 21:40:25 +02:00
Harry Mallon bb2215f4db avformat/mxfenc: Write Mastering Display Colour Volume to MXF
Described in Annex B SMPTE ST 2067-21:2020

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
2020-09-17 21:40:25 +02:00
Harry Mallon 90e2a4d61b avformat/mxfdec: Read Mastering Display Colour Volume from MXF
Described in Annex B SMPTE ST 2067-21:2020

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
2020-09-17 21:40:25 +02:00
Zane van Iperen c79f07cc0c
avformat/argo_asf: initialise file header inline
Garbage was left-over in the ArgoASFFileHeader::name field if the url
was too short. This zero-initialises it.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-16 13:26:06 +10:00
James Almer d0418f0658 avformat/argo_asf: add missing avformat.h include
Fixes make checkheaders

Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-15 19:29:37 -03:00
James Almer 8a81820624 avcodec/packet: move AVPacketList definition and function helpers over from libavformat
And replace the flags parameter with a function callback that can be used to
copy the contents of the packet (e.g, av_packet_ref and av_packet_copy_props).

Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-15 09:53:39 -03:00
Zane van Iperen 119efa275e
avformat: add Argonaut Games BRP demuxer
Used in FMVs for FX Fighter and Croc. Supports BVID and BASF streams,
requests samples for anything else.

Due to the way BASF streams are contained in the file, only one is
supported. I have yet to see a BRP file with multiple.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-14 14:38:45 +10:00
Zane van Iperen 121016f827
avformat/argo_asf: add ASF_MIN_BUFFER_SIZE #define
For future use by the argo_brp demuxer

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-14 14:24:01 +10:00
Zane van Iperen 442249ef28
avformat/argo_asf: split functionality into a header
For future use by the argo_brp demuxer.

Adds:
  - void ff_argo_asf_parse_file_header(ArgoASFFileHeader *hdr, const uint8_t *buf);
  - int  ff_argo_asf_validate_file_header(AVFormatContext *s, const ArgoASFFileHeader *hdr);
  - void ff_argo_asf_parse_chunk_header(ArgoASFChunkHeader *hdr, const uint8_t *buf);
  - int  ff_argo_asf_fill_stream(AVStream *st, const ArgoASFChunkHeader *ckhdr);

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-14 14:23:54 +10:00
Zane van Iperen 0476b6ee1e
avformat/argo_asf: bail if invalid tag
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-09-14 14:23:15 +10:00
Marton Balint 9b434bea75 avformat: use av_timecode_make_smpte_tc_string2
WSD format has no frames stored for playback time.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-09-13 17:51:57 +02:00
Paul B Mahol ddc9cce3cd avformat: add Square SVS demuxer 2020-09-13 16:05:01 +02:00
Paul B Mahol cd67bf2a28 avformat/moflex: make seeking more useful 2020-09-13 16:05:01 +02:00
Paul B Mahol 2752323046 avformat/flic: add support for seeking to start 2020-09-13 16:05:01 +02:00
Paul B Mahol e1da139a33 avcodec/cdgraphics: fix decoded output when seeking to start of file
Also in cdg demuxer do not skip packets data, and remove
private context which is not really needed.
2020-09-13 16:05:01 +02:00
Michael Niedermayer aa8935b395 avformat/cdg: Fix integer overflow in duration computation
Fixes: signed integer overflow: 8398407 * 300 cannot be represented in type 'int'
Fixes: 23914/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4702539290509312

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-13 10:40:02 +02:00
Paul B Mahol 60c4459075 avformat/brstm: remove custom allocation of table to hold coeffs 2020-09-12 14:52:31 +02:00
Paul B Mahol 3382b0290a avformat/brstm: fix decoding brstm with custom coeff offsets 2020-09-12 14:52:31 +02:00
Jun Zhao 856363710f lavf/mov: Remove redundant code
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-09-12 17:27:26 +08:00
Andreas Rheinhardt 5fc3eda8de avformat/utils: Avoid duplicating extradata from extract_extradata BSF
Instead move the extradata contained in packet side-data to its
destination. This is possible because the side data already has zeroed
padding.

Notice that the check for FF_MAX_EXTRADATA_SIZE has been dropped,
because said constant is from libavcodec/internal.h. If libavcodec
wanted to enforce this, it should do so in the extract_extradata BSF
instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-11 14:38:18 +02:00
Paul B Mahol f4b84d89d1 avformat/brstm: clip timestamp when seeking into acceptable range 2020-09-10 17:38:08 +02:00
Paul B Mahol 38be47017b avformat/mca: clip timestamp when seeking into acceptable range 2020-09-10 17:38:08 +02:00
Zixing Liu d58f8fd8e6 avformat: add mca demuxer
Signed-off-by: liushuyu <liushuyu@aosc.io>
2020-09-10 17:38:08 +02:00
Andreas Rheinhardt 3c9382ba26 avformat/segment: Avoid duplicating string when parsing frames list
Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-10 13:44:12 +02:00
Andreas Rheinhardt 1d090dfa91 avformat/segment: Fix error messages
Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-10 13:44:12 +02:00
Andreas Rheinhardt 5db09e8930 avformat/segment: Remove redundant code for freeing in write_trailer
This code mostly duplicates code in the deinit function; the only
exception is av_opt_free(): The options are freed generically lateron.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-10 13:44:12 +02:00
Andreas Rheinhardt 848f96a2a6 avformat/segment: Free SegmentListEntries in deinit, not write_trailer
This fixes leaks when the trailer is never written.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-10 13:44:12 +02:00
Andreas Rheinhardt 30de02998d avformat/segment: Fix leak and invalid free of AVIOContext
seg_init() and seg_write_header() currently contain a few error paths
in which an already opened AVIOContext for the child muxer leaks (namely
if there are unrecognized options for the child muxer or if writing the
header of the child muxer fails); the reason for this is that this
AVIOContext is not closed in the deinit function. If all goes well, it
is closed when writing the trailer. From this it also follows that the
AVIOContext also leaks when the trailer is never written, even when
writing the header succeeds.

But simply freeing said AVIOContext in the deinit function is
complicated by the fact that the AVIOContext may or may not have been
opened via the io_open callback: If options are set to discard header
and trailer, said AVIOContext can also be a null context which must not
be closed via the io_close callback. This may lead to crashes, as
io_close may presume the AVIOContext's opaque to be set. It currently
works with the default io_close callback which simply calls avio_close(),
because avio_close() doesn't care about opaque being NULL since commit
6e8e8431e1. Therefore this commit records
which of the two kinds of AVIOContext is currently in use to use the
right way to close it.

Finally there was one instance (namely if initializing the child muxer
fails with no unrecognized options) where the AVIOContext was always
closed via the io_close callback. The above remark applies to this; it
has been fixed, too.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-10 13:44:12 +02:00
Andreas Rheinhardt 3152a2a218 avformat/segment: Fix leak of string on error
A string containing the segment's filename that the segment muxer
allocates got only freed in its write_trailer function. This implies
that it leaks if write_trailer is never called, e.g. if initializing
the child muxer fails. This commit fixes this by freeing the string
in the deinit function instead.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-10 13:44:12 +02:00
Andreas Rheinhardt 936d967871 avformat/segment: Fix segfault when error happens and segment list is output
The segment muxer has an option to output a file containing a list of
the segments written. The AVIOContext used for writing this file is
opened via the main AVFormatContext's io_open callback; seg_free()
meanwhile unconditionally closes this AVIOContext by calling
ff_format_io_close() with the child muxer (the one for the actual output
format) as AVFormatContext.

The problem hereby is that the child AVFormatContext need not exist,
even when the AVIOContext does. This leads to a segfault in
ff_format_io_close() when the child muxer's io_close callback is called.

Situations in which the AVFormatContext can be NULL range from an
invalid reference stream parameter to an unavailable/bogus/unsupported
output format to inability to allocate the AVFormatContext.

The solution is to simply close the AVIOContext with the AVFormatContext
that was used to open it: The main AVFormatContext.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-10 13:44:12 +02:00
Andreas Rheinhardt 06f99cc4dd avformat/segment: Fix segfault on allocation error, avoid allocation
If the user has set none of the options specifying the segments'
durations, a default value of 2s is used by duplicating a "2" string and
using av_parse_time() on it. Yet duplicating the string was unchecked
and if the allocation failed, one would get a segfault in
av_parse_time().

This commit solves this by turning said option into an option of type
AV_OPT_TYPE_DURATION (which also uses av_parse_time() internally),
avoiding duplicating the string altogether.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-10 13:43:43 +02:00
Andreas Rheinhardt 4b836c8613 avformat/segment: Fix leak of duration/framenumber lists upon error
The code to free them is not in the segment muxer's deinit function,
but in its write_trailer function which means that these lists leak if
write_trailer isn't called after their allocation. This happens e.g. if
the given lists are invalid (e.g. consisting only of ',' (which delimit
entries)), so that parsing them fails and so does the muxer's init
function; write_trailer is then never called.

This has been fixed by moving the code to free them to the deinit
function.

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-10 13:24:58 +02:00
Andreas Rheinhardt 92c8b79b5a avformat/segment: Don't overwrite AVCodecParameters after init
The segment muxer copies the user-provided AVCodecParameters to the
newly created child streams in its init function before initializing the
child muxer; and since commit 8e6478b723,
it does this again before calling avformat_write_header() if that is
called from seg_write_header(). The reason for this is complicated:

At that time writing the header was delayed, i.e. it was not triggered
by avformat_write_header() (unless the AVFMT_FLAG_AUTO_BSF was unset),
but instead by writing the very first packet. The rationale behind this
was to allow to run bitstream filters on the packets in the interleavement
queue in order to generate missing extradata from them before the muxer's
write_header function is actually called.

The segment muxer went even further: It initialized the child muxer and
ran the child muxer's check_bitstream functions on the packets in its
own muxing queue and stole any bitstream filters that got inserted. The
reason for this is that the segment muxer has an option to write the
header to a separate file and for this it is needed to write the child
muxer's header without delay, but with correct extradata. Unsetting
AVFMT_FLAG_AUTO_BSF for the child muxer accomplished the first goal and
stealing the bitstream filters the second; and in order for the child
muxer to actually use the updated extradata, the old AVCodecParameters
(set before avformat_init_output()) were overwritten with the new ones.

Updating the extradata proceeded as follows: The bitstream filter itself
simply updated the AVBSFContext's par_out when processing a packet, in
violation of the new BSF API (where par_out may only be set in the init
function); the muxing code then simply forwarded the updated extradata,
overwriting the par_in of the next BSF in the BSF chain with the fresh
par_out of the last one and the AVStream's par with the par_out of the
last BSF. This was an API violation, too, of course, but it made
remuxing ADTS AAC into mp4/matroska work.

But this no longer serves a useful purpose since the aac_adtstoasc BSF
was updated to propagate new extradata via packet side data in commit
f63c3516577d605e51cf16358cbdfa0bc97565d8; the next commit then removed
the code in mux.c passing new extradata along the filter chain. This
alone justifies removing the code for setting the AVCodecParameters a
second time.

But there is even another reason to do so: It is harmful. The ogg muxer
parses the extradata of Theora and Vorbis in its init function and keeps
pointers to parts of it. Said pointers become dangling when the
extradata is overwritten by the segment muxer, leading to
use-after-frees as has happened in ticket #8881 which this commit fixes.

Ticket #8517 is about another issue caused by this: Immediately after
having overwritten the old AVCodecParameters the segment muxer checks
whether the codec_tag is ok (the codec_tag is set generically when
initializing the child muxer based upon muxer-specific lists). The check
used is: If the child output format has such a list and if the codec tag
of the non-child stream does not match the codec id given the list of
codec tags and if there is a match for the codec id in the codec tag
list, then set the codec tag to zero (and not to the existing match),
otherwise set the codec tag of the child stream to the codec tag
of the corresponding stream of the main AVFormatContext (which is btw
redundant given that the child AVCodecParameters have just been
overwritten with the AVCodecParameters of the corresponding stream of
the main AVFormatContext).

Reviewed-by: Ridley Combs <rcombs@rcombs.me>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-10 12:44:38 +02:00
Michael Niedermayer 6a2df7ca26 avformat/electronicarts: change non failure return of read_header() to 0
This matches the documentation, but makes no functional difference

Found-by: James Almer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-08 00:06:53 +02:00
Michael Niedermayer 39a98623ed avformat/electronicarts: Check if there are any streams
Fixes: Assertion failure (invalid stream index)
Fixes: 25120/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6565251898933248

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-07 23:05:25 +02:00
Zane van Iperen d2f7b39914
avformat/argo_asf: fix handling of v1.1 files
Version 1.1 (FX Fighter) files all have a sample rate of 44100
in the header, but only play back correctly at 22050.

Force the sample rate to 22050 when reading, and restrict it
when muxing.
2020-09-07 13:13:33 +10:00
Michael Niedermayer cf0c700b0c avformat/avidec: Fix io_fsize overflow
Fixes: signed integer overflow: 7958120835074169528 * 9 cannot be represented in type 'long long'
Fixes: 23382/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6230683226996736

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-09-05 17:48:59 +02:00
Jan Ekström 3249c757ae avformat/dashdec: drop arbitrary DASH manifest size limit
Currently the utilized AVBPrint API is internally limited to unsigned
integers, so if we limit the file size as well as the amount to read
to UINT_MAX - 1, we do not require additional limiting to be performed
on the values.

This change is based on the fact that initially the 8*1024 value added
in 96d70694ae was only for the case where
the file size was not known. It was not a maximum file size limit.

In 2912118898 this was reworked to be
a maximum manifest file size limit, while its commit message appears
to only note that it added support for larger manifest file sizes.

This should enable various unfortunately large MPEG-DASH manifests,
such as Youtube's multi-megabyte live stream archives to load up
as well as bring back the original intent of the logic.
2020-09-05 11:50:49 +03:00
Carl Eugen Hoyos d263838958 lavf/img2dec: Auto-detect Kodak Photo CD image files. 2020-09-05 10:45:52 +02:00