Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-05-06avformat/utils: move is_intra_only() to header and rename to ff_is_intra_only()Limin Wang
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-06avformat/rtmpproto: use av_reallocp_array()Limin Wang
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-06avformat/smoothstreamingenc: use av_reallocp_array()Limin Wang
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-06avformat/matroskaenc: Check allocations implicit in dynamic buffersAndreas Rheinhardt
Failures of the allocations that happen under the hood when using dynamic buffers are usually completely unchecked and the Matroska muxer is no exception to this. The API has its part in this, because there is no documented way to actually check for errors: The return value of both avio_get_dyn_buf() as well as avio_close_dyn_buf() is only documented as "the length of the byte buffer", so that using this to return errors would be an API break. Therefore this commit uses the only reliable way to check for errors with avio_get_dyn_buf(): The AVIOContext's error flag. (This is one of the advantages of avio_get_dyn_buf(): By not destroying the AVIOContext it is possible to inspect this value.) Checking whether the size or the pointer vanishes is not enough as it does not check for truncated output (the dynamic buffer API is int based and so has to truncate the buffer even when enough memory would be available; it's current actual limit is even way below INT_MAX). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-06avformat/matroskaenc: Simplify writing bufferAndreas Rheinhardt
If one already has the contents of a master elements in a buffer of known size, then writing a EBML master element is no different from writing an EBML binary element. It is overtly complicated to use start/end_ebml_master() as these functions first write an unkown-length size field of the appropriate length, then write the buffer's contents, followed by a seek to the length field to overwrite it with the real size (obtained via avio_tell() although it was already known in advance), followed by another seek to the previous position. Just use put_ebml_binary() instead. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-06avformat/matroskaenc: Avoid dynamic buffer when writing ColourAndreas Rheinhardt
There is a good upper bound for the maximum length of the Colour master element; it is therefore unnecessary to use a dynamic buffer for it. A simple buffer on the stack is enough. This commit implements this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-06avformat/matroskaenc: Unify writing level 1 elements preliminarilyAndreas Rheinhardt
The Matroska muxer updates several header elements when the output is seekable; if unseekable, the buffer containing the contents of the element is immediately freed after writing. Before this commit, there were three places doing exactly the same: Checking whether the output is seekable and calling the function that writes and frees or the function that just writes the EBML master. This has been unified; adding SeekHead entries for these elements has been unified, too. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-06avformat/matroskaenc: Move adding SeekEntry into end_ebml_master_crc32()Andreas Rheinhardt
Up until now, SeekEntries were already added before start_ebml_master_crc32() was even called and before we were actually sure that we really write the element the SeekHead references: After all, we might also error out later; and given that the allocations implicit in dynamic buffers should be checked, end_ebml_master_crc32() will eventually have to return errors itself, so that it is the right place to add SeekHead entries. The earlier behaviour is of course a remnant of the time in which start_ebml_master_crc32() really did output something, so that the position before start_ebml_master_crc32() needed to be recorded. Erroring out later is also not as dangerous as it seems because in this case no SeekHead will be written (if it happened when writing the header, the whole muxing process would abort; if it happened when writing the trailer (when writing chapters not available initially), writing the trailer would be aborted and no SeekHead containing the bogus chapter entry would be written). This commit does not change the way the SeekEntries are added for those elements that are output preliminarily; this is so because the SeekHead is written before those elements are finally output and doing it otherwise would increase the amount of seeks. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-06avformat/hlsenc: Improve checks for invalid stream mappingsAndreas Rheinhardt
The mapping of streams to the various variant streams to be created by the HLS muxer is roughly as follows: Space and tab separate variant stream group maps while the entries in each variant stream group map are separated by ','. The parsing process of each variant stream group proceeded as follows: At first the number of occurences of "a:", "v:" and "s:" in each variant stream group is calculated so that one can can allocate an array of streams with this number of entries. Then each entry is checked and the check for stream numbers was deficient: It did check that there is a number beginning after the ":", but it did not check that the number extends until the next "," (or until the end). This means that an invalid variant stream group like v:0_v:1 will not be rejected; the problem is that the variant stream in this example is supposed to have two streams associated with it (because it contains two "v:"), yet only one stream is actually associated with it (because there is no ',' to start a second stream specifier). This discrepancy led to segfaults (null pointer dereferencing) in the rest of the code (when the nonexistent second stream associated to the variant stream was inspected). Furthermore, this commit also removes an instance of using atoi() whose behaviour on a range error is undefined. Fixes ticket #8652. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-06lavf/dashdec: support larger manifestsrcombs
2020-05-06avformat/url: check url root node when rel include double dot and trim ↵Steven Liu
double dot fix ticket: 8625 and add testcase into url for double dot corner case Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2020-05-06avformat/hlsenc: resend full url of the init fragment mp4Steven Liu
fix ticket: 8651 because the init fragment mp4 file name is without base url name, so just modify it use the full url which splice after init function. Tested-by: matclayton Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
2020-05-06libavformat/hlsenc: Allow usage of 'periodic-rekey' with multi-variant streamsYaroslav Pogrebnyak
This patch adds possibility to use 'periodic-rekey' option with multi-variant streams to hlsenc muxer. All streams variants use parameters from the same key_info_file. There are 2 sets of encryption options that kind of overlaps and add complexity, so I tried to do the thing without changing too much code. There is a little duplication of the key_file, key_uri, iv_string, etc in the VariantStream since we copy it from hls to each variant stream, but generally all the code remains the same to minimise appearing of unexpected bugs. Refactoring could be done as a separate patch then as needed. Signed-off-by: Yaroslav Pogrebnyak <yyyaroslav@gmail.com>
2020-05-06avformat/hlsenc: compute segment duration use current pts minus last segment ↵Steven Liu
end pts segment duration is using vs duration which compute by frame per second, that can not fix problem of VFR video stream, so compute the duration when split the segment, set the segment target duration use current packet pts minus the prev segment end pts.. Reported-by: Zhao Jun <barryjzhao@tencent.com> Reviewed-by: Zhao Jun <barryjzhao@tencent.com> Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
2020-05-05avformat: add demuxer for Pro Pinball Series' SoundbanksZane van Iperen
Adds support for the soundbank files used by the Pro Pinball series of games. https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2020-May/262094.html Signed-off-by: Zane van Iperen <zane@zanevaniperen.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-05avformat/nutenc: Write size into right dynamic bufferAndreas Rheinhardt
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-05avformat/aviobuf, nutenc: Move ff_puv_v, ff_get_v_length to nutenc.cAndreas Rheinhardt
and make it static again. These functions have been moved from nutenc to aviobuf and internal.h in f8280ff4c00eeaa245085fa9691035203abd168c in order to use them in a forthcoming patch in utils.c. Said patch never happened, so this commit moves them back and makes them static, effectively reverting said commit as well as f8280ff4c00eeaa245085fa9691035203abd168c (which added the ff-prefix to these functions). Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-05avformat/nutenc: Add goto fail in nut_write_headers()Andreas Rheinhardt
It allows to combine several ffio_free_dyn_buf(). Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-05avformat/nutenc: Reuse dynamic buffers when possibleAndreas Rheinhardt
NUT uses variable-length integers in order to for length fields. Therefore the NUT muxer often writes data into a dynamic buffer in order to get the length of it, then writes the length field using the fewest amount of bytes needed. To do this, a new dynamic buffer was opened, used and freed for each element which involves lots of allocations. This commit changes this: The dynamic buffers are now resetted and reused. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-05libavformat/nutenc: Remove redundant function parameterAndreas Rheinhardt
calculate_checksum in put_packet() is always 1. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-05avformat/mxfdec: reindent codeLimin Wang
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-04avformat/matroskadec: Free right buffer on errorAndreas Rheinhardt
Since commit 979b5b89594c7628bd846c63198cb64ef9d81d16, reverting the Matroska ContentCompression is no longer done inside matroska_parse_frame() (the function that creates AVPackets out of the parsed data (unless we are dealing with certain codecs that need special handling)), but instead in matroska_parse_block(). As a consequence, the data that matroska_parse_frame() receives is no longer always owned by an AVBuffer; it is owned by an AVBuffer iff no ContentCompression needed to be reversed; otherwise the data is independently allocated and needs to be freed on error. Whether the data is owned by an AVBuffer or not is indicated by a variable buf of type AVBufferRef *: If it is NULL, the data is independently allocated, if not it is owned by the underlying AVBuffer (and is used to avoid copying the data when creating the AVPackets). Because the allocation of the buffer holding the uncompressed data happens outside of matroska_parse_frame() (if a ContentCompression needs to be reversed), the data is passed as uint8_t ** in order to not leave any dangling pointers behind in matroska_parse_block() should the data need to be freed: In case of errors, said uint8_t ** would be av_freep()'ed in case buf indicated the data to be independently allocated. Yet there is a problem with this: Some codecs (namely WavPack and ProRes) need special handling: Their packets are only stored in Matroska in a stripped form to save space and the demuxer reconstructs full packets. This involved allocating a new, enlarged buffer. And if an error happens when trying to wrap this new buffer into an AVBuffer, this buffer needs to be freed; yet instead the given uint8_t ** (holding the uncompressed, yet still stripped form of the data) would be freed (av_freep()'ed) which certainly leads to a memleak of the new buffer; even worse, in case the track does not use ContentCompression the given uint8_t ** must not be freed as the actual data is owned by an AVBuffer and the data given to matroska_parse_frame() is not the start of the actual allocated buffer at all. Both of these issues are fixed by always freeing the current data in case it is independently allocated. Furthermore, while it would be possible to track whether the pointer from matroska_parse_block() needs to be reset or not, there is no gain in doing so, as the pointer is not used at all afterwards and the sematics are clear: If the data passed to matroska_parse_frame() is independently allocated, then ownership of the data passes to matroska_parse_frame(). So don't pass the data via uint8_t **. Fixes Coverity ID 1462661 (the issue as described by Coverity is btw a false positive: It thinks that this error can be triggered by ProRes with a size of zero after reconstructing the original packets, but the reconstructed packets can't have a size of zero). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-03avformat/matroskaenc: Check mimetypes earlierAndreas Rheinhardt
This avoids errors lateron after the file header has already been partially written. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-03avformat/matroskaenc: Fix memleak upon encountering bogus chapterAndreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-03avformat/matroskaenc: Make sure UIDs of delayed chapters are != 0Andreas Rheinhardt
This has previously only been checked if the chapters were initially available, but not if they were only written in the trailer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-03avformat/vorbiscomment: Switch to AVIOContext from bytestream APIAndreas Rheinhardt
Up until now ff_vorbiscomment_write() used the bytestream API to write VorbisComments. Therefore the caller had to provide a sufficiently large buffer to write the output. Yet two of the three callers (namely the FLAC and the Matroska muxer) actually want the output to be written via an AVIOContext; therefore they allocated buffers of the right size just for this purpose (i.e. they get freed immediately afterwards). Only the Ogg muxer actually wants a buffer. But given that it is easy to wrap a buffer into an AVIOContext this commit changes ff_vorbiscomment_write() to use an AVIOContext for its output. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-03avformat/vorbiscomment: Replace AVDictionary ** by const AVDictionary *Andreas Rheinhardt
ff_vorbiscomment_write() used an AVDictionary ** parameter for a dictionary whose contents ought to be written; yet this can be replaced by AVDictionary * since commit 042ca05f0fdc5f4d56a3e9b94bc9cd67bca9a4bc; and this in turn can be replaced by const AVDictionary * to indicate that the dictionary isn't modified; the latter also applies to ff_vorbiscomment_length(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-03avformat/matroskaenc: Replace impossible condition with assertAndreas Rheinhardt
If a FLAC track uses an unconventional channel layout, the Matroska muxer adds a WAVEFORMATEXTENSIBLE_CHANNEL_MASK VorbisComment to the CodecPrivate to preserve this information. And given that FLAC uses 24bit length fields, the muxer checks if the length is more than this and errors out if it is. Yet this can never happen, because we create the AVDictionary that is the source for the VorbisComment. It only contains exactly one entry that can't grow infinitely large (in fact, the length of the VorbisComment is <= 4 + 33 + 1 + 18 + strlen(LIBAVFORMAT_IDENT)). So we can simply assert the size to be < (1 << 24) - 4. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-03avformat/matroskaenc: Write SeekHead when livestreamingAndreas Rheinhardt
Commit 6fd300ac6c2c3871736ce0e6df95603255004dc6 added support for WebM Chunk livestreaming; in this case, both the header as well as each Cluster is written to a file of its own, so that even if the AVIOContext seems seekable, the muxer has to behave as if it were not. Yet one of the added checks makes no sense: It ensures that no SeekHead is written preliminarily (and hence no SeekHead is written at all) if the option for livestreaming is set, although one should write the SeekHead in this case when writing the Header. E.g. the WebM-DASH specification [1] never forbids writing a SeekHead and in some instances (that don't apply here) even requires it (if Cues are written after the Clusters). [1]: https://sites.google.com/a/webmproject.org/wiki/adaptive-streaming/webm-dash-specification Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-03avformat/matroskaenc: Only write Cluster if it has in fact been openedAndreas Rheinhardt
Since commit 4aa0665f393847c35387a1c673e62346d0acfc95, the dynamic buffer destined for the contents of the current Cluster is no longer constantly allocated, reallocated and then freed after writing the content; instead it is reset and reused when closing a Cluster. Yet the code in mkv_write_trailer() still checked for whether a Cluster is open by checking whether the pointer to the dynamic buffer is NULL or not (instead of checking whether the position of the current Cluster is -1 or not). If a Cluster was not open, an empty Cluster would be output. One usually does not run into this issue, because unless there are errors, there are only three possibilities to not have an opened Cluster at the end of writing a packet: The first is if one sent an audio packet to the muxer. It might trigger closing and outputting the old Cluster, but because the muxer caches audio packets internally, it would not be output immediately and therefore no new Cluster would be opened. The second is an audio packet that does not contain data (such packets are sometimes sent for side-data only, e.g. by the FLAC encoder). The only difference to the first scenario is that such packets are not cached. The third is if one explicitly flushes the muxer by sending a NULL packet via av_write_frame(). If one also allows for errors, then there is also another possibility: Caching the audio packet may fail in the first scenario. If one calls av_write_trailer() after the first scenario, the cached audio packet will be output when writing the trailer, for which a Cluster is opened and everything is fine; because flushing the muxer does currently not output the cached audio packet (if one is cached), the issue also does not exist if an audio packet has been cached before flushing. The issue only exists in one of the other scenarios. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-03avformat/libsrt: change open_timeout to int64_t to avoid integer overflowLimin Wang
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-03avformat/libsrt: clarify option description for timeout and latency unit of ↵Limin Wang
measurement Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-02avformat/oggdec: Reallocate buffer before writing into itMichael Niedermayer
Fixes: out of array write Fixes: Regression since f619e1ec66b89215582eff4404b681b760540b4f Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-02avformat/oggdec: Factor buffer reallocation outMichael Niedermayer
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-05-01avformat/hlsenc: add support for microseconds since epoch based sequence numberMarton Balint
Sequence numbers of segments should be unique, if an encoder is using shorter than 1 second segments and it is restarted, then future segments will be using already used sequence numbers if initial sequence number is based on the number of seconds since epoch and not microseconds. Signed-off-by: Marton Balint <cus@passwd.hu>
2020-05-01avformat/concat: priv_data should be freed internallyLimin Wang
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-01avformat/dashenc: remove the arbitrary restrictions for filenameLimin Wang
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-01avformat/matroskadec: CosmeticsAndreas Rheinhardt
Reindentation as well as marking several variables used for demuxing RealAudio as const to clearly see that they don't change during demuxing. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-01avformat/matroskadec: Support ContentCompression for all codecsAndreas Rheinhardt
The Matroska demuxer has three functions for creating packets out of the data read: One for certain RealAudio codecs (ATRAC3, cook, sipr, RealAudio 28.8), one for WebVTT (actually, the WebM flavour of it) and one for all the others. Only the last function supported Matroska's ContentCompression (e.g. it reversed zlib compression or added the removed headers to the packets). But in Matroska, all tracks are allowed to be compressed. This commit adds support for this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-01avformat/matroskadec: Cache whether a track needs to be decodedAndreas Rheinhardt
There is no need to recheck this for every frame. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-01avformat/matroskadec: Improve forward compabilityAndreas Rheinhardt
Matroska is built around the principle that a reader does not need to understand everything in a file in order to be able to make use of it; it just needs to ignore the data it doesn't know about. Our demuxer typically follows this principle, but there is one important instance where it does not: A Block belonging to a TrackEntry with no associated stream is treated as invalid data (i.e. the demuxer will try to resync to the next level 1 element because it takes this as a sign that it has lost sync). Given that we do not create streams if we don't know or don't support the type of the TrackEntry, this impairs this demuxer's forward compability. Furthermore, ignoring Blocks belonging to a TrackEntry without corresponding stream can (in future commits) also be used to ignore TrackEntries with obviously bogus entries without affecting the other TrackEntries (by not creating a stream for said TrackEntry). Finally, given that matroska_find_track_by_num() already emits its own error message in case there is no TrackEntry with a given TrackNumber, the error message (with level AV_LOG_INFO) for this can be removed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-01avformat/matroskadec: Don't discard valid packetsAndreas Rheinhardt
A Block (meaning both a Block in a BlockGroup as well as a SimpleBlock) must have at least three bytes after the field containing the encoded TrackNumber. So if there are <= 3 bytes, the Matroska demuxer would skip this block, believing it to be an empty, but valid Block. This might discard valid nonempty Blocks, namely if the track uses header stripping. And certain definitely spec-incompliant Blocks don't raise errors: Those with two or less bytes left after the encoded TrackNumber and those with three bytes left, but with flags indicating that the Block uses lacing as then there has to be further data describing the lacing. Furthermore, zero-sized packets were still possible because only the size of the last entry of a lace was checked. This commit fixes this. All spec-compliant Blocks that contain data (even if side data only) are now returned to the caller; spec-compliant Blocks that don't contain anything are not returned. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-01avformat/matroskadec: Simplify checks for cook and ATRAC3Andreas Rheinhardt
Some conditions which don't change and which can therefore be checked in read_header() were instead rechecked upon parsing each block. This has been changed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-01avformat/matroskadec: Don't output uninitialized data for RealAudio 28.8Andreas Rheinhardt
The Matroska demuxer splits every sequence of h Matroska Blocks into h * w / cfs packets of size cfs; here h (sub_packet_h), w (frame_size) and cfs (coded_framesize) are parameters from the track's CodecPrivate. It does this by splitting the Block's data in h/2 pieces of size cfs each and putting them into a buffer at offset m * 2 * w + n * cfs where m (range 0..(h/2 - 1)) indicates the index of the current piece in the current Block and n (range 0..(h - 1)) is the index of the current Block in the current sequence of Blocks. The data in this buffer is then used for the output packets. The problem is that there is currently no check to actually guarantee that no uninitialized data will be output. One instance where this is trivially so is if h == 1; another is if cfs * h is so small that the input pieces do not cover everything that is output. In order to preclude this, rmdec.c checks for h * cfs == 2 * w and h >= 2. The former requirement certainly makes much sense, as it means that for every given m the input pieces (corresponding to the h different values of n) form a nonoverlapping partition of the two adjacent frames of size w corresponding to m. But precluding h == 1 is not enough, other odd values can cause problems, too. That is because the assumption behind the code is that h frames of size w contain data to be output, although the real number is h/2 * 2. E.g. for h = 3, cfs = 2 and w = 3 the current code would output four (== h * w / cfs) packets. although only data for three (== h/2 * h) packets has been read. (Notice that if h * cfs == 2 * w, h being even is equivalent to cfs dividing w; the latter condition also seems very reasonable: It means that the subframes are a partition of the frames.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-01avformat/matroskadec: Fix buffer overflow when demuxing RealAudio 28.8Andreas Rheinhardt
RealAudio 28.8 (like other RealAudio codecs) uses a special demuxing mode in which the data of the existing Matroska Blocks is not simply forwarded as-is. Instead data from several Blocks is recombined together to output several packets. The parameters governing this process are parsed from the CodecPrivate: Coded framesize (cfs), frame size (w) and sub_packet_h (h). During demuxing, h/2 pieces of data of size cfs each are read from every Matroska (Simple)Block and put at offset m * 2 * w + n * cfs of a buffer of size h * w, where m ranges from 0 to h/2 - 1 for each Block while n is initially zero and incremented after a Block has been parsed until it is h, at which poin the assembled packets are output and n reset. The highest offset is given by (h/2 - 1) * 2 * w + (h - 1) * cfs + cfs while the destination buffer's size is given by h * w. For even h, this leads to a buffer overflow (and potential segfault) if h * cfs > 2 * w; for odd h, the condition is h * cfs > 3 * w. This commit adds a check to rule this out. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-01avformat/matroskadec: Fix demuxing RealAudio 28.8Andreas Rheinhardt
RealAudio 28.8 does not need or use sub_packet_size for its demuxing and this field is therefore commonly set to zero. But since 18ca491b the Real Audio specific demuxing is no longer applied if sub_packet_size is zero because the codepath for cook and ATRAC3 divide by it; this made these files undecodable. Furthermore, since 569d18aa (merged in 2c8d876d) sub_packet_size being zero is used as an indicator for invalid data, so that a file containing such a track was completely skipped. This commit fixes this by not checking sub_packet_size for RealAudio 28.8 at all. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-01avformat/matroskadec: Simplify check for RealAudioAndreas Rheinhardt
They need a special parsing mode and in order to find out whether this mode is in use, several checks have to be performed. They can all be combined into one: If the buffer that is only used to assemble their packets has been allocated, use the RealAudio parsing mode. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-01avformat/matroskadec: Reject sipr flavor > 3Andreas Rheinhardt
Only flavors 0..3 seem to exist. E.g. rmdec.c treats any flavor > 3 as invalid data. Furthermore, we do not know how big the packets to create ought to be given that for sipr these values are not read from the bitstream, but from a table. Furthermore, flavor is only used for sipr, so only check it for sipr; rmdec.c does the same. (The old check for flavor being < 0 was always wrong given that flavor is an int that is read via avio_rb16(), so it has been removed completely.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-01avformat/mpegts: fix av_freep for dovi pointerLimin Wang
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-05-01avformat/mov: fix av_freep for dovi pointerLimin Wang
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>