summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
Commit message (Collapse)AuthorAge
...
* avformat/utils: Combine identical statementsAndreas Rheinhardt2021-04-18
| | | | | | | | | | | This would only make a difference in case the first attempt to initialize the encoder failed and the second succeeded. The only reason I can think of for this to happen is that the options (in particular the codec whitelist) are not used for the second try and that obviously implies that we should not even try a second time to open the decoder. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavf: do not derive timebase from avg_frame_rateAnton Khirnov2021-04-08
| | | | | | avg_frame_rate is the _average_ framerate, its presence does not guarantee that the stream is CFR, so it should not be used for setting the timebase.
* avformat/utils: add helper functions to retrieve index entries from an AVStreamJames Almer2021-04-07
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Check allocations for failureAndreas Rheinhardt2021-04-02
| | | | | | There would be leaks in case of failure. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Free new streams in ff_add_attached_pic on errorAndreas Rheinhardt2021-04-01
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: Add and use helper function to add attachment streamsAndreas Rheinhardt2021-04-01
| | | | | | | | | All instances of adding attached pictures to a stream or adding a stream and an attached packet to said stream have several things in common like setting the index and flags of the packet, setting the stream disposition etc. This commit therefore factors this out. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Extend overflow check in dts wrap in compute_pkt_fields()Michael Niedermayer2021-03-31
| | | | | | | | Fixes: signed integer overflow: -9223372032574480351 - 4294967296 cannot be represented in type 'long long' Fixes: 30022/clusterfuzz-testcase-minimized-ffmpeg_dem_KUX_fuzzer-5568610275819520 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Fix integer overflow with duration_gcd in ff_rfps_calculate()Michael Niedermayer2021-03-29
| | | | | | | | Fixes: signed integer overflow: 136323327 * 281474976710656 cannot be represented in type 'long' Fixes: 30913/clusterfuzz-testcase-minimized-ffmpeg_dem_IVF_fuzzer-5753392189931520 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Remove redundant checkAndreas Rheinhardt2021-03-28
| | | | | | | | | | This check is outdated because the caller doesn't need to check that the multiplication overflows when using av_realloc_array() (the code in question used av_realloc() before that); furthermore, the check is also a remnant of the time in which our allocation functions didn't use size_t parameters. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/rtpdec: attach producer reference time if availableAlok Priyadarshi2021-03-23
| | | | | | | This produces true wallclock time at rtp source instead of the local wallclock time at rtp client. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Don't allocate separate packet for extract_extradataAndreas Rheinhardt2021-03-23
| | | | | | One can simply reuse AVFormatInternal.parse_pkt instead. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* libavformat/utils: Fix indentationAndreas Rheinhardt2021-03-23
| | | | | | | | | | | Originally added in 12f996edfab67b65af0ff1ee829f9eeabb025b0f behind #if 0; aebb56e1844d61965c97e95534c3ae0da69df028 then removed the #if and replaced it by using av_dlog. Then commit 1a3eb042c704dea190c644def5b32c9cee8832b8 replaced this with av_log at trace level. Yet the code block always stayed within { } at an increased level of indentation. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: Fix confusing return value for ff_read_packet()Andreas Rheinhardt2021-03-23
| | | | | | | | | | | | | | | | | | | | Currently, ff_read_packet() sometimes forwards the return value of AVInputFormat.read_packet() (which should be zero on success, but isn't for all demuxers) and sometimes it overwrites this with zero. Furthermore, it uses two variables, one for the read_packet return value and one for other errors, which is a bit confusing; it is also unnecessary given that the documentation explicitly states that ff_read_packet() never returns positive values. Returning a positive value would lead to leaks with some callers (namely asfrtp_parse_packet and estimate_timings_from_pts). So always return zero in case of success. (This behaviour stems from a time before av_read_packet sanitized the return value of read_packet at all: It was added in commit 626004690c23c981f67228ea325dde3f35193988 and was unnecessary since 88b00723906f68b7563214c30333e48888dddf78.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: Always leave parse_pkt in blank state, avoid resettingAndreas Rheinhardt2021-03-20
| | | | | | | | | Always leaving said packet in a blank state after having used it allows to avoid having to reset it before one uses it; and it also allows to use it in more places than just in parse_packet() here. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat: Make AVChapter.id an int64_t on next major bumpAndreas Rheinhardt2021-03-19
| | | | | | | | | 64 bits are needed in order to retain the uid values of Matroska chapters; the type is kept signed because the semantics of NUT chapters depend upon whether the id is > 0 or < 0. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mux: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/packet_internal: make avpriv_packet_list_* functions use an internal ↵James Almer2021-03-17
| | | | | | | | | struct The next pointer is kept at the end for backwards compatability until the major bump, when it should ideally be moved at the front. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: use the buffer_size_t typedef where requiredJames Almer2021-03-10
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: change AVStream side data related public function and struct ↵James Almer2021-03-10
| | | | | | | | | size types to size_t av_stream_add_side_data() already defines size as a size_t, so this makes it consistent across all side data functions. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: Deprecate AVFMT_FLAG_PRIV_OPT, remove av_demuxer_open on bumpAndreas Rheinhardt2021-03-03
| | | | | | | | | | | | | | | | | | | | | | | This flag was added in 492026209b9b58eaf6d2ea56423f6b1e1a8a76a5 in conjunction with av_demuxer_open() to allow to pass private options to demuxers. It worked as follows: av_open_input_stream() (the predecessor of avformat_open_input()) would not call the read_header function if this flag is set. Instead the user could set private options of the demuxer via the format's private class after avformat_open_input() and then call av_demuxer_open() which called the format's read_header function. This approach was abandoned in e37f161e66e042d6c2c7470c4d9881df9427fc4a and av_demuxer_open() deprecated; instead the AVDictionary based way of passing private options to the demuxer was choosen. Yet AVFMT_FLAG_PRIV_OPT has never been deprecated and av_demuxer_open() never removed. This commit implements the deprecation of the flag and schedules av_demuxer_open for removal on the next major bump. Given that av_demuxer_open() has been deprecated in 2012 and that this flag is useless without it, the flag will be ignored after the next major version bump. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec: remove pointless lowres deprecation wrappersJames Almer2021-02-22
| | | | | | | | Neither the feature, public fields, or AVOptions were ever truly deprecated, nor will have been removed if this FF_API_ define was left in place, so get rid of it as it's misleading. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Add av_assert1 to preclude NULL + len, len != 0Andreas Rheinhardt2021-02-15
| | | | | | | | | Such a scenario is undefined behaviour and would also indicate a bug in our code. Suggested-by: James Almer <jamrial@gmail.com> Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: Fix undefined NULL + 0Andreas Rheinhardt2021-02-14
| | | | | | | | | | | This is undefined behaviour in C, so use data = len ? data + len : data instead of data += len. GCC optimizes the branch away in this case; Clang unfortunately doesn't. Fixes ticket #8592. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: force lowres to 0 in avformat_find_stream_info()James Almer2021-02-13
| | | | | | Instead of applying it and then restoring the original codecpar dimensions. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Use av_sat_sub64() in max_analyze_duration checkMichael Niedermayer2021-01-29
| | | | | | | | Fixes: signed integer overflow: 9223372036854710272 - -541165944832 cannot be represented in type 'long' Fixes: 27000/clusterfuzz-testcase-minimized-ffmpeg_dem_IVF_fuzzer-5643670608674816 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: Change avpriv_new_chapter() from O(n) to (1) in the common caseMichael Niedermayer2021-01-28
| | | | | | | | Fixes: timeout (slow -> 300ms) Fixes: 28876/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5664824587583488 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Check dts in update_initial_timestamps() moreMichael Niedermayer2021-01-26
| | | | | | | | Fixes: signed integer overflow: -9223372036853488158 - 90000000 cannot be represented in type 'long long' Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_MPSUB_fuzzer-6696625298866176 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Check dts - (1<<pts_wrap_bits) overflowMichael Niedermayer2021-01-23
| | | | | | | | Fixes: signed integer overflow: -9223372036842389247 - 2147483648 cannot be represented in type 'long long' Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_FLV_fuzzer-4845007531671552 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavformat/utils: consider avio_size() failure in ffio_limit()Michael Niedermayer2021-01-21
| | | | | | | | Fixes: Timeout (>20sec -> 3ms) Fixes: 26918/clusterfuzz-testcase-minimized-ffmpeg_dem_THP_fuzzer-5750425191710720 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: check for integer overflow in av_get_frame_filename2()Michael Niedermayer2021-01-20
| | | | | | | | Fixes: signed integer overflow: 317316873 * 10 cannot be represented in type 'int' Fixes: 24708/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5731180885049344 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: wrap_timestamp() is only needed for less than 64 bitsMichael Niedermayer2021-01-11
| | | | | | | | | Fixes: shift exponent 64 is too large for 64-bit type 'unsigned long long' Fixes: 26497/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-5690188355076096 Fixes: 26903/clusterfuzz-testcase-minimized-ffmpeg_dem_LUODAT_fuzzer-5641466929741824 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: do not overwrite already existing program with defaults in ↵Marton Balint2021-01-09
| | | | | | | | | av_new_program av_new_program returns the existing program if that already exists, in that case it makes no sense to overwrite existing attributes. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/utils: Change compute_chapters_end() from O(n²) to O(n log n)Michael Niedermayer2021-01-08
| | | | | | | | Fixes: Timeout (49sec -> 9sec) Fixes: 27427/clusterfuzz-testcase-minimized-ffmpeg_dem_FFMETADATA_fuzzer-5140589838073856 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Mark some pointers as constAndreas Rheinhardt2021-01-01
| | | | | Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: Improve ffio_limit logicAndreas Rheinhardt2020-12-11
| | | | | | | | | | | | | | | The earlier code would not complain if the remaining size was one byte short of the desired size; and the way it performed the check could run into signed integer overflow. Fixes: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long' Fixes: Timeout Fixes: 26434/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5752845451919360 Fixes: 26444/clusterfuzz-testcase-minimized-ffmpeg_dem_BINK_fuzzer-4697773380993024 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavf: move AVStream.probe_data to AVStreamInternalAnton Khirnov2020-10-28
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.pts_buffer to AVStreamInternalAnton Khirnov2020-10-28
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.*index_entries* to AVStreamInternalAnton Khirnov2020-10-28
| | | | | | | Those are private fields, no reason to have them exposed in a public header. Since there are some (semi-)public fields located after these, even though this section is supposed to be private, keep some dummy padding there until the next major bump to preserve ABI compatibility.
* lavf: move AVStream.{request_probe,skip_to_keyframe} to AVStreamInternalAnton Khirnov2020-10-28
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.{*skip_samples.*_discard_sample} to AVStreamInternalAnton Khirnov2020-10-28
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.{nb_decoded_frames,mux_ts_offset} to AVStreamInternalAnton Khirnov2020-10-28
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.{pts_wrap_*,update_initial_durations_done} to ↵Anton Khirnov2020-10-28
| | | | | | | AVStreamInternal Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.pts_reorder_error[_count] to AVStreamInternalAnton Khirnov2020-10-28
| | | | | Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.{last_dts_for_order_check,dts_[mis]ordered} to ↵Anton Khirnov2020-10-28
| | | | | | | AVStreamInternal Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.{inject_global_side_data,display_aspect_ratio} to ↵Anton Khirnov2020-10-28
| | | | | | | AVStreamInternal Those are private fields, no reason to have them exposed in a public header.
* lavf: move AVStream.info to AVStreamInternalAnton Khirnov2020-10-28
| | | | | | | This struct is for internal use of avformat_find_stream_info(), so it should not be exposed in public headers. Keep a stub pointer in its place to avoid changing AVStream layout, since e.g. ffmpeg.c accesses some fields located after it (even though they are marked as private).
* avformat: add a stream event flag for new packetsAnton Khirnov2020-10-28
|
* libavformat/utils: Fix misleading indentChris Miceli2020-10-20
| | | | | | | | | 6f69f7a8bf6a0d013985578df2ef42ee6b1c7994 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>
* avformat/utils: add missing FF_API_LAVF_AVCTX checkJames Almer2020-10-01
| | | | Signed-off-by: James Almer <jamrial@gmail.com>