summaryrefslogtreecommitdiff
path: root/libavformat
Commit message (Collapse)AuthorAge
* avformat: add bonk demuxerPaul B Mahol2022-09-12
|
* avformat/riffdec: don't unconditionally overwrite WAVEFORMATEXTENSIBLE layoutJames Almer2022-09-11
| | | | | | | | Do it only if the value conflicts with the previous channels value. Fixes ticket #9912 Signed-off-by: James Almer <jamrial@gmail.com>
* libavformat/hls: Free keysMichael Niedermayer2022-09-10
| | | | | | | | | Fixes: memleak Fixes: 50703/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-6399058578636800 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Steven Liu <lingjiujianke@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: don't read duration from mvhd atomJames Almer2022-09-08
| | | | | | | | | | | | | | | This duration is equal to the longest duration in all track's tkhd atoms, which may be comprised of the sum of all edit lists in each track. Empty edit lists in tracks represent start_time, and the actual media duration is stored in the mdhd atom. This change lets the generic demux code derive the longest track duration taken from mdhd atoms, so the correct duration and start_time combination will be reported. Should fix ticket #9775. Reviewed-by: zhilizhao(赵志立) <quinkblack@foxmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/imfdec: check if Asset/Id exists before trying to read itPierre-Anthony Lemieux2022-09-07
| | | | | | Fixes Coverity issue #1512406 Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Write CodecDelay for codecs != OpusAndreas Rheinhardt2022-09-05
| | | | | | | | | The field is not specific to Opus. The mp2fixed encoder signals initial_padding and is used by both the matroska-encoding-delay test as well as the lavf-mkv tests which necessitated several FATE ref changes. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Use custom min timestampAndreas Rheinhardt2022-09-05
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mux: Allow muxers to set custom min timestampAndreas Rheinhardt2022-09-05
| | | | | | | | | | | | | | Matroska requires pts to be >= 0 with a slight exception: It has a mechanism to deal with codec delay, i.e. with the data added at the beginning that does not correspond to actual input data and should be discarded by the player. Only the audio actually intended to be output needs to have a timestamp >= 0. In order to avoid unnecessary timestamp shifting, this patch allows muxers to inform the shifting code about this so that it can take it into account. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Actually apply timestamp offset for OpusAndreas Rheinhardt2022-09-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Matroska generally requires timestamps to be nonnegative, but there is an exception: Data that corresponds to encoder delay and is not supposed to be output anyway can have a negative timestamp. This is achieved by using the CodecDelay header field: The demuxer has to subtract this value from the raw (nonnegative) timestamps of the corresponding track. Therefore the muxer has to add this value first to write this raw timestamp. Support for writing CodecDelay has been added in FFmpeg commit d92b1b1babe69268971863649c225e1747358a74 and in Libav commit a1aa37dd0b96710d4a17718198a3f56aea2040c1. The former simply wrote the header field and did not apply any timestamp offsets, leading to desynchronisation (if one uses multiple tracks). The latter applied it at two places, but not at the one where it actually matters, namely in mkv_write_block(), leading to the same desynchronisation as with the former commit. It furthermore used the wrong stream timebase to convert the delay to the stream's timebase, as the conversion used the timebase from before avpriv_set_pts_info(). When the latter was merged in 82e4f39883932c1b1e5c7792a1be12dec6ab603d, it was only done in a deactivated state that still did not offset the timestamps when muxing due to "assertion failures and av sync errors". a1aa37dd0b96710d4a17718198a3f56aea2040c1 made it definitely more likely to run into assertion failures (namely if the relative block timestamp doesn't fit into an int16_t). Yet all of the above issues have been fixed (in commits 962d63157322466a9a82f9f9d84c1b6f1b582f65, 5d3953a5dcfd5f71391b7f34908517eb6f7e5146 and 4ebeab15b037a21f195696cef1f7522daf42f3ee. This commit therefore enables applying CodecDelay, fixing ticket #7182. There is just one slight regression from this: If one has input with encoder delay where the first timestamp is negative, but the pts of the part of the data that is actually intended to be output is nonnegative, then the timestamps will currently by default be shifted to make them nonnegative before they reach the muxer; the muxer will then ensure that the shifted timestamps are retained. Before this commit, the muxer did not ensure this; instead the timestamps that the demuxer will output were shifted and if the first timestamp of the actually intended output was zero before shifting, then this unintentional shift just cancels the shift performed before the packet reached the muxer. (But notice that this only applies if all the tracks use the same CodecDelay, or the relative sync between tracks will be impaired.) This happens in the matroska-opus-remux and matroska-ogg-opus-remux FATE tests. Future commits will forward the information that the Matroska muxer has a limited capability to handle negative timestamps so that the shifting in libavformat can take advantage of it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't override samplerate for CodecDelayAndreas Rheinhardt2022-09-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opus can be decoded to multiple samplerates (namely 48kHz, 24KHz, 16Khz, 12 KHz and 8Khz); libopus as well as our encoder wrapper support these sample rates. The OpusHead contains a field for this original samplerate. Yet the pre-skip (and the granule-position in the Ogg-Opus mapping in general) are always in the 48KHz clock, irrespective of the original sample rate. Before commit c3c22bee6362737cf290929b7f31df9fb88da983, our libopus encoder was buggy: It did not account for the fact that the pre-skip field is always according to a 48kHz clock and wrote a too small value in case one uses the encoder with a sample rate other than 48kHz; this discrepancy between CodecDelay and OpusHead led to Firefox rejecting such streams. In order to account for that, said commit made the muxer always use 48kHz instead of the actual sample rate to convert the initial_padding (in samples in the stream's sample rate) to ns. This meant that both fields are now off by the same factor, so Firefox was happy. Then commit f4bdeddc3cab807e43e0450744dfe9a45661e1d7 fixed the issue in libopusenc; so the OpusHead is correct, but the CodecDelay is still off*. This commit fixes this by effectively reverting c3c22bee6362737cf290929b7f31df9fb88da983. *: Firefox seems to no longer abort when CodecDelay and OpusHead are off. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Only write DiscardPadding if nonzeroAndreas Rheinhardt2022-09-05
| | | | | | | | | | | | | | | | | It is possible for the trailing padding to be zero, namely e.g. if the AV_PKT_DATA_SKIP_SAMPLES side data is used for leading padding. Matroska supports this (use a negative DiscardPadding), but players do not; at least Firefox refuses to play such a file. So for now only write DiscardPadding if it is trailing padding and nonzero. The fate-matroska-ogg-opus-remux was affected by this. (I wish CodecDelay would not exist and DiscardPadding would be used to instead trim the codec delay away (with the Block timestamp corresponding to the time at which the actually output audio is output).) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavf/mov: avoid leaks with multiple dv-audio streamsAnton Khirnov2022-09-05
|
* lavf/dv: do not update AVCodecParameters.sample_rate while demuxingAnton Khirnov2022-09-05
| | | | | | Demuxers are not allowed to do this and few callers, if any, will handle this correctly. Send the AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE side data instead.
* lavf/dv: set audio bitrate only at stream creationAnton Khirnov2022-09-05
| | | | | | Demuxers are not supposed to update AVCodecParameters after the stream was seen by the caller. This value is not important enough to support dynamic updates for.
* lavf/dv: set non-changing AVStream fields only onceAnton Khirnov2022-09-05
|
* lavf/dv: forward errors from avformat_new_stream()Anton Khirnov2022-09-05
|
* lavf/dv: return a meaningful error code from avpriv_dv_produce_packet()Anton Khirnov2022-09-05
|
* lavf/dv: make returning the video packet optionalAnton Khirnov2022-09-05
| | | | | | | | | | The mov demuxer only returns DV audio, video packets are discarded. It first reads the data to be parsed into a packet. Then both this packet and the pointer to its data are passed together to avpriv_dv_produce_packet(), which parses the data and partially overwrites the packet. This is confusing and potentially dangerous, so just pass NULL and avoid pointless packet modification.
* lavc/dv: rename constants to follow our naming conventionsAnton Khirnov2022-09-05
| | | | CamelCase for enum tags, ALL_CAPS for enum values.
* lavf/dv: always provide avpriv_dv_* symbolsAnton Khirnov2022-09-05
| | | | They are used from libavdevice.
* lavf/dv: remove DVMuxContext declaration from dv.hAnton Khirnov2022-09-05
| | | | | DVMuxContext is only used inside dvenc.c, there is no reason for it to be visible outside of that file.
* avformat/avisynth: reindentStephen Hutchinson2022-09-04
| | | | Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
* avformat/avisynth: implement avisynth_flags optionStephen Hutchinson2022-09-04
| | | | Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
* avformat/avisynth: read _SARNum/_SARDen from frame propertiesStephen Hutchinson2022-09-04
| | | | | | | Initialized to 1:1, but if the script sets these properties, it will be set to those instead (0:0 disables it, apparently). Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
* avutil/internal: Move avpriv-file API to a header of its ownAndreas Rheinhardt2022-09-03
| | | | | | | It is not used by the large majority of files that include lavu/internal.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil/dict: Move avpriv_dict_set_timestamp() to a header of its ownAndreas Rheinhardt2022-09-03
| | | | | | | It is used almost nowhere, so it needn't be auto-included almost everywhere. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/flac: Don't use bytestream API unnecessarilyAndreas Rheinhardt2022-09-02
| | | | | | | It makes no sense here, as flac_parse_block_header() is not even supposed to advance the caller's pointer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hevc: Reindent after the previous commitAndreas Rheinhardt2022-09-02
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hevc: Fix crash on allocation failure, avoid allocationsAndreas Rheinhardt2022-09-02
| | | | | | | | | | | | | | | | | | The HEVC code currently uses an array of arrays of NALUs; one such array contains all the SPS NALUs, one all PPS NALUs etc. The array of arrays is grown dynamically via av_reallocp_array(), but given that the latter function automatically frees its buffer upon reallocation error, it may only be used with PODs, which this case is not. Even worse: While the pointer to the arrays is reset, the counter for the number of arrays is not, leading to a segfault in hvcc_close(). Fix this by avoiding the allocations of the array of arrays altogether. This is easily possible because their number is bounded (by five). Furthermore, as a byproduct we can ensure that the code always produces the recommended ordering of VPS-SPS-PPS-SEI (which was not guaranteed before). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/asfdec_o: limit recursion depth in asf_read_unknown()Michael Niedermayer2022-08-31
| | | | | | | | | | The threshold of 5 is arbitrary, both smaller and larger should work fine Fixes: Stack overflow Fixes: 50603/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-6049302564175872 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/sdp: Add missing version.h includeCarl Eugen Hoyos2022-08-31
| | | | Fixes lavf version output in SDP, regression since 4eb9232c
* avformat/mov: Check count sums in build_open_gop_key_points()Michael Niedermayer2022-08-28
| | | | | | | | | | | Fixes: ffmpeg.md Fixes: Out of array access Fixes: CVE-2022-2566 Found-by: Andy Nguyen <theflow@google.com> Found-by: 3pvd <3pvd@google.com> Reviewed-by: Andy Nguyen <theflow@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* libavformat/iff: Check for overflow in body_end calculationMichael Niedermayer2022-08-28
| | | | | | | | Fixes: signed integer overflow: -6322983228386819992 - 5557477266266529857 cannot be represented in type 'long' Fixes: 50112/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-6329186221948928 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/avidec: Prevent entity expansion attacksMichael Niedermayer2022-08-28
| | | | | | | Fixes: Timeout Fixes no testcase, this is the same idea as similar attacks against XML parsers Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/tests/imf: Test ff_imf_parse_cpl_from_xml_dom cleanup on errorAndreas Rheinhardt2022-08-27
| | | | | | | Improves the test; also should fix Coverity issue #1512408. Reviewed-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/imf_cpl: Check the right variableAndreas Rheinhardt2022-08-25
| | | | | | | Fixes Coverity issue #1512407. Reviewed-by: Pierre-Anthony Lemieux <pal@sandflow.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/riff: add support for ICMV filesPaul B Mahol2022-08-25
|
* avformat/wavdec: fix the ID3 metadata obtained in WAV format's missingWujian(Chin)2022-08-24
| | | | | | | Fixes ticket #9848. Signed-off-by: wujian_nanjing <wujian2@huawei.com> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/os_support: Include stdint.h for int64_tAndreas Rheinhardt2022-08-24
| | | | | | Fixes checkheaders for Windows targets. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/subviewerdec: Make read_ts() more flexibleMichael Niedermayer2022-08-23
| | | | | | | Fixes: signed integer overflow: -1948269928 * 10 cannot be represented in type 'int' Fixes: 49451/clusterfuzz-testcase-minimized-ffmpeg_dem_SUBVIEWER_fuzzer-6344614822412288 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
* lavf: deprecate av_stream_get_end_pts()Anton Khirnov2022-08-22
| | | | | | | | | | | According to its documentation it returns "pts of the last muxed packet + its duration", but the value it actually returns right now is (possibly guessed) dts after muxer-internal bitstream filtering (if any). This function was added for ffmpeg.c, but it is not used there anymore. Since the value it returns is ill-defined and so inappropriate for any serious use, deprecate it.
* mov: Compare frag times in correct time base when seeking a stream without a ↵Derek Buitenhuis2022-08-19
| | | | | | | | | | | | | | | | corresponding sidx Some muxers, such as GPAC, create files with only one sidx, but two streams muxed into the same fragments pointed to by this sidx. Prevously, in such a case, when we seeked in such files, we fell back to, for example, using the sidx associated with the video stream, to seek the audio stream, leaving the seekhead in the wrong place. We can still do this, but we need to take care to compare timestamps in the same time base. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avformat/mov: fix encryption index in the case of multiple trunZhao Zhili2022-08-16
| | | | | | | | | | frag_stream_info->index_entry isn't the first sample/trun index. cenc.frag_index_entry_base failed to catch the case since current_index > 0. Fix ticket #9807. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avformat/mov: fix frag_index.current out of syncZhao Zhili2022-08-16
| | | | | | | | | frag_index.current is used by cenc_filter, and is updated inside mov_read_moof. It can out of sync regarding to mov_read_packet. Partly fix ticket #9807. Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* ipfsgateway: Remove default gatewayDerek Buitenhuis2022-08-15
| | | | | | | A gateway can see everything, and we should not be shipping a hardcoded default from a third party company; it's a security risk. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* configure: always enable gnu_windres if availableTimo Rothenpieler2022-08-13
| | | | | Use the appropiate Makefile variable to ensure the resource file is only built into shared libraries instead.
* avformat/avisynth: add missing avs_release_video_frameStephen Hutchinson2022-08-12
| | | | | | | | | The AviSynth C API requires using avs_release_video_frame whenever avs_get_frame has been used, but the recent addition of frameprop reading to the demuxer was missing this in avisynth_create_stream_video. Signed-off-by: Stephen Hutchinson <qyot27@gmail.com>
* avformat/imfdec: preserve stream informationPierre-Anthony Lemieux2022-08-12
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: refactor ff_stream_encode_params_copy() to stream_params_copy()Pierre-Anthony Lemieux2022-08-12
| | | | | | Addresses http://ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299726.html Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mov: Rework the AVIF parser to handle multiple itemsVignesh Venkatasubramanian2022-08-09
| | | | | | | | | | | | Stores the item ids of all the items found in the file and processes the primary item at the end of the meta box. This patch does not change any behavior. It sets up the code for parsing alpha channel (and possibly images with 'grid') in follow up patches. Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com> Signed-off-by: James Zern <jzern@google.com>