Commit Graph

23083 Commits

Author SHA1 Message Date
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
Andreas Rheinhardt
ef91d18a04 avformat/yuv4mpegenc: Add const where appropriate
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-04 17:34:44 +02:00
Andreas Rheinhardt
a162fa0772 avformat/yuv4mpegenc: Simplify writing global and packet headers
YUV4MPEG writes a string as header for both the file itself as well as
for every frame; these strings contain magic strings and these were up
until now included in the string to write via %s. Yet they are compile
time constants, so one can use the compile-time string concatentation
instead of inserting these strings at runtime.
Furthermore, the global header has been written via snprintf() to
a local buffer first before writing it. This can be simplified by using
avio_printf().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-09-04 17:34:26 +02:00
Paul B Mahol
c8e38950e3 avcodec: add PhotoCD decoder 2020-09-04 16:01:53 +02:00
James Almer
f901d75bf1 avformat/yuv4mpegenc: simplify writing the header
Actually write it in yuv4_write_header() instead of with the first
packet.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-09-03 17:08:23 -03:00
Derek Buitenhuis
2c0d6ac9ae avformat/mov: Stash mfra size if we're reading it anyway
This also changes a check for mfra_size from < 0 to == 0, since
it was always wrong, as avio_rb32 returns an unsigned integer.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-09-03 19:04:29 +01:00
Derek Buitenhuis
97fa669a6f avformat/mov: Only read the mfra size once during sidx parsing
On files with more than one sidx box, like live fragmented MP4
files, it was previously re-reading and seeking on every singl
sidx box, leading to extremely poor performance on larger files,
especially over the network.

Only do it on the first one, and stash its result.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-09-03 19:04:29 +01:00
Derek Buitenhuis
19064a36e3 avformat/mov: Do not try and seek to an mfra if the reader can't seek
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-09-03 19:04:29 +01:00
Derek Buitenhuis
0c13f8a28c avformat/mov: Fix return type used for av_seek in mfra code
It should be a 64-bit integer, otherwise it overflows and fails
on files greater than 2GB on some systems like x86_64 Linux.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-09-03 19:04:29 +01:00
Paul B Mahol
cfe2c90de0 avformat: add MODS demuxer 2020-09-03 18:11:00 +02:00
Paul B Mahol
0a30683a01 avformat: add moflex demuxer 2020-09-03 18:10:28 +02:00
Paul B Mahol
69e22e21e3 avformat/musx: improve probing 2020-09-03 18:03:18 +02:00
Paul B Mahol
2a14d55a7c avformat/wavdec: add support for chapters
Support parsing 'cue ' and 'adtl' chunks.
2020-09-01 14:19:19 +02:00
Paul B Mahol
809d6aeffc avformat/wavdec: allow to change max size of single demuxed packet
Can make demuxing much faster, expecially for files with
huge number of channels.
2020-09-01 10:35:03 +02:00
Paul B Mahol
93aa0bec84 avformat/wavdec: add support for demuxing Broadcast Wave 64Bit 2020-09-01 10:35:03 +02:00
Chris Miceli
4136652289 libavformat/dashenc: Reduce confusion in par error message
In ticket #8754 there is discourse surrounding the error
message which is printed upon a mismatched aspect ratio in
derived encodings. This should make it clearer to the user
as to the issues which they are experiencing.

Reviewed-by: "Jeyapal, Karthick" <kjeyapal@akamai.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-31 23:43:06 +02:00
Marvin Scholz
ff4cc8c654 adtsenc: Add ability to write MPEG2 ID
Reviewed-by: Kieran Kunhya <kierank@obe.tv>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00
Harry Mallon
abd58a4192 libavformat/mxfenc: color_range should be inclusive
MXF CDCI color range was being set to (1<<sc->component_depth) - 1
for full range but it should be (1<<sc->component_depth) as 0 is
a valid value.

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
2020-08-29 11:02:35 +02:00
Harry Mallon
719eb8a2e4 avformat/mxfdec: Read video range from CDCIEssenceDescriptor
* Capture black_ref, white_ref and color_range and recognise
  full and narrow range.

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
2020-08-29 11:02:35 +02:00
Dale Curtis
2ff3c466ec avformat/mov: See if mfra makes up the difference for an incomplete sidx.
A few popular sites have started generating MP4 files which have a
sidx plus an mfra. The sidx accounts for all size except the mfra,
so the old code did not mark the fragment index as complete.

Instead we can just check if there's an mfra and if its size makes
up the difference we can mark the index as complete.

Bug: https://crbug.com/1107130
Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-08-28 15:58:47 +01:00
Limin Wang
9bb4707b1f avformat/mpegtsenc: reindent the code
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-08-26 14:20:10 +08:00
Limin Wang
4aa6eda76e avformat/mpegtsenc: add registration descriptor for AC-3 and EAC3
Some DVB and ATSC captures are using the official MPEG2 registration
descriptor in addition to using the correct stream type and the
AC-3_audio_stream_descriptor/AC3_descriptor. So let's add it even if it is not
strictly needed for DVB/ATSC.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-08-26 14:20:10 +08:00
Carl Eugen Hoyos
09e260f69a lavf/rtpdec_jpeg: Fix JFIF version.
See also b1931321
2020-08-25 19:29:34 +02:00
Carl Eugen Hoyos
3092a53cbc lavf/mxfdec: Limit score for files with run-in.
Only return AVPROBE_SCORE_MAX if the header partition pack key
is at the start of the file.
Fixes ticket #8846.

Reviewed-by: Tomas Härdin
2020-08-25 01:05:51 +02:00
Vikas Agrawal
026fea827d Set AVSTREAM_PARSE_HEADERS flag for AV1 MP4 streams
It help initialize chroma format and other info properly
Chroma format wasn't correct if I use below code:
        avformat_find_stream_info(fmtc, NULL);
        iVideoStream = av_find_best_stream(fmtc, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
        eChromaFormat = (AVPixelFormat)fmtc->streams[iVideoStream]->codecpar->format;

Signed-off-by: James Almer <jamrial@gmail.com>
2020-08-24 11:40:03 -03:00
Limin Wang
7e61940794 avformat/mpegtsenc: support DVB 6A descriptor for AC-3
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-08-23 07:19:11 +08:00
Thierry Foucu
5cf439e72e libavformat/ffmetadec.c: Fix Use-of-uninitialized-value
Check the return value of sscanf as it can return -1(EOF), for example
when the first char in the line is 0x00

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-22 22:51:07 +02:00
hax@riseup.net
118e63dff1 libavformat/nut: Support SSA and ASS subtitles
ffmpeg documentation says the NUT container supports SubStation Alpha
This brings actual functionality in line with documentation.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-22 22:51:07 +02:00
Michael Bradshaw
c5b20cfe19 avformat/movenc: write the colr atom by default
The write_colr flag has been marked as experimental for over 5 years.
It should be safe to enable its behavior by default as follows:

  - Write the colr atom by default for mp4/mov if any of the following:
     - The primaries/trc/matrix are all specified, OR
     - There is an ICC profile, OR
     - The user specified +write_colr
  - Keep the write_colr flag for situations where the user wants to
    write the colr atom even if the color info is unspecified (e.g.,
    http://ffmpeg.org/pipermail/ffmpeg-devel/2020-March/259334.html)

This fixes https://trac.ffmpeg.org/ticket/7961

Signed-off-by: Michael Bradshaw <mjbshaw@google.com>
2020-08-21 10:01:58 -07:00
Nicolas Sugino
86f5fd471d avformat/libsrt: close listen fd in listener mode
In listener mode the first fd is not closed when libsrt_close() is called
because it is overwritten by the new accept fd.  Added the listen_fd to the
context to properly close it when libsrt_close() is called.

Fixes trac ticket #8372.

Signed-off-by: Nicolas Sugino <nsugino@3way.com.ar>
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-08-20 16:24:46 +02:00
Michael Niedermayer
8931c55789 avformat/siff: Reject audio packets without audio stream
Fixes: Assertion failure
Fixes: 24612/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6600899842277376.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-20 13:27:22 +02:00
Thierry Foucu
36f7b83568 libavformat/r3d.c: Fix Use-of-uninitialized-value in filename.
While reading the filename tag, it may return a EOF and we are still
copying the file with uninitialized value.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-20 13:27:22 +02:00
Jan Ekström
c820c2d4bf avformat/mpegts: only reset timestamps to NOPTS for DVB teletext
While having the possibility of non-NOPTS values that can suddenly
jump in time due to adjustments to match PCR is not nice for DVB
subtitles, apparently the parser for this format bases its behavior on
whether the packets' timestamps are NOPTS or not. Thus while we can
adjust timestamps, we should exclude DVB subtitles from the timestamp
unsetting logic.

Fixes #8844
2020-08-18 22:29:22 +03:00
Michael Niedermayer
e8a88a16f7 avformat/mpeg: Check avio_read() return value in get_pts()
Found-by: Thierry Foucu <tfoucu@gmail.com>
Fixes: Use-of-uninitialized-value
Reviewed-by: Thierry Foucu <tfoucu@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-18 14:56:04 +02:00
Andreas Rheinhardt
d661cfc184 avformat/mlvdec: Only store dimensions after having validated them
Otherwise it might happen that invalid dimensions are used when reading
a video packet; this might lead to undefined overflow.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-18 14:26:40 +02:00
Andreas Rheinhardt
0d560873da avformat/mlvdec: Don't leak open AVIOContexts on error
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-18 14:25:30 +02:00
Andreas Rheinhardt
6e0dd41fa3 avformat/mlvdec: Check for existence of AVIOContext before using it
The mlv demuxer supports input split into multiple files; if invalid
data is encountered when parsing one of the subsequent files, that file
is closed. But at this point some index entries belonging to this file
might already have been added. In this case, the read_packet function
might try to use the AVIOContext (which is NULL) to read data which will
of course crash. This commit fixes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-18 14:18:18 +02:00
Andreas Rheinhardt
97d8029149 avformat/hls: Use av_init_pkt() directly
and remove reset_packet(). The packet's data pointer is already zeroed,
so the only thing that reset_packet() does that av_init_pkt() doesn't is
redundant.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-18 07:03:00 +02:00
Andreas Rheinhardt
8c91b5c48a avformat/hls: Remove redundant resetting of AVPacket
av_read_frame() already returns blank packets on error.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-18 07:02:52 +02:00
Andreas Rheinhardt
dfc6a9f075 avformat/hls: Fix memleak when url is empty
Fixes Coverity ID 1465888.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-18 07:02:43 +02:00
James Almer
b6e92d928f avformat/av1dec: don't update temporal_unit_size after it's no longer used
Signed-off-by: James Almer <jamrial@gmail.com>
2020-08-15 23:31:41 -03:00
James Almer
a72d5290c5 avformat/av1dec: inline obu_read_data() and obu_prefetch() into obu_get_packet()
They don't really help making the demuxer more readable.

Reviewed-by: Guangxin Xu <oddstone@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-08-15 13:01:30 -03:00
James Almer
a762fd2c1b avformat/av1dec: fix return value on some code paths
If avio_read() returns a value of bytes read that's lower than the
expected, return an error instead. And when there are zero bytes in
the prefetch buffer, return 0 in order for the frame merge bsf to
drain all potentially buffered packets.

Missed by mistake when amending and committing 9a7bdb6d71.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-08-14 00:14:37 -03:00
James Almer
3105e97050 avformat/av1dec: add missing preprocessor wrappers to annexb and obu demuxers
Ensure the modules are compiled only if enabled.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-08-14 00:02:29 -03:00
Xu Guangxin
9a7bdb6d71 avformat/av1dec: add low-overhead bitstream format
It's defined in Section 5.2, used by netflix.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-08-14 00:02:13 -03:00
Nicolas George
1201687da2 lavf/url: rewrite ff_make_absolute_url() using ff_url_decompose().
Also add and update some tests.

Change the semantic a little, because for filesytem paths
symlinks complicate things.
See the comments in the code for detail.

Fix trac tickets #8813 and 8814.
2020-08-12 16:45:21 +02:00
Nicolas George
d853293679 lavf/url: add ff_url_decompose(). 2020-08-12 16:33:09 +02:00
Harry Mallon
64ff61b3c5 avformat/mxfenc: Write color metadata to MXF
Writes color_primaries, color_trc and color_space to mxf
headers. ULs are from https://registry.smpte-ra.org/ site.

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
2020-08-12 15:50:41 +02:00
Andreas Rheinhardt
7ad4928580 avformat/ty: Remove write-only array and variable
Up until now, the TiVo demuxer parse an array of SEQ entries, yet it has
never ever made any use of them. In fact, parse_master, the function
parsing said table, only influenced the outside world in three ways: Via
an excessive amount of error message in case a certain parameter is not
what it expected; via an allocation (the aforementioned write-only
array); and by setting a certain parameter (ty->cur_chunk_pos), but that
parameter is always overwritten before it is used (it is overwritten
in get_chunk() on success and if get_chunk() fails, the error is
returned to the caller anyway). So remove the array and the function
used to parse it.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-11 16:44:11 +02:00
Zane van Iperen
d2f42b9be1
avformat/argo_asf: strip file extension from name
Only when the user hasn't manually specified one.
Matches the original files more closely.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-08-11 08:50:27 +10:00
Zane van Iperen
a3a4591868
avformat/argo_asf: add name option
Reviewed-by: Alexander Strasser <eclipse7@gmx.net>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-08-11 08:50:27 +10:00
Zane van Iperen
1f9dd53d5d
avformat/argo_asf: add version_major and version_minor options
Reviewed-by: Alexander Strasser <eclipse7@gmx.net>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-08-11 08:50:27 +10:00
Zane van Iperen
a3e9821787
avformat/argo_asf: don't check file version
It has no bearing on structure. Determined by looking at the ASF
files from several Argonaut games:
  - FX Fighter,
  - Croc,
  - Croc 2,
  - The Emperor's New Groove, and
  - Disney's Aladdin in Nasira's Revenge

The only versions that appear are 1.1, 1.2, and 2.1, and their
structure is identical.

Reviewed-by: Alexander Strasser <eclipse7@gmx.net>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-08-11 08:50:26 +10:00
Zane van Iperen
97aaa15089
avformat/argo_asf: add games to version list
Reviewed-by: Alexander Strasser <eclipse7@gmx.net>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-08-11 08:50:19 +10:00
Andreas Rheinhardt
1ead176d87 avformat/mpegts: Don't leave context in inconsistent state upon error
Up until now, opening a section filter works as follows: A filter is
opened and (on success) attached to the MpegTSContext. Then a buffer for
said filter is allocated and upon success attached to the section
filter; on error, the filter is simply freed without removing it from
the MpegTSContext, leaving the latter in an inconsistent state. This
leads to use-after-frees lateron.

This commit fixes this by allocating the buffer first; the filter is
only opened if the buffer could be successfully allocated.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-10 21:07:54 +02:00
Steven Liu
40597add98 avformat/hlsenc: write temp file for append single file by encryption mode
fix ticket: 8783
Because in single file by encryption mode, it cannot get the last one
block of the file, it need ff_format_io_close for get full file size,
then hlsenc can get the total size of the encryption content,
so write the content into temp file first, and get the temp file content
append the temp file content into append to single file, then hlsenc can
get the correct file/content size and offset.

Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
2020-08-10 15:52:59 +08:00
Steven Liu
6e4bba4055 avformat/hls: support avio_seek in encryption mode
Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
2020-08-10 15:52:54 +08:00
Andreas Rheinhardt
ea8f8d28d0 avformat/sierravmd: Don't return packets for non-existing stream
It leads to an assert in ff_read_packet().

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-09 19:07:23 +02:00
Andreas Rheinhardt
c4a4fe938d avformat/vividas: Check allocation for success
Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-09 19:07:23 +02:00
Andreas Rheinhardt
a3dced69c8 avformat/vividas: Check return value before storing it in smaller type
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-09 19:07:23 +02:00
Zane van Iperen
0549daa71b
avformat: add argo_asf muxer
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-07 23:14:28 +10:00
Zane van Iperen
b0b87f28c3
avformat/argo_asf: check sample count in demuxer
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-08-07 23:04:15 +10:00
Harry Mallon
7031a7beae avformat/mxfdec: Read color metadata from MXF
Reads color_primaries, color_trc and color_space from mxf
headers. ULs are from https://registry.smpte-ra.org/ site.

Signed-off-by: Harry Mallon <harry.mallon@codex.online>
2020-08-06 12:52:34 +02:00
Andreas Rheinhardt
1fbfa42432 avformat/dv: Avoid allocation for reading timecode
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-06 00:02:19 +02:00
Andreas Rheinhardt
8b0bba864b avformat/dv: Avoid alloction of DVDemuxContext
This commit avoids allocating a DVDemuxContext when demuxing raw DV by
making it part of the demuxer's context. This also allows to remove
dv_read_close().

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-06 00:02:19 +02:00
Andreas Rheinhardt
edcd7c735c avformat/3dostr: Return directly after having read packet
Avoids an avio_skip(s->pb, 0).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-05 23:14:39 +02:00
Michael Niedermayer
ffa6072fc7 avformat/mov: Check comp_brand_size
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 24457/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5760093644390400

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-04 18:27:51 +02:00
Andreas Rheinhardt
8129c32e48 avcodec, avfilter, avformat: Remove redundant avpriv_align_put_bits
flush_put_bits() already fills the bitstream with zeroes, so it is
unnecessary to align the bitstream before.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-01 18:56:32 +02:00
Zane van Iperen
be3c10d551
avformat/apm: fix APM_FILE_HEADER_SIZE value
Value was incorrectly changed in 3bf1be2101.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-07-30 11:48:28 +10:00
Marton Balint
b2318c1e53 avformat/hlsenc: increase initial program date time precision
Also query time only once, not for every variant stream, otherwise variant
streams might get a slightly different initial program date time. And we can
set this unconditionally because HLS_PROGRAM_DATE_TIME flag is checked
elsewhere.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-07-29 23:10:12 +02:00
Andreas Rheinhardt
dfd12ee053 avformat/smacker: Don't return packets for streams with AVDISCARD_ALL
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-28 06:29:58 +02:00
Andreas Rheinhardt
0df4e1ff93 avformat/smacker: Fix duration for PCM audio
For non-PCM audio, a Smacker frame contains the size of the decoded
audio in the first four bytes of the audio packet data; for PCM data,
said information would be redundant and according to [1] this field does
not exist. Therefore this commit sets the duration and timestamps
properly for PCM audio.

[1]: https://wiki.multimedia.cx/index.php/Smacker#Audio_Track_Chunk

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-28 06:29:58 +02:00
Andreas Rheinhardt
40494460f5 avformat/smacker: Set audio duration
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-28 06:29:58 +02:00
Timotej Lazar
edea156579 avformat/smacker: Support seeking to first frame
Add .read_seek function to the smacker demuxer for the special case of
seeking to ts=0. This is useful because smacker – like bink, with a
similar implementation – was mostly used to encode clips in video
games, where random seeks are rare but looping media are common.

Signed-off-by: Timotej Lazar <timotej.lazar@araneo.si>
2020-07-28 06:29:58 +02:00
Jun Zhao
7c59e1b0f2 lavf/srt: fix build fail when used the libsrt 1.4.1
libsrt changed the:
SRTO_SMOOTHER   -> SRTO_CONGESTION
SRTO_STRICTENC  -> SRTO_ENFORCEDENCRYPTION
and removed the front of deprecated options (SRTO_SMOOTHER/SRTO_STRICTENC)
in the header, it's lead to build fail

fix #8760

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-07-28 09:30:11 +08:00
Michael Niedermayer
a6df1fd5e9 avformat/ape: Error out in case of EOF in the header
Fixes: OOM
Fixes: 24375/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6216862443241472

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-07-26 18:29:57 +02:00
Andreas Rheinhardt
37f5feccc6 avformat/segafilmenc: Avoid seek when writing header
Up until now, the Sega FILM muxer would first write all the packet data,
then shift the data (in the muxer's write_trailer function) by the amount
necessary to write the header at the front (which entails a seek to the
front), then seek back to the beginning and actually write the header.

This commit changes this: The dynamic buffer that is used to write the
sample table (containing information about each sample in the file) is
now used to write the complete header. This is possible because the size
of everything in the header except the sample table is known in advance.
Said buffer can then be used as one of the two temporary buffers used
for shifting which also reduces the amount one has to allocate for this.
Thereby the header will be written when shifting, so that the second
seek to the beginning is unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 17:10:06 +02:00
Andreas Rheinhardt
8a3329ffba avformat/segafilmenc: Don't store packet info in linked list
Up until now, the Sega FILM muxer would store some information about
each packet in a linked list. When writing the trailer, the information
in said linked list would be used to write a table in the file header.
Each entry in said table is 16 bytes long, but each entry of the linked
list is 32 bytes long (assuming 64 bit pointer and no padding).
Therefore it makes sense to remove the linked list and write the array
entries directly into a dynamic buffer while writing the packet (this is
possible because the table entries don't depend on any information not
available when writing the packet (the offset is not relative to the
beginning of the file, but to the end of the table). This also
simplifies writing the array at the end (there is no need to traverse a
linked list).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 17:02:24 +02:00
Andreas Rheinhardt
37ec33f42c avformat/segafilmenc: Simplify writing two bytes
Use avio_wb16() instead of avio_write() to write two zero bytes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 17:01:16 +02:00
Andreas Rheinhardt
f71116deb5 avformat/segafilmenc: Remove write-only variable
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:59:32 +02:00
Andreas Rheinhardt
efcb4112fc avformat/segafilm: Reorder elements of struct to make it smaller
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:58:42 +02:00
Andreas Rheinhardt
3d114c102a avformat/daudenc: Return proper error codes instead if -1
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:57:58 +02:00
Andreas Rheinhardt
3ba72593b3 avformat/daudenc: Turn write_header function into init function
daud_write_header() doesn't write anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:57:21 +02:00
Andreas Rheinhardt
f38d01714a avformat/webmdashenc: Cosmetics
Mostly using intermediate pointers for accesses (i.e. storing s->pb in a
variable pb and then using pb for writing instead of s->pb) to improve
readability. Furthermore, the opening brace '{' of a function has been
moved into a line of its own in instances where it wasn't before.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:47:01 +02:00
Andreas Rheinhardt
e45365d15d avformat/webmdashenc: Only check for existence of metadata if it is used
Also return proper error codes when it is absent: AVERROR(EINVAL)
instead of AVERROR_INVALIDDATA.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:44:07 +02:00
Andreas Rheinhardt
f163b2eb27 avformat/webmdashenc: Avoid allocations, fix memleak
When using the WebM DASH Manifest muxer, every stream of each adaptation
set has to contain a metadata entry containing the filename of the
source file. In case of live stream manifests, said filename has to
conform to a pattern of
<file_description>_<representation_id>.<extension>. These pieces are
used to create the other strings that are actually output. Up until now,
these other strings would be allocated, used once and then freed
directly after usage. This commit changes this: The function that
allocated and assembled these strings now returns pointers to the '_'
and '.' delimiters and so that the caller can easily pick substrings
from it without needing to copy the string.

Avoiding allocations also fixes a memleak: One of the allocated strings
would leak upon a subsequent allocation failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:39:53 +02:00
Andreas Rheinhardt
c1fab8637e avformat/webmdashenc: Fix segfault when no filename is given when live
by checking a bit earlier.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:22:24 +02:00
Gyan Doshi
93694fe777 avformat/riffenc: correct calculation for extradata size
In 1ec2b3de5a, the extradata size was affected when the raster was
signaled as flipped due to user-set option rather than via extradata.
This resulted in a wrong header size being written. Fixed.
2020-07-26 11:09:39 +05:30
Limin Wang
bae2ae62ba avformat/mpegtsenc: use local variable store st->codecpar->codec_id
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-25 10:20:30 +08:00
Limin Wang
a35facfeb3 avformat/mpegtsenc: reindent the last commit
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-25 10:20:26 +08:00
Limin Wang
cf81d64282 avformat/mpegtsenc: simplify code for condition checks
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-25 10:20:18 +08:00
Andreas Rheinhardt
6f134c6d17 avformat/matroskadec: Slightly simplify version check
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-24 04:25:45 +02:00
Andreas Rheinhardt
880519c1de avformat/matroskadec: Avoid undefined pointer arithmetic
The Matroska demuxer currently always opens a GetByteContext to read the
content of the projection's private data buffer; it does this even if
there is no private data buffer in which case opening the GetByteContext
will lead to a NULL + 0 which is undefined behaviour.
Furthermore, in this case the code relied both on the implicit checks
of the bytestream2 API as well as on the fact that it returns zero
if there is not enough data available.

Both of these issues have been addressed by not using the bytestream API
any more; instead the data is simply read directly by using AV_RB. This
is possible because the offsets are constants.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-24 04:25:45 +02:00
Andreas Rheinhardt
28ce651c6d avformat/mxfdec: Fix memleak upon repeating tags
When parsing MXF encountering some tags leads to allocations. And when
these tags were encountered repeatedly, this could lead to memleaks,
because the pointer to the old data got simply overwritten with a
pointer to the new data (or to NULL on allocation failure). This has
been fixed.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-24 03:23:07 +02:00
Andreas Rheinhardt
78f21cab18 avformat/mxfdec: Fix memleak when parsing tag fails
The MXF demuxer uses an array of pointers to different structures of
metadata (all containing a common initial sequence containing a type
field to distinguish them) and some of these structures contain pointers
to separately allocated subelements. If an error happens while reading
and creating the tags, the semi-finished new tag is freed using the
function to free these tags. But this function doesn't free the already
allocated subelements, because the type has not been set yet. This commit
changes this.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-24 03:22:06 +02:00
Andreas Rheinhardt
49e78548c3 avformat/mxfdec: Fix memleak when adding element to array fails
Said array contains pointers to other structs and both the designated
new element as well as other stuff contained in it (e.g. strings) leak
if the new element can't be added to the array.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-24 03:21:37 +02:00
Zane van Iperen
4eb6ec3a85 avformat: add apm muxer
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-07-21 11:36:14 +10:00
Zane van Iperen
8598fc4010 avcodec/apm: fix sample_rate check
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-07-21 11:33:00 +10:00
Michael Niedermayer
b6663adaae avformat/sbgdec: Check for overflow in parse_timestamp()
Fixes: signed integer overflow: 33986707200000000 + 9195561788997000192 cannot be represented in type 'long'
Fixes: 23790/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6554232198266880

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-07-20 19:47:27 +02:00
Jun Zhao
ba31fdfd7b lavf/dashdec: enable custom interrup callback in sub-demuxer
Enable the custom callback in sub-demuxer

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-07-20 19:23:15 +08:00
Jun Zhao
4239a8c983 lavf/hls: enable custom interrup callback in sub-demuxer
Enable the custom callback in sub-demuxer

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-07-20 19:17:42 +08:00
Steven Liu
2c1cc326e9 avformat/crypto.c: remove unnecessary code
Because the newpos variable is set value before use it.
The newpos variable declared at the head partition of crypto_seek.
Make the code clean.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2020-07-20 10:14:53 +08:00
Zane van Iperen
91a9f86edf avformat/apm: fix variable/structure names and cosmetics 2020-07-19 14:43:04 +10:00
Zane van Iperen
1b0a0da63a avformat/apm: use the entire APMState structure as extradata
Is the "actual" codec extradata instead of the hand-crafted one
from the previous revision.
2020-07-19 14:42:51 +10:00
Zane van Iperen
3bf1be2101 avformat/apm: read header correctly
The leading WAVEFORMATEX in .APM files is malformed:
* The nAvgBytesPerSec field is wrong, and
* sizeof(cbSize) is 4 instead of 2.
2020-07-19 14:38:40 +10:00
Andreas Rheinhardt
1998d1d6af avformat/au: Avoid allocation for metadata string
When there are potentially annotation (i.e. metadata) fields to write,
au_get_annotations() is called to produce a string with them. To do so,
it uses an AVBPrint which is finalized to create the string. This is
wasteful, because it always leads to an allocation even if the string
actually fits into the internal buffer of the AVBPrint. This commit
changes this by making au_get_annotations() modify an AVBPrint that
resides on the stack of the caller (i.e. of au_write_header()).

Furthermore, the AVBPrint is now checked for truncation; limiting
the allocations implicit in the AVBPrint allowed to offload the overflow
checks. Notice that these were not correct before: The size parameter of
avio_write() is an int, yet the string in the AVBPrint was allowed to
grow bigger than INT_MAX. And if the length of the string was so near
UINT_MAX that the length + 32 overflowed, the old code would write the
first eight bytes of the string and nothing more, leading to an invalid
file.

Finally, the special case in which the metadata dictionary of the
AVFormatContext is empty (in which case one still has to write eight
binary zeroes) is now no longer treated specially, because this case
no longer incurs any allocation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-18 18:18:41 +02:00
Andreas Rheinhardt
c2e17e8d84 avformat/au: Simplify writing string into AVBPrint
by using av_bprintf() instead of several av_bprint_append().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-18 18:03:19 +02:00
Andreas Rheinhardt
84340497c0 avformat/au: Remove redundant av_freep()
This av_freep(&key) in conjunction with the fact that the loop condition
checks for key != NULL was equivalent to a av_freep(&key) + a break
immediately thereafter. But given that there is an av_freep(&key)
directly after the loop, the av_freep(&key) is unnecessary and the break
can also be added explicitly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-18 18:00:46 +02:00
Andreas Rheinhardt
8d3556b7a3 avformat/au: Store strings instead of pointers to strings in array
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-18 17:16:24 +02:00
Zhao Zhili
af7b1031e1 avformat/mov: fix atom type to string conversion
The conversion was endian-dependent, and it may contain non-printable
characters.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-07-16 17:44:53 +02:00
Gyan Doshi
1ec2b3de5a avformat/riffenc: indicate storage of flipped RGB bitmaps
Some legacy applications such as AVI2MVE expect raw RGB bitmaps
to be stored bottom-up, whereas our RIFF BITMAPINFOHEADER assumes
they are always stored top-down and thus write a negative value
for height. This can prevent reading of these files.

Option flipped_raw_rgb added to AVI and Matroska muxers
which will write positive value for height when enabled.

Note that the user has to flip the bitmaps beforehand using other
means such as the vflip filter.
2020-07-15 20:52:01 +05:30
Limin Wang
448a9aaa78 API: add AV_PKT_DATA_S12M_TIMECODE to AVPacketSideDataType
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-15 05:47:14 +08:00
Moritz Barsnick
2dabee7c0f avformat/mov: fix missing line break in messages
One of them can be triggered by https://samples.ffmpeg.org/F4V/H263_NM_f.mp4.

Signed-off-by: Moritz Barsnick <barsnick@gmx.net>
2020-07-12 20:40:54 +05:30
Jun Zhao
3205ed31a7 lavf/udp: fix the comments for default UDP socket recvbuf size
15d160cc0b increased the UDP socket receiving buffer size
(64K ->384K), but missed to update this comments.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-07-12 08:13:00 +08:00
Andreas Rheinhardt
5d91b7718e avformat/sdp: Fix potential write beyond end of buffer
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-10 20:36:31 +02:00
Andreas Rheinhardt
ec59dc73f0 avformat/mm: Check for existence of audio stream
No audio stream is created unconditionally and if none has been created,
no packet with stream_index 1 may be returned. This fixes an assert in
ff_read_packet() in libavformat/utils reported in ticket #8782.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-10 20:36:31 +02:00
Siyuan Huang
05feb7a26b libavformat/dashenc.c: Support mpd update period
According ISO 23009-1, in live cases, mpd refresh period should be configurable

Signed-off-by: Siyuan Huang <saber.huang@samsung.com>
2020-07-09 11:17:32 +05:30
Limin Wang
1dee8bf909 avformat/gifdec: -1 -> AV_BPRINT_SIZE_UNLIMITED
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-08 23:09:29 +08:00
Zhao Zhili
806a4d5187 avformat/mov: Fix unaligned read of uint32_t and endian-dependance in mov_read_default
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-07-07 19:25:19 +02:00
Michael Niedermayer
321ea59dac avformat/smjpegdec: Check the existence of referred streams
Fixes: Assertion failure
Fixes: 23758/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5160954605338624.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-07-07 15:15:34 +02:00
Steven Liu
73fe0cbb94 avformat/hlsenc: check fragment size plus start_pos large than hls_segment_size
if vs->size + vs->start_pos > hls->max_seg_size, should split segment.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2020-07-07 14:32:00 +08:00
Andrey Semashev
93a435dd4b libavformat/hlsenc: Remove duplicate close of the output stream.
The result of the first close attempt is ignored and may be lost. By removing
it we ensure the close result code is properly analyzed.
2020-07-06 15:16:45 +08:00
Andreas Rheinhardt
d534009f76 avformat/smacker: Cosmetics
Mainly reindentation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-04 19:19:34 +02:00
Andreas Rheinhardt
e40ad1c0d4 avformat/smacker: Use st->priv_data to store array
It simplifies freeing and allows to completely remove smacker_read_close.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-04 19:19:34 +02:00
Andreas Rheinhardt
638ef5f758 avformat/smacker: Don't read only one byte at a time
Instead use ffio_read_size to read data into a buffer. Also check that
the desired size was actually successfully read and combine the check
with the check for reading the extradata.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-04 19:19:34 +02:00
Andreas Rheinhardt
09a39042db avformat/smacker: Don't allocate arrays separately
Allocating two arrays with the same number of elements together
simplifies freeing them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-04 19:19:34 +02:00
Andreas Rheinhardt
6e5dbd6268 avformat/smacker: Improve timestamps
A Smacker file can contain up to seven audio tracks. Up until now,
the pts for the i. audio packet contained in a Smacker frame was
simply the end timestamp of the last i. audio packet contained in
an earlier Smacker frame.

The problem with this is that a Smacker stream need not contain data in
every Smacker frame and so the current i. audio packet present may come
from a different underlying stream than the last i. audio packet
contained in an earlier frame.

The sample hypnotix.smk* exhibits this. It has three audio tracks and
the first of the three has a longer first packet, so that the audio for
the first track is contained in only 235 packets contained in the first
235 Smacker frames; the end timestamp of this track is 166696 (about 7.56s
at a timebase of 1/22050); the other two audio tracks both have 253 packets
contained in the first 253 Smacker frames. Up until now, the 236th
packet of the second track being the first audio packet in the 236th
Smacker frame would get the end timestamp of the last first audio packet
from the last Smacker frame containing a first audio packet and said
last audio packet is the first audio packet from the 235th Smacker frame
from the first audio track, so that the timestamp is 166696. In contrast,
the 236th packet from the third track (whose packets contain the same number
of samples as the packets from the second track) has a timestamp of
156116 (because its timestamp is derived from the end timestamp of the
235th packet of the second audio track). In the end, the second track
ended up being 177360/22050 s = 8.044s long; in contrast, the third
track was 166780/22050 s = 7.56s long which also coincided with the
video.

This commit fixes this by not using timestamps from other tracks for
a packet's pts.

*: https://samples.ffmpeg.org/game-formats/smacker/wetlands/hypnotix.smk

Reviewed-by: Timotej Lazar <timotej.lazar@araneo.si>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-04 19:19:34 +02:00
Andreas Rheinhardt
316dc0674e avformat/smacker: Stop caching and copying audio frames
The layout of a Smacker frame is as follows: For some frames, the
beginning of the frame contained a palette for the video stream; then
there are potentially several audio frames, followed by the data for the
video stream.

The Smacker demuxer used to read the palette, then cache every audio frame
into a buffer (that gets reallocated to the desired size every time a
frame is read into this buffer), then read and return the video frame
(together with the palette). The cached audio frames are then returned
by copying the data into freshly allocated buffers; if there are none
left, the next frame is read.

This commit changes this: At the beginning of a frame, the palette is
read and cached as now. But audio frames are no longer cached at all;
they are returned immediately. This gets rid of copying and also allows
to remove the code for the buffer-to-AVStream correspondence.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-04 19:19:34 +02:00
Andreas Rheinhardt
2f687bc83e avformat/smacker: Check audio frame size
The first four bytes of smacker audio are supposed to contain the number
of samples, so treat audio frames smaller than that as invalid.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-04 19:19:34 +02:00
Andreas Rheinhardt
02bbb37006 avformat/smacker: Avoid potential inifinite loop on error
When reading a new frame, the Smacker demuxer seeks to the next frame
position where it excepts the next frame; then it (potentially) reads
the palette, the audio packets associated with the frame and finally the
actual video frame. It is only at the end that the frame counter as well
as the position where the next frame is expected get updated.

This has a downside: If e.g. invalid data is encountered when reading
the palette, the demuxer returns immediately (with an error) and if the
caller calls av_read_frame again, the demuxer seeks to the position where
it already was, reads the very same palette data again and therefore will
return an error again. If the caller calls av_read_frame repeatedly
(say, until a packet is received or until EOF), this meight become an
infinite loop.

This could also happen if e.g. the size of one of the audio frames was
invalid or if the frame size was gigantic.

This commit changes this by skipping a frame if it turns out to be
invalid or an error happens otherwise. This ensures that EOF will be
returned eventually in the above scenario.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-04 19:19:34 +02:00
Andreas Rheinhardt
5fcc49e0d1 avformat/smacker: Don't increase packet counter prematurely
The Smacker demuxer buffers audio packets before it outputs them, but it
increments the counter of buffered packets prematurely: If allocating
the audio buffer fails, an error (most likely AVERROR(ENOMEM)) is returned.
If the caller decides to call av_read_frame() again, the next call will
take the codepath for returning already buffered audio packets and it
will fail (because the buffer that ought to be allocated isn't) without
decrementing the number of supposedly buffered audio packets (it doesn't
matter whether there would be enough memory available in subsequent calls).
Depending on the caller's behaviour this is potentially an infinite loop.

This commit fixes this by only incrementing the number of buffered audio
packets after having successfully read them and unconditionally reducing
said number when outputting one of them. It also changes the semantics
of the curstream variable: It is now the number of currently buffered
audio packets whereas it used to be the index of the last audio stream
to be read. (Index refers to the index in the array of buffers, not to
the stream index.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-04 19:19:34 +02:00
Gautam Ramakrishnan
35adac6e92 libavformat/img2dec: Added pgx demuxer
This patch adds support to demux pgx file
format.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-07-03 23:28:26 +02:00
Marvin Scholz
c0c45e238f avformat/icecast: Add option to use TLS connection
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-07-02 17:14:31 +02:00
Limin Wang
0e10f54585 avformat/hlsenc: simplify code to pass s directly
Suggested-by:  Nicolas George <george@nsup.org>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-02 21:12:37 +08:00
Limin Wang
fdda832603 avformat/hlsenc: fix av_bprint_finalize() usage
Don't need to do double check by the description of the API.

Reviewed-by:   Nicolas George <george@nsup.org>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-02 21:12:37 +08:00
Limin Wang
db92efd83e avformat/hlsenc: use proper error codes
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-02 21:12:37 +08:00
Limin Wang
64059f5063 avformat/au: check return value of au_read_annotation()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-02 21:12:37 +08:00
Limin Wang
a7aa903b7b avformat/au: check return value of av_bprint_finalize()
Reviewed-by:   Nicolas George <george@nsup.org>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-02 21:12:37 +08:00
Limin Wang
af5751940e avformat/dump: add a \n for end of ERROR log
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-02 21:12:37 +08:00
Andreas Rheinhardt
1884d887ba avformat/hevc: Defer initializations in ff_isom_write_hvcc()
Saves initialization of an HEVCDecoderConfigurationRecord when
the data is already in ISOBMFF-format or if it is plainly invalid.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-02 02:09:59 +02:00
Zhao Zhili
f3dc38a186 avformat/mov: fix memleaks
Fix two cases of memleaks:
1. The leak of dv_demux
2. The leak of dv_fctx upon dv_demux allocate failure

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-01 15:28:03 +02:00
Andreas Rheinhardt
61f5c6ab06 libavformat/mov: Fix memleaks when demuxing DV audio
The code for demuxing DV audio predates the introduction of refcounted
packets and when the latter was added, changes to the former were
forgotten. This meant that when avpriv_dv_produce_packet initialized the
packet containing the AVBufferRef, the AVBufferRef as well as the
underlying AVBuffer leaked; the actual packet data didn't leak: They
were directly freed, but not via their AVBuffer's free function.

https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2
contains samples for this (enable_drefs needs to be enabled for them).

Moreover, errors in avpriv_dv_produce_packet were ignored; this has been
changed, too.

Furthermore, in the hypothetical scenario that the track has a palette,
this would leak, too, so reorder the code so that the palette code
appears after the DV audio code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-01 15:12:49 +02:00
Michael Niedermayer
10cc82c35b avformat/utils: reorder duration computation to avoid overflow
Fixes: signed integer overflow: 8 * 9223372036854774783 cannot be represented in type 'long'
Fixes: 23381/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4818340509122560

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-07-01 11:41:35 +02:00
Michael Niedermayer
b5e39880fb avformat/hls: Pass a copy of the URL for probing
The segments / url can be modified by the io read when reloading

This may be an alternative or additional fix for Ticket8673
as a further alternative the reload stuff could be disabled during
probing

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-07-01 11:41:35 +02:00
Zhao Zhili
1379bbc154 avformat/isom: add comment to mov_mdhd_language_map
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-07-01 11:41:35 +02:00
Andreas Rheinhardt
e365076c10 avformat/dump: Use intermediate pointer for access to programs array
Improves readability.

Reviewed-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-30 17:11:12 +02:00
Andreas Rheinhardt
0179ef7eac avformat/dump: Use const where appropriate
Also switch to using a pointer to access stream side data instead of
copying the stream's AVPacketSideData.

Reviewed-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-30 16:45:35 +02:00
Derek Buitenhuis
d5247fb1da lavf/movenc: Use a dynamic buffer when writing the mfra box
When doing streamed output, with e.g. +dash, if the mfra box ended
up being larger than the AVIOContext write buffer, the (unchecked)
seeking back to update the box size would silently fail and produce
an invalid mfra box.

This is similar to how other boxes are written in fragmented mode.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-06-28 20:16:29 +01:00
Andreas Rheinhardt
3129897c05 avformat/smoothstreaming: Add deinit function
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-27 23:19:58 +02:00
Andreas Rheinhardt
76a413d961 avformat/smoothstreaming: Don't write trailer of subcontext
Nothing written in avformat_write_trailer() for the submuxers will be
output anyway because the AVIOContexts used for actual output have been
closed before the call. Writing the trailer of the subcontext has probably
only been done in order to free the memory allocated by the submuxer.
And this job has been taken over by the deinit functions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-27 23:17:07 +02:00
Michael Niedermayer
b6fbbe08c3 avformat/mvdec: Fix integer overflow with billions of channels
Fixes: signed integer overflow: 1394614304 * 2 cannot be represented in type 'int'
Fixes: 23491/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5697377020411904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-06-27 12:43:51 +02:00
Andreas Rheinhardt
a0b6df0a39 avformat/avc, mxfenc: Avoid allocation of H264 SPS structure, fix memleak
Up until now, ff_avc_decode_sps would parse a SPS and return some
properties from it in a freshly allocated structure. Yet said structure
is very small and completely internal to libavformat, so there is no
reason to use the heap for it. This commit therefore changes the
function to return an int and to modify a caller-provided structure.
This will also allow ff_avc_decode_sps to return better error codes in
the future.

It also fixes a memleak in mxfenc: If a packet contained multiple SPS,
only the SPS structure belonging to the last SPS would be freed, the
other ones would leak when the pointer is overwritten to point to the
new SPS structure. Of course, without allocations there are no leaks.
This is Coverity issue #1445194.

Furthermore, the SPS structure has been renamed from
H264SequenceParameterSet to H264SPS in order to avoid overlong lines.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-26 12:13:43 +02:00
Andreas Rheinhardt
264ba34808 avformat/avc: Don't use ff_ prefix for static function
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-26 12:04:49 +02:00
Andreas Rheinhardt
7447045cc0 avformat/webvttdec: Accept \r as newline
After parsing the end timestamp of a WebVTT cue block, the current code
skips everything after the start of the timestamp that is not a \t, ' '
or \n and treats what is next as the start of a WebVTT cue settings list.
Yet if there is no such list, but a single \r, this will skip a part of
the cue payload (namely everything until the first occurence of \t, ' '
or \n) and treat what has not been skipped as the beginning of the
WebVTT cue settings list that extends until the next \r or \n (or the
end).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-26 07:48:10 +02:00
Andreas Rheinhardt
36fa84e7ac avformat/av1: Avoid using dynamic buffer when assembling av1c
Given that AV1 only has exactly one sequence header, it is unnecessary
to copy the content of said sequence header into an intermediate dynamic
buffer; instead the sequence header can be copied from where it is in
the input buffer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-26 07:12:31 +02:00
Michael Niedermayer
a8fb7612a9 avformat/microdvddec: skip malformed lines without frame number.
Fixes: signed integer overflow: 1 - -9223372036854775808 cannot be represented in type 'long'
Fixes: 23490/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5133490093031424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-06-25 12:50:22 +02:00
Levis Florian
bd6ae462f8 avformat/libamqp: add option delivery_mode
Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
Signed-off-by: Levis Florian <levis.florian@gmail.com>
2020-06-24 23:15:52 -04:00
Andreas Rheinhardt
6c777a6688 avformat/smoothstreaming: Forward errors from copying white/blacklists
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-24 16:07:38 +02:00
Andreas Rheinhardt
05475ad26b avformat/sccdec: Avoid variable that is always zero
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 13:17:02 +02:00
Andreas Rheinhardt
a7b82fe52b avformat/pjsdec: Avoid variable that is always zero
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 13:16:58 +02:00
Andreas Rheinhardt
dc4af87d2f avformat/mpl2dec: Avoid variable that is always zero
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 13:16:53 +02:00
Andreas Rheinhardt
7256c363a0 avformat/mov: Cosmetics
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 13:16:01 +02:00
Andreas Rheinhardt
9ce1eb5eb0 avformat/mov: Avoid allocation when reading ddts atom
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 13:14:52 +02:00
Andreas Rheinhardt
316a3e91be avformat/mov: Use ffio_read_size where appropriate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 13:13:48 +02:00
Andreas Rheinhardt
526f5f59df avformat/mov: Avoid allocation+copy when moving extradata
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 13:12:49 +02:00
Andreas Rheinhardt
88dc77e243 avformat/mov: Read attached pics directly into st->attached_pic
Given that av_get_packet returns a blank packet on error, the only
difference to the current approach (that uses intermediate AVPackets on
the stack) is that st->attached_pic will be properly initialized on error
(i.e. the timestamps are AV_NOPTS_VALUE) whereas right now st->attached_pic
is only zeroed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 13:10:58 +02:00
Andreas Rheinhardt
ddd6274944 avformat/mov: Check earlier whether reel_name string is empty
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 12:41:20 +02:00
Andreas Rheinhardt
c3cd6b765b avcodec, avformat: Remove unnecessary initializations of side data size
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 12:20:37 +02:00
Andreas Rheinhardt
b8c6aae575 avformat/avformat: Improve documentation of av_stream_get_side_data
Document that it also sets the size in case the desired side data is
absent (if the pointer has been supplied).

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 12:20:23 +02:00
Andreas Rheinhardt
b054a3a216 avformat/flvdec: Cosmetics
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 12:19:56 +02:00
Przemysław Sobala
82352f3c1a avformat/dashenc: Calculate average bitrate for adaptation sets in static manifest
If stream's bitrate is not specified:
- for static manifest: an average bitrate will be calculated and used,
- for dynamic manifest: first segment's bitrate will be calculated and used, as before,
for bandwidth setting in adaptation sets.
2020-06-22 10:32:44 +05:30
Przemysław Sobala
19726288d8 Revert "avformat/dashenc: use AVStream timebase when computing missing bitrate"
This reverts commit 2a9ffd89fc as duration is always in AV_TIME_BASE units
2020-06-22 10:32:10 +05:30
Limin Wang
04172d233d avformat/dvenc: return error code of dv_assemble_frame()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-06-19 23:12:49 +08:00
Paul B Mahol
71f19bf5e3 avformat: add MCC demuxer
Fixes #7680
2020-06-18 21:31:13 +02:00
Paul B Mahol
b52ca2cec2 avformat/sccdec: make splitting more robust 2020-06-18 21:28:09 +02:00