summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
Commit message (Collapse)AuthorAge
* 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>
* avcodec/packet: move AVPacketList definition and function helpers over from ↵James Almer2020-09-15
| | | | | | | | | libavformat And replace the flags parameter with a function callback that can be used to copy the contents of the packet (e.g, av_packet_ref and av_packet_copy_props). Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Avoid duplicating extradata from extract_extradata BSFAndreas Rheinhardt2020-09-11
| | | | | | | | | | | | | Instead move the extradata contained in packet side-data to its destination. This is possible because the side data already has zeroed padding. Notice that the check for FF_MAX_EXTRADATA_SIZE has been dropped, because said constant is from libavcodec/internal.h. If libavcodec wanted to enforce this, it should do so in the extract_extradata BSF instead. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: reorder duration computation to avoid overflowMichael Niedermayer2020-07-01
| | | | | | | | Fixes: signed integer overflow: 8 * 9223372036854774783 cannot be represented in type 'long' Fixes: 23381/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4818340509122560 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: Print analyze duration and probesize when printing a ↵Michael Niedermayer2020-06-14
| | | | | | suggestion to increase them Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: Fix overflow in compute_pkt_fields().Dale Curtis2020-06-06
| | | | | Signed-off-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Find a fallback probe decoder that will also match a forced ↵Samuel Foss2020-06-04
| | | | | | | | | decoder's codec. Prevent codecpar->codec_id from getting out of sync with the codec instantiated for probing. Signed-off-by: Samuel Foss <sfoss@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/utils: fix start_time/duration dump if it is AV_NOPTS_VALUEJun Zhao2020-05-30
| | | | | | | | | | | | e,g: the command: ffprobe -show_format -i fate-suite/aac/foo.aac -loglevel 99 will dump the trace message as follow when start_time is AV_NOPTS_VALUE [aac @ 0x55bf8e1f3dc0] stream 0: start_time: -326791809695.818 duration: 2.174 [aac @ 0x55bf8e1f3dc0] format: start_time: -9223372036854.775 duration: 2.174 bitrate=120 kb/s after this fix, will dump the start_time with "NOPTS". Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/utils: Use av_sat_add64() when updating start_time by skip_samples.Dale Curtis2020-05-29
| | | | | | | Avoids overflow from fuzzed skip_samples values. Signed-off-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/id3v2: Remove unnecessary indirectionAndreas Rheinhardt2020-05-25
| | | | | | | | | ff_id3v2_parse_apic/chapters/priv/priv_dict all had a parameter extra_meta of type ID3v2ExtraMeta ** as if the functions wanted to make *extra_meta point to something else. But they don't, so just use an ID3v2ExtraMeta *. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: Set stream side-data size even without side-dataAndreas Rheinhardt2020-05-22
| | | | | Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: move is_intra_only() to header and rename to ff_is_intra_only()Limin Wang2020-05-06
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/utils: change the duration to int64_t for update_initial_durationsLimin Wang2020-05-01
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat: only allow a single bitstream filter when muxingMarton Balint2020-04-26
| | | | | | | | | | | | Current muxers only use a single bitstream filter, so there is no need to maintain code which operates on a list of bitstream filters. When multiple bitstream filters are needed muxers can simply use a list bitstream filter. If there is a use case in the future when different bitstream filters should be added at subsequent packets then a new API possibly involving reconfiguring the list bitstream filter can be added knowing the exact requirements. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/utils: Remove superfluous headersAndreas Rheinhardt2020-04-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | stdarg.h has been included in 780d7897a9c9295b43f1f0e9b49a11f99cd402c3 for ff_url_join(). This header became unnecessary when this function was moved into a separate file in df9f22d42b0905385629a9d368bb5a1eef2b45ef. libavutil/pixdesc.h has been included for av_get_pix_fmt_name() in 603b8bc2a109978c8499b06d2556f1433306eca7 and is unused since commit 2fb7501938b7103624c9bef740ca498258cacdab that removed the stuff belonging to FF_API_FORMAT_PARAMETERS. Notice that this file still uses AV_PIX_FMT_NONE and that therefore the header libavutil/pixfmt.h has been included (this header is included in pixdesc.h as well as also in libavutil/internal.h which is also included). libavutil/time_internal.h has been included for gmtime_r() in commit e7dd97b5d8cd6ea150446591f37a5946e8ab7cfb; it is unused since commit b72a7b96f84e5f16dd93b60668aecfda99442c71 which basically moved the code making use of gmtime_r() to libavutil/dict.c to use in avpriv_dict_set_timestamp(). audiointerleave.h has been added in c26e58e32cf430f060209e0d6088181f4426b3ce because of ff_interleave_compare_dts() (at that time the muxing code was not split from utils.c yet); said function became static in commit 101e1f6ff90c3365bfde05469ae26d2ee7f71f3e, making this header redundant. metadata.h has been mostly included for what now resides in libavutil/dict.h. The stuff that now resides in metadata.h has only been used briefly: From commits ed7694d8cf4633da444237f4df7efc48936419d2 to d60a9f52eb42dc76dea9996c8ba3567ae98a9a04. riff.h has been added in 45da8124a09d0ac5f9d8174884584c5f80309d0c because riff.h once contained declarations for (ff_)codec_get_tag(). This was changed in bfe5454cd238b16e7977085f880205229103eccb. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: Fix memleak when decoding subtitle in find_stream_infoAndreas Rheinhardt2020-04-20
| | | | | | | | | | | | | | | | | 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 b1511e00f6fefde6cb31b2e17f7812cfac1c8bd6 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>
* lavf/utils: stop using deprecated av_codec_next()Josh de Kock2020-04-20
| | | | Signed-off-by: Josh de Kock <josh@itanimul.li>
* avformat/utils: Make find_stream_info get side data from codec contextNicolas Gaullier2020-03-20
| | | | | | This will allow probing input coded side data, and also forwarding them to the output. Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avformat/utils: Don't trigger errors for multiple id3 tags.Dale Curtis2020-02-22
| | | | | | | | | | | | Such errors may make sense for specific formats, but general parsing logic shouldn't be treating these as errors regardless of the error recognition mode. Fixes loading of the following wave when using -err_detect explode: https://cs.chromium.org/chromium/src/third_party/blink/web_tests/external/wpt/webaudio/resources/4ch-440.wav Signed-off-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Fix integer overflow with complex time bases in ↵Michael Niedermayer2020-02-16
| | | | | | | | | | | avformat_find_stream_info() Fixes: signed integer overflow: 2045163756 * 2 cannot be represented in type 'int' Fixes: Ticket5132 Found-by: tsmith Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: avoid unsigned integer overflowsPaul B Mahol2020-02-16
|
* avformat/utils: make av_url_split search for hashmark as well to separate ↵Marton Balint2020-02-15
| | | | | | | | | | | hostname RFC 3986 states that the generic syntax uses the slash ("/"), question mark ("?"), and number sign ("#") characters to delimit components that are significant to the generic parser's hierarchical interpretation of an identifier. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/utils: Fix memleaks in avformat_open_input()Andreas Rheinhardt2020-02-15
| | | | | | | | | | | | | | | A demuxer might have allocated memory while reading the header. If reading the header was successfull and an error happens before returning (e.g. when queueing the attached pictures), the read_close function would have never been called, so that all those allocations would leak. This commit changes this. Furthermore, there would be even more memleaks if the error level was set to AV_EF_EXPLODE in case there is both metadata and id3v2 metadata. This has been fixed, too. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/utils: Fix undefined behavior in ff_configure_buffers_for_index()Dale Curtis2020-02-11
| | | | | | | | When e2_pts == INT64_MIN and e1_pts >= 0 the calculation of e2_pts - e1_pts will overflow an int64_t. Signed-off-by: Dale Curtis <dalecurtis@chromium.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: log corrupt packetsGyan Doshi2020-01-23
|
* Revert "avformat/utils: make ff_ntp_time() accept a timestamp as input argument"James Almer2020-01-16
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: make ff_ntp_time() accept a timestamp as input argumentJames Almer2020-01-15
| | | | | | Will be needed by the next patch. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Remove redundant save+restoreAndreas Rheinhardt2020-01-08
| | | | | | | | | | | | If the size of the input packet is zero, av_grow_packet() used to call av_new_packet() which would initialize the packet and (in particular) reset the pos field. This behaviour (which was never documented and arguably always contradicted the documented behaviour) was changed in 2fe04630. This means that it is unnecessary to save and restore the packet's position in append_packet_chunked(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Silence "string-plus-int" warning shown by clang.Carl Eugen Hoyos2020-01-06
| | | | libswscale/utils.c:89:42: warning: adding 'unsigned long' to a string does not append to the string [-Wstring-plus-int]
* avformat: Don't free old extradata before ff_alloc/get_extradataAndreas Rheinhardt2019-12-12
| | | | | | | | These functions already free it themselves before they allocate the new extradata. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: Forward errors where possibleAndreas Rheinhardt2019-12-12
| | | | | | | | | | It is not uncommon to find code where the caller thinks to know better what the return value should be than the callee. E.g. something like "if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM);". This commit changes several instances of this to instead forward the actual error. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavc/codec_desc: introduce AV_CODEC_PROP_INTRA_ONLY flag to audio codecYuki Tsuchiya2019-12-12
| | | | | | | Introduce AV_CODEC_PROP_INTRA_ONLY flag to audio codec as well as video codec to support non intra-only audio codec. Signed-off-by: Yuki Tsuchiya <Yuki.Tsuchiya@sony.com> Signed-off-by: James Almer <jamrial@gmail.com>
* libavformat/utils: Fix code indentationLinjie Fu2019-12-03
| | | | | | | Introduced since 077939626eeaa0c1364065414c18ab9b3a072281. Signed-off-by: Linjie Fu <linjie.fu@intel.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: Add max_probe_packets optionAndriy Gelman2019-11-03
| | | | | | | Allows user to set maximum number of buffered packets when probing a codec. It was a hard-coded parameter before this commit. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: call AVOutputFormat->deinit() when freeing the contextJames Almer2019-10-21
| | | | | | | | | | | | Despite the doxy stating that it's called when the muxer is destroyed, this was not true in practice. It's only called by av_write_trailer() and on init() failure. An AVFormatContext may be closed without writing the trailer if errors ocurred while muxing packets, so in order to prevent memory leaks, it should effectively be called when freeing the muxer. Signed-off-by: James Almer <jamrial@gmail.com>
* lavf/utils: support duration estimate method dumpJun Zhao2019-09-30
| | | | | | | | add new function duration_estimate_name to dump duration estimate method, it's will help to debug some duration issue. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>