summaryrefslogtreecommitdiff
path: root/libavformat
Commit message (Collapse)AuthorAge
* avformat/matroskaenc: Avoid temporary buffers when reformatting H.2645Andreas Rheinhardt2022-01-19
| | | | | | | | | | | | Do this by using the new NALUList API. This avoids an allocation of a dynamic buffer per packet as well as the (re)allocation of the actual buffer as well as copying the data around. This improves performance: The time for one call to write_packet decreased from 703501 to 357900 decicyles when remuxing a 5min 14000 kb/s H.264 transport stream. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avc: Add functions to split access unit into list of NALUsAndreas Rheinhardt2022-01-19
| | | | | | | | This will allow to avoid the temporary buffer and memcpys when repacketing annex B to mp4-style H.264/H.265 without searching twice for start codes. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Use common function for H.2645 annex B->mp4Andreas Rheinhardt2022-01-19
| | | | | | | | Matroska does not have different profiles that allow or disallow in-band extradata, so one can just use the ordinary H.264 function for H.265, too. (Both use ff_avc_parse_nal_units() internally anyway.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Redo reformatting AV1Andreas Rheinhardt2022-01-19
| | | | | | | This avoids allocations+copies in all cases, not only those in which the desired OBUs are contiguous in the input buffer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/av1: Document actual behaviour of ff_av1_filter_obus()Andreas Rheinhardt2022-01-19
| | | | | | | Document that it can be used with a NULL AVIOContext to get the output size in a first pass. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Speed up reformatting WavPackAndreas Rheinhardt2022-01-19
| | | | | | | | | | | | | WavPack's blocks use a length field, so that parsing them is fast. Therefore it makes sense to parse the block twice, once to get the length of the output packet and once to write the actual data instead of writing the data into a temporary buffer in a single pass. This speeds up muxing from 1597092 to 761850 Decicycles per write_packet call for a 2000kb/s stereo WavPack file muxed to /dev/null with writing CRC-32 disabled. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Allow to use custom reformatting functionsAndreas Rheinhardt2022-01-19
| | | | | | | | | | | | | | | | | | Matroska uses variable-length elements and in order not to waste bytes on length fields, the length of the data to write needs to be known before writing the length field. Annex B H.264/5 and WavPack need to be reformatted to know this length and this currently involves writing the data into temporary buffers; AV1 sometimes suffers from this as well. This commit aims to solve this by adding a callback that is called twice per packet: Once to get the size and once to actually write the data. In case of WavPack and AV1 (where parsing is cheap due to length fields) both calls will just parse the data with only the second function writing anything. For H.264/5, the position of the NALUs will need to be stored to be written lateron. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Factor writing Info outAndreas Rheinhardt2022-01-19
| | | | | | | | | Avoids the surprise of using pb for the main AVIOContext at the beginning and end of mkv_write_header() and for for the dynamic buffer opened for the Info element in the middle of mkv_write_header(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't waste bytes on ChapterAtoms length fieldsAndreas Rheinhardt2022-01-19
| | | | | | Also check the (user-provided) metadata tags for being too long. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't waste bytes on Video element length fieldsAndreas Rheinhardt2022-01-19
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Factor writing TrackVideo outAndreas Rheinhardt2022-01-19
| | | | | | It is already quite big. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Avoid seeks when writing EBML headerAndreas Rheinhardt2022-01-19
| | | | | | | | | | | | | | | Using start/end_ebml_master() to write an EBML Master element uses seeks under the hood. This does not work if the output is unseekable with the AVIOContext's buffer being very small (the size of the currently written Matroska EBML header is 40) or with the AVIOContext being in direct mode, because then this seek can't be performed in the AVIOContext's buffer. So using an approach that does not rely on seeking at all is preferable; this is achieved by switching to EbmlWriter. Also factor writing the EBML header out into a function of its own. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't waste bytes on AttachedFiles' length fieldsAndreas Rheinhardt2022-01-19
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't waste bytes on SimpleTags length fieldsAndreas Rheinhardt2022-01-19
| | | | | | | Also check the (user-provided) tags for being overlong; the earlier code had an implicit unchecked size_t->int conversion. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Add API to write Masters with minimal length fieldAndreas Rheinhardt2022-01-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This muxer currently uses two ways to ensure that no bytes are wasted by writing unnecessary long EBML length fields for Master elements and the (Simple)Block element (all the other elements are fine as one either already has the right length or getting the actual length is easy and necessary anyway): Either use an upper bound that is good enough in case one is available or write the data into a dynamic buffer first to get the length; the former approach is impossible in lots of cases, whereas the latter incurs allocations and memcpying. It is therefore unfeasible to use the latter for e.g. the attachments or the BlockGroups. This patch adds a third alternative to complement the other two: It consists of an EbmlWriter that one can add EBML elements to that can be written later by calling ebml_writer_write(); the latter function first traverses the written elements recursively and calculates the length of each element; then a second pass is performed in which all the elements are written directly (without any seeks). This new API also performs checks for overlong elements; this is in contrast to put_ebml_string() which simply performs a size_t->int conversion even for strings originating from the user. The new API is designed to have very low overhead: It uses stack arrays and performs no allocations; this also comes at a price: Right now, it can only be used in contexts in which there is a compile-time upper bound for the number of elements. It is also incompatible with storing the offset of an element in order to update this field later. Furthermore, it puts the onus of memory management (i.e. ensuring that pointers stay valid) on the user. These restrictions might be overcome in the future. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't open BlockGroup twiceAndreas Rheinhardt2022-01-19
| | | | | | | | | | | | | This would happen in case non-WebVTT-subtitles had BlockAdditional or DiscardPadding side-data. Given that these are not accounted for in the length of the outer BlockGroup (which is a quite sharp upper bound) it is possible for the outer BlockGroup to use an insufficient number of bytes which leads to an assert in end_ebml_master(). Fix this by not opening a second BlockGroup inside an already opened BlockGroup. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Fix potential overflowAndreas Rheinhardt2022-01-19
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* http: honor response headers in redirect cachingerankor2022-01-18
| | | | | | | | | | | | | | add a dictionary that maps "src_url" -> "expiry;dst_url", the dictionary is checked before issuing an http request, and updated after getting a 3xx redirect response. the cache expiry is determined according to the following (in desc priority) - 1. Expires header 2. Cache-Control containing no-cache/no-store (disables caching) 3. Cache-Control s-maxage/max-age 4. Http codes 301/308 are cached indefinitely, other codes are not cached
* avformat/mpegts: add option max_packet_sizeGyan Doshi2022-01-16
| | | | | | Makes maximum size of emitted packet user-tunable. Default is existing 204800 bytes.
* avformat/matroskaenc: Add option to shift data to write cues at frontAndreas Rheinhardt2022-01-13
| | | | | | | | | | | | | This is similar to the faststart option of the mov muxer, yet in contrast to it it works together with reserve_index_space (the equivalent to reserved_moov_size): If the reserved space does not suffice, the data is shifted; if not, the Cues are written at the front without shifting the data. Several tests that cover (not only) this have been added. Implements #7017. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/rawvideodec: check packet sizeMichael Niedermayer2022-01-13
| | | | | | | | | | | Fixes: division by zero Fixes: integer overflow Fixes: 43347/clusterfuzz-testcase-minimized-ffmpeg_dem_V210X_fuzzer-5846911637127168 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: lance.lmwang@gmail.com Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/rtpenc_rfc4175: support for interlace formatLimin Wang2022-01-12
| | | | | | | | | | | | | | | | | Below are steps how to test on your local host: wget --no-check-certificate https://samples.ffmpeg.org/MPEG2/interlaced/burosch1.mpg 1. interlace format: ffmpeg -re -i ./burosch1.mpg -c:v bitpacked -pix_fmt yuv422p10 -f rtp rtp://239.255.0.1:6000 copy and create sdp file test.sdp ffplay -buffer_size 671088640 -protocol_whitelist "file,rtp,udp" test.sdp 2. progressive format: ffmpeg -re -i ./burosch1.mpg -vf yadif -c:v bitpacked -pix_fmt yuv422p10 -f rtp rtp://239.255.0.1:6000 copy and create sdp file test.sdp ffplay -buffer_size 671088640 -protocol_whitelist "file,rtp,udp" test.sdp Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/rtpdec_rfc4175: reindent after last commitLimin Wang2022-01-12
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/rtpdec_rfc4175: support for interlace formatLimin Wang2022-01-12
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* lavf/udp: do not return an uninitialized value from udp_open()Anton Khirnov2022-01-11
|
* lavf/dvenc: replace av_fifo_peek2() with av_fifo_generic_peek_at()Anton Khirnov2022-01-10
| | | | | This is the only remaining caller of av_fifo_peek2(), which will be deprecated.
* avformat/movenc: fix duration in mdhd boxZhao Zhili2022-01-10
| | | | | | | mvhd and tkhd present the post-editlist duration, while mdhd should have the pre-editlist duration. Regression since c2424b1f3. Signed-off-by: Martin Storsjö <martin@martin.st>
* avformat/amr: Return error upon errorAndreas Rheinhardt2022-01-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/dashdec: do not use filesize when reading XML fileMarton Balint2022-01-09
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/imfdec: do not use filesize when reading XML fileMarton Balint2022-01-09
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mxfdec: support MCA audio informationMarc-Antoine Arnaud2022-01-09
| | | | | | | Channel reordering is removed from this patch because the new channel layout API will support it properly. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/rawvideodec: Disable option accidentally added for v210(x)Andreas Rheinhardt2022-01-09
| | | | | | | | | 41f213c3bf629d549400e935e7f123e6cfa959ab accidentally added an unused pixel_format option to the v210(x) demuxers. Remove it before it really becomes part of the API. Reviewed-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hlsenc: convey stream id to segment streamsGyan Doshi2022-01-09
|
* avformat/matroskaenc: Disable MKV-only code if MKV muxer is disabledAndreas Rheinhardt2022-01-08
| | | | | | | | The Matroska muxer has quite a lot of dependencies and lots of them are unnecessary for WebM. By disabling the Matroska-only code at compile time one can get rid of them. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Move AAC extradata check to other audio checksAndreas Rheinhardt2022-01-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/rtsp: #if unused functions away, fix -O0 compilationAndreas Rheinhardt2022-01-08
| | | | | | | | | | | parse_rtsp_message() is only called if the rtsp demuxer is enabled and so it is normally compiled away if said demuxer is disabled. Yet this does not happen when compiling with -O0 and this leads to a linking failure because parse_rtsp_message() calls functions that may not be available if the rtsp demuxer is disabled. Fix this by properly #if'ing the unused functions away. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/img2dec: Don't include disabled demuxersAndreas Rheinhardt2022-01-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/Makefile: Add entries for CRI, GEM and PGX image pipe demuxersAndreas Rheinhardt2022-01-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/Makefile: Add missing alp-muxer->rawenc.o dependencyAndreas Rheinhardt2022-01-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/amr: Fix writing AMR headerAndreas Rheinhardt2022-01-08
| | | | | | Regression since f282c34c009e3653ec160c3880e64fc1a9300d0e. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/amr: Don't reset AVFormatContext.priv_dataAndreas Rheinhardt2022-01-08
| | | | | | | | The AMR muxer doesn't have a private context, so it's priv_data will be NULL. If it weren't, simply setting it to NULL would lead to a memleak. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/Makefile, amr: Add missing amr-demuxers->rawdec.o dependencyAndreas Rheinhardt2022-01-08
| | | | | | | | | Forgotten in 1f447fd95463bbf39a78d886359a3006d82f6a94. Also only enable amr_probe() and amr_read_header() in case the AMR demuxer is enabled; this avoids having to add a rawdec.o dependency to the muxer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/Makefile: Add missing libamqp->urldecode dependencyAndreas Rheinhardt2022-01-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mvdec: re-indent after last commitJohn-Paul Stewart2022-01-08
| | | | | | Signed-off-by: John-Paul Stewart <jpstewart@personalprojects.net> Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Reviewed-by: Peter Ross <pross@xvid.org>
* avformat/mvdec: make audio stream conditionalJohn-Paul Stewart2022-01-08
| | | | | | | | | | | | | | | Only allocate an audio stream if there is one in the data. Silicon Graphics movie format will contain default values (16 bit samples, 2 audio channels, 22050 Hz sample rate) even when no audio is present in the file. This confuses FFmpeg into thinking such an audio stream is present with 0 samples in it. There is a flag value in the format to indicate whether or not audio is present. This patch checks that and behaves accordingly. Signed-off-by: John-Paul Stewart <jpstewart@personalprojects.net> Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Reviewed-by: Peter Ross <pross@xvid.org>
* avformat/matroskaenc: Fix build with only WebM muxer enabledAndreas Rheinhardt2022-01-07
| | | | | | | | | In this case ff_isom_put_dvcc_dvvc() might not be available, leading to linking failures. Given that WebM currently doesn't support DOVI, this is fixed by #if'ing the offending code away if the Matroska muxer is not enabled. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/Makefile: Fix name of PhotoCD demuxerAndreas Rheinhardt2022-01-07
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/takdec: Don't initialize get_bits context to read one valueAndreas Rheinhardt2022-01-07
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/imf: Fix indentationPierre-Anthony Lemieux2022-01-05
| | | | | Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/imf: fix CPL parsing error handlingPierre-Anthony Lemieux2022-01-05
| | | | | Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>