1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

22839 Commits

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