summaryrefslogtreecommitdiff
path: root/libavformat
Commit message (Collapse)AuthorAge
* avformat/allformats: Fix data race when accessing devices listsAndreas Rheinhardt2021-10-09
| | | | | | | | | | | | | | | | | | Up until now setting the input and output devices lists is guarded by a mutex. This prevents data races emanating from multiple concurrent calls to avpriv_register_devices() (triggered by multiple concurrent calls to avdevice_register_all()). Yet reading the lists pointers was done without any lock and with nonatomic variables. This means that there are data races in case of concurrent calls to av_(de)muxer_iterate() and avdevice_register_all() (but only if the iteration in av_(de)muxer_iterate exhausts the non-device (de)muxers). This commit fixes this by putting said pointers into atomic objects. Due to the unavailability of _Atomic the object is an atomic_uintptr, leading to ugly casts. Switching to atomics also allowed to remove the mutex currently used in avpriv_register_devices(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/wavdec: Check smv_block_sizeMichael Niedermayer2021-10-09
| | | | | | | | Fixes: Timeout Fixes: 39554/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-4915221701984256 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/rmdec: Check for multiple audio_stream_infoMichael Niedermayer2021-10-09
| | | | | | | | Fixes: memleak Fixes: 39166/clusterfuzz-testcase-minimized-ffmpeg_dem_IVR_fuzzer-5153276690038784 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/img2dec: add GEM Raster image demuxerPeter Ross2021-10-08
| | | | Signed-off-by: Peter Ross <pross@xvid.org>
* oavformat/avidec: Check offset in odmlMichael Niedermayer2021-10-07
| | | | | | | | Fixes: signed integer overflow: 9223372036854775807 + 8 cannot be represented in type 'long' Fixes: 38787/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-4859845799444480 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegts: use actually read packet size in mpegts_resync special caseMichael Niedermayer2021-10-07
| | | | | | | | | Fixes: infinite loop Fixes: 37986/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGTSRAW_fuzzer-5292311517462528 - Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Marton Balint <cus@passwd.hu> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/flacdec: Also set channels when setting channel_layoutAndreas Rheinhardt2021-10-07
| | | | | | | | | This brings the FLAC demuxer in line with all the other demuxers. Furthermore, if it is not done and the FLAC decoder is disabled, the FLAC parser will overwrite the channel layout with the standard channel layout for that number of channels. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/format: Improve const-correctnessAndreas Rheinhardt2021-10-07
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/lrcenc: Unify writing timestampsAndreas Rheinhardt2021-10-07
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/lrcenc: Avoid allocations for writing packet dataAndreas Rheinhardt2021-10-07
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/sccdec: Remove nonsense castAndreas Rheinhardt2021-10-07
| | | | | | | | In most contexts, arrays are automatically converted to a pointer to their first element; taking the address of the array just yields a pointer to an array of fixed-size arrays, which is not intended here. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/{isom,mov,movenc}: add support for CMAF DASH rolesJan Ekström2021-10-04
| | | | | | | | | | | | | | | | This information is coded in a standard MP4 KindBox and utilizes the scheme and values as per the DASH role scheme defined in MPEG-DASH. Other schemes are technically allowed, but where multiple schemes define the same concepts, the DASH scheme should be utilized. Such flagging is additionally utilized by the DASH-IF CMAF ingest specification, enabling an encoder to inform the following component of the roles of the incoming media streams. A test is added for this functionality in a similar manner to the matroska test. Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
* avformat/{aviobuf,avio_internal}: add max_len argument to ↵Jan Ekström2021-10-04
| | | | | | | | | | ff_read_string_to_bprint_overwrite This is especially useful when reading things such as null-terminated strings from MOV/MP4-likes, where the size of the box is known, but not the exact size of the string. Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
* avformat/{aviobuf,avio_internal}: add ff_read_string_to_bprint_overwriteJan Ekström2021-10-04
| | | | | | | For now, same as ff_read_line_to_bprint_overwrite, but reads until the end of a null-terminated string. Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
* avformat/aviobuf: add a full string reading mode to read_line_to_bprintJan Ekström2021-10-04
| | | | | | | | | | Additionally: * rename it to read_string_to_bprint * split most of ff_read_line_to_bprint_overwrite into an internal function which can then be utilized to implement other functionality without duplicating code. Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
* avformat/mux: Remove unnecessary av_packet_unref()Andreas Rheinhardt2021-10-03
| | | | | | AVFormatInternal.parse_pkt is always blank after having been used. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/tee: ReindentationAndreas Rheinhardt2021-10-03
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/tee: Process strings immediately if possibleAndreas Rheinhardt2021-10-03
| | | | | | This avoids having to free them manually lateron. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/tee: Fix leak of FIFO-options dictionaryAndreas Rheinhardt2021-10-03
| | | | | | Happened for all slaves which didn't use the FIFO. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/tee: Fix leak of stringsAndreas Rheinhardt2021-10-03
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/tee: Avoid stack packetAndreas Rheinhardt2021-10-03
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/tee: Unref packet on av_bsf_send_packet() failureAndreas Rheinhardt2021-10-03
| | | | | | | | Given that the packet sent to av_bsf_send_packet() is always already refcounted, it is doubtful whether the error can even be triggered currently. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/tee: Fix inconsistency wrt av_packet_ref() failure handlingAndreas Rheinhardt2021-10-03
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/webpenc: Don't use sizeof(AVPacket)Andreas Rheinhardt2021-10-03
| | | | | | | | | In this case it means replacing a packet in the muxer's context by a pointer to an AVPacket, namely AVFormatInternal.pkt. Because this packet is freed generically, one can remove the muxer's deinit function. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/flacenc: Avoid stack packetAndreas Rheinhardt2021-10-03
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/img2enc: Don't use sizeof(AVPacket)Andreas Rheinhardt2021-10-03
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mp3enc: Avoid stack packetAndreas Rheinhardt2021-10-03
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/ttaenc: Avoid stack packetAndreas Rheinhardt2021-10-03
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/matroskaenc: Avoid allocation of AVPacketAndreas Rheinhardt2021-10-03
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avienc: Avoid allocating AVPacketAndreas Rheinhardt2021-10-03
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/amvenc: Avoid allocating packetAndreas Rheinhardt2021-10-03
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/internal: Allow AVFormatInternal.pkt to be used by muxersAndreas Rheinhardt2021-10-03
| | | | | | It is unused by the generic muxing code. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/asfenc: Return proper error codesAndreas Rheinhardt2021-10-03
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/asfenc: Add deinit functionAndreas Rheinhardt2021-10-03
| | | | | | Fixes leaks when the trailer is never written. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/asfenc: Avoid allocations when writing metadataAndreas Rheinhardt2021-10-03
| | | | | | Also improves the error check for avio_open_dyn_buf(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/asfenc: Remove unused fields from ASFStreamAndreas Rheinhardt2021-10-03
| | | | | | | | | It has never been done in b08569a23948db107e5e6175cd4c695427d5339d, 30b8f3e7dcd0318b91e205dcbf774ef92fb6193c. After this change, this muxer does no longer use sizeof(AVPacket). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mux: Use AVFormatInternal.parse_pkt for temporary packetsAndreas Rheinhardt2021-10-03
| | | | | | | | The documentation of said packet ("Every user has to ensure that this packet is blank after using it") perfectly fits how we use said packet in the generic muxing code. Better than the documentation of pkt. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mux: Don't use stack packet when writing interleaved packetsAndreas Rheinhardt2021-10-03
| | | | | | | | | | | | | | | | | | | Currently the interleave_packet functions use a packet for a new packet to be interleaved (may be NULL if there is none) and a packet for output; said packet is always a stack packet in interleaved_write_packet(). But all the interleave_packet functions in use first move the packet to the packet list and then check whether a packet can be returned, i.e. the effective lifetime of the new packet ends before the packet for output is touched. So one can use one packet both for input and output by adding a new parameter that indicates whether there is a packet to add to the packet list; there is just one complication: In case the muxer is flushed, there is no packet available. This can be solved by reusing one of the packets from AVFormatInternal. They are currently unused when flushing in av_interleaved_write_frame(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: Clarify documentation of av_interleaved_write_frame()Andreas Rheinhardt2021-10-03
| | | | | | | | | | | | | | | | | | | The earlier documentation claimed that av_interleaved_write_frame() always orders by dts, which is not necessarily true when using muxers with custom interleavement functions or the audio_preload option. Furthermore, the documentation stated that libavformat takes ownership of the reference of the provided packet (if it is refcounted) and that the caller may not access the data through this reference after the function returns. This suggests that the returned packet is not blank, but instead still contains some set, but invalid fields, which implies that it would be dangerous to unreference this packet again. But this is not true: av_interleaved_write_frame()'s actual behaviour is to always output blank packet (even on error). This commit documents this fact so that callers know that they can directly reuse this packet. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mux: Sanitize packets without data and side-dataAndreas Rheinhardt2021-10-03
| | | | | | | | | The BSF API treats such packets as signalling EOF and therefore such a packet might corrupt the BSF state. In such a case, the guarantee that av_interleaved_write_frame() always frees the packet is not upheld. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/amr*dec: add multichannel supportPaul B Mahol2021-10-03
|
* avcodec: add amr parserPaul B Mahol2021-10-02
|
* avformat/lrcenc: Remove unnecessary headerAndreas Rheinhardt2021-10-02
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/(lrc|scc)enc: Use avio_w8() to write a single charAndreas Rheinhardt2021-10-02
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/subtitles: Honour ff_subtitles_read_line() documentationAndreas Rheinhardt2021-10-02
| | | | | | | | | It claims to always zero-terminate its buffer like snprintf(), yet it does it not on EOF. Because of this the mcc demuxer used uninitialized values when reading an empty input file. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/sccdec: Avoid zero-terminating unnecessarilyAndreas Rheinhardt2021-10-02
| | | | | | | | ff_subtitles_queue_insert() does not require its events to be zero-terminated as it has a parameter for the length. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/sccdec: Make constants more intelligibleAndreas Rheinhardt2021-10-02
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/sccdec: Fix position of returned subtitle packetsAndreas Rheinhardt2021-10-02
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/sccdec: Remove redundant checkAndreas Rheinhardt2021-10-02
| | | | | | | The av_sscanf() will filter lines like "Scenarist_SCC V1.0" out. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/sccdec: Don't use uninitialized data, fix crash, simplify logicAndreas Rheinhardt2021-10-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, the scc demuxer not only read the line that it intends to process, but also the next line, in order to be able to calculate the duration of the current line. This approach leads to unnecessary complexity and also to bugs: For the last line, the timing of the next subtitle is not only logically indeterminate, but also uninitialized and the same applies to the duration of the last packet derived from it.* Worse yet, in case of e.g. an empty file, it is not only the duration that is uninitialized, but the whole timing as well as the line buffer itself.** The latter is used in av_strtok(), which could lead to crashes. Furthermore, the current code always outputs at least one packet, even for empty files. This commit fixes all of this: It stops using two lines at a time; instead only the current line is dealt with and in case there is a packet after that, the duration of the last packet is fixed up after having already parsed it; consequently the duration of the last packet is left in its default state (meaning "unknown/up until the next subtitle"). If no further line could be read, processing is stopped; in particular, no packet is output for an empty file. *: Due to stack reuse it seems to be zero quite often; for the same reason Valgrind does not report any errors for a normal input file. **: While ff_subtitles_read_line() claims to always zero-terminate the buffer like snprintf(), it doesn't do so if it didn't read anything. And even if it did, it would not necessarily help here: The current code jumps over 12 bytes that it deems to have read even when it hasn't. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>