aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/concatdec.c
Commit message (Collapse)AuthorAgeFilesLines
* avformat/concatdec: Clip duration in one more case in get_best_effort_duration()Michael Niedermayer2025-07-211-1/+1
| | | | | | | | | Fixes: signed integer overflow: 40000 - -9223372036854770000 cannot be represented in type 'long' Fixes: 427262541/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-4831506940100608 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/concatdec: Check fileMichael Niedermayer2024-05-091-0/+5
| | | | | | | | Fixes: null pointer dereference Fixes: -stream_loop 1 -ss 00:00:05 -i zgclab/ffmpeg_crash/poc2 -codec:v copy -codec:a aac -y output.mp4 Found-by: Wang Dawei and Zhou Geng, from Zhongguancun Laboratory Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-311-0/+1
| | | | | | | | | | | There are lots of files that don't need it: The number of object files that actually need it went down from 2011 to 884 here. Keep it for external users in order to not cause breakages. Also improve the other headers a bit while just at it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/concatdec: Check user_duration sumMichael Niedermayer2024-03-261-0/+2
| | | | | | | | Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-6434245599690752 Fixes: signed integer overflow: 9223372026773000000 + 22337000000 cannot be represented in type 'long' Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/internal: Move FF_FMT_INIT_CLEANUP to demux.hAndreas Rheinhardt2024-03-261-1/+1
| | | | | | | | | and rename it to FF_INFMT_INIT_CLEANUP. This flag is demuxer-only, so this is the more appropriate place for it. This does not preclude adding internal flags common to both demuxer and muxer in the future. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/concatdec: clip outpoint - inpoint overflow in ↵Michael Niedermayer2024-03-261-1/+1
| | | | | | | | | | | | get_best_effort_duration() An alternative would be to limit all time/duration fields to below 64bit Fixes: signed integer overflow: -93000000 - 9223372036839000000 cannot be represented in type 'long long' Fixes: 64546/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5110813828186112 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/concatdec: Check in and outpoints to be to produce a positive ↵Michael Niedermayer2024-03-101-0/+6
| | | | | | | | | | representable duration Fixes: signed integer overflow: -93000000 - 9223372036839000000 cannot be represented in type 'long' Fixes: 64546/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5110813828186112 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/avformat: Add FFInputFormat, hide internals of AVInputFormatAndreas Rheinhardt2024-03-071-4/+4
| | | | | | | | | | | | | | | | | | | | | This commit does for AVInputFormat what commit 59c9dc82f450638a3068deeb1db5c56f6d155752 did for AVOutputFormat: It adds a new type FFInputFormat, moves all the internals of AVInputFormat to it and adds a now reduced AVInputFormat as first member. This does not affect/improve extensibility of both public or private fields for demuxers (it is still a mess due to lavd). This is possible since 50f34172e0cca2cabc5836308ec66dbf93f5f2a3 (which removed the last usage of an internal field of AVInputFormat in fftools). (Hint: tools/probetest.c accesses the internals of FFInputFormat as well, but given that it is a testing tool this is not considered a problem.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-201-0/+1
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-221-1/+0
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: use the side data from AVStream.codecparJames Almer2023-10-061-1/+0
| | | | | | | | | | | | Deprecate AVStream.side_data and its helpers in favor of the AVStream's codecpar.coded_side_data. This will considerably simplify the propagation of global side data to decoders and from encoders. Instead of having to do it inside packets, it will be available during init(). Global and frame specific side data will therefore be distinct. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/concatdec: Check in/outpoint for overflowMichael Niedermayer2023-10-031-1/+3
| | | | | | | | | Fixes: signed integer overflow: 91542414454000000 - -9154241494546000000 cannot be represented in type 'long' Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-4739147999084544 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/concatdec: check that there's extradata before trying to copy itJames Almer2022-11-171-2/+3
| | | | | | The first argument for memcpy must not be NULL. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/internal: Don't include avcodec.hAndreas Rheinhardt2022-09-261-0/+1
| | | | | | | | | | | | | | | The general demuxing API uses parsers and decoders. Therefore FFStream contains pointers to AVCodecContexts and AVCodecParserContext and lavf/internal.h includes lavc/avcodec.h. Yet actually only a few files files really use these; and it is best when this number stays small. Therefore this commit uses opaque structs in lavf/internal.h for these contexts and stops including avcodec.h. This also avoids including lavc/codec_desc.h implicitly. All other headers are implicitly included as now (mostly through codec.h). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/demux: Add new demux.h headerAndreas Rheinhardt2022-05-101-0/+1
| | | | | | And move those stuff already in demuxer-only files to it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/concat: refactor to use ff_rescale_interval()Pierre-Anthony Lemieux2022-03-191-14/+4
| | | | Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
* libavformat: add side_data copy in concat demuxerGerard Sole2021-12-221-0/+1
| | | | | | | | | | | | Adds support for concat demuxer to copy the side data information from the input file to the resulting file. It will behave like the metadata copy, where the metadata of the first file is kept in the the output file. Extract the current code that already performs the stream side_data copy into a separate method and reuse the method in the concat demuxer. Signed-off-by: Gerard Sole <g.sole.ca@gmail.com>
* avformat/concatdec: fix NEEDS_UNSAFE flag valueGoogleplex2021-11-141-1/+1
| | | | | | | | NEEDS_UNSAFE has the same value as NEEDS_FILE, causing "duration not allowed if safe" error while duration directive doesn't require unsafe mode. Signed-off-by: Googleplex <yyoung2001@gmail.com>
* avformat/concatdec: Use FAIL() macro instead of direct return in ↵Michael Niedermayer2021-09-221-1/+1
| | | | | | | | | | | concat_parse_script() Fixes: memleak Fixes: 38893/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-4785231933079552 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: Avoid allocation for AVStreamInternalAndreas Rheinhardt2021-09-171-2/+4
| | | | | | | | | | Do this by allocating AVStream together with the data that is currently in AVStreamInternal; or rather: Put AVStream at the beginning of a new structure called FFStream (which encompasses more than just the internal fields and is a proper context in its own right, hence the name) and remove AVStreamInternal altogether. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* lavf/concatdec: add stream_extradata directiveNicolas George2021-09-161-0/+11
|
* lavf/concat: add support for chaptersNicolas George2021-09-161-1/+11
|
* lavf/concatdec: add stream_codec directiveNicolas George2021-09-161-0/+13
|
* lavf/concatdec: support stream metadataNicolas George2021-09-161-2/+12
|
* lavf/concat: deprecate file_packet_metadataNicolas George2021-09-161-0/+3
|
* lavf/concat: add file_packet_meta directiveNicolas George2021-09-161-0/+9
| | | | Same as file_packet_metadata without the double parsing.
* lavf/concat: refactor parsingNicolas George2021-09-161-88/+167
|
* lavf/concatdec: support per-file optionsNicolas George2021-08-221-1/+34
|
* libavformat/concatdec: remove support for unsafe=-1Nicolas George2021-08-221-4/+2
| | | | | It only makes sense as the default value, but it is not the default since 689211d5727231c3fe92762d224dbadebdbf4e30.
* avformat/internal: Move ff_read_line_to_bprint_overwrite to avio_internal.hAndreas Rheinhardt2021-07-291-0/+1
| | | | | | | | | | | | | It only uses an AVIOContext and an AVBPrint. When doing so, it turned out that several non-users of ff_read_line_to_bprint_overwrite() and ff_bprint_to_codecpar_extradata() relied on libavformat/internal.h to include bprint.h or avstring.h for them. In order to avoid a repeat of this and in order to reduce unnecessary dependencies, a forward declaration of struct AVBPrint is used instead of including bprint.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Remove unnecessary avassert.h inclusionsAndreas Rheinhardt2021-07-221-1/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/avcodec: Stop including bsf.h in avcodec.hAndreas Rheinhardt2021-07-221-0/+1
| | | | | | Also include bsf.h directly wherever it is used. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/concatdec: Simplify cleanup after read_header failureAndreas Rheinhardt2021-07-071-3/+1
| | | | | | | | | | by setting the FF_FMT_INIT_CLEANUP flag. (Btw: concat_read_close() is not idempotent (it frees cat->files, but doesn't reset cat->nb_files), so this demuxer was incompatible with simply calling read_close generically upon read_header failure.) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: move AVStream.{first,cur}_dts to AVStreamInternalJames Almer2021-06-091-2/+2
| | | | | | They are private fields, no reason to have them exposed in a public header. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: Constify all muxer/demuxersAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | This is possible now that the next-API is gone. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avutil/buffer: Switch AVBuffer API to size_tAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | Announced in 14040a1d913794d9a3fd6406a6d8c2f0e37e0062. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/packet: Also change av_packet_pack/unpack_dictionary to size_tAndreas Rheinhardt2021-03-191-1/+1
| | | | | | | | | These are auxiliary side-data functions, so they should have been switched to size_t in d79e0fe65c51491f9bf8a470bbe36fb09f3e1280, but this has been forgotten. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/concatdec: use av_strstart()Michael Niedermayer2020-11-031-4/+4
| | | | | | | | | | Fixes: out array read Fixes: 26610/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-5631838049271808 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/concatdec: Avoid duplicating buffer when adding side-dataAndreas Rheinhardt2020-05-281-6/+5
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat: Remove unnecessary av_packet_unref()Andreas Rheinhardt2020-02-101-3/+1
| | | | | | | | | Since bae8844e the packet will always be unreferenced when a demuxer returns an error, so that a lot of calls to av_packet_unref() in lots of demuxers are now redundant and can be removed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: Don't free old extradata before ff_alloc/get_extradataAndreas Rheinhardt2019-12-121-4/+0
| | | | | | | | These functions already free it themselves before they allocate the new extradata. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf: Constify the probe function argument.Carl Eugen Hoyos2019-03-211-1/+1
| | | | | Reviewed-by: Lauri Kasanen Reviewed-by: Tomas Härdin
* avformat/concatdec: always re-calculate start time and durationMarton Balint2019-01-221-8/+6
| | | | | | | | | | | | | | | | | | | | | This allows the underlying files to change their duration on subsequent avformat context opens. An example use case where this matters: ffconcat version 1.0 file dummy.mxf file dummy.mxf ffmpeg -re -stream_loop -1 -i dummy.ffconcat -f sdl2 none The user can seamlessly change the input by atomically replacing dummy.mxf. v2: Set ConcatFile duration in read_header for all segments with known durations because from now on we always recalculate the start time in open_file, and an instant seek could have caused unset ConcatFile durations. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/concatdec: fix cur_dts based duration calculation with nonzero ↵Marton Balint2019-01-221-1/+1
| | | | | | stream start_time Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/concatdec: factorize the duration calculating functionMarton Balint2019-01-221-14/+23
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/concatdec: always allow seeking to startMarton Balint2018-12-301-2/+7
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/concatdec: only set output stream index before returning packetMarton Balint2018-04-021-1/+1
| | | | | | | Fixes ticket #6434. Reviewed-by: Nicolas George <george@nsup.org> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/concatdec: add support for very long line sizesMarton Balint2018-02-241-8/+11
| | | | | | Fixes ticket #6761. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat: migrate to AVFormatContext->urlMarton Balint2018-01-281-2/+2
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* lavf/concatdec: properly init streams timestamp parameters.Nicolas George2017-12-311-1/+1
| | | | | | pts_wrap_bits defaults to 33 (like MPEG), that causes valid timestamps to be unwrapped and become invalid. Inspired by a patch by Wu Zhiqiang <mymoeyard@gmail.com>.