aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
Commit message (Collapse)AuthorAgeFilesLines
* avformat/smacker: CosmeticsAndreas Rheinhardt2020-07-041-31/+29
| | | | | | Mainly reindentation. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Use st->priv_data to store arrayAndreas Rheinhardt2020-07-041-13/+3
| | | | | | It simplifies freeing and allows to completely remove smacker_read_close. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Don't read only one byte at a timeAndreas Rheinhardt2020-07-041-8/+5
| | | | | | | | Instead use ffio_read_size to read data into a buffer. Also check that the desired size was actually successfully read and combine the check with the check for reading the extradata. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Don't allocate arrays separatelyAndreas Rheinhardt2020-07-041-8/+4
| | | | | | | Allocating two arrays with the same number of elements together simplifies freeing them. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Improve timestampsAndreas Rheinhardt2020-07-041-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A Smacker file can contain up to seven audio tracks. Up until now, the pts for the i. audio packet contained in a Smacker frame was simply the end timestamp of the last i. audio packet contained in an earlier Smacker frame. The problem with this is that a Smacker stream need not contain data in every Smacker frame and so the current i. audio packet present may come from a different underlying stream than the last i. audio packet contained in an earlier frame. The sample hypnotix.smk* exhibits this. It has three audio tracks and the first of the three has a longer first packet, so that the audio for the first track is contained in only 235 packets contained in the first 235 Smacker frames; the end timestamp of this track is 166696 (about 7.56s at a timebase of 1/22050); the other two audio tracks both have 253 packets contained in the first 253 Smacker frames. Up until now, the 236th packet of the second track being the first audio packet in the 236th Smacker frame would get the end timestamp of the last first audio packet from the last Smacker frame containing a first audio packet and said last audio packet is the first audio packet from the 235th Smacker frame from the first audio track, so that the timestamp is 166696. In contrast, the 236th packet from the third track (whose packets contain the same number of samples as the packets from the second track) has a timestamp of 156116 (because its timestamp is derived from the end timestamp of the 235th packet of the second audio track). In the end, the second track ended up being 177360/22050 s = 8.044s long; in contrast, the third track was 166780/22050 s = 7.56s long which also coincided with the video. This commit fixes this by not using timestamps from other tracks for a packet's pts. *: https://samples.ffmpeg.org/game-formats/smacker/wetlands/hypnotix.smk Reviewed-by: Timotej Lazar <timotej.lazar@araneo.si> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Stop caching and copying audio framesAndreas Rheinhardt2020-07-041-51/+43
| | | | | | | | | | | | | | | | | | | | | The layout of a Smacker frame is as follows: For some frames, the beginning of the frame contained a palette for the video stream; then there are potentially several audio frames, followed by the data for the video stream. The Smacker demuxer used to read the palette, then cache every audio frame into a buffer (that gets reallocated to the desired size every time a frame is read into this buffer), then read and return the video frame (together with the palette). The cached audio frames are then returned by copying the data into freshly allocated buffers; if there are none left, the next frame is read. This commit changes this: At the beginning of a frame, the palette is read and cached as now. But audio frames are no longer cached at all; they are returned immediately. This gets rid of copying and also allows to remove the code for the buffer-to-AVStream correspondence. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Check audio frame sizeAndreas Rheinhardt2020-07-041-3/+3
| | | | | | | The first four bytes of smacker audio are supposed to contain the number of samples, so treat audio frames smaller than that as invalid. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Avoid potential inifinite loop on errorAndreas Rheinhardt2020-07-041-21/+27
| | | | | | | | | | | | | | | | | | | | | | | | | When reading a new frame, the Smacker demuxer seeks to the next frame position where it excepts the next frame; then it (potentially) reads the palette, the audio packets associated with the frame and finally the actual video frame. It is only at the end that the frame counter as well as the position where the next frame is expected get updated. This has a downside: If e.g. invalid data is encountered when reading the palette, the demuxer returns immediately (with an error) and if the caller calls av_read_frame again, the demuxer seeks to the position where it already was, reads the very same palette data again and therefore will return an error again. If the caller calls av_read_frame repeatedly (say, until a packet is received or until EOF), this meight become an infinite loop. This could also happen if e.g. the size of one of the audio frames was invalid or if the frame size was gigantic. This commit changes this by skipping a frame if it turns out to be invalid or an error happens otherwise. This ensures that EOF will be returned eventually in the above scenario. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smacker: Don't increase packet counter prematurelyAndreas Rheinhardt2020-07-041-5/+4
| | | | | | | | | | | | | | | | | | | | | | The Smacker demuxer buffers audio packets before it outputs them, but it increments the counter of buffered packets prematurely: If allocating the audio buffer fails, an error (most likely AVERROR(ENOMEM)) is returned. If the caller decides to call av_read_frame() again, the next call will take the codepath for returning already buffered audio packets and it will fail (because the buffer that ought to be allocated isn't) without decrementing the number of supposedly buffered audio packets (it doesn't matter whether there would be enough memory available in subsequent calls). Depending on the caller's behaviour this is potentially an infinite loop. This commit fixes this by only incrementing the number of buffered audio packets after having successfully read them and unconditionally reducing said number when outputting one of them. It also changes the semantics of the curstream variable: It is now the number of currently buffered audio packets whereas it used to be the index of the last audio stream to be read. (Index refers to the index in the array of buffers, not to the stream index.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* libavformat/img2dec: Added pgx demuxerGautam Ramakrishnan2020-07-033-1/+11
| | | | | | | This patch adds support to demux pgx file format. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/icecast: Add option to use TLS connectionMarvin Scholz2020-07-021-1/+5
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/hlsenc: simplify code to pass s directlyLimin Wang2020-07-021-6/+2
| | | | | Suggested-by: Nicolas George <george@nsup.org> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsenc: fix av_bprint_finalize() usageLimin Wang2020-07-021-2/+2
| | | | | | | Don't need to do double check by the description of the API. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsenc: use proper error codesLimin Wang2020-07-021-6/+8
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/au: check return value of au_read_annotation()Limin Wang2020-07-021-1/+4
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/au: check return value of av_bprint_finalize()Limin Wang2020-07-021-2/+4
| | | | | Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/dump: add a \n for end of ERROR logLimin Wang2020-07-021-6/+6
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hevc: Defer initializations in ff_isom_write_hvcc()Andreas Rheinhardt2020-07-021-10/+8
| | | | | | | Saves initialization of an HEVCDecoderConfigurationRecord when the data is already in ISOBMFF-format or if it is plainly invalid. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mov: fix memleaksZhao Zhili2020-07-011-4/+3
| | | | | | | | Fix two cases of memleaks: 1. The leak of dv_demux 2. The leak of dv_fctx upon dv_demux allocate failure Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* libavformat/mov: Fix memleaks when demuxing DV audioAndreas Rheinhardt2020-07-011-10/+13
| | | | | | | | | | | | | | | | | | | | | The code for demuxing DV audio predates the introduction of refcounted packets and when the latter was added, changes to the former were forgotten. This meant that when avpriv_dv_produce_packet initialized the packet containing the AVBufferRef, the AVBufferRef as well as the underlying AVBuffer leaked; the actual packet data didn't leak: They were directly freed, but not via their AVBuffer's free function. https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket4671/dir1.tar.bz2 contains samples for this (enable_drefs needs to be enabled for them). Moreover, errors in avpriv_dv_produce_packet were ignored; this has been changed, too. Furthermore, in the hypothetical scenario that the track has a palette, this would leak, too, so reorder the code so that the palette code appears after the DV audio code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/utils: reorder duration computation to avoid overflowMichael Niedermayer2020-07-011-1/+1
| | | | | | | | 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/hls: Pass a copy of the URL for probingMichael Niedermayer2020-07-011-2/+4
| | | | | | | | | | The segments / url can be modified by the io read when reloading This may be an alternative or additional fix for Ticket8673 as a further alternative the reload stuff could be disabled during probing Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/isom: add comment to mov_mdhd_language_mapZhao Zhili2020-07-011-19/+139
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/dump: Use intermediate pointer for access to programs arrayAndreas Rheinhardt2020-06-301-7/+8
| | | | | | | Improves readability. Reviewed-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dump: Use const where appropriateAndreas Rheinhardt2020-06-301-43/+48
| | | | | | | | Also switch to using a pointer to access stream side data instead of copying the stream's AVPacketSideData. Reviewed-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavf/movenc: Use a dynamic buffer when writing the mfra boxDerek Buitenhuis2020-06-281-12/+26
| | | | | | | | | | | When doing streamed output, with e.g. +dash, if the mfra box ended up being larger than the AVIOContext write buffer, the (unchecked) seeking back to update the box size would silently fail and produce an invalid mfra box. This is similar to how other boxes are written in fragmented mode. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
* avformat/smoothstreaming: Add deinit functionAndreas Rheinhardt2020-06-271-27/+16
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/smoothstreaming: Don't write trailer of subcontextAndreas Rheinhardt2020-06-271-4/+0
| | | | | | | | | | Nothing written in avformat_write_trailer() for the submuxers will be output anyway because the AVIOContexts used for actual output have been closed before the call. Writing the trailer of the subcontext has probably only been done in order to free the memory allocated by the submuxer. And this job has been taken over by the deinit functions. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mvdec: Fix integer overflow with billions of channelsMichael Niedermayer2020-06-271-2/+2
| | | | | | | | Fixes: signed integer overflow: 1394614304 * 2 cannot be represented in type 'int' Fixes: 23491/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5697377020411904 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/avc, mxfenc: Avoid allocation of H264 SPS structure, fix memleakAndreas Rheinhardt2020-06-263-25/+21
| | | | | | | | | | | | | | | | | | | | | | Up until now, ff_avc_decode_sps would parse a SPS and return some properties from it in a freshly allocated structure. Yet said structure is very small and completely internal to libavformat, so there is no reason to use the heap for it. This commit therefore changes the function to return an int and to modify a caller-provided structure. This will also allow ff_avc_decode_sps to return better error codes in the future. It also fixes a memleak in mxfenc: If a packet contained multiple SPS, only the SPS structure belonging to the last SPS would be freed, the other ones would leak when the pointer is overwritten to point to the new SPS structure. Of course, without allocations there are no leaks. This is Coverity issue #1445194. Furthermore, the SPS structure has been renamed from H264SequenceParameterSet to H264SPS in order to avoid overlong lines. Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/avc: Don't use ff_ prefix for static functionAndreas Rheinhardt2020-06-261-2/+2
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/webvttdec: Accept \r as newlineAndreas Rheinhardt2020-06-261-1/+1
| | | | | | | | | | | | | After parsing the end timestamp of a WebVTT cue block, the current code skips everything after the start of the timestamp that is not a \t, ' ' or \n and treats what is next as the start of a WebVTT cue settings list. Yet if there is no such list, but a single \r, this will skip a part of the cue payload (namely everything until the first occurence of \t, ' ' or \n) and treat what has not been skipped as the beginning of the WebVTT cue settings list that extends until the next \r or \n (or the end). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/av1: Avoid using dynamic buffer when assembling av1cAndreas Rheinhardt2020-06-261-11/+7
| | | | | | | | | Given that AV1 only has exactly one sequence header, it is unnecessary to copy the content of said sequence header into an intermediate dynamic buffer; instead the sequence header can be copied from where it is in the input buffer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/microdvddec: skip malformed lines without frame number.Michael Niedermayer2020-06-251-1/+5
| | | | | | | | | Fixes: signed integer overflow: 1 - -9223372036854775808 cannot be represented in type 'long' Fixes: 23490/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5133490093031424 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>
* avformat/libamqp: add option delivery_modeLevis Florian2020-06-241-1/+5
| | | | | Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com> Signed-off-by: Levis Florian <levis.florian@gmail.com>
* avformat/smoothstreaming: Forward errors from copying white/blacklistsAndreas Rheinhardt2020-06-241-1/+3
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/sccdec: Avoid variable that is always zeroAndreas Rheinhardt2020-06-221-2/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/pjsdec: Avoid variable that is always zeroAndreas Rheinhardt2020-06-221-2/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mpl2dec: Avoid variable that is always zeroAndreas Rheinhardt2020-06-221-2/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mov: CosmeticsAndreas Rheinhardt2020-06-221-60/+54
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mov: Avoid allocation when reading ddts atomAndreas Rheinhardt2020-06-221-13/+4
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mov: Use ffio_read_size where appropriateAndreas Rheinhardt2020-06-221-22/+12
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mov: Avoid allocation+copy when moving extradataAndreas Rheinhardt2020-06-221-5/+2
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mov: Read attached pics directly into st->attached_picAndreas Rheinhardt2020-06-221-8/+4
| | | | | | | | | | Given that av_get_packet returns a blank packet on error, the only difference to the current approach (that uses intermediate AVPackets on the stack) is that st->attached_pic will be properly initialized on error (i.e. the timestamps are AV_NOPTS_VALUE) whereas right now st->attached_pic is only zeroed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/mov: Check earlier whether reel_name string is emptyAndreas Rheinhardt2020-06-221-7/+4
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec, avformat: Remove unnecessary initializations of side data sizeAndreas Rheinhardt2020-06-229-12/+10
| | | | | Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/avformat: Improve documentation of av_stream_get_side_dataAndreas Rheinhardt2020-06-221-1/+2
| | | | | | | | Document that it also sets the size in case the desired side data is absent (if the pointer has been supplied). Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/flvdec: CosmeticsAndreas Rheinhardt2020-06-221-15/+10
| | | | | Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashenc: Calculate average bitrate for adaptation sets in static ↵Przemysław Sobala2020-06-221-8/+16
| | | | | | | | | manifest If stream's bitrate is not specified: - for static manifest: an average bitrate will be calculated and used, - for dynamic manifest: first segment's bitrate will be calculated and used, as before, for bandwidth setting in adaptation sets.
* Revert "avformat/dashenc: use AVStream timebase when computing missing bitrate"Przemysław Sobala2020-06-221-1/+1
| | | | This reverts commit 2a9ffd89fcb09bd69b2130da039ad2caba79cf33 as duration is always in AV_TIME_BASE units