Commit Graph

23083 Commits

Author SHA1 Message Date
Zane van Iperen
53ac499f01
avformat/riff: prevent muxing adpcm_swf with a variable block size
Prefer to error than to create a broken file. Closes ticket #5829.

Effectively disables remuxing adpcm_swf from flv -> wav.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-10-21 11:23:23 +10:00
Chris Miceli
be852803eb libavformat/utils: Fix misleading indent
6f69f7a8bf introduced this and it was part
of a very large merging of refactoring. Current behaviour is what is
reflected by this indenting change, however my understanding of timing
is such that this correct behaviour.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-20 15:33:13 +02:00
Michael Niedermayer
44ff5a1bff avformat/boadec: Check that channels and block_align are set
Fixes: Infinite loop
Fixes: 26381/clusterfuzz-testcase-minimized-ffmpeg_dem_BOA_fuzzer-5745789089087488

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-20 15:33:13 +02:00
Michael Niedermayer
2be51d14f2 avformat/av1dec: Fix padding in obu_get_packet()
Fixes: stack buffer overflow (read)
Fixes: 26369/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5721057325219840

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-20 15:33:13 +02:00
Michael Niedermayer
0d088a47ca avformat/asfdec_f: Check name_len for overflow
Fixes: signed integer overflow: -1172299744 * 2 cannot be represented in type 'int'
Fixes: 26258/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5672758488596480

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-20 15:33:13 +02:00
Andreas Rheinhardt
fe2be5d9ce avformat/hlsenc: Fix check for SPS
Check all the six bits, not only the two bits that are set for SPS.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-20 13:00:04 +02:00
Andreas Rheinhardt
c4f65611bc avformat/hlsenc: Fix mixed declaration and code
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-20 12:55:22 +02:00
Andreas Rheinhardt
1ba174f461 avformat/hlsenc: Don't use uninitialized buffer in av_stristr()
Introduced in a2b1dd0ce3.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-20 12:52:49 +02:00
Andreas Rheinhardt
96ad55df5b avformat/hlsenc: Fix extradata length check
Commit a2b1dd0ce3 added support for
parsing annex B HEVC extradata to extract profile and level information.
Yet it only checks for there to be enough data left for the startcode
and the first byte of the NAL unit header and not for the full NAL unit
header; it simply presumes the second byte of the NAL unit header to be
present and skips it. Then the remaining size of the extradata is calculated
which ends up negative if the second byte of the NAL unit header is not
present. Yet when calling ff_nal_unit_extract_rbsp() it
will be converted to an uint32_t and end up as UINT32_MAX which
will cause mayhem.

This is solved by making sure that there is always enough remaining
extradata that could (pending 0x03 escapes) contain the data that we
are interested in.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-20 12:43:16 +02:00
Michael Niedermayer
685ed1cbd1 avformat/sbgdec: Check for timestamp overflow in parse_time_sequence()
Fixes: signed integer overflow: 3458015007900000256 + 6425686373040000000 cannot be represented in type 'long'
Fixes: 26430/clusterfuzz-testcase-minimized-ffmpeg_dem_BRSTM_fuzzer-5761175004119040

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-10-20 10:27:31 +02:00
Steven Liu
a2b1dd0ce3 avformat/hlsenc: support CODECS Attribute in hevc EXT-X-STREAM-INF
fix ticket: 8904
parse the SPS from extradata and get profile_tier_level
write the profile_tier_level info into CODECS Attribute

HLS CODECS Attribute reference to :https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices/hls_authoring_specification_for_apple_devices_appendixes

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
2020-10-20 11:41:44 +08:00
Steven Liu
b5ca8f2c66 avformat/hlsenc: compute video_keyframe_size after write keyframe
fix ticket: 8636
When write keyframe and the keyframe is the frist packet of the segment,
then compute the size of the keyframe which have been write into segment
first packet. and set the start position of the segment, should not use
avio_tell(vs->out) to get the keyframe position, because it can be set
to 0 if close at above of the workflow, that maybe inaccurate, but the
start_pos can be used here, because start_pos is set after write
the previous packet.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
2020-10-20 11:41:44 +08:00
Steven Liu
1ee52b2b6c avformat/dashdec: check the root url length
if the length of the root url is 0, unnecessary process the root_url

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
2020-10-20 11:41:44 +08:00
Steven Liu
a424671e4f avformat/hlsenc: process hls_time value too small sence
The target duration will be a negative value when there are
some b frames after prevous frame, the pts after current packet
is large than the pts of current packet, so the target duration
will compute as 0.040000 - 0.080000, then the value of the target
duration will be -0.040000. so hls muxer should check the pts after
current packet minus the pts of current packet, hls muxer can split
the stream as a segment if the target duration is neither negative nor
zero, hls muxer cannot split the stream as a segment if the
target duration is either negative or zero then get the next packet
until the target duration is not negative or zero.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
Suggested-by: Zhili Zhao <quinkblack@foxmail.com>
Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
2020-10-20 11:41:44 +08:00
James Almer
bddf53841a avformat/options: use the iterate API in format_child_class_next()
Signed-off-by: James Almer <jamrial@gmail.com>
2020-10-19 11:54:45 -03:00
Michael Niedermayer
7ac87a2c34 avformat/kvag: Fix integer overflow in bitrate computation
Fixes: signed integer overflow: 1077952576 * 4 cannot be represented in type 'int'
Fixes: 26152/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5674758518341632

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-18 21:27:23 +02:00
Michael Niedermayer
3162482a14 avformat/ape: Remove seektable and bittable
Suggested-by: Andreas
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-18 20:42:20 +02:00
Michael Niedermayer
aee8477c6b avformat/rmdec: sanity check coded_framesize
Fixes: signed integer overflow: -14671840 * 8224 cannot be represented in type 'int'
Fixes: 24793/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5101884323659776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-18 20:42:20 +02:00
Michael Niedermayer
33624f4f2e avformat/flvdec: Check for EOF in amf_parse_object()
Fixes: Timeout (too long -> 1ms)
Fixes: 26108/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5653887668977664

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-17 14:36:11 +02:00
Michael Niedermayer
3300f5c133 avformat/icodec: Change order of operations to avoid NULL dereference
Fixes: SEGV on unknown address 0x000000000000
Fixes: 26379/clusterfuzz-testcase-minimized-ffmpeg_dem_ICO_fuzzer-5709011753893888

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-17 14:36:11 +02:00
Brad Hards
fcec7a6848 avformat/mpegts: replace magic descriptor_tag values with defines
This takes the used values from ISO/IEC 13818-1 Table 2-45 and adds
them to the mpegts.h header. No functional changes.

Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-16 23:31:45 +02:00
Zhao Zhili
15a74d21f3 avformat/udp: remove redundant setting of h->max_packet_size
h->max_packet_size is being reset in the following code.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-16 23:16:55 +02:00
Marton Balint
f076a5fef6 Revert "aviobuf: Discard old buffered, previously read data in ffio_read_partial"
This is unneeded after 2ca48e4666 and it breaks
ffio_ensure_seekback().

This reverts commit 53c25ee073.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-16 23:16:46 +02:00
Marton Balint
fb0304fcc9 avformat/libsrt: fix cleanups on failed libsrt_open() and libsrt_setup()
- Call srt_epoll_release() to avoid fd leak on libsrt_setup() error.
- Call srt_cleanup() on libsrt_open() failure.
- Fix return value and method on mode parsing failure.

Based on a patch by Nicolas Sugino <nsugino@3way.com.ar>.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-16 23:15:09 +02:00
Michael Niedermayer
b7f51428b1 avformat/subviewerdec: fail on AV_NOPTS_VALUE
Such values are not supported by ff_subtitles_queue*

Fixes: signed integer overflow: 10 - -9223372036854775808 cannot be represented in type 'long'
Fixes: 24193/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5714901855895552

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-15 18:44:31 +02:00
Chris Miceli
0c90377a40 libavformat/avidec: check memory allocation
Memory allocation for AVIOContext should be checked. In this code,
all error conditions are sent to the "goto error".

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-14 21:11:49 +02:00
Paul B Mahol
af5ad79fe1 avformat/isom: add support for RAW ASC Bayer BGGR in mov 2020-10-12 12:19:29 +02:00
Carl Eugen Hoyos
86f0bba776 lavc, lavf: Remove newlines from calls to avpriv_request_sample(). 2020-10-11 19:59:24 +02:00
Justin Ruggles
2be3eb7f77 Allow using only the mfra info for seeking using the fragment index
The mfra has enough information to enable seeking, and reading it is
behind an AVOption flag, so we shouldn't require that sidx information
also be present in order to seek using the fragment index.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2020-10-11 12:16:47 +01:00
James Almer
f0cec744a9 avformat/avformat.h: add missing FF_API_NEXT wrappers
Signed-off-by: James Almer <jamrial@gmail.com>
2020-10-10 23:58:26 -03:00
Marton Balint
a11cc04786 avformat/aviobuf: increase default read buffer size to 2*max_buffer_size for streamed data
This should increase the effectiveness of ffio_ensure_seekback by reducing the
number of buffer reallocations and memmoves/memcpys because even a small
seekback window requires max_buffer_size+window_size buffer space.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-09 21:07:18 +02:00
Marton Balint
25ced19aa3 avformat/aviobuf: fix indentation
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-09 21:07:18 +02:00
Marton Balint
84d8815499 avformat/aviobuf: do not allocate a new buffer in ffio_ensure_seekback if not needed
Let's move unread data to the start of the old buffer instead.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-09 21:07:18 +02:00
Marton Balint
da74a74061 avformat/aviobuf: discard part of the IO buffer in ffio_ensure_seekback if needed
Previously ffio_ensure_seekback never flushed the buffer, so successive
ffio_ensure_seekback calls were all respected. This could eventually cause
unlimited memory and CPU usage if a demuxer called ffio_ensure_seekback on all
it's read data.

Most demuxers however only rely on being able to seek back till the position of
the last ffio_ensure_seekback call, therefore we change the semantics of
ffio_ensure_seekback so that a new call can invalidate seek guarantees of the
old. In order to support some level of "nested" ffio_ensure_seekback calls, we
document that the function only invalidates the old window (and potentially
discards the already read data from the IO buffer), if the newly requested
window does not fit into the old one.

This way we limit the memory usage for ffio_ensure_seekback calls requesting
consecutive data windows.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-09 21:07:18 +02:00
Marton Balint
1490a682dc avformat/mpjpegdec: make sure we seek back to the ensured buffer
It was possible for the old code to seek back before the most recently read
data if start of a new multipart was across read boundaries. Now we read some
small sections multiple times to avoid this, but that is OK.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-09 21:07:18 +02:00
Marton Balint
2933ee8ff0 avformat/mpegts: make sure mpegts_resync do not run out of the initially requested probe buffer
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-09 21:07:18 +02:00
Marton Balint
a3943c4847 avformat/aviobuf: fix checks in ffio_ensure_seekback
The new buf_size was detemined too conservatively, maybe because of the
off-by-one issue which was fixed recently in fill_buffer. We can safely
substract 1 more from the new buffer size, because max_buffer_size space must
only be guaranteed when we are reading the last byte of the requested window.

Comparing the new buf_size against filled did not make a lot of sense, what
makes sense is that we want to reallocate the buffer if the new buf_size is
bigger than the old, therefore the change in the check.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-09 21:07:18 +02:00
Marton Balint
6d972beb23 avformat/aviobuf: check if requested seekback buffer is already read
Existing code did not check if the requested seekback buffer is
already read entirely. In this case, nothing has to be done to guarantee
seekback.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-09 21:07:18 +02:00
Marton Balint
74c70efd12 avformat/aviobuf: write data into the IO buffer till the very end of the buffer
There was an off-by-one error when checking if the IO buffer still has enough
space till the end. One more byte can be safely written.

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-10-09 21:07:18 +02:00
Andriy Gelman
0d156eb58a avformat/rtsp: allocate correct max number of pollfds
There is one general rtsp connection plus two connections per stream (rtp/rtcp).

Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-10-08 23:18:18 -04:00
Andriy Gelman
b4103e0eb6 avformat/rtspdec: add newline in log message
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
2020-10-08 23:18:18 -04:00
Andreas Rheinhardt
39ab256125 avformat/libopenmpt: Don't discard const
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-08 22:56:31 +02:00
Andreas Rheinhardt
616eb93a40 avformat/dashdec: Reset pointer to NULL after freeing it
This is currently safe here, because the effective lifetime of
adaptionset_lang is parse_manifest_adaptationset() (i.e. the pointer
gets overwritten each time on entry to the function and gets freed
before exiting the function), but it is nevertheless safer to reset the
pointer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-08 15:40:02 +02:00
Christopher Degawa
0117d5aa03 libavformat/dashdec: Fix issue with dash on Windows
Use xmlFree instead of av_freep

snip from libxml2:

 * xmlGetProp:
...
 * Returns the attribute value or NULL if not found.
 *     It's up to the caller to free the memory with xmlFree().

According to libxml2, you are supposed to use xmlFree instead of free
on the pointer returned by it, and also using av_freep on Windows will
call _aligned_free instead of normal free, causing _aligned_free to raise
SIGTRAP and crashing ffmpeg and ffplay.

Signed-off-by: Christopher Degawa <ccom@randomderp.com>
2020-10-08 10:05:09 -03:00
Carl Eugen Hoyos
bc43588a71 lavf/img2dec: Auto-detect Cintel scanner images. 2020-10-08 09:34:55 +02:00
Paul B Mahol
283f950a65 avcodec: add Cintel RAW decoder 2020-10-07 22:16:09 +02:00
hwren
1e97fbb3b6 lavf/avs2dec.c: optimize code style
Signed-off-by: hwren <hwrenx@126.com>
2020-10-06 00:01:35 +08:00
hwren
b15e875c8c lavf/davs2.c: rename as avs2dec.c for better understanding
Signed-off-by: hwren <hwrenx@126.com>
2020-10-06 00:01:34 +08:00
hwren
026be690e6 lavc/avs2_parser.c,lavf/davs2.c: add AVS2_* prefix
Add AVS2_* prefix to macro definitions to avoid confusion

Signed-off-by: hwren <hwrenx@126.com>
2020-10-06 00:01:34 +08:00
hwren
ff74ad2a4b lavf/avs3dec: add raw avs3 demuxer
Signed-off-by: hbj <hanbj@pku.edu.cn>
Signed-off-by: hwren <hwrenx@126.com>
2020-10-06 00:01:27 +08:00