Commit Graph

97435 Commits

Author SHA1 Message Date
Błażej Szczygieł 561ba15c97 lavf/tls_gnutls: check for interrupt inside handshake loop
fixes #8080

Signed-off-by: Błażej Szczygieł <spaz16@wp.pl>
2020-04-21 21:14:26 +03:00
Lynne e3c7b22451
hwcontext_vulkan: correctly download and upload flipped images
We derive the destination buffer stride from the input stride,
which meant if the image was flipped with a negative stride,
we'd be FFALIGNING a negative number which ends up being huge,
thus making the Vulkan buffer allocation fail and the whole
image transfer fail.

Only found out about this as OpenGL compositors can copy an entire
image with a single call if its flipped, rather than iterate over
each line.
2020-04-21 19:00:51 +01:00
Andreas Rheinhardt 8a4fda029a avformat/matroskaenc: Cosmetics
Reindentation, removal of { } if they contain only one statement
and moving the return statement to a line of its own in situations
like "if (ret < 0) return ret;". Moreover, several overlong lines
were made shorter and a camelCase variable received a name in line
with our naming conventions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-21 08:50:22 +02:00
Andreas Rheinhardt e3c54b549a avformat/matroskaenc: Redo handling of FlagDefault
Up until now, the Matroska muxer would mark a track as default if it had
the disposition AV_DISPOSITION_DEFAULT or if there was no track with
AV_DISPOSITION_DEFAULT set; in the latter case even more than one track
of a kind (audio, video, subtitles) was marked as default which is not
sensible.

This commit changes the logic used to mark tracks as default. There are
now three modes for this:
a) In the "infer" mode the first track of every type (audio, video,
subtitles) with default disposition set will be marked as default; if
there is no such track (for a given type), then the first track of this
type (if existing) will be marked as default. This behaviour is inspired
by mkvmerge. It ensures that the default flags will be set in a sensible
way even if the input comes from containers that lack the concept of
default flags. This mode is the default mode.
b) The "infer_no_subs" mode is similar to the "infer" mode; the
difference is that if no subtitle track with default disposition exists,
no subtitle track will be marked as default at all.
c) The "passthrough" mode: Here the track will be marked as default if
and only the corresponding input stream had disposition default.

This fixes ticket #8173 (the passthrough mode is ideal for this) as
well as ticket #8416 (the "infer_no_subs" mode leads to the desired
output).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-21 08:36:20 +02:00
Andreas Rheinhardt 75e50c3141 avformat/matroskaenc: Don't needlessly copy AVCodecParameters
At the end of encoding, the FLAC encoder sends a packet whose side data
contains updated extradata (e.g. a correct md5 checksum). The Matroska
muxer uses this to update the CodecPrivate.

In doing so, the stream's codecpar was copied. But given that writing
a FLAC CodecPrivate does not modify the used AVCodecParameters at all,
there is no need to do so and this commit changes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-21 08:28:58 +02:00
Andreas Rheinhardt abc7dc32bd avformat/matroskaenc: Add const where appropriate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-21 08:20:02 +02:00
Andreas Rheinhardt 5b6e164b4b avformat/matroskaenc: Don't waste bytes on length fields
Several EBML Master elements for which a good upper bound of the final
length was available were nevertheless written without giving an
upper bound of the final length to start_ebml_master(), so that their
length fields were eight bytes long. This has been changed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-21 08:11:09 +02:00
Andreas Rheinhardt a9844341f7 avformat/matroskaenc: Only write Tracks if there is a track
The Matroska muxer does not write every stream as a Matroska track;
some streams are written as AttachedFile. But should no stream be
written as a Matroska track, the Matroska muxer would nevertheless
write a Tracks element without a TrackEntry. This is against the spec.
This commit changes this and only writes a Tracks if there is a Matroska
track.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-21 07:49:39 +02:00
Andreas Rheinhardt ef45cccc81 avformat/matroskaenc: Warn that WebM doesn't support Attachments
As WebM doesn't support Attachments, the Matroska muxer drops them when
in WebM mode. This happened silently until this commit which adds a
warning for this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-21 07:41:21 +02:00
Andreas Rheinhardt 4dd63ae86c avformat/matroskaenc: Don't use size of inexistent Cluster
In order to determine whether the current Cluster needs to be closed
because of the limits on clustersize and clustertime,
mkv_write_packet() would first get the size of the current Cluster by
applying avio_tell() on the dynamic buffer holding the current Cluster.
It did this without checking whether there is a dynamic buffer for
writing Clusters open right now.

In this case (which happens when writing the first packet)
avio_tell() returned AVERROR(EINVAL); yet it is not good to rely on
avio_tell() (or actually, avio_seek()) to handle the situation
gracefully.

Fixing this is easy: Only check whether a Cluster needs to be closed
if a Cluster is in fact open.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-21 07:33:04 +02:00
Andreas Rheinhardt 86de864741 avformat/matroskaenc: Add check for using explicit TrackNumber
When creating DASH streams, the TrackNumber is externally prescribed
and not derived from the number of streams in the AVFormatContext, so
if the number of tracks for a file using an explicit TrackNumber was
more than one, the resulting file would be broken (it would be impossible
to tell to which track a Block belongs if different tracks share the
same TrackNumber). So disallow this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-21 07:31:10 +02:00
Andreas Rheinhardt 945b928730 avformat/matroskaenc: Improve Cues in case of no video
The Matroska muxer currently only adds CuePoints in three cases:
a) For video keyframes. b) For the first audio frame in a new Cluster if
in DASH-mode. c) For subtitles. This means that ordinary Matroska audio
files won't have any Cues which impedes seeking.

This commit changes this. For every track in a file without video track
it is checked and tracked whether a Cue entry has already been added
for said track for the current Cluster. This is used to add a Cue entry
for each first packet of each track in each Cluster.

Implements #3149.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 21:30:46 +02:00
Andreas Rheinhardt 13c12cd470 avformat/matroskaenc: Remove limit on the number of tracks
The Matroska file format has practically no limit on the number of
tracks (the current limit is 2^56 - 1); yet because they are encoded in
a variable length format in (Simple)Blocks this muxer has simply imposed
a limit on the number of tracks in order to ensure that they can always
be written on one byte in order to simplify the muxing process.

This commit removes said limit.

Also, zero is an invalid TrackNumber, so disallow this value in the
dash_track_number option.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 21:30:46 +02:00
Andreas Rheinhardt 112afaccdf avformat/matroskaenc: Refactor writing EBML lengths
This commit factors the ability to write ordinary EBML numbers out of
the functions for writing EBML lengths. This is in preparation for
future commits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 21:30:46 +02:00
Andreas Rheinhardt 40d038a635 avformat/matroskaenc: Rename functions to better reflect what they do
EBML uses variable length integers both for the EBML IDs as well as for
the EBML lengths; Matroska also uses them for the TrackNumber in
(Simple)Blocks and for the lengths of laces when EBML lacing is used.

When encoding EBML lengths, certain encodings have a special meaning,
namely that the element has an unknown length. This is not so when
encoding general EBML variable length integers.

Yet the functions called ebml_num_size() and put_ebml_num() had this
special meaning hardcoded, i.e. they are there to write EBML lengths and
not general EBML numbers. So rename them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 21:30:46 +02:00
Andreas Rheinhardt 9b0f9003df avformat/matroskaenc: Make ebml_num_size() more robust
Matroska (or actually EBML) uses variable-length numbers where only
seven bits of every byte is usable for the length; the other bits encode
the length of the variable-length number. So in order to find out how
many bytes one needs to encode a given number one can use a loop like
while (num >> 7 * bytes) bytes++; the Matroska muxer effectively did this.

Yet it has a disadvantage: It is impossible for the result of a single
right shift of an unsigned number with most significant bit set to be
zero, because one can only shift by 0..(width - 1). On some
architectures like x64 it is not even possible to do it with undefined
right shifts in which case this leads to an infinite loop.

This can be easily avoided by switching to a loop whose condition is
(num >>= 7). The maximum value the so modified function can return
is 10; any value > 8 is invalid and will now lead to an assert in
put_ebml_num() or in start_ebml_master() (or actually in
put_ebml_size_unknown()).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 21:30:46 +02:00
Andreas Rheinhardt 67e957b43a avformat/matroska: Move mime_tag lists to matroskadec
They are not used any more by the muxer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 21:24:18 +02:00
Andreas Rheinhardt 3589b3f2e2 avformat/matroskaenc: Improve mimetype search
Use the mime_types of the corresponding AVCodecDescriptor instead of
tables specific to Matroska. The former are generally more encompassing:
They contain every item of the current lists except "text/plain" for
AV_CODEC_ID_TEXT and "binary" for AV_CODEC_ID_BIN_DATA.

The former has been preserved by special-casing it while the latter is
a hack added in c9212abf so that the demuxer (which uses the same tables)
sets the appropriate CodecID for broken files ("binary" is not a correct
mime type at all); using it for the muxer was a mistake. The correct
mime type for AV_CODEC_ID_BIN_DATA is "application/octet-stream" and
this is what one gets from the AVCodecDescriptor.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 21:00:19 +02:00
Michael Niedermayer 4c7bcaa385 avcodec/pngdec: Pass ret from decode_iccp_chunk()
Found while reviewing a patch fixing a similar issue

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-20 20:38:41 +02:00
Zane van Iperen 0bce55ac89 avcodec/adpcm: update get_nb_samples() doc
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-20 20:03:00 +02:00
Zane van Iperen 7150123aab avcodec/adpcm_ima_{apc, ssi, oki}: replace while() with for()
Per discussion at https://ffmpeg.org/pipermail/ffmpeg-devel/2020-April/260854.html

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-20 20:03:00 +02:00
James Almer 300e6f03d9 fate/truehd: add a test for the truehd_core bitstream filter
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:53:42 -03:00
James Almer 051d5b284e fate: move TrueHD tests to their own file
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:53:42 -03:00
James Almer 1f5d6e6b66 avformat/dashenc: add missing startWithSap attribute to AdaptationSet elements
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:49:15 -03:00
James Almer ff327a58f1 avformat/dashenc: add a PlaybackRate element
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:49:15 -03:00
James Almer 0ea41ee32e avformat/dashenc: add a maxSegmentDuration attribute to the Manifest
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:49:15 -03:00
James Almer fd0f110a37 doc/muxers: fix some dashenc option names
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:49:15 -03:00
James Almer 795ff53f18 avcodec/qpeg: mark the init function as thread-safe and init cleanup capable
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:46:37 -03:00
James Almer 18bb1d40c1 avcodec/qpeg: export missing frame properties
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:46:37 -03:00
James Almer 1b13023860 avcodec/qpeg: remove an unnecessary intermediary AVFrame
Decoding can be handled directly in the output frame.

Also ensure flushing cleans the reference frame in all cases.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-20 13:46:37 -03:00
Andreas Rheinhardt 0fcf74f435 avformat/oggenc: Don't free AVStream's priv_data, fix memleak
For FLAC, Speex, Opus and VP8 the Ogg muxer allocates two buffers
for building the headers: The first for extradata in an Ogg-specific
format and the second contains a Vorbiscomment. These buffers are
reachable via pointers in the corresponding AVStream's priv_data.

If an error happens during building the headers, the AVStream's
priv_data would be freed. This is pointless in general as it would be
freed generically anyway, but here it is actively harmful: If the second
of the aforementioned allocations fails, the first buffer would leak
upon freeing priv_data.

This commit stops freeing priv_data manually, which allows the muxer to
properly clean up in the deinit function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 18:43:53 +02:00
Andreas Rheinhardt d026fef999 avformat/utils: Fix memleak when decoding subtitle in find_stream_info
avformat_find_stream_info() may decode some frames to get stream
information. And when it does this for subtitles, the decoded subtitles
leak.

(Decoding subtitles was added in b1511e00f6
for PGS subtitles. When PGS subtitles originate from a container that
exports every segment as a packet of its own, no output will be
generated when decoding a packet, because not enough input is available.
Yet when used with PGS subtitles in the Matroska form a single packet
contains enough data to generate output. Yet said output is not freed,
hence this leak.)

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 18:35:00 +02:00
Andreas Rheinhardt ee593bff98 avcodec/bsf: Use macro for "packet is empty"
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 18:25:02 +02:00
Andreas Rheinhardt 4e254ec6be avformat/rtsp: Put strings instead of pointers to strings into array
In this example, the difference in length between the shortest and
longest string is three, so that not using pointers to strings saves
space even on 32bit systems.

Moreover, there is no need to use a sentinel here; it can be replaced
with FF_ARRAY_ELEMS.

Reviewed-by: Ross Nicholson <phunkyfish@gmail.com>
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 18:21:39 +02:00
Andreas Rheinhardt 87b056e6af avformat/rtsp: Don't free uninitialized AVBPrint
Fixes Coverity ID 1462307.

Reviewed-by: Marton Balint <cus@passwd.hu>
Reviewed-by: Ross Nicholson <phunkyfish@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-20 18:16:24 +02:00
Limin Wang a97281699b avformat/movenc: cosmetics
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Josh de Kock <josh@itanimul.li>
2020-04-20 15:59:32 +00:00
Josh de Kock 39962072a8 tools: stop using deprecated av_codec_next()
Signed-off-by: Josh de Kock <josh@itanimul.li>
2020-04-20 15:08:20 +00:00
Josh de Kock 43c648817d lavf/utils: stop using deprecated av_codec_next()
Signed-off-by: Josh de Kock <josh@itanimul.li>
2020-04-20 15:08:20 +00:00
Josh de Kock bd2e7b74e1 lavc: stop using deprecated av_codec_next()
Signed-off-by: Josh de Kock <josh@itanimul.li>
2020-04-20 15:08:20 +00:00
Anton Khirnov 4cde83c780 cmdutils: stop using deprecated av_codec_next()
Signed-off-by: Josh de Kock <josh@itanimul.li>
2020-04-20 14:50:03 +00:00
qoroliang cacdac819f lavc/hevcdec: fix the HEVC decoder crash when memory over-read
Fix an occasional crash for hevc decoder in ARM 32 platform, the
root cause is the memory over read(read cross the memory boundary)
in SAO NENO functions ff_hevc_sao_band_filter_neon_8 and
ff_hevc_sao_edge_filter_neon_8.

After this fix, the crash disapper in the massive Android phone
test.

Signed-off-by: qoroliang <qoroliang@tencent.com>
2020-04-20 10:28:04 +08:00
Wolfgang Haupt 428a0987e4 libavformat/rtsp: pass protocol options for udp multicast
Protocol options like buffer_size need to be passed to the
underlying transport implementation for udp multicasts as well.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-19 23:27:45 +02:00
Martin Storsjö 872790b1f9 swscale: aarch64: Avoid using the x18 register
The x18 is a reserved platform register on Darwin and Windows.

x8/w8 seems to be unused in this function though (and same about
x10 and x14), so there's really no reason to use x18 here - just change
the uses of x18/w18 into x8/w8 instead without any further rewrites.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-04-20 00:09:34 +03:00
James Almer 16650beedf configure: add MLP parser as dependency to MLP and TrueHD demuxers
It's needed to assemble complete frames.

Signed-off-by: James Almer <jamrial@gmail.com>
2020-04-19 15:58:45 -03:00
Andreas Rheinhardt 4bbf2a240f avcodec/truehd_core_bsf: Remove unused AVClass pointer
The context structure of the truehd_core bsf had a pointer to a const
AVClass as its first member; yet this bsf does not have any AVClass
associated with it, so that this pointer is always NULL. So remove it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-19 19:20:03 +02:00
Michael Niedermayer 13171ad2e3 avcodec/rv40dsp: Fix integer overflows in rv40_weight_func_*()
Fixes: signed integer overflow: 40550400 * 128 cannot be represented in type 'int'
Fixes: 20331/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV40_fuzzer-5676685725007872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-04-19 17:08:08 +02:00
phunkyfish 2a322906b7 avformat/rtp: Pass sources and block filter addresses via sdp file for rtp
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-04-19 13:18:01 +02:00
Andreas Rheinhardt 18d69e9a98 avformat/mpc: Simplify cleanup
Currently Musepack allocates an array that needs to be freed later in
the demuxer's read_close-function; it is the sole reason for said
function's existence. But it is unnecessary, because one can store this
array in the stream's priv_data pointer, so that it will be freed
generically.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-19 02:37:46 +02:00
Andreas Rheinhardt 3059b7746a avformat/matroskadec: Remove redundant setting of chapter titles
Chapter titles are added to the chapter's metadata since 6cb6e159,
yet since 012867f0 (the predecessor of) avpriv_new_chapter() already
adds the title to the chapter's metadata. So setting it again in
matroskadec.c is redundant and expensive.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-19 00:33:34 +02:00
Andreas Rheinhardt 2e92e1fb27 fate/matroska: Add test for chapters, Vorbis and WebM DASH
Moreover, putting the Cues in front of the Clusters by reserving space
in advance is also tested.

The new capability of using ffprobe during a remux/transcode test are
used here for information about the chapters.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-19 00:25:05 +02:00