1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-09-03 23:11:29 +02:00
Commit Graph

24137 Commits

Author SHA1 Message Date
Andreas Rheinhardt
dbc76e4e70 avformat/mpegenc: Simplify writing padding/stuffing
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:59 +02:00
Andreas Rheinhardt
62c8b96a13 avformat/matroskaenc: Simplify writing qt-compatibility header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:59 +02:00
Andreas Rheinhardt
2c47a94911 avformat/movenc: Simplify reserving space for tfrf tags
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:59 +02:00
Andreas Rheinhardt
1cf3c59b58 avformat/movenc: Limit ism_lookahead to a sane value
There can only be a maximum of 255 entries in a tfrf tag, so using
more makes no sense; moreover, several size computations can overflow
in this case. Fix this by limiting it to 255.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:59 +02:00
Andreas Rheinhardt
63a5e83de8 avformat/icoenc: Use avcodec_get_name() instead of codec descriptor
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:59 +02:00
Andreas Rheinhardt
7d5e27b473 avformat/icoenc: Simplify writing bitmask
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:59 +02:00
Andreas Rheinhardt
d94b641b4a avformat/cafenc: Fix memleak when trailer is never written
Do this by using the AVStream's priv_data for the buffer holding
the packet size data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:58 +02:00
Andreas Rheinhardt
19a6b51fe6 avformat/cafenc: Don't segfault upon allocation error
If an array for the packet sizes could not be successfully reallocated
when writing a packet, the CAF muxer frees said array, but does not
reset the number of valid bytes. As a result, when the trailer is
written later, avio_write tries to read that many bytes from NULL,
which segfaults.

Fix this by not freeing the array in case of error; also, postpone
writing the packet data after having successfully (re)allocated the
array, so that even on allocation error the file can be correctly
finalized.

Also remove an unnecessary resetting of the number of size entries
used at the end.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:58 +02:00
Andreas Rheinhardt
42fe438482 avformat/cafenc: Fix potential integer overflow
(As long as avio_write() only accepts an int, it makes no sense
to try to support sizes that don't fit into an int.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 07:08:58 +02:00
Andreas Rheinhardt
3042e71776 avformat/filmstripenc: Simplify writing reserved elements
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 06:06:08 +02:00
Andreas Rheinhardt
aeee5e3967 avformat/chromaprint: Improve returned error codes
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 06:05:46 +02:00
Andreas Rheinhardt
dd1975b0bb avformat/chromaprint: Add deinit function
Fixes memleaks in case the trailer is never written.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-27 06:04:39 +02:00
Michael Niedermayer
451ceb5131 avformat/mov: Fix last mfra check
Fixes: signed integer overflow: 9223372036854775360 + 536870912 cannot be represented in type 'long'
Fixes: 37940/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6095637855207424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-09-26 17:22:18 +02:00
Andreas Rheinhardt
2b787ef766 avformat/dv: Set AVFMTCTX_NOHEADER flag
Audio streams are only added when a packet is read.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-26 08:51:58 +02:00
Andreas Rheinhardt
3022f74874 avformat/argo_asf: Use memcpy to copy string without its NUL
This avoids a -Wstringop-truncation warning from GCC which takes
issue with the fact that the destination might not be NUL-terminated.

Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-26 08:51:41 +02:00
Andreas Rheinhardt
2882286a08 avformat/jvdec: Make sizeof(JVFrame) smaller to save memory
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-26 01:43:18 +02:00
Andreas Rheinhardt
54e8dcce8e avformat/jacosubenc: Fix writing extradata
The terminating '\0' is no longer included in the size of
the extradata output by the demuxer since commit
36e61e24e7.
E.g. if one remuxes the JACOsub sample JACOsub_capability_tester.jss
from the FATE suite, one receives a file not recognized as JACOsub
before this patch.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-25 23:11:56 +02:00
Andreas Rheinhardt
a46e78d5b7 avformat/aviobuf: Extend ffio_fill to 64bits
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-24 00:14:25 +02:00
Andreas Rheinhardt
874f03fae7 avformat/omadec: Don't output uninitialized values
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-24 00:14:10 +02:00
Andreas Rheinhardt
bb50823d24 avformat/riffenc: Fix indentation
Forgotten after bf9a8d183d.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-24 00:14:01 +02:00
Andreas Rheinhardt
0f12d79a88 avformat/movenchint: Simplify writing padding
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-24 00:13:49 +02:00
Andreas Rheinhardt
6e26015a6b avformat/astenc: Simplify writing padding
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-23 17:37:22 +02:00
Nicolas Gaullier
8a3f8afa4e avformat/mov: Set AVSTREAM_PARSE_HEADERS flag for H264
Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-09-23 10:35:09 -03:00
Nicolas Gaullier
daf04868d8 avformat/demux: Use r_frame_rate in compute_frame_duration if codec_framerate is unknown
Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-09-23 10:35:09 -03:00
Marc-Antoine Arnaud
447cf53774 avformat/mxfdec: rename sub_descriptors as file_descriptors
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-09-22 22:44:30 +02:00
Michael Niedermayer
0b761e87c0 avformat/concatdec: Use FAIL() macro instead of direct return in concat_parse_script()
Fixes: memleak
Fixes: 38893/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-4785231933079552

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>
2021-09-22 18:53:53 +02:00
Andreas Rheinhardt
1ea3650823 Replace all occurences of av_mallocz_array() by av_calloc()
They do the same.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 01:03:52 +02:00
Michael Niedermayer
71b4d16bca avformat/dhav: do not use zero fps
Fixes: assertion failure
Fixes: 38332/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-4522405595316224

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>
2021-09-19 20:12:32 +02:00
Andreas Rheinhardt
6c8f96f18b avformat/rtsp: Use av_dict_set_int()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-19 04:40:13 +02:00
Andreas Rheinhardt
cef920853f avformat/demux: Use av_opt_set_int() where appropriate
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-18 23:16:49 +02:00
Zhao Zhili
e4f499f842 avformat/libsrt: remove url_get_file_handle implementation
SRTSOCKET is an abstraction designed by libsrt, it's not guaranteed
to be a real file descriptor. Even if it is, it should not be
operated directly outside of libsrt.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-09-18 22:10:03 +02:00
Zhao Zhili
fc9832f255 avformat/libsrt: log streamid in listener mode
It's useful for test client which pass streamid to ffmpeg/ffplay.
For example, use ffmpeg to test streamid support in VLC:
./ffmpeg -v info -re -i foo.mp4 -c copy -f mpegts -mode listener srt://127.0.0.1:9000
./vlc srt://127.0.0.1:9000?streamid=foobar

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-09-18 21:44:25 +02:00
Nicolas Jorge Dato
5a0a9f7825 avformat/mpegts: fixes overflow when parsing the PMT
When a possible overflow was detected, there was a break to exit the while
loop. However, it should have already substracted 2 bytes from
program_info_length (descriptor ID + length).

Fixes ticket #9422.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-09-18 21:19:39 +02:00
Andreas Rheinhardt
6af21de373 avformat/utils: Use st for AVStream variable in avpriv_set_pts_info
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 14:45:15 +02:00
Andreas Rheinhardt
f5bfc11b5d avformat/demux: Don't free inexistent ID3v2 metadata
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 14:45:10 +02:00
Andreas Rheinhardt
bde2cdfe9b avformat/utils: Move demuxing code out into a new file
libavformat/utils.c has over 4800 lines and is supposed to contain
"various utility functions for use within FFmpeg". In reality it
contains all that and the whole demuxing core of libavformat.
This is especially bad, because said file includes the FFMPEG_VERSION
(the git commit sha) so that it is rebuilt whenever the commit HEAD
points to changes. Therefore this commit makes it smaller by moving
the demuxing code out to a new file, demux.c (in analogy to mux.c
for the muxing code).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 14:42:17 +02:00
Andreas Rheinhardt
cf7c51f24b avformat/utils: Move seeking code out into a new file
libavformat/utils.c has over 5500 lines and is supposed to contain
"various utility functions for use within FFmpeg". In reality it
contains all that and the whole demuxing+seeking core of libavformat.
This is especially bad, because said file includes the FFMPEG_VERSION
(the git commit sha) so that it is rebuilt whenever the commit HEAD
points to changes. Therefore this commit starts making it smaller
by factoring the seeking code out.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 13:53:30 +02:00
Andreas Rheinhardt
a55ce5baf3 avformat/utils: Reindentation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 13:44:46 +02:00
Andreas Rheinhardt
40bdd8cc05 avformat: Avoid allocation for AVStreamInternal
Do this by allocating AVStream together with the data that is
currently in AVStreamInternal; or rather: Put AVStream at the
beginning of a new structure called FFStream (which encompasses
more than just the internal fields and is a proper context in its own
right, hence the name) and remove AVStreamInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 13:22:25 +02:00
Andreas Rheinhardt
9f05b3ba60 avformat/mux, utils: Use dedicated pointer for AVStreamInternal
This gets rid of ugly "->internal" and is in preparation for removing
AVStreamInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 13:02:35 +02:00
Andreas Rheinhardt
fed0282508 avformat: Avoid allocation for AVFormatInternal
Do this by allocating AVFormatContext together with the data that is
currently in AVFormatInternal; or rather: Put AVFormatContext at the
beginning of a new structure called FFFormatContext (which encompasses
more than just the internal fields and is a proper context in its own
right, hence the name) and remove AVFormatInternal altogether.

The biggest simplifications occured in avformat_alloc_context(), where
one can now simply call avformat_free_context() in case of errors.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 04:58:34 +02:00
Andreas Rheinhardt
dfbf41775c avformat/mux, mxfenc, utils: Use dedicated pointer for AVFormatInternal
This gets rid of ugly "->internal" and is in preparation for removing
AVFormatInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 04:43:04 +02:00
Andreas Rheinhardt
eaacb5c513 avformat/asfenc, mux, utils: Use smaller scope for variables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 04:17:25 +02:00
Andreas Rheinhardt
8ab5bf512a avformat/mp3dec: Simplify checking for no-metadata
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 04:15:56 +02:00
Andreas Rheinhardt
6d1e792980 avformat/mp3dec: Avoid calling avio_tell() multiple times
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 04:14:25 +02:00
James Almer
229e949c8e avformat/mvdec: Don't signal success on parse_audio_var() error
Propagate the error it returned instead.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-09-16 19:44:32 -03:00
Michael Niedermayer
737e6bf216 avformat/mvdec: Do not set invalid sample rate
Fixes: signed integer overflow: -682581959642593728 * 16 cannot be represented in type 'long'
Fixes: 37883/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5311691517198336

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-09-16 18:41:10 +02:00
Michael Niedermayer
f624c92d4c avformat/sbgdec: Check for t0 overflow in expand_tseq()
Fixes: signed integer overflow: 4611686025627387904 + 4611686025627387904 cannot be represented in type 'long'
Fixes: 35489/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-4862678601433088

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>
2021-09-16 18:41:10 +02:00
Nicolas George
94aa7e8a76 lavf/concatdec: add stream_extradata directive 2021-09-16 10:17:59 +02:00
Nicolas George
2263ff505c lavf/concat: add support for chapters 2021-09-16 10:17:59 +02:00
Nicolas George
0a267bc5e2 lavf/concatdec: add stream_codec directive 2021-09-16 10:17:59 +02:00
Nicolas George
c753b49c38 lavf/concatdec: support stream metadata 2021-09-16 10:17:59 +02:00
Nicolas George
76cf1ff979 lavf/concat: deprecate file_packet_metadata 2021-09-16 10:17:59 +02:00
Nicolas George
7517777d06 lavf/concat: add file_packet_meta directive
Same as file_packet_metadata without the double parsing.
2021-09-16 10:17:59 +02:00
Nicolas George
74ab93fa7f lavf/concat: refactor parsing 2021-09-16 10:17:59 +02:00
Michael Niedermayer
e2c2872393 avformat/rmdec: Use 64bit for intermediate for DEINT_ID_INT4
Fixes: runtime error: signed integer overflow: 65312 * 65535 cannot be represented in type 'int'
Fixes: 32832/clusterfuzz-testcase-minimized-ffmpeg_dem_RM_fuzzer-4817710040088576

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-09-15 19:55:17 +02:00
Michael Niedermayer
2768928624 avformat/sbgdec: Check opt_duration and start for overflow
Fixes: signed integer overflow: 2788626175500000000 + 7118941284000000000 cannot be represented in type 'long'
Fixes: 35215/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6123272247836672

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-09-15 14:57:36 +02:00
Michael Niedermayer
9a222f140e avformat/mov: Check for duplicate clli
Fixes: memleak
Fixes: 35261/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4869656287510528

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-09-14 17:34:33 +02:00
Michael Niedermayer
4d81550df9 avformat/utils: Ignore negative duration in codec_info_duration computation
Fixes: signed integer overflow: -5994697211974418462 + -3255307777713450286 cannot be represented in type 'long'
Fixes: 35332/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-5868035117285376

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-09-14 16:51:29 +02:00
Michael Niedermayer
989febfbd0 avformat/jacosubdec: Check for min in t overflow in get_shift()
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: 34651/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-5157941012463616

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-09-13 22:48:10 +02:00
Michael Niedermayer
3dd5a8a135 avformat/mxfdec: check channel number in mxf_get_d10_aes3_packet()
Fixes: Out of array access
Fixes: 37030/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5387719147651072

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-09-13 21:13:05 +02:00
Paul B Mahol
d1971d69c7 avformat/dv: always set audio packet duration
If audio packet is present in DV stream it have duration of 1 in DV timebase units.
2021-09-12 22:23:35 +02:00
Andreas Rheinhardt
3008a93b4d avformat/rtpdec: Make ff_rtp_handler_iterate() static
Possible since 6197453761.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-08 22:59:14 +02:00
Andreas Rheinhardt
cd3d7b0f8f avformat/rawdec: Make ff_raw_data_read_header() static
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-08 22:59:14 +02:00
Andreas Rheinhardt
49916dafb9 avformat/mov_chan: Make ff_mov_get_channel_layout() static
Possible since 3bab7cd128.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-08 22:59:14 +02:00
Paul B Mahol
7b523a06d0 avformat/dhav: use frame number if timestamp difference is zero 2021-09-08 22:54:55 +02:00
Paul B Mahol
7ebeef6aff avformat/mlpdec: fix time_base for packet timestamps 2021-09-07 18:16:13 +02:00
Peter Ross
c655a734b1 avcodec/siren: MSN Siren decoder
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Peter Ross <pross@xvid.org>
2021-09-07 18:07:11 +10:00
Andreas Rheinhardt
2f710734c8 avformat/mux: Fix double-free when using AVPacket.opaque_ref
Up until now, ff_write_chained() copied the packet (manually, not with
av_packet_move_ref()) from a packet given to it to a stack packet whose
timing and stream_index is then modified before being sent to another
muxer via av_(interleaved_)write_frame(). Afterwards it is intended to
sync the fields of the packet relevant to freeing again; yet this only
encompasses buf, side_data and side_data_elems and not the newly added
opaque_ref. The other fields are not synced so that the returned packet
can have a size > 0 and data != NULL despite its buf being NULL (this
always happens in the interleaved codepath; before commit
fe251f77c8 it could also happen in the
noninterleaved one). This leads to double-frees if the interleaved
codepath is used and opaque_ref is set.

This commit therefore changes this by directly reusing the packet
instead of a spare packet. Given that av_write_frame() does not
change the packet given to it, one only needs to restore the timing
information to return it as it was; for the interleaved codepath
it is not possible to do likewise*, because av_interleaved_write_frame()
takes ownership of the packets given to it and returns blank packets.
But precisely because of this users of the interleaved codepath
have no legitimate expectation that their packet will be returned
unchanged. In line with av_interleaved_write_frame() ff_write_chained()
therefore returns blank packets when using the interleaved codepath.

Making the only user of said codepath compatible with this was trivial.

*: Unless one wanted to create a full new reference.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-03 19:23:18 +02:00
Paul B Mahol
11d39873ab avformat/cafdec: try skipping various chunks only when seeking is possible 2021-09-03 01:21:51 +02:00
James Almer
8a6beccf0d avformat: add an AV1 Low overhead bitstream format muxer
Suggested-by: BBB
Signed-off-by: James Almer <jamrial@gmail.com>
2021-09-01 19:55:30 -03:00
Andreas Rheinhardt
fea4f953b5 avformat/utils: Use av_memdup to duplicate array of AVChapter *
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-31 17:01:38 +02:00
Andreas Rheinhardt
bcbd84f435 avformat/utils: Don't allocate zero-sized array
It is unnecessary and also ill-defined: av_malloc() returns a 1-byte
block of memory in this case, but this is not documented.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-31 17:01:04 +02:00
Andreas Rheinhardt
e04ddba64f avformat/utils: Don't compare pointers when sorting chapters
The chapters are independently allocated, so that comparing
the pointers is undefined behaviour. Furthermore, its result
is not platform-independent (and may not even be deterministic
on a particular platform). So compare the chapters' ids instead.
(avpriv_new_chapter() ensures that there are no duplicate ids.)

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-31 17:00:42 +02:00
Andreas Rheinhardt
6e0823ab83 avformat/utils: Allocate AVStream.info only for input streams
This structure is only used for demuxers (mostly in
avformat_find_stream_info()), so only allocate it for them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-30 16:12:22 +02:00
Andreas Rheinhardt
10646d30a3 avformat/utils: Don't initialize AVStreamInternal.info multiple times
It has been allocated and initialized in avformat_find_stream_info()
until fd0368e7ca when the structure
was moved to AVStreamInternal and its allocation to avformat_new_stream.
In order to also initialize the struct for new streams that only get
created during avformat_find_stream_info() said the initialization has
been added to avformat_new_stream() later. Due to the Libav-FFmpeg split
this has been done twice: In 4cda8aa1c5
and in 30c26c2442. The initialization in
avformat_find_stream_info() has not been removed at all despite being
redundant. This commit removes it and the duplicated initialization in
avformat_new_stream().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-30 16:12:22 +02:00
Andreas Rheinhardt
2c3c83663d avformat/utils: Remove redundant flushing of packet queue
The packet queue is already flushed in avformat_free_context() which
is called a few lines below.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-30 16:12:22 +02:00
Andreas Rheinhardt
bafb65ba2a avformat/mux: Don't access AVStream's internal AVCodecContext
An AVStream's internal AVCodecContext is pretty much unused for muxing:
The only place where any of its fields are set is
avformat_transfer_internal_stream_timing_info() where its time base is
set based upon the desired output format. The max_b_frames field is
never set at all, so don't read it in mux.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-30 16:12:22 +02:00
Andreas Rheinhardt
c6d780b92e avformat/utils: Make ff_compute_frame_duration() static
Since 1c0885334d ff_compute_frame_duration
is only called from within utils.c and only for demuxers. So make it
static and remove the code in it that deals with muxers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-30 16:12:22 +02:00
Andreas Rheinhardt
3f991325b5 avformat/utils: Remove obsolete todo
Also initialize the AVCodecContexts directly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-30 16:12:22 +02:00
Andreas Rheinhardt
f265374bc0 avformat/utils: Remove always-false check
AVFormatContext.internal is already allocated by
avformat_alloc_context() on success; and on error,
avformat_alloc_context() cleans up manually without
avformat_free_context().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-30 16:12:22 +02:00
Andreas Rheinhardt
9abf0e0419 avformat/yuv4mpegdec: Don't call avio_tell() twice
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-30 15:48:11 +02:00
Andreas Rheinhardt
b2d61d0f02 avformat/matroskadec: Fix heap-buffer overflow upon gigantic timestamps
The WebM DASH Manifest demuxer creates a comma-delimited list of
all the timestamps of index entries. It allocates 20 bytes per
timestamp; yet the largest 64bit numbers have 20 decimal digits
(for int64_t it can be '-'+ 19 digits), so that one needs 21B
per entry because of the comma (resp. the final NUL).

The code uses snprintf, but snprintf returns the strlen of the string
that would have been written had the supplied buffer been big enough.
And if this is 21, then the next entry is written at an offset of 21
from the current position. So if enough such entries exist, the buffer
won't suffice.

This commit fixes this by replacing the allocation of buffer for
the supposedly worst-case with dynamic allocations by using an AVBPrint.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-30 15:48:11 +02:00
Michael Niedermayer
4de4bc06fd avformat/mov: Check dts for overflow in mov_read_trun()
Fixes: signed integer overflow: 9223372034248226491 + 3275247799 cannot be represented in type 'long'
Fixes: clusterfuzz-testcase-minimized-audio_decoder_fuzzer-4538729166077952

Reported-by: Matt Wolenetz <wolenetz@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-29 21:34:38 +02:00
Michael Niedermayer
a4c98c507e avformat/avidec: Use 64bit for frame number in odml index parsing
Fixes: signed integer overflow: 1179337772 + 1392508928 cannot be represented in type 'int'
Fixes: 34088/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-5846945303232512

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-08-28 20:47:24 +02:00
Andreas Rheinhardt
0871273a2f avformat/flac_picture: Reindentation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-28 15:25:18 +02:00
Andreas Rheinhardt
e304f5f758 avformat/flac_picture: Simplify parsing title
Don't allocate the buffer for the title ourselves, leave it to
av_dict_set(). This simplifies freeing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-28 15:25:18 +02:00
Andreas Rheinhardt
c1f4858242 avformat/flac_picture: Try to reuse buffer for attached picture
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-28 15:25:18 +02:00
Andreas Rheinhardt
b10a8a30db avformat/oggparsevorbis: Avoid tmp bufs when parsing VorbisComment
A single VorbisComment consists of a length field and a
non-NUL-terminated string of the form "key=value". Up until now,
when parsing such a VorbisComment, zero-terminated duplicates of
key and value would be created. This is wasteful if these duplicates
are freed shortly afterwards, as happens in particular in case of
attached pictures: In this case value is base64 encoded and only
needed to decode the actual data.

Therefore this commit changes this: The buffer is temporarily modified
so that both key and value are zero-terminated. Then the data is used
in-place and restored to its original state afterwards.

This requires that the buffer has at least one byte of padding. All
buffers currently have AV_INPUT_BUFFER_PADDING_SIZE bytes padding,
so this is ok.

Finally, this also fixes weird behaviour from ogm_chapter():
It sometimes freed given to it, leaving the caller with dangling
pointers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-28 15:25:18 +02:00
Andreas Rheinhardt
f1d89d6dd0 avformat/oggparsevorbis: Factor parsing a single VorbisComment out
This is in preparation for further commits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-28 15:25:18 +02:00
Andreas Rheinhardt
831718bbab avformat/movenc: Avoid calling strlen multiple times
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-27 10:47:35 +02:00
Andreas Rheinhardt
64020dfe08 avformat/vorbiscomment: Don't compute strlen twice
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-27 10:47:23 +02:00
Andreas Rheinhardt
52bd399972 avformat/aviobuf: Use ffio_fill for padding
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Andreas Rheinhardt
f5f984c9c3 avformat/aviobuf: Avoid allocation when using dynamic buffer
This can be achieved by allocating the AVIOContext and
the dynamic buffer's opaque and internal write buffer together.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Andreas Rheinhardt
45bfe8b838 avformat/avio: Move internal AVIOContext fields to avio_internal.h
Currently AVIOContext's private fields are all over AVIOContext.
This commit moves them into a new structure in avio_internal.h instead.
Said structure contains the public AVIOContext as its first element
in order to avoid having to allocate a separate AVIOContextInternal
which is costly for those use cases where one just wants to access
an already existing buffer via the AVIOContext-API.
For these cases ffio_init_context() can't fail and always returned zero,
which was typically not checked. Therefore it has been made to not
return anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Andreas Rheinhardt
530ac6aa30 avformat/aviobuf: Make ffio_set_buf_size() static
Possible since 9c3adb7ce2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Andreas Rheinhardt
19093100fd avformat/utils: Move ffio_limit() to aviobuf
It is the more natural place for it given that it only deals with I/O;
in fact, the function already has the ffio prefix and its declaration
already is in avio_internal.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:53 +02:00
Andreas Rheinhardt
e75ab15fd4 avformat/matroskadec: Read RealAudio extradata directly
Don't use the avio-API to read a few bytes at fixed offsets.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:53 +02:00
Andreas Rheinhardt
7cfff1512c avformat/aviobuf: Avoid calling function twice due to FFMAX()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:53 +02:00
Jan Ekström
e41bd075dd avformat/movenc: add support for TTML muxing
Includes basic support for both the ISMV ('dfxp') and MP4 ('stpp')
methods. This initial version also foregoes fragmentation support
in case the built-in sample squashing is to be utilized, as this
eases the initial review.

Additionally, add basic tests for both muxing modes in MP4.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2021-08-25 09:26:46 +03:00