summaryrefslogtreecommitdiff
path: root/libavformat
Commit message (Collapse)AuthorAge
* avformat/demux: Remove fake-loopAndreas Rheinhardt2021-12-16
| | | | | | | When flushing, try_decode_frame() itself loops until the desired properties have been found or the decoder is drained. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/rtpdec_rfc4175: cosmetic changesLimin Wang2021-12-14
| | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/hlsenc: deprecate hls_ts_options optionSteven Liu2021-12-13
| | | | | | | Because the hls_ts_options will be misunderstand by user, and then user can use hls_segment_options instead of hls_ts_options. Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* avformat/hlsenc: add hls_segment_options correct the segment options nameSteven Liu2021-12-13
| | | | | | | Because the hls_ts_options will be misunderstand by user that only can be used in mpegts segments option. So add this option for segments. Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* avformat/img2enc: do not ignore IO errorsMarton Balint2021-12-12
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: introduce AVFormatContext io_close2 which returns an intMarton Balint2021-12-12
| | | | | | | | | | | | | | | | | Otherwise there is no way to detect an error returned by avio_close() because ff_format_io_close cannot get the return value. Checking the return value of the close function is important in order to check if all data was successfully written and the underlying close() operation was successful. It can also be useful even for read mode because it can return any pending AVIOContext error, so the user don't have to manually check AVIOContext->error. In order to still support if the user overrides io_close, the generic code only uses io_close2 if io_close is either NULL or the default io_close callback. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/aviobuf: return stored AVIO context error on avio_closeMarton Balint2021-12-12
| | | | | | Otherwise IO errors at avio_flush() before closing may be lost. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/file: use proper return value in file_closeMarton Balint2021-12-12
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mxfdec: Check for duplicate mxf_read_index_entry_array()Michael Niedermayer2021-12-09
| | | | | | | | | Fixes: memleak Fixes: 41596/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6439060204290048 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mxfdec: Check component_depth in mxf_get_color_range()Michael Niedermayer2021-12-09
| | | | | | | | | Fixes: shift exponent 4294967163 is too large for 32-bit type 'int' Fixes: 41449/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6183636217495552 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/utils: Add const where appropriateAndreas Rheinhardt2021-12-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Fix wrong indentationAndreas Rheinhardt2021-12-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mov: Simplify data->hex conversionAndreas Rheinhardt2021-12-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/md5proto: Simplify data->hex conversionAndreas Rheinhardt2021-12-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/aadec: Use smaller scope for variablesAndreas Rheinhardt2021-12-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/aadec: Simplify data->hex conversionAndreas Rheinhardt2021-12-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/aadec: Simplify deriving file keyAndreas Rheinhardt2021-12-08
| | | | | | | | Don't use different src and dst in av_tea_crypt(); use in-place modifications instead. Also let av_tea_crypt() encrypt all three blocks in one call. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/aadec: Don't unnecessarily reinitialize AVTEA contextAndreas Rheinhardt2021-12-08
| | | | | | | | We use ECB, not CBC mode here, so one does not need to reinitialize the context; for the same reason, one can also just let av_tea_crypt() loop over the blocks, avoiding a loop here. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/aadec: Avoid copying data aroundAndreas Rheinhardt2021-12-08
| | | | | | | | | | | | | Up until now, the packets have been read in blocks of at most eight bytes at a time; then these blocks have been decrypted and copied into a buffer on the stack (that was double the size needed...). From there they have been copied to the dst packet. This commit changes this: The data is read in one go; and the decryption avoids temporary buffers, too, by making use of the fact that src and dst of av_tea_crypt() can coincide. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/aadec: Don't use the same loop counter in inner and outer loopAndreas Rheinhardt2021-12-08
| | | | | | | Due to this bush.aa (from the FATE suite) exported garbage metadata with key "_040930". Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/utils: Make ff_data_to_hex() zero-terminate the stringAndreas Rheinhardt2021-12-08
| | | | | | Most callers want it that way anyway. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/rtsp: fix the error code from ffurl_read_complete()Limin Wang2021-12-07
| | | | | Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/rtsp: add error code handling for ff_rtsp_skip_packet()Limin Wang2021-12-07
| | | | | Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/rtsp: free the alloc memory if failedLimin Wang2021-12-07
| | | | | Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/rtsp: remove redundant assignmentLimin Wang2021-12-07
| | | | | Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/concatf: ignore trailing whitespacesGyan Doshi2021-12-07
| | | | | | | | The concatf protocol returns an opaque error on open if concatf list file contains trailing newlines. Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro> Reviewed-by: James Almer <jamrial@gmail.com>
* lavf/protocols: avoid discarding const in avio_enum_protocols()Anton Khirnov2021-12-07
| | | | | | Instead of storing the protocol pointer in the opaque iteration state, store just the index of the next protocol, similarly to how ff_urlcontext_child_class_iterate() works.
* lavf/img2enc: avoid a useless copy of the urlAnton Khirnov2021-12-07
| | | | | img2enc keeps a private (and possibly truncated) copy of the url that is never modified. Just use AVFormatContext.url instead.
* lavf/ftp: check for truncation in snprintfAnton Khirnov2021-12-07
| | | | | | | | | | | Silences e.g. the following warning in gcc 10: src/libavformat/ftp.c: In function ‘ftp_move’: src/libavformat/ftp.c:1122:46: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4091 [-Wformat-truncation=] 1122 | snprintf(command, sizeof(command), "RNTO %s\r\n", path); | ^~ ~~~~ src/libavformat/ftp.c:1122:5: note: ‘snprintf’ output between 8 and 4103 bytes into a destination of size 4096 1122 | snprintf(command, sizeof(command), "RNTO %s\r\n", path); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* avformat/mov: Disallow duplicate smdmMichael Niedermayer2021-12-06
| | | | | | | | Fixes: memleak Fixes: 39879/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5327819907923968 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mov: Check for EOF in mov_read_glbl()Michael Niedermayer2021-12-06
| | | | | | | | Fixes: Infinite loop Fixes: 41351/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5433895854669824 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/smoothstreamingenc: Move buffers to the end of structsAndreas Rheinhardt2021-12-05
| | | | | | | | This reduces codesize because the offsets of commonly used elements are now smaller and thus need less bytes to encode in ptr+offset addressing modes (with GCC 11.2 on x64: 0x1b8b -> 0x1a7b). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/takdec: Simplify data->hex conversionAndreas Rheinhardt2021-12-05
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: do not use AVIO_FLAG_* with avio_alloc_contextMarvin Scholz2021-12-04
| | | | | | | | | | | | | The documentation states that here 0 should be used for read-only and 1 for a writable buffer. AVIO_FLAG_WRITE however is 2, while it works due to the way the flag is handled internally, it is still wrong according to the documentation. Additionally it makes it seem as if the AVIO_FLAG_* values could be used here, which is actually not true, as when AVIO_FLAG_READ would be used here it would create a writable buffer as AVIO_FLAG_READ is defined as 1. Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avformat/rtspdec: get rid of the hardcoded max size for sdpLimin Wang2021-12-04
| | | | | Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/rtsp: load the sdp file with avio_read_to_bprint()Limin Wang2021-12-04
| | | | | | | this allows getting rid of the hardcoded max size of SDP. Reviewed-by: Martin Storsjö <martin@martin.st> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/aviobuf: check if read_packet() exist before read_packet_wrapper()Limin Wang2021-12-04
| | | | | | | without it, read_packet_wrapper() will return AVERROR(EINVAL) and avio_read will be failed. Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* all: Use av_memdup() where appropriateAndreas Rheinhardt2021-12-03
| | | | | Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/mvdec: handle audio sample sizeJohn-Paul Stewart2021-12-03
| | | | | | | Adds support for reading audio sample size from the data instead of assuming all audio is 16 bits per sample. Reviewed-by: Peter Ross <pross@xvid.org>
* avformat/mvdec: fix reading number of audio channelsJohn-Paul Stewart2021-12-03
| | | | | | | | | The number of audio channels is stored after the magic number identifying the audio format. Prior to this patch the code has been reading it earlier, causing files with only one audio channel to be handled incorrectly. Reviewed-by: Peter Ross <pross@xvid.org>
* avformat/scd: add demuxerZane van Iperen2021-12-02
| | | | | | | | | | | | | | | | Adds demuxer for Square Enux SCD files. Based off [1] and personal investigation. This has only been tested against Drakengard 3 (PS3) *_SCD.XXX files (big-endian). As it is highly likely that FFXIV (PC) files are little-endian, this demuxer is marked as experimental until this can be confirmed. [1]: http://ffxivexplorer.fragmenterworks.com/research/scd%20files.txt Reviewed-by: Peter Ross <pross@xvid.org> Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* avformat/matroskaenc: Sort cues entries by ptsAndreas Rheinhardt2021-11-30
| | | | | | | | | | | Currently they are ordered as-written (i.e. by increasing position); in case av_interleaved_write_frame() is used, this is (mostly) the same as ordered by increasing dts. Yet the Matroska specification strongly recommends (SHOULD) that the CuePoints be sorted by CueTime. mkvalidator warns when they are not. Therefore this commit sorts them accordingly. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/fifo: avoid repeated scaling of timestamps on failure and recoveryRyoji Gyoda2021-11-29
| | | | | | | | | | | | | | | | | | | If fifo_thread_recover() succeeds immediately after fifo_thread_dispatch_message() fails, the dts of the packet is scaled twice, causing cur_dts to be abnormally large and "Application provided invalid, non monotonically increasing dts to muxer in stream" to occur repeatedly. Steps to reproduce: 1. ffmpeg -f lavfi -i testsrc -c:v libx264 -map 0:v -flags +global_header -f fifo -fifo_format flv -attempt_recovery 1 -recover_any_error 1 rtmp://example.com/livekey 2. set a breakpoint on fifo_thread_recover 3. force disconnect from the rtmp server 4. wait for break 5. reconnect to the rtmp server 6. resume execution of ffmpeg Signed-off-by: Ryoji Gyoda <gy.cft4@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/flvenc: avoid 24bit timestamp truncation for FLV metadataasilvestre2021-11-29
| | | | | | | | | | | | | | | | | FLV AMF tags have a 24bit field for timestamps plus an 8bit for extended timestamps. All FLV AMF tags except when we write metadata handle this correctly using the put_timestamp function. Until now when writing metadata we were only using the first 24 bits and thus the timestamp value was wraping around 4 hours 40 minutes (16,800,000 ms, max 24 bit value 16,777,216) of playback. This commit fixes this applying this same function put_timestamp for the metadata FLV tag. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/mov: Check channels for mov_parse_stsd_audio()Michael Niedermayer2021-11-29
| | | | | | | | Fixes: signed integer overflow: -776522110086937600 * 16 cannot be represented in type 'long' Fixes: 40563/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6644829447127040 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: probe JFIF/Exif headerAlex Xu (Hello71)2021-11-27
| | | | | | | | | | | | | | | | | Due to reasons, mpv doesn't pass filename when probing. mpv also sets default probescore threshold to 26. Since the current jpeg_probe implementation returns 25 until EOI, it means that the whole image needs to be probed to succeed. Worse, the whole image is not passed at once; increasingly large buffers are tried before that. Adding it up together, if many demuxers are enabled, moderately large JPEG files (few MB) can take several seconds to open, despite taking less than 1 second to actually decode. Therefore, adjust the heuristic to be more optimistic if proper JFIF or Exif segments are found. While not strictly required, the vast majority of JPEG-ish files have one or the other or both. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/mpegtsenc: Avoid allocation of AVPacketAndreas Rheinhardt2021-11-27
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/movenc: Avoid allocation of AVPacketAndreas Rheinhardt2021-11-27
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/dashenc: Don't use stack packetAndreas Rheinhardt2021-11-27
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: Add AVStream parameter to check_bitstream() sigAndreas Rheinhardt2021-11-27
| | | | | | | | | | For most check_bitstream() functions this just avoids having to dereference s->streams[pkt->stream_index] themselves; but for meta-muxers it will allow to forward the packet to stream with a different stream_index (belonging to a different AVFormatContext) without using a spare packet. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>