summaryrefslogtreecommitdiff
path: root/libavformat
Commit message (Collapse)AuthorAge
...
* avformat/tests: add /imf to .gitignorePierre-Anthony Lemieux2022-02-05
| | | | Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/demux: don't truncate the return value of ts_to_samples()James Almer2022-02-05
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/demux: print skip_samples and discard_padding as unsigned values in ↵James Almer2022-02-05
| | | | | | | | | debug log It's the type they should be interpreted as in the AV_PKT_DATA_SKIP_SAMPLES side data. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/demux: don't propagate unsupported skip samples packet side data valuesJames Almer2022-02-05
| | | | | | Should fix ticket #9622 Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/imf_cpl: do not use filesize when reading XML fileMarton Balint2022-02-05
| | | | | | Similar to the earlier patch applied to imfdec. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/rtpdec_rfc4175: fix interlace formatPatrick Keroulas2022-02-05
| | | | | | | | | | | | | In previous state, a new frame was allocated on each timestamp step, i.e. each frame/field transition. However, for interlace, a new frame should be allocated on 1st field, completed with the 2nd and finally freed. This commit fixes the frame allocation and the detection of missing RTP markers. Signed-off-by: Patrick Keroulas <patrick.keroulas@radio-canada.ca> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/img2dec: increase probe score for GEM image fourcc variantsPeter Ross2022-02-04
| | | | Signed-off-by: Peter Ross <pross@xvid.org>
* avformat/img2dec: fix logic error in GEM Raster file probePeter Ross2022-02-04
| | | | | | | | Use correct logic to express limits of the planes and pattern_size fields. Fix ticket# 9605 Signed-off-by: Peter Ross <pross@xvid.org>
* Add MKV tags for AVS2 and AVS3 codecs.TianBo Zheng2022-02-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: TianBo Zheng <naturalwalker@hotmail.com> MKV codec mappings: V_AVS2 and V_AVS3 (https://github.com/ietf-wg-cellar/matroska-specification/blob/master/codec_specs.md) Encoding tool: Ffmpeg with AVS2/AVS3 enabled: https://github.com/xatabhk/FFmpeg-avs2-avs3/releases Command line: ffmpeg -i xxxx.mp4 -vcodec avs2 -acodec copy xxxx_avs2.mkv ffmpeg -i xxxx.mp4 -vcodec avs2 -speed_level 4 -acodec copy xxxx_avs2.mkv` Players: (1) Ffmpeg with avs2/avs3 enabled: (https://github.com/xatabhk/FFmpeg-avs2-avs3/releases): Command line: ffplay xxxx_avs2.mkv ffplay xxxx_avs3.mkv (2) VLC 3.0.x with AVS2/AVS3 enabled: https://github.com/xatabhk/vlc-3.0-avs2-avs3/releases (3) Mpc-hc 1.9.x with AVS2/AVS3 enabled: https://gitee.com/zhengtianbo/cavs-avs2-avs3_decoder_added_to_mpc_hc/releases AVS2/AVS3 MKV samples: https://github.com/xatabhk/avs2-avs3-video-samples Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mov: Check size before subtractionMichael Niedermayer2022-02-01
| | | | | | | | Fixes: signed integer overflow: -9223372036854775808 - 8 cannot be represented in type 'long' Fixes: 43542/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5237670148702208 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/http: Fix double-free on errorAndreas Rheinhardt2022-02-01
| | | | | | | | | | | av_dict_set() with AV_DICT_DONT_STRDUP_VAL takes ownership of the string it is passed to as val; this includes freeing it on error. Fixes Coverity issue #1497468. Reviewed-by: Eran Kornblau <eran.kornblau@kaltura.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* http: remove cache_redirect optionerankor2022-01-31
| | | | | | | | | following 625ea2d, redirect caching is performed according to the http response headers, there's no need to have it as an option - always start from the original uri, and apply any redirects according to the redirect_cache dictionary. Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
* avformat/dashdec: avoid calling strlen multiple timesLimin Wang2022-01-30
| | | | | Reviewed-by: Steven Liu <liuqi05@kuaishou.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/rtpdec: return value check for init_get_bits()Limin Wang2022-01-30
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/rtpdec: Fix negative missed packets in warning messageLimin Wang2022-01-30
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/matroskadec: Export rectangular projection as displaymatrixAndreas Rheinhardt2022-01-29
| | | | | | | This is the officially supported way to express rotations and flips in Matroska. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hls: Remove redundant castAndreas Rheinhardt2022-01-21
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mux: Peek into the muxing queue for avoid_negative_tsAndreas Rheinhardt2022-01-21
| | | | | | | | | | | Peeking into the muxing queue can improve the estimate of the lowest timestamp needed for avoid_negative_ts in case the lowest timestamp is in a packet other than the first packet to be muxed. This fixes tickets #4536 and #5784 as well as the output from the matroska-avoid-negative-ts FATE-test. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mux: Preserve sync even if later packet has negative tsAndreas Rheinhardt2022-01-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | write_packet() has code to shift the packets timestamps to make them nonnegative or even make them start at ts zero; this code inspects every packet that is written and if a packet with negative timestamp (whether this is dts or pts depends upon another flag; basically: Matroska uses pts, everyone else dts) is encountered, this is offset to make the timestamp zero. All further packets will be offset accordingly (with the offset converted according to the streams' timebases). This is based around an assumption, namely that the timestamps are indeed non-decreasing, so that the first packet with negative timestamps is the first packet with timestamps. This assumption is often fulfilled given that the default interleavement function by default interleaves per dts; yet there are scenarios in which it may not be fulfilled: a) av_write_frame() instead of av_interleaved_write_frame() is used. b) The audio_preload option is used. c) When the timestamps that are made nonnegative/zero are pts (i.e. with Matroska), because the packet with the smallest dts is not necessarily the packet with the smallest pts. d) Possibly with custom interleavement functions. In these cases the relative sync of the first few packet(s) is offset relative to the later packets. This contradicts the documentation ("When shifting is enabled, all output timestamps are shifted by the same amount"). Therefore this commit changes this: As soon as the first packet with valid timestamps is output, it is checked and recorded whether the timestamps need to be shifted. Further packets are no longer checked for needing to be offset; instead they are simply offset. In the cases above this leads to packets with negative timestamps (and the appropriate warnings) instead of desync. This will mostly be fixed in the next commit. This commit also factors handling the avoid_negative_ts stuff out of write_packet() in order to be able to return immediately. Tickets #4536 and #5784 as well as the matroska-avoid-negative-ts-test are examples of c); as has been said, some timestamps are now negative, yet the ref file update does not show it because ffmpeg.c sanitizes the timestamps (-copyts disables it; ffprobe and mkvinfo also show the original timestamps). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: Add AVFMT_AVOID_NEG_TS_DISABLEDAndreas Rheinhardt2022-01-21
| | | | | | And also don't use explicit constants in the movenc test. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mux: Remove assert based on faulty assumptionsAndreas Rheinhardt2022-01-21
| | | | | | | | | This assert is based upon the wrong assumption that the noninterleaved codepath is never used; if it is used, max_interleave_delta is irrelevant. It furthermore ignores audio_preload. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mov: Fix endian-dependent parsingAndreas Rheinhardt2022-01-21
| | | | | | | | | | MOVAtom.type is always read as a little-endian number (despite MOV/ISOBMFF being big-endian). Fixes the matroska-dovi-write-config8 FATE-test on big-endian arches (which runs into the "index out of range" warning message). Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavf/network: log ff_listen() errors to proper contexts rather than NULLAnton Khirnov2022-01-21
|
* lavf/network: log ff_socket() errors to proper contexts rather than NULLAnton Khirnov2022-01-21
|
* lavf/udp: log net errors to proper contexts rather than NULLAnton Khirnov2022-01-21
|
* avformat/matroskaenc: Fix writing AV_SPHERICAL_EQUIRECTANGULARAndreas Rheinhardt2022-01-20
| | | | | | | | According to the documentation, the ISOBMFF 'equi' box must be present for equirectangular projections. Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskadec: Use correct type for field_orderAndreas Rheinhardt2022-01-19
| | | | | | It is unsigned in the spec and read from an uint64_t field. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/imfdec: Use proper logcontextAndreas Rheinhardt2022-01-19
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Write data directly into dynamic buffersAndreas Rheinhardt2022-01-19
| | | | | | | | This avoids copying the data in small chunks (1024B) into the dynamic buffer's small buffer before finally writing them into the "big" buffer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Avoid repeated avio_tell()Andreas Rheinhardt2022-01-19
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: ReindentationAndreas Rheinhardt2022-01-19
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Remove duplicated code for writing WebVTT subsAndreas Rheinhardt2022-01-19
| | | | | | | | | | | | | | | | | | | | | | Up until now, the WebM variant of WebVTT subtitles has been handled specially: It had its own function to write it, because the data had to be reformatted before writing. But given that other codecs also need reformatting, this is no good reason to also duplicate the generic stuff for writing Block(Group)s. This commit therefore uses an ordinary reformatting function for this task; writing WebVTT subtitles now uses the generic code and therefore automatically uses the least amount of bytes for its BlockGroup length fields whereas the earlier code used an overestimation for the length of the Duration element. This is the reason for the changes to the webm-webvtt-remux FATE-test. (This commit does not implement support for Matroska's way of muxing WebVTT; it also does not add checks to ensure that WebM-style subtitles don't get muxed in Matroska. But the function for reformatting gets a webm prefix to indicate that this is for WebM.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Don't waste bytes on BlockGroup length fieldsAndreas Rheinhardt2022-01-19
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit uses the new EbmlWriter API to write the length fields of the BlockGroup and its descendants that are themselves Master elements (namely BlockAdditions and BlockMore) on the least amount of bytes. This fixes regressions introduced when the special code for writing general subtitles was removed. Accordingly, the binsub-mksenc and matroska-zero-length-block FATE-tests have now been reverted back to their old state again; the advantages of this approach are evident with the matroska-vp8-alpha-remux test which up until now wrote all the length fields of all BlockGroups, BlockAdditions and BlockMore on eight bytes. Using the EbmlWriter API also allowed to improve locality in mkv_write_block(): E.g. both DiscardPadding as well as the BlockAdditional side-data are now directly used to add elements to the writer whereas the earlier code had to first check for whether a BlockGroup should be used and then check again (after the place where a BlockGroup would be opened if one were used) for whether there is DiscardPadding or BlockAdditional side-data to write. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Redo applying ProRes offsetAndreas Rheinhardt2022-01-19
| | | | | | | | | Add a field to mkv_track that is set to the offset instead of checking for whether the track is ProRes when writing the Block. This makes writing the Block independent of the AVCodecParameters. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Pass more parameters explicitly to mkv_write_blockAndreas Rheinhardt2022-01-19
| | | | | | | | This e.g. stops recalculating ts again. Also pass the AVFormatContext as pointer to void as it is only used for logging. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Remove special code for writing subtitlesAndreas Rheinhardt2022-01-19
| | | | | | | | | | | | | | | | | | Once upon a time, mkv_write_block() only wrote a (Simple)Block, not a BlockGroup which is needed for subtitles to convey the duration. But with the introduction of support for writing BlockAdditions and DiscardPadding (both of which require a BlockGroup), mkv_write_block() can also open and close a BlockGroup of its own. This naturally led to some code duplication which is removed in this commit. This new code leads to one regression: It always uses eight bytes for the BlockGroup's length field, whereas the earlier code usually used the lowest amount of bytes needed. This will be fixed in a future commit. This temporary regression is also the reason for changes to the binsub-mksenc and matroska-zero-length-block fate tests. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* 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>