summaryrefslogtreecommitdiff
path: root/libavformat/demux.c
Commit message (Collapse)AuthorAge
* avformat/demux: add duration_probesize AVOptionNicolas Gaullier2024-04-02
| | | | | | | | | | | | | | | | | | | | | | | | Yet another probesize used to get the durations when estimate_timings_from_pts is required. It is aimed at users interested in better durations probing for itself, or because using avformat_find_stream_info indirectly and requiring exact values: for concatdec for example, especially if streamcopying above it. The current code is a performance trade-off that can fail to get video stream durations in a scenario with high bitrates and buffering for files ending cleanly (as opposed to live captures): the physical gap between the last video packet and the last audio packet is very high in such a case. Default behaviour is unchanged: 250k up to 250k << 6 (step by step). Setting this new option has two effects: - override the maximum probesize (currently 250k << 6) - reduce the number of steps to 1 instead of 6, this is to avoid detecting the audio "too early" and failing to reach a video packet. Even if a single audio stream duration is found but not the other audio/video stream durations, there will be a retry, so at the end the full user-overriden probesize will be used as expected by the user. Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-31
| | | | | | | | | | | 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/internal: Move FF_FMT_INIT_CLEANUP to demux.hAndreas Rheinhardt2024-03-26
| | | | | | | | | 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/demux: Combine "Packet corrupt" logmessagesAndreas Rheinhardt2024-03-24
| | | | | | | Otherwise these statements might be torn apart by av_logs from other threads. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/demux: Restore pkt->stream_index assert checkAndreas Rheinhardt2024-03-24
| | | | | | | | | | It has been moved after "st = s->streams[pkt->stream_index]" in b140b8332c617b0eef4f872f3ef90c469e99920f. Deduplicate ff_read_packet() and ff_buffer_packet() while fixing this. This also fixes shadowing in ff_read_packet(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avformat: Add FFInputFormat, hide internals of AVInputFormatAndreas Rheinhardt2024-03-07
| | | | | | | | | | | | | | | | | | | | | 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>
* avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUTJames Almer2024-03-07
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/demux: allow demuxers to output more than one packet per ↵James Almer2024-02-20
| | | | | | read_packet() call Signed-off-by: James Almer <jamrial@gmail.com>
* lavf/demux: stop calling avcodec_close()Anton Khirnov2024-02-09
| | | | | | Replace it with recreating the codec context. This is the last remaining blocker for deprecating avcodec_close().
* avformat/avformat: use the side data from AVStream.codecparJames Almer2023-10-06
| | | | | | | | | | | | 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>
* lavf/demux: restrict video parser duration handling to just GIFAnton Khirnov2023-10-03
| | | | | | The parser does not have a timebase associated with it, so in general it makes no sense for it to be exporting durations. Longer-term this should be handled more cleanly with a new parser API.
* all: Replace __FUNCTION__ by __func__Andreas Rheinhardt2023-09-07
| | | | | | | Only the latter is valid ISO C. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/demux: propagate the internal decoder's bitrate propertiesJames Almer2023-09-06
| | | | | | | Muxers may access this information through cpb properties within the stream's side data. Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/internal: Use forward declaration for AVCodecDescriptorAndreas Rheinhardt2023-08-05
| | | | | | | | | | | This avoids including lavc/codec_desc.h everywhere and thereby forces users to include it directly instead of lazily and potentially unknowingly relying on indirect inclusions. Also add the proper inclusion to libavformat/demux.c, one of the two files that actually use the new field. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat: add demuxer and probe support for H266/VVCThomas Siedel2023-06-29
| | | | | | | Add demuxer to probe raw vvc and parse vvcc byte stream format. Co-authored-by: Nuo Mi <nuomi2021@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/mov_demuxer: Extended MOV demuxer to handle EVC video contentDawid Kozinski2023-06-15
| | | | | | - Added evc extension to the list of extensions for ff_mov_demuxer Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com>
* avformat/demux: add support to derive timestamps from packet durations for videoPaul B Mahol2023-05-25
|
* lavf: use AV_CODEC_PROP_FIELDS where appropriateAnton Khirnov2023-05-15
| | | | | | | | | | H.264 and mpeg12 parsers need to be adjusted at the same time to stop using the value of AVCodecContext.ticks_per_frame, because it is not set correctly unless the codec has been opened. Previously this would result in both the parser and lavf seeing the same incorrect value, which would cancel out. Updating lavf and not the parsers would result in correct value in lavf, but the wrong one in parsers, which would break some tests.
* lavf/demux: export codec-level framerate in avformat_find_stream_info()Anton Khirnov2023-05-07
|
* lavf/demux: use avg_frame_rate for packet durations for notimestamps formatsAnton Khirnov2023-05-05
| | | | | avg_frame_rate, if set, should be more reliable than stream timebase in this case.
* lavf/demux: treat streams with AVSTREAM_PARSE_FULL_RAW as having timestampsAnton Khirnov2023-04-13
| | | | | | | In this case the timestamps are set by the parser. Cf. a6b3471c44fd981d3b33ea9050f78a0bc9494c5e Required by the following commit.
* avcodec: remove FF_API_AVCTX_TIMEBASEJames Almer2023-02-09
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/demux: Avoid stack packet when decoding frameAndreas Rheinhardt2023-02-09
| | | | | | | Possible now that avcodec_decode_subtitle2() accepts a const AVPacket*. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: Anton Khirnov <anton@khirnov.net>
* avformat/internal: Don't include avcodec.hAndreas Rheinhardt2022-09-26
| | | | | | | | | | | | | | | 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>
* Revert "avformat/demux: Make read_frame_internal() return AVERREOR(EAGAIN) ↵Marton Balint2022-07-06
| | | | | | | | on stuck empty input parser" Hides the underlying real problem with a demuxer returning 0 sized packets. This reverts commit 02699490c14e86105104940c009953081f69432c.
* Revert "avformat/demux: Count EAGAIN as 100 bytes in relation to read limit ↵Marton Balint2022-07-06
| | | | | | | | | | in avformat_find_stream_info()" Modifying avformat_find_stream_info() behaviour based on the number of EAGAINs it encounters is a hack which usually only hides the real issue if such thing happen. This reverts commit b0cac7082d8a3ff2d4f039af01b45c48bb578de7.
* avformat/demux: Count EAGAIN as 100 bytes in relation to read limit in ↵Michael Niedermayer2022-06-17
| | | | | | | | | | | avformat_find_stream_info() Fixes: Timeout Fixes: 43717/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5206008287330304 Fixes: 45738/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6142535657979904 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/demux: Make read_frame_internal() return AVERREOR(EAGAIN) on stuck ↵Michael Niedermayer2022-06-17
| | | | | | | | | | empty input parser Fixes: read_frame_internal() which does not return even though both demuxer and parser do return Fixes: 43717/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5206008287330304 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 definition of FFStream->info to demux.hAndreas Rheinhardt2022-05-10
| | | | | | It is only used by avformat_find_stream_info(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/demux: Add new demux.h headerAndreas Rheinhardt2022-05-10
| | | | | | And move those stuff already in demuxer-only files to it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/demux: Use unsigned to check duration vs duration_textMichael Niedermayer2022-04-21
| | | | | | | | | Fixes: signed integer overflow: 9223371898743775808 - -138111000000 cannot be represented in type 'long' Fixes: 46245/clusterfuzz-testcase-minimized-ffmpeg_dem_OGG_fuzzer-5075129786302464 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: Do not search through the AVOption table for a option not in it ↵Michael Niedermayer2022-03-27
| | | | | | | | | | | repeatedly on each packet This search takes alot of time especially when compared with small packets 46631 decicycles -> 15719 decicycles in read_frame_internal() for amr-nb in 3gp Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/demux: ensure ch_layout is not lost in the stream's internal avctxJames Almer2022-03-21
| | | | | | | | | This is a workaround until avcodec_close() stops freeing ch_layout through av_opt_fre(), or the former is removed. Fixes a regression since 327efa66331ebdc0087c6b656059a8df2f404019. Signed-off-by: James Almer <jamrial@gmail.com>
* configure: Use a separate config_components.h header for $ALL_COMPONENTSMartin Storsjö2022-03-16
| | | | | | | | This avoids unnecessary rebuilds of most source files if only the list of enabled components has changed, but not the other properties of the build, set in config.h. Signed-off-by: Martin Storsjö <martin@martin.st>
* lavc: drop temporary compat wrappers for channel layout API changeAnton Khirnov2022-03-15
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavc: switch to the new channel layout APIVittorio Giovara2022-03-15
| | | | | | | | Since the request_channel_layout is used only by a handful of codecs, move the option to codec private contexts. Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
* lavf: drop the channel layout compat layer for old-style (de)muxersAnton Khirnov2022-03-15
| | | | | | All the (de)muxers have been converted to the new API. Signed-off-by: James Almer <jamrial@gmail.com>
* lavf: convert the generic layer to the new channel layoutAnton Khirnov2022-03-15
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* lavf: add a temporary compat layer for the channel layout API changeAnton Khirnov2022-03-15
| | | | | | | Mediates between old-style (de)muxers and new-style callers. Will be removed once all the (de)muxers are converted to the new API. Signed-off-by: James Almer <jamrial@gmail.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>
* avcodec/packet_internal: Add proper PacketList structAndreas Rheinhardt2022-01-04
| | | | | | | | | | | | | | | Up until now, we had a PacketList structure which is actually a PacketListEntry; a proper PacketList did not exist and all the related functions just passed pointers to pointers to the head and tail elements around. All these pointers were actually consecutive elements of their containing structs, i.e. the users already treated them as if they were a struct. So add a proper PacketList struct and rename the current PacketList to PacketListEntry; also make the functions use this structure instead of the pair of pointers. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/raw: Reduce number of avpriv symbolsAndreas Rheinhardt2022-01-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libavcodec currently exports four avpriv symbols that deal with PixelFormatTags: avpriv_get_raw_pix_fmt_tags, avpriv_find_pix_fmt, avpriv_pix_fmt_bps_avi and avpriv_pix_fmt_bps_mov. The latter two are lists of PixelFormatTags, the former returns such a list and the second searches a list for a pixel format that matches a given fourcc; only one of the aforementioned three lists is ever searched. Yet for avpriv_pix_fmt_bps_avi, avpriv_pix_fmt_bps_mov and avpriv_find_pix_fmt the overhead of exporting these functions actually exceeds the size of said objects (at least for ELF; the following numbers are for x64 Ubuntu 20.10): The code size of avpriv_find_pix_fmt is small (GCC 10.2 37B, Clang 11 41B), yet exporting it adds a 20B string for the name alone to the exporting as well as to each importing library; there is more: Four bytes in the exporting libraries .gnu.hash; two bytes each for the exporting as well as each importing libraries .gnu.version; 24B in the exporting as well as each importing libraries .dynsym; 16B+24B for an entry in .plt as well as the accompanying relocation entry in .rela.plt for each importing library. The overhead for the lists is similar: The strings are 23B and the .plt+.rela.plt pair is replaced by 8B+24B for an entry in .got and a relocation entry in .rela.dyn. These lists have a size of 80 resp. 72 bytes. Yet for ff_raw_pix_fmt_tags, exporting it is advantageous compared to duplicating it into libavformat and potentially libavdevice. Therefore this commit replaces all library uses of the four symbols with a single function that is exported for shared builds. It has an enum parameter to choose the desired list besides the parameter for the fourcc. New lists can be supported with new enum values. Unfortunately, avpriv_get_raw_pix_fmt_tags could not be removed, as the fourcc2pixfmt tool uses the table of raw pix fmts. No other user of this function remains. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/demux: Remove redundant prevention against infinite loopAndreas Rheinhardt2021-12-16
| | | | | | | | | | | | | | | | | | | This piece of code has been added as FFmpeg's answer to infinite loops in try_decode_frame() in commit 6072a19b4f311cb172d45e90daad90824e40e4b6. There is no loop around try_decode_frame() any more, so this code can be removed. This code is only triggered in case a) the codec parameter could not be determined, b) the decode delay could not be guessed or c) no packet was ever encountered and the encoder has the AV_CODEC_CAP_CHANNEL_CONF. In these cases the new code will no longer emit a "decoding for stream %d failed" message, which is prima facie false. In case a) an additional "Could not find codec parameters" message is (and will be) emitted. No warning will be emitted any more in case b) (this happens e.g. with some h264-conformance FATE-files). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* 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/demux: allow total size of packets in raw_packet_buffer to reach ↵Marton Balint2021-11-14
| | | | | | | | | | | | | | probesize Previously this was hardcoded to 2500000 bytes, so probing of the stream codecs was always limited by this, and not probesize. Also keep track of the actual size of packets in raw_packet_buffer and not the remaining size for simplicity. Fixes ticket #5860. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/demux: preserve AV_PKT_FLAG_CORRUPT in parse_packetAlex Shumsky2021-10-29
| | | | | | | If original packet is corrupted, then parsed packet is probably corrupted too. Let the application decide what to do. Signed-off-by: Alex Shumsky <alexthreed@gmail.com>
* avformat/demux: Use r_frame_rate in compute_frame_duration if ↵Nicolas Gaullier2021-09-23
| | | | | | | codec_framerate is unknown Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/demux: Use av_opt_set_int() where appropriateAndreas Rheinhardt2021-09-18
| | | | | Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>