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-07-01avformat/matroskaenc: Don't use NULL for %s format stringAndreas Rheinhardt
The argument pertaining to a printf %s conversion specifier must not be NULL, even if the precision (i.e. the number of characters to write) is zero. If it is NULL, it is undefined behaviour. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit 6de6ce7bc80e874099895b6c73977bc2efb06a4d) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-20avformat/matroskaenc: Don't segfault when seekability changesAndreas Rheinhardt
If the Matroska muxer's AVIOContext was unseekable when writing the header, but is seekable when writing the trailer, the code for writing the trailer presumes that a dynamic buffer exists and tries to update its content in order to overwrite data that has already been preliminarily written when writing the header, yet said buffer doesn't exist as it has been written finally and not preliminarily when writing the header (because of the unseekability it was presumed that one won't be able to update the data anyway). This commit adds a check for this and also for a similar situation involving updating extradata with new data from packet side-data. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit 8aabcf6c1151b9e50ae5447da6709a72022b9a60)
2020-05-20avformat/matroskaenc: Fix memleak upon encountering bogus chapterAndreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit cb255b616cf1ebc6bc89b3538b6b7465dc2c526b)
2020-05-20avformat/matroskaenc: Make ebml_num_size() more robustAndreas Rheinhardt
Matroska (or actually EBML) uses variable-length numbers where only seven bits of every byte is usable for the length; the other bits encode the length of the variable-length number. So in order to find out how many bytes one needs to encode a given number one can use a loop like while (num >> 7 * bytes) bytes++; the Matroska muxer effectively did this. Yet it has a disadvantage: It is impossible for the result of a single right shift of an unsigned number with most significant bit set to be zero, because one can only shift by 0..(width - 1). On some architectures like x64 it is not even possible to do it with undefined right shifts in which case this leads to an infinite loop. This can be easily avoided by switching to a loop whose condition is (num >>= 7). The maximum value the so modified function can return is 10; any value > 8 is invalid and will now lead to an assert in put_ebml_num() or in start_ebml_master() (or actually in put_ebml_size_unknown()). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> (cherry picked from commit 9b0f9003dfab6a230d46aaa94091bf509d889f37)
2020-05-20avformat/matroskaenc: Check BlockAdditional size before useAndreas Rheinhardt
Don't read a 64bit number before having checked that the data is at least 8 bytes long. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 6e9cc964293bf1e0cca6a52b2938a20d711e4146)
2020-05-20avformat/matroskaenc: Check functions that can failAndreas Rheinhardt
Sometimes it has not been checked whether opening the dynamic buffer for writing Tags fails; this might have led to segfaults. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit b4f300f8ea209b861865ef495b298a88b48f3913)
2020-05-20avformat/matroskaenc: Check for reformatting errorsAndreas Rheinhardt
This is needed especially for AV1: If a reformatting error happens (e.g. if the length field of an OBU contained in the current packet indicates that said OBU extends beyond the current packet), the data pointer is still NULL, yet the size is unchanged, so that writing the data leads to a segmentation fault. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com> (cherry picked from commit 58428bef4b2c053f47dce35157fb96833ba8efea)
2020-03-30avformat/matroskaenc: Write level 1 elements in one goAndreas Rheinhardt
Up until now, writing level 1 elements proceeded as follows: First, the element id was written to the ordinary output AVIOContext and a dynamic buffer was opened for the content of the level 1 element in start_ebml_master_crc32(). Then this buffer was actually used and after it was closed (in end_ebml_master_crc32()), the size field corresponding to the buffer's size was written, after which the actual data was written. This commit changes this: Nothing is written to the main AVIOContext any more in start_ebml_master_crc32(). end_ebml_master_crc32() now writes both the id, the length field as well as the data. This is benefical for streaming, because a client that receives just a Cluster ID and nothing more might infer that this is EOF; in certain usecases there is also the danger of a client receiving the Cluster without the actual Cluster ID at the beginning. Addresses #8578. (cherry picked from commit d9c21ec) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2019-05-08avformat/matroskaenc: Reduce usage of ebml_masterAndreas Rheinhardt
After the last few commits, the functions for writing master elements with CRC-32 elements didn't really make use of the ebml_master structure any more, so remove these parameters from the functions. The only things that still need to be kept are the positions of the level 1 elements that are written preliminarily and updated later. These positions are stored in the MatroskaMuxContext and replace the corresponding ebml_master structures. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Improve log messages for blocksAndreas Rheinhardt
Up until now, a block's relative offset has been reported as the offset in the log messages output when writing blocks; given that it is impossible to know the real offset from the beginning of the file at this point due to the fact that it is not yet known how many bytes will be used for the containing cluster's length field both the relative offset in the cluster as well as the offset of the containing cluster will be reported from now on. Furthermore, the TrackNumber of the written block has been added to the log output. Also, the log message for writing vtt blocks has been brought in line with the message for normal blocks. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Don't waste bytes writing level 1 elementsAndreas Rheinhardt
Up until now, the length field of most level 1 elements has been written using eight bytes, although it is known in advance how much space the content of said elements will take up so that it would be possible to determine the minimal amount of bytes for the length field. This commit changes this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Cosmetics and typoAndreas Rheinhardt
Fixes intendation, whitespace, a typo and renames a variable (dyn_bc->cluster_bc) to make its meaning clearer and to bring it more in line with the naming of similar variables. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Write CRC-32 in non-seekable modeAndreas Rheinhardt
Given that in both the seekable as well as the non-seekable mode dynamic buffers are used to write level 1 elements and that now no seeks are used in the seekable case any more, the two modes can be combined; as a consequence, the non-seekable mode automatically inherits the ability to write CRC-32 elements. There are no differences in case the output is seekable; when it is not and writing CRC-32 elements is disabled, there can still be minor differences because before this commit, the EBML ID and length field were counted towards the cluster size limit; now they no longer are. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Avoid seeking when writing level 1 elementsAndreas Rheinhardt
Up until now, the writing process for level 1 elements (those elements for which CRC-32 elements are written by default) was this in case the output was seekable: Write the EBML ID, write an "unkown length" EBML number of the desired length, then write the element into a dynamic buffer, then write the dynamic buffer (after possible calculation and writing of the CRC-element), then seek back to the size element and overwrite the unknown-size element with the real size. The seeking and overwriting part has been eliminated by not writing the size initially. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Change variable typesAndreas Rheinhardt
A Matroska EBML ID can only be maximally four bytes long, so make the variables denoting EBML IDs uint32_t instead of unsigned int to better reflect this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Remove redundant checkAndreas Rheinhardt
All places where end_ebml_master_crc32_preliminary are used already check for whether the output is seekable, so the check in the function is redundant. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Improve log messageAndreas Rheinhardt
Since 4e3bdf729a80f868b014ceb02901d87198b545a5 there is no reason any more to treat the seekable and non-seekable cases separate with regards to the log message for a new cluster. This effectively reverts d41aeea8a64bab5d7aacd602f7214f95baad109f. Also improved the log message: "pts 80dts 0" -> "pts 80, dts 0". Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Simplify check for writing CRCsAndreas Rheinhardt
Up until now, the check for whether to write CRC32 elements was always mkv->write_crc && mkv->mode != MODE_WEBM. This is equivalent to simply set write_crc to zero in WebM-mode. And this is what this commit does. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Remove traces of secondary seek headAndreas Rheinhardt
Up until e7ddafd515dc9826915b739d0b977a63c21e96af the Matroska muxer wrote a secondary seek head referencing all the clusters. When this was changed, a (now completely wrong) comment remained and the unique remaining seek head was still called main_seekhead. This has been changed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Don't waste bytes in EBML HeaderAndreas Rheinhardt
Up until now the EBML Header length field has been written with eight bytes, although the EBML Header is always so small that only one byte is needed for it. This patch saves seven bytes for every Matroska/Webm file. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Slightly improve size bounds for cuesAndreas Rheinhardt
The upper bounds currently used for determining the size of a CuePoint's length field can be improved somewhat; as a result, a CuePoint containing three CueTrackPositions will now only need a size field with one byte length. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Fix BlockGroup size calculationAndreas Rheinhardt
The earlier code included the size of the BlockGroup's length field and the EBML ID in the calculation of the size for the payload and ignored the size of the duration's length field. This meant that Blockgroups corresponding to packets with size 2^(7n) - 17 - n - i, i = 0,..., n - 1, n = 1,..., 8 (i.e. 110, 16364, 16365, 2097130..2097132, ...) were written with length fields that are unnecessarily long. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-05-08avformat/matroskaenc: Fix relative timestamp checkAndreas Rheinhardt
At this point, ts already includes the ts_offset so that the relative time written with the cluster is already given by ts - mkv->cluster_pts. It is this number that needs to fit into an int16_t. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2019-04-09avformat/matroskaenc: fix leak on errorTristan Matthews
Signed-off-by: James Almer <jamrial@gmail.com>
2019-04-09lavf/matroskaenc: Fix memory leak after write trailerJun Zhao
Fix memory leak after write trailer for #7827, only store a audio packet whose buffer has size greater than zero in cur_audio_pkt. Audio packets with size zero, but with side-data currently lead to memleaks, in the Matroska muxer, because they are not properly freed: They are currently put into an AVPacket in the MatroskaMuxContext to ensure that the necessary audio is always available for a new cluster, but are only written and freed when their size is > 0. As the only use we have for such packets consists in updating the CodecPrivate it makes no sense to store these packets at all and this is how this commit solves the memleak. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@googlemail.com> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2019-03-10lavf/matroskaenc: Allow dvdsub remuxing from some containers.Carl Eugen Hoyos
Fixes ticket #7783.
2018-12-18avformat/vorbiscomment: add support for writing chaptersPaul B Mahol
Fixes #7532.
2018-10-01avformat/matroskaenc: reserve free space for metadata on requestSigga Regina
Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-26avformat/matroskaenc: reindent after the previous commitJames Almer
Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-26avformat/matroskaenc: refactor checks for allowed codecs in WebMJames Almer
Use the new ff_webm_codec_tags[] array for this purpose. Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-26avformat/matroskaenc: implement AVOutputFormat.query_codec for webmJames Almer
Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-26avformat/matroskaenc: remove unnecessary additional codec tagsJames Almer
They are listed in riff.c already. Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-22Revert "avformat/matroskaenc: write CodecPrivate in WebM"James Almer
This reverts commit 4755b6e6d194b0a0fb72957cd3dc0eaf7b2375f7. This change was not necessary. CodecPrivate was being written to WebM for codecs like AV1 already.
2018-09-21avformat/matroskaenc: write CodecPrivate in WebMJames Almer
This is now needed for AV1. Signed-off-by: James Almer <jamrial@gmail.com>
2018-09-21lavf/matroska: Allow AV1 in WebMKagami Hiiragi
Nothing prevents it to work except this check. AV1 is already supported by Matroska muxer and aomenc produces WebM/AV1 files as well. Signed-off-by: Kagami Hiiragi <kagami@genshiken.org> Signed-off-by: James Almer <jamrial@gmail.com>
2018-08-19avformat/matroskaenc: handle AV1 extradata in packet side dataJames Almer
This is a temporary workaround for transcoding scenarious using libaom-av1 encoder, which currently can't propagate extradata during initialization. Signed-off-by: James Almer <jamrial@gmail.com>
2018-08-02avformat/matroskaenc: filter and reorder AV1 OBUsJames Almer
Make sure to not write forbidden OBUs to CodecPrivate, and do the same with unnecessary OBUs for packets. Signed-off-by: James Almer <jamrial@gmail.com>
2018-05-04avformat/matroskaenc: do not write timebase as frameratewm4
If the API user doesn't set avg_frame_rate, matroskaenc will write the current timebase as "default duration" for the video track. This makes no sense, because the "default duration" implies the framerate of the video. Since the timebase is forced to 1/1000, this will make the resulting file claim 1000fps. Drop it and don't write the element. It's optional, so it's better not to write it if the framerate is unknown. Strangely does not require FATE changes.
2018-02-13lavf/matroskaenc: Force the minimum value for -reserve_index_space to 2.Carl Eugen Hoyos
Fixes an assertion failure: Assertion size >= 2 failed at libavformat/matroskaenc.c:298
2017-11-28avformat/matroskaenc: add missing allocation failure checks for stream durationsJames Almer
Signed-off-by: James Almer <jamrial@gmail.com>
2017-11-28avformat/matroskaenc: move some initialization checks to mkv_initJames Almer
It's the correct place for them. Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
2017-11-27avformat/matroskaenc: actually enforce the stream limitJames Almer
Prevents out of array accesses. Adressess ticket #6873 Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com>
2017-10-21Merge commit '827a05eaa9482e9ac2a17f7f2e42ead07c1d7574'James Almer
* commit '827a05eaa9482e9ac2a17f7f2e42ead07c1d7574': matroskaenc: add support for Spherical Video elements See 58eb0f57f6702d57b6f97ec5010657bb2c076eff. Merged for cosmetics purposes. Also includes changes from d32d59bc977b43031007bb2ab21e232f96d2ebcb Merged-by: James Almer <jamrial@gmail.com>
2017-10-02Merge commit '5d3953a5dcfd5f71391b7f34908517eb6f7e5146'James Almer
* commit '5d3953a5dcfd5f71391b7f34908517eb6f7e5146': matroskaenc: factor ts_offset into block timecode computation Merged-by: James Almer <jamrial@gmail.com>
2017-09-09avformat/matroskaenc: also write tags when output is WebMJames Almer
WebM supports a subset of elements from the Tags master. See https://www.webmproject.org/docs/container/#tagging Reviewed-by: Ivan Janatra <janatra@google.com> Signed-off-by: James Almer <jamrial@gmail.com>
2017-08-02avformat/riff.h : remove unused function parameter "const AVCodecTag *tags" ↵Aleksandr Slobodeniuk
of "void ff_put_bmp_header()" Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-06-03avformat/matroskaenc: also write chapters when output is WebMJames Almer
WebM supports a subset of elements from the Chapters master. See https://www.webmproject.org/docs/container/#chapters Addresses ticket #6425 Reviewed-by: James Zern <jzern@google.com> Signed-off-by: James Almer <jamrial@gmail.com>
2017-05-25avformat/matroskaenc: check packet side data for AAC extradata updatesJames Almer
This adapts and merges commit f4bf236338f6001736a4784b9c23de863057a583 from libav, originally skipped in 13a211e6320d061d9e8c29354c81239324b2db03 as it was not necessary back then. Is's applied now in preparation for the following patches, where the aac_adtstoasc bitstream filter will start to correctly propagate the new extradata through packet side data. Signed-off-by: James Almer <jamrial@gmail.com>
2017-05-01avformat/matroskaenc: add support for writing Content Light Level elementsJames Almer
Signed-off-by: James Almer <jamrial@gmail.com>
2017-04-08avformat/matroskaenc: don't try to update flac extradata if live streamingJames Almer