1
0
Fork 0
Commit Graph

63 Commits

Author SHA1 Message Date
Hendrik Leppkes 78b63de976
HACK avformat: restore old framerate logic
The new logic produces inconsistent results for field-based codecs, the
old logic has been proven to work for years, so just stick to it.
2024-05-28 18:18:37 +02:00
Hendrik Leppkes 3c401cd7c4
mpegts: do not use teletext streams as wrap reference
teletext streams are often badly interleaved and/or have broken
timestamps, using them as wrap reference can result in seeking breaking
and wrap detection causing rather wrong timestamps.
2024-05-28 18:18:31 +02:00
Hendrik Leppkes 908b706779
avformat: try harder to find a duration of the media
This helps finding a duration in files with a lot of garbage data at the
end, increasing the lookup area from 4MB to 32MB.

There should be no speed loss on files which previously worked fine, since
it'll stop looking once it found a duration.
2024-05-28 18:18:28 +02:00
Hendrik Leppkes b997fe9991
HACK: Don't return -1 in avformat_find_stream_info when codec details are still unknown. 2024-05-28 18:18:23 +02:00
Hendrik Leppkes 404e618cd3
Add "safe" full parsing mode.
In this mode, the parser does completely process the frame, but timestamps
are not mangled in compute_pkt_fields.
2024-05-28 18:18:22 +02:00
Hendrik Leppkes c350c85aac
Don't discard timestamps that are considered "invalid", still better then none at all. 2024-05-28 18:18:21 +02:00
Hendrik Leppkes 640bee330c
HACK: Disable tb_unreliable, preserve original fps information. 2024-05-28 18:18:21 +02:00
Cory Fields c61a16304d
get accurate estimate from the PTSes 2024-05-28 18:18:21 +02:00
Cory Fields 67be3f97dc
if av_read_packet returns AVERROR_IO, we are done. ffmpeg's codecs might or might not handle returning any completed demuxed packets correctly 2024-05-28 18:18:21 +02:00
Michael Niedermayer 33da5f4e27
avformat/demux: resurrect dead stores
Fixes: CID1473512 Unused value
Fixes: CID1529228 Unused value

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-05-28 03:48:03 +02:00
James Almer 757367e068 avformat/demux: extract extradata from packets when context update is requested
If the demuxer doesn't set extradata in the stream's codecpar, a
need_context_update request will delete the previously extracted extradata in
the stream's internal AVCodecContext.
As we can't ensure the old extradata is valid for the stream in its post
context update request state, try to get extradata from the new packet instead
of attempting to preserve the old in some form.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-04-24 00:11:37 -03:00
Nicolas Gaullier ed9363052f avformat/demux: add duration_probesize AVOption
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>
2024-04-02 19:53:40 +02:00
Andreas Rheinhardt 790f793844 avutil/common: Don't auto-include mem.h
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>
2024-03-31 00:08:43 +01:00
Andreas Rheinhardt 4a4dcde339 avformat/internal: Move FF_FMT_INIT_CLEANUP to demux.h
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>
2024-03-26 06:36:43 +01:00
Andreas Rheinhardt ccd2b7f858 avformat/demux: Combine "Packet corrupt" logmessages
Otherwise these statements might be torn apart by
av_logs from other threads.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-24 19:02:41 +01:00
Andreas Rheinhardt 07064f9bda avformat/demux: Restore pkt->stream_index assert check
It has been moved after "st  = s->streams[pkt->stream_index]"
in b140b8332c.
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>
2024-03-24 19:02:41 +01:00
Andreas Rheinhardt b800327f4c avformat/avformat: Add FFInputFormat, hide internals of AVInputFormat
This commit does for AVInputFormat what commit
59c9dc82f4 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 50f34172e0
(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>
2024-03-07 08:53:31 -03:00
James Almer 65ddc74988 avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUT
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
James Almer b140b8332c avformat/demux: allow demuxers to output more than one packet per read_packet() call
Signed-off-by: James Almer <jamrial@gmail.com>
2024-02-20 11:24:19 -03:00
Anton Khirnov ca18bb5972 lavf/demux: stop calling avcodec_close()
Replace it with recreating the codec context.

This is the last remaining blocker for deprecating avcodec_close().
2024-02-09 16:14:56 +01:00
James Almer 5432d2aaca avformat/avformat: use the side data from AVStream.codecpar
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>
2023-10-06 10:03:57 -03:00
Anton Khirnov 80401b86d3 lavf/demux: restrict video parser duration handling to just GIF
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.
2023-10-03 16:57:02 +02:00
Andreas Rheinhardt e999a09f19 all: Replace __FUNCTION__ by __func__
Only the latter is valid ISO C.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:48:50 +02:00
James Almer 8e972b13a9 avformat/demux: propagate the internal decoder's bitrate properties
Muxers may access this information through cpb properties within the stream's
side data.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-09-06 10:27:44 -03:00
Andreas Rheinhardt 76f244b84e avformat/internal: Use forward declaration for AVCodecDescriptor
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>
2023-08-05 09:40:06 +02:00
Thomas Siedel ac2b25f4e5 avformat: add demuxer and probe support for H266/VVC
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>
2023-06-29 14:12:50 -03:00
Dawid Kozinski 091705cd55 avformat/mov_demuxer: Extended MOV demuxer to handle EVC video content
- Added evc extension to the list of extensions for ff_mov_demuxer

Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com>
2023-06-15 09:57:41 -03:00
Paul B Mahol e7cadd0ee5 avformat/demux: add support to derive timestamps from packet durations for video 2023-05-25 19:51:47 +02:00
Anton Khirnov e930b834a9 lavf: use AV_CODEC_PROP_FIELDS where appropriate
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.
2023-05-15 10:31:55 +02:00
Anton Khirnov 6deaf1e409 lavf/demux: export codec-level framerate in avformat_find_stream_info() 2023-05-07 15:47:25 +02:00
Anton Khirnov e38e9f3d54 lavf/demux: use avg_frame_rate for packet durations for notimestamps formats
avg_frame_rate, if set, should be more reliable than stream timebase in
this case.
2023-05-05 14:49:40 +02:00
Anton Khirnov 7b827a0293 lavf/demux: treat streams with AVSTREAM_PARSE_FULL_RAW as having timestamps
In this case the timestamps are set by the parser.
Cf. a6b3471c44

Required by the following commit.
2023-04-13 15:34:07 +02:00
James Almer 5f9e848e68 avcodec: remove FF_API_AVCTX_TIMEBASE
Signed-off-by: James Almer <jamrial@gmail.com>
2023-02-09 15:35:08 +01:00
Andreas Rheinhardt f23ae839fc avformat/demux: Avoid stack packet when decoding frame
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>
2023-02-09 15:24:15 +01:00
Andreas Rheinhardt 2b41463b87 avformat/internal: Don't include avcodec.h
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>
2022-09-26 03:02:50 +02:00
Marton Balint 7acc124121 Revert "avformat/demux: Make read_frame_internal() return AVERREOR(EAGAIN) on stuck empty input parser"
Hides the underlying real problem with a demuxer returning 0 sized packets.

This reverts commit 02699490c1.
2022-07-06 23:37:29 +02:00
Marton Balint dbc3b5a902 Revert "avformat/demux: Count EAGAIN as 100 bytes in relation to read limit 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 b0cac7082d.
2022-07-06 23:37:29 +02:00
Michael Niedermayer b0cac7082d avformat/demux: Count EAGAIN as 100 bytes in relation to read limit in 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>
2022-06-17 01:54:05 +02:00
Michael Niedermayer 02699490c1 avformat/demux: Make read_frame_internal() return AVERREOR(EAGAIN) on stuck 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>
2022-06-17 01:54:05 +02:00
Andreas Rheinhardt 3cfae9e038 avformat/internal: Move definition of FFStream->info to demux.h
It is only used by avformat_find_stream_info().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:37:43 +02:00
Andreas Rheinhardt 35ec5c819b avformat/demux: Add new demux.h header
And move those stuff already in demuxer-only files to it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:37:38 +02:00
Michael Niedermayer 6007d5688c avformat/demux: Use unsigned to check duration vs duration_text
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>
2022-04-21 22:42:20 +02:00
Michael Niedermayer 6265f0b4e1 avformat: Do not search through the AVOption table for a option not in it 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>
2022-03-27 11:58:54 +02:00
James Almer 37f4440682 avformat/demux: ensure ch_layout is not lost in the stream's internal avctx
This is a workaround until avcodec_close() stops freeing ch_layout through
av_opt_fre(), or the former is removed.

Fixes a regression since 327efa6633.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-21 08:50:28 -03:00
Martin Storsjö a78f136f3f configure: Use a separate config_components.h header for $ALL_COMPONENTS
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>
2022-03-16 14:12:49 +02:00
Anton Khirnov 5636972c7a lavc: drop temporary compat wrappers for channel layout API change
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:46 -03:00
Vittorio Giovara 548aeb9383 lavc: switch to the new channel layout API
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>
2022-03-15 09:42:39 -03:00
Anton Khirnov b6746b7462 lavf: drop the channel layout compat layer for old-style (de)muxers
All the (de)muxers have been converted to the new API.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:39 -03:00
Anton Khirnov ac10e3c47c lavf: convert the generic layer to the new channel layout
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:29 -03:00
Anton Khirnov c30e22c9fb lavf: add a temporary compat layer for the channel layout API change
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>
2022-03-15 09:42:29 -03:00