summaryrefslogtreecommitdiff
path: root/libavformat
Commit message (Collapse)AuthorAge
* avformat/avio: add avio_protocol_get_classSteven Liu2020-01-30
| | | | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Suggested-by: Hendrik Leppkes <h.leppkes@gmail.com> Suggested-by: Nicolas George <george@nsup.org> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/tty: add probe functionPaul B Mahol2020-01-29
|
* avformat/mov: Don't leak MOVFragmentStreamInfo on errorAndreas Rheinhardt2020-01-28
| | | | | | | Fixes Coverity issue #1441933. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Free encryption data on errorAndreas Rheinhardt2020-01-28
| | | | | | | Fixes memleak and Coverity issue #1439587. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: update extensionsGyan Doshi2020-01-28
| | | | | Added all extensions used by the mov muxer family, except m4v which is also used for raw MPEG-4 Part 2 bitstreams
* avformat/matroskaenc: Remove useless AVIOContextAndreas Rheinhardt2020-01-27
| | | | | | | | | Write a few numbers directly via AV_WB32 instead of using an AVIOContext (that is initialized only for this very purpose) to write these numbers at known offsets into a fixed buffer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/matroskaenc: Improve writing ProjectionAndreas Rheinhardt2020-01-27
| | | | | | | | | | The Matroska Projection master element has such a small maximum length that it can always be written with a length field of length one. So it is unnecessary to first write the element into a dynamic buffer to get the accurate length in order not to waste bytes on the length field. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mux: Don't use av_ prefix for static functionsAndreas Rheinhardt2020-01-27
| | | | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mux: Don't unnecessarily zero-initialize AVPacketListAndreas Rheinhardt2020-01-26
| | | | | | | | | If no error occurs and this AVPacketList is used at all, its packet substructure will be overwritten and its next pointer explicitly set, so every field will still be initialized even when using av_malloc. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mux: Move packet referencesAndreas Rheinhardt2020-01-26
| | | | | | | | | | | | | | | | | | | In the common case that the input packet was already refcounted, ff_interleave_add_packet would allocate a new AVPacketList, use av_packet_ref to create a new reference to the buffer for the AVPacketList's packet, interleave the packet and finally unreference the original input packet. This commit changes this: It uses av_packet_move_ref to transfer the packet to its destination. In case the input packet is refcounted, this saves an allocation and a free (of an AVBufferRef); if not, the packet is made refcounted before moving it. When the input packet has side data, one saves even more than one allocation+free. Furthermore, when the packet is in reality an uncoded frame, a hacky ad-hoc variant of av_packet_move_ref has been employed. Not any more. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/gxfenc: Add deinit functionAndreas Rheinhardt2020-01-26
| | | | | | | | Fixes memleaks when the trailer is never written (e.g. if the call to gxf_write_map_packet() at the end of gxf_write_header() fails). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mxfenc: Add deinit functionAndreas Rheinhardt2020-01-26
| | | | | | | | Fixes memleaks when allocating the private data of the timecode_track fails or when the trailer is never written. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mxfenc: Don't free priv_data of AVStreamAndreas Rheinhardt2020-01-26
| | | | | | | It will be freed when the AVStream is freed later anyway. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/audiointerleave: Check before dereferencingAndreas Rheinhardt2020-01-26
| | | | | | | | | | | | | | | | | | In order to use ff_audio_rechunk_interleave() (a special interleavement function for situations where the ordinary "interleave by dts" is not appropriate), the AVStreams must have private data and this private data must begin with an AudioInterleaveContext which contains a fifo that may need to be freed and when ff_audio_interleave_close() was called, it just assumed that everything has been properly set up, i.e. that every streams priv_data exists. This implies that this function can not be called from the deinit function of a muxer, because such functions might be called if the private data has not been successfully allocated. In order to change this, add a check for whether the private data exists before trying to free the fifo in it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/dvenc: Don't zero unnecessarilyAndreas Rheinhardt2020-01-26
| | | | | | | | | The muxing context has already been zeroed when it was allocated, hence it is unnecessary to do it again. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/dvenc: Replace write_trailer by deinit functionAndreas Rheinhardt2020-01-26
| | | | | | | | | | | The old write_trailer only freed memory, so it is better to make a dedicated deinit function out of it. Given that this function will also be called when writing the header fails, one can also remove code that frees already allocated fifos when allocating another one fails. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/yuv4mpegdec: increase header limitGyan Doshi2020-01-26
| | | | Allows demuxing UHD 30000/1001 fps yuvj420p files
* avformat/yuv4mpegdec: better error loggingGyan Doshi2020-01-26
|
* avformat/av1: Avoid allocation + copying when filtering OBUsAndreas Rheinhardt2020-01-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | Certain types of OBUs are stripped away before muxing into Matroska and ISOBMFF; there are two functions to do this: One that outputs by directly writing in an AVIOContext and one that returns a freshly allocated buffer with the units not stripped away copied into it. The latter option is bad for performance, especially when the input does already not contain any of the units intended to be stripped away (this covers typical remuxing scenarios). Therefore this commit changes this by avoiding allocating and copying when possible; it is possible if the OBUs to be retained are consecutively in the input buffer (without an OBU to be discarded between them). In this case, the caller receives the offset as well as the length of the part of the buffer that contains the units to be kept. This also avoids copying when e.g. the only unit to be discarded is a temporal delimiter at the front. For a 22.7mb/s file with average framesize 113 kB this improved the time for the calls to ff_av1_filter_obus_buf() when writing Matroska from 313319 decicycles to 2368 decicycles; for another file with 1.5mb/s (average framesize 7.3 kB) it improved from 34539 decicycles to 1922 decicyles. For these files the only units that needed to be stripped away were temporal unit delimiters at the front. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: Fix nits in the documentation of ff_av1_filter_obus_buf()Andreas Rheinhardt2020-01-26
| | | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1, avc, hevc: Remove av_freep()Andreas Rheinhardt2020-01-26
| | | | | | | | | | | | | | | ff_av1_filter_obus_buf() and ff_avc_parse_nal_units_buf() both have a pointer-to-pointer parameter which they use to pass a newly allocated buffer to the caller. And both functions freed what this pointer points to before overwriting it. But no caller of these functions used this feature, but some had to initialize the pointer just because of this. So remove it and update the documentation of ff_av1_filter_obus_buf() wrt this fact. ff_hevc_annexb2mp4_buf in contrast did not free the pointer. This has been documented, too. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1: Improve filtering AV1 OBUsAndreas Rheinhardt2020-01-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both ISOBMFF as well as Matroska require certain OBUs to be stripped before muxing them. There are two functions for this purpose; one writes directly into an AVIOContext, the other returns a freshly allocated buffer with the undesired units stripped away. The latter one actually relies on the former by means of a dynamic buffer. This has several drawbacks: The underlying buffer might have to be reallocated multiple times; the buffer will eventually be overallocated; the data will not be directly copied into the final buffer, but rather first in the write buffer (in chunks of 1024 byte) and then written in these chunks. Moreover, the API for dynamic buffers is defective wrt error checking and as a consequence, the earlier code would indicate a length of -AV_INPUT_BUFFER_PADDING_SIZE on allocation failure, but it would not return an error; there would also be no error in case the arbitrary limit of INT_MAX/2 that is currently imposed on dynamic buffers is hit. This commit changes this: The buffer is now parsed twice, once to get the precise length which will then be allocated; and once to actually write the data. For a 22.7mb/s file with average framesize 113 kB this improved the time for the calls to ff_av1_filter_obus_buf() when writing Matroska from 753662 decicycles to 313319 decicycles (based upon 50 runs a 2048 frames each); for another 1.5mb/s file (with average framesize of 7.3 kB) it improved from 79270 decicycles to 34539 decicycles (based upon 50 runs a 4096 frames). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/movenc: Check for reformatting errors when writing hint tracksAndreas Rheinhardt2020-01-26
| | | | | | | | If this is not done, the avio_write() calls will cause segfaults immediately afterwards on error. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/av1, hevc: Make *_buf-functions return 0 on successAndreas Rheinhardt2020-01-26
| | | | | | | | | | | The output size is already returned via a pointer argument, so there is no need to return it via the ordinary return value as well. The rationale behind this is to not poison the return value on success. It also unifies the behaviour of the *_buf-functions for AVC, AV1 and HEVC. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/hevc: Fix potential leak in case of ff_hevc_annexb2mp4_buf failureAndreas Rheinhardt2020-01-26
| | | | | | | | | | | | ff_hevc_annexb2mp4_buf() could indicate an error, yet leave cleaning after itself to the caller, so that a caller could not simply return the error, but had to free the buffer first. (Given that all current callers have set filter_ps = 0, this error can currently not be triggered.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/matroskaenc: CosmeticsAndreas Rheinhardt2020-01-26
| | | | | | | | | | | | | Add {, } in situations like if () ... else if () /* Comment */ ... else ... Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/matroskaenc: Check for reformatting errorsAndreas Rheinhardt2020-01-26
| | | | | | | | | | | 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>
* avformat: add demuxer for argonaut games' ASF formatZane van Iperen2020-01-26
| | | | | | | | | | Adds support for the custom ASF container used by some Argonaut Games' games, such as 'Croc! Legend of the Gobbos', and 'Croc 2'. Can also handle the sample files in: https://samples.ffmpeg.org/game-formats/brender/part2.zip Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/udp: increase the default buffer size of a receiving socket to 384KMarton Balint2020-01-25
| | | | | | | | | | | | It is a common mistake that people only increase fifo_size when they experience drops, unfortunately this does not help for higher bitrate (> 100 Mbps) streams when the reader thread simply might not receive the packets in time (especially under high CPU load) if the default 64 KB of kernel buffer size is used. New default is determined so that common linux systems can set this buffer size without tuning kernel parameters. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/udp: properly use return value of pthread_cond_timedwaitMarton Balint2020-01-25
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/udp: add newline after warningMarton Balint2020-01-25
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/movenc: allow ISMV timescale to be user-setGyan Doshi2020-01-25
| | | | | | | | As per the PIFF standard, the timescale of 10000000 is recommended but not mandatory, so don't override the user-set value. A warning is shown for non-recommended values.
* avformat/libsrt: add missing SRT_VERSION_VALUE checkMarton Balint2020-01-23
| | | | | | This was missed in d7e2a2bb35e394287b3e3dc27744830bf0b7ca99. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/utils: log corrupt packetsGyan Doshi2020-01-23
|
* avformat/libzmq: Replace fail statements with gotoAndriy Gelman2020-01-21
| | | | | | Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/libzmq: Check return of zmq_setsockoptAndriy Gelman2020-01-21
| | | | | Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/hlsenc: fix default AES key file url with variant streamsBela Bodecs2020-01-20
| | | | | | | | | | | | | | Currently when hls_enc is active and there are multiple variant stream outputs, default key file url construction does not work, because it is based on the FormatContext' url field. But in case of multiple variant streams, it contains the variant m3u8 output playlist url that contains the %v placeholder. So the result key file url will hold the %v placeholder causing run time error message about "could not write the key file". This patch correct this behaviour, and use the master playlist url for constructing the output key file url when master playlist is vailable. Signed-off-by: Bela Bodecs <bodecsb@vivanet.hu>
* avformat/hlsenc: program_date_time and append_list flags conflictBela Bodecs2020-01-20
| | | | | | | | | | | | | | | | | | | | | | When program_date_time flag is present, in m3u8 playlist file each segment has a corresponding EXT-X-PROGRAM-DATE-TIME value. The intial program-date-time value is the actual current time at init and each new segment increments this value by its duration. When append_list flags is also present, existing playlist parsing by hls_append_segment treats existing segments as new segments regarding the program-date-time calculation. But it should not do that, because this way all real the new segments' EXT-X-PROGRAM-DATE-TIME values will be shifted erroneously by the sum duration of existing segments. Instead it should have decremented the initial program-date-time value by its duration. This would ensure that the first new segment's program-date-time value had the current time as it is expected. This patch corrects this behaviour and prevent existing segments to increment the value of initial_prog_date_time variable but decrements it. Reviewed-by: Steven Liu <lq@onvideo.cn> Signed-off-by: Bela Bodecs <bodecsb@vivanet.hu>
* avformat/udp: modify the not write-only to read-only mode.Xuchen Su2020-01-20
| | | | | | not write-only include read-write pseudo flag. so make the flag read-only Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/hlsenc: compare without the last directory separator in ↵Steven Liu2020-01-20
| | | | | | | | | | get_relative_url fix ticket: 8461 there is no problem before commit 75aea52a1051a22bdebd0b7a8098ac6479a529a0 Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/dashenc: use ff_rename instead of avpriv_io_moveMarton Balint2020-01-19
| | | | | | ff_rename always logs the error message. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/avio: fix ff_rename to respect used protocolMarton Balint2020-01-19
| | | | | | | | | | | Also simplify it and make it always log the error. This fixes for example the image2 muxer when used with an URL which also contains the protocol: ffmpeg -f lavfi -i testsrc -vframes 10 -atomic_writing 1 file:out%d.png Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/avio: move ff_rename implementation from internal.h to avio.cMarton Balint2020-01-19
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/libsrt: fix enabling nonblocking modeAnthony Delannoy2020-01-19
| | | | | | | | As written in https://github.com/Haivision/srt/blob/v1.4.1/docs/API.md, the nonblock mode is activated if SRTO_SNDSYN and SRTO_RCVSYN, for sending and receiving respectively, are set to 0. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/img2enc: add support for specifying protocol optionsMarton Balint2020-01-18
| | | | | | v2: simplified example Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/dtsdec: make S16LE discrimination sharperMichael Niedermayer2020-01-18
| | | | | | | | | | Both S16LE as well as DTS can have lots of 0 bytes in silent segments Using these results in error. Thus this patch skips 0 bytes in comparission. Fixes Ticket6561 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/hls: support data protocol in uri for EXT-X-MAPSteven Liu2020-01-18
| | | | Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/oggparsevorbis: Use AV_DICT_DONT_STRDUP_VAL to avoid av_strdupAndreas Rheinhardt2020-01-17
| | | | | | | | | | | | | This will likely also fix CID 1452427, a false positive resulting from Coverity thinking that av_dict_set() automatically frees its key and value parameters (even without the AV_DICT_DONT_STRDUP_* flags). (AV_DICT_APPEND and AV_DICT_DONT_STRDUP_VAL are compatible with each other since a8c5b455, so we can reset this flag here. It has originally been removed in 0dc66553 when appending was added.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flvenc: Avoid unnecessary seekAndreas Rheinhardt2020-01-17
| | | | | | | | | | | | | | When shifting the already written data in order to write the keyframe index, the flv muxer would first store the pre-shift size, then calculate how big the index will be eventually, then perform some seeks to update some size fields, then seek back to the end of the file to get the new position, followed by a seek to the position where writing will really start. Seeking back to the (already known) end position (that is actually used to perform this seek) to get the end position is of course unnecessary. It has been removed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/movenc, segafilmenc: Remove unnecessary avio_tell()Andreas Rheinhardt2020-01-17
| | | | | | | | | | | | | | When the faststart option for the mov/mp4 muxer is used, the current position (i.e. the size of the already written data pre-shifting) was evaluated twice: First in an initialization and then again later, overwriting the first value without having ever touched it. So remove the initialization. Also, the clone of this code in the Sega FILM muxer behaves the same and has been treated the same. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>