summaryrefslogtreecommitdiff
path: root/libavformat
Commit message (Collapse)AuthorAge
* avformat/dhav: use frame number if timestamp difference is zeroPaul B Mahol2021-09-08
|
* avformat/mlpdec: fix time_base for packet timestampsPaul B Mahol2021-09-07
|
* avcodec/siren: MSN Siren decoderPeter Ross2021-09-07
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Peter Ross <pross@xvid.org>
* avformat/mux: Fix double-free when using AVPacket.opaque_refAndreas Rheinhardt2021-09-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, ff_write_chained() copied the packet (manually, not with av_packet_move_ref()) from a packet given to it to a stack packet whose timing and stream_index is then modified before being sent to another muxer via av_(interleaved_)write_frame(). Afterwards it is intended to sync the fields of the packet relevant to freeing again; yet this only encompasses buf, side_data and side_data_elems and not the newly added opaque_ref. The other fields are not synced so that the returned packet can have a size > 0 and data != NULL despite its buf being NULL (this always happens in the interleaved codepath; before commit fe251f77c80b0512ab8907902e1dbed3f4fe1aad it could also happen in the noninterleaved one). This leads to double-frees if the interleaved codepath is used and opaque_ref is set. This commit therefore changes this by directly reusing the packet instead of a spare packet. Given that av_write_frame() does not change the packet given to it, one only needs to restore the timing information to return it as it was; for the interleaved codepath it is not possible to do likewise*, because av_interleaved_write_frame() takes ownership of the packets given to it and returns blank packets. But precisely because of this users of the interleaved codepath have no legitimate expectation that their packet will be returned unchanged. In line with av_interleaved_write_frame() ff_write_chained() therefore returns blank packets when using the interleaved codepath. Making the only user of said codepath compatible with this was trivial. *: Unless one wanted to create a full new reference. Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/cafdec: try skipping various chunks only when seeking is possiblePaul B Mahol2021-09-03
|
* avformat: add an AV1 Low overhead bitstream format muxerJames Almer2021-09-01
| | | | | Suggested-by: BBB Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/utils: Use av_memdup to duplicate array of AVChapter *Andreas Rheinhardt2021-08-31
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Don't allocate zero-sized arrayAndreas Rheinhardt2021-08-31
| | | | | | | It is unnecessary and also ill-defined: av_malloc() returns a 1-byte block of memory in this case, but this is not documented. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Don't compare pointers when sorting chaptersAndreas Rheinhardt2021-08-31
| | | | | | | | | | | The chapters are independently allocated, so that comparing the pointers is undefined behaviour. Furthermore, its result is not platform-independent (and may not even be deterministic on a particular platform). So compare the chapters' ids instead. (avpriv_new_chapter() ensures that there are no duplicate ids.) Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Allocate AVStream.info only for input streamsAndreas Rheinhardt2021-08-30
| | | | | | | This structure is only used for demuxers (mostly in avformat_find_stream_info()), so only allocate it for them. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Don't initialize AVStreamInternal.info multiple timesAndreas Rheinhardt2021-08-30
| | | | | | | | | | | | | | | | It has been allocated and initialized in avformat_find_stream_info() until fd0368e7ca35e2feaf7960564e61a76655c4d1f6 when the structure was moved to AVStreamInternal and its allocation to avformat_new_stream. In order to also initialize the struct for new streams that only get created during avformat_find_stream_info() said the initialization has been added to avformat_new_stream() later. Due to the Libav-FFmpeg split this has been done twice: In 4cda8aa1c5bc58f8a7f53a21a19b03e7379bbcdc and in 30c26c2442e4e44ac5a763c23c4b0fdd9921a7f5. The initialization in avformat_find_stream_info() has not been removed at all despite being redundant. This commit removes it and the duplicated initialization in avformat_new_stream(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Remove redundant flushing of packet queueAndreas Rheinhardt2021-08-30
| | | | | | | The packet queue is already flushed in avformat_free_context() which is called a few lines below. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mux: Don't access AVStream's internal AVCodecContextAndreas Rheinhardt2021-08-30
| | | | | | | | | | An AVStream's internal AVCodecContext is pretty much unused for muxing: The only place where any of its fields are set is avformat_transfer_internal_stream_timing_info() where its time base is set based upon the desired output format. The max_b_frames field is never set at all, so don't read it in mux.c. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Make ff_compute_frame_duration() staticAndreas Rheinhardt2021-08-30
| | | | | | | | Since 1c0885334dda9ee8652e60c586fa2e3674056586 ff_compute_frame_duration is only called from within utils.c and only for demuxers. So make it static and remove the code in it that deals with muxers. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Remove obsolete todoAndreas Rheinhardt2021-08-30
| | | | | | Also initialize the AVCodecContexts directly. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Remove always-false checkAndreas Rheinhardt2021-08-30
| | | | | | | | | AVFormatContext.internal is already allocated by avformat_alloc_context() on success; and on error, avformat_alloc_context() cleans up manually without avformat_free_context(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/yuv4mpegdec: Don't call avio_tell() twiceAndreas Rheinhardt2021-08-30
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskadec: Fix heap-buffer overflow upon gigantic timestampsAndreas Rheinhardt2021-08-30
| | | | | | | | | | | | | | | | | | | The WebM DASH Manifest demuxer creates a comma-delimited list of all the timestamps of index entries. It allocates 20 bytes per timestamp; yet the largest 64bit numbers have 20 decimal digits (for int64_t it can be '-'+ 19 digits), so that one needs 21B per entry because of the comma (resp. the final NUL). The code uses snprintf, but snprintf returns the strlen of the string that would have been written had the supplied buffer been big enough. And if this is 21, then the next entry is written at an offset of 21 from the current position. So if enough such entries exist, the buffer won't suffice. This commit fixes this by replacing the allocation of buffer for the supposedly worst-case with dynamic allocations by using an AVBPrint. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mov: Check dts for overflow in mov_read_trun()Michael Niedermayer2021-08-29
| | | | | | | | Fixes: signed integer overflow: 9223372034248226491 + 3275247799 cannot be represented in type 'long' Fixes: clusterfuzz-testcase-minimized-audio_decoder_fuzzer-4538729166077952 Reported-by: Matt Wolenetz <wolenetz@google.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/avidec: Use 64bit for frame number in odml index parsingMichael Niedermayer2021-08-28
| | | | | | | | Fixes: signed integer overflow: 1179337772 + 1392508928 cannot be represented in type 'int' Fixes: 34088/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-5846945303232512 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flac_picture: ReindentationAndreas Rheinhardt2021-08-28
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/flac_picture: Simplify parsing titleAndreas Rheinhardt2021-08-28
| | | | | | | Don't allocate the buffer for the title ourselves, leave it to av_dict_set(). This simplifies freeing. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/flac_picture: Try to reuse buffer for attached pictureAndreas Rheinhardt2021-08-28
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/oggparsevorbis: Avoid tmp bufs when parsing VorbisCommentAndreas Rheinhardt2021-08-28
| | | | | | | | | | | | | | | | | | | | | | | | A single VorbisComment consists of a length field and a non-NUL-terminated string of the form "key=value". Up until now, when parsing such a VorbisComment, zero-terminated duplicates of key and value would be created. This is wasteful if these duplicates are freed shortly afterwards, as happens in particular in case of attached pictures: In this case value is base64 encoded and only needed to decode the actual data. Therefore this commit changes this: The buffer is temporarily modified so that both key and value are zero-terminated. Then the data is used in-place and restored to its original state afterwards. This requires that the buffer has at least one byte of padding. All buffers currently have AV_INPUT_BUFFER_PADDING_SIZE bytes padding, so this is ok. Finally, this also fixes weird behaviour from ogm_chapter(): It sometimes freed given to it, leaving the caller with dangling pointers. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/oggparsevorbis: Factor parsing a single VorbisComment outAndreas Rheinhardt2021-08-28
| | | | | | This is in preparation for further commits. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/movenc: Avoid calling strlen multiple timesAndreas Rheinhardt2021-08-27
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/vorbiscomment: Don't compute strlen twiceAndreas Rheinhardt2021-08-27
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/aviobuf: Use ffio_fill for paddingAndreas Rheinhardt2021-08-25
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/aviobuf: Avoid allocation when using dynamic bufferAndreas Rheinhardt2021-08-25
| | | | | | | This can be achieved by allocating the AVIOContext and the dynamic buffer's opaque and internal write buffer together. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avio: Move internal AVIOContext fields to avio_internal.hAndreas Rheinhardt2021-08-25
| | | | | | | | | | | | | | Currently AVIOContext's private fields are all over AVIOContext. This commit moves them into a new structure in avio_internal.h instead. Said structure contains the public AVIOContext as its first element in order to avoid having to allocate a separate AVIOContextInternal which is costly for those use cases where one just wants to access an already existing buffer via the AVIOContext-API. For these cases ffio_init_context() can't fail and always returned zero, which was typically not checked. Therefore it has been made to not return anything. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/aviobuf: Make ffio_set_buf_size() staticAndreas Rheinhardt2021-08-25
| | | | | | Possible since 9c3adb7ce23522dcceb264bc0bffd3592dd3e1a5. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Move ffio_limit() to aviobufAndreas Rheinhardt2021-08-25
| | | | | | | | It is the more natural place for it given that it only deals with I/O; in fact, the function already has the ffio prefix and its declaration already is in avio_internal.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskadec: Read RealAudio extradata directlyAndreas Rheinhardt2021-08-25
| | | | | | Don't use the avio-API to read a few bytes at fixed offsets. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/aviobuf: Avoid calling function twice due to FFMAX()Andreas Rheinhardt2021-08-25
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/movenc: add support for TTML muxingJan Ekström2021-08-25
| | | | | | | | | | | Includes basic support for both the ISMV ('dfxp') and MP4 ('stpp') methods. This initial version also foregoes fragmentation support in case the built-in sample squashing is to be utilized, as this eases the initial review. Additionally, add basic tests for both muxing modes in MP4. Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
* avformat/ttml: split TTML paragraph based or not check into headerJan Ekström2021-08-25
| | | | | | This way it can be re-utilized in movenc. Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
* avformat/matroskaenc: Only compile functions when neededAndreas Rheinhardt2021-08-24
| | | | | | Fixes unused function warnings in case e.g. the WebM muxer is disabled. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskadec: Include webm_dash_manifest demuxer only if enabledAndreas Rheinhardt2021-08-24
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Pass dispositions through unchanged by defaultAndreas Rheinhardt2021-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, the Matroska muxer did not use the dispositions it is given as-is; instead it by default overrode the disposition of the first track of a kind (audio, video, subtitles) if no track of this kind has the default disposition set. And up until recently, it also enforced by default that no more than one track of each kind be marked as default. The rationale for the former is that there are lots of containers which lack the concept of default streams, so that it is not uncommon for no stream to be marked as default at all; the rationale for the latter was that up until recently, it was dubious whether the Matroska specification allowed more than one default stream for track type (e.g. mkvmerge disallowed it). It was this point which led to the implementation of the above mentioned behaviour inspired by mkvmerge. Yet the Matroska specifications have changed and now explicitly allow to set more than one track of each type as default, so that the main reason of not using the dispositions as-is was rendered moot. Therefore this commit changes the default to pass the disposition through. The matroska-mpegts-remux FATE-test has been updated to still use the old "infer" mode so that it is still covered by FATE; the matroska-zero-length-block test has also been updated to cover the infer_no_subs mode. The references for lots of other FATE tests needed to be updated because of a newly added FlagDefault element with value zero (whereas a FlagDefault with value 1 needn't be coded at all, as it coincided with the default value of said element). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Allow to set multiple streams as defaultAndreas Rheinhardt2021-08-24
| | | | | | | | | | The Matroska specifications have evolved and now allow to mark multiple tracks of the same kind as default (whether this was legal or not before was dubious; e.g. mkvmerge disallowed it). Yet when the Matroska muxer is set to infer default dispositions if absent, it also enforced the now outdated restriction. So update this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/crcenc: Simplify writing trailerAndreas Rheinhardt2021-08-24
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/av1dec: Disallow seeking by bytesAndreas Rheinhardt2021-08-23
| | | | | | | | | The low overhead OBU format provides no means to resync after performing a byte-based seek; in other words: Byte based seeking is just not supported. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/av1dec: Flush BSF upon seekingAndreas Rheinhardt2021-08-23
| | | | | | | | | | | | | | The av1_merge_frame BSF outputs its cached data when it sees the beginning of a new frame, i.e. when it sees a temporal delimiter OBU. Therefore it typically has a temporal delimiter OBU cached after outputting a packet. This implies that the OBU demuxer must flush its BSF upon seeking because otherwise the first frame returned after a seek consists of an old temporal delimiter OBU only. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Also set io_repositioned for generic seekingAndreas Rheinhardt2021-08-23
| | | | | | | | It allows demuxers to perform certain tasks after a successful generic seek. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/av1dec: Deduplicate Annex B and low overhead OBU AV1 demuxerAndreas Rheinhardt2021-08-23
| | | | | Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/av1dec: Set position of AVPackets given to BSFAndreas Rheinhardt2021-08-23
| | | | | Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mov: add AVFMT_SHOW_IDS flagGyan Doshi2021-08-22
| | | | | | The MOV muxer can store streamids as track ids but they aren't visible when probing the result via lavf/dump or ffprobe due to lack of this flag in the demuxer.
* lavf/concatdec: support per-file optionsNicolas George2021-08-22
|
* libavformat/concatdec: remove support for unsafe=-1Nicolas George2021-08-22
| | | | | It only makes sense as the default value, but it is not the default since 689211d5727231c3fe92762d224dbadebdbf4e30.
* avformat/hlsenc: minus subtitle streams count when subtitle stream between ↵Steven Liu2021-08-19
| | | | | | | | | | | | | | | | | | video and audio streams because subtitles streams will be written to webvtt m3u8 list so the stream index should minus subtitles streams count when subtitle between audio and video streams. testcase: before patch: ffmpeg -i input -map 0:a:0 -map 0:s:0 -map 0:v:0 -f hls aaaa.m3u8 will EXC_BAD_ACCESS after patch: ffmpeg -i input -map 0:a:0 -map 0:s:0 -map 0:v:0 -f hls aaaa.m3u8 will ok Signed-off-by: Steven Liu <liuqi05@kuaishou.com>