[FFmpeg-devel] [PATCH 7/9] lavf: replace FFFormatContext.prefer_codec_framerate with FF_INFMT_FLAG
Anton Khirnov
anton at khirnov.net
Sun Oct 13 14:24:16 EEST 2024
There is no reason for this to be a dynamic property, as the only
demuxer using this sets it unconditionally.
---
libavformat/demux.c | 3 ++-
libavformat/demux.h | 5 +++++
libavformat/internal.h | 5 -----
libavformat/mpegts.c | 4 ++--
4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 658981cab8..f9517454ad 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -2946,7 +2946,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
best_fps = std_fps.num;
}
- if (si->prefer_codec_framerate && codec_frame_rate.num > 0 && codec_frame_rate.den > 0) {
+ if ((ffifmt(ic->iformat)->flags_internal & FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE) &&
+ codec_frame_rate.num > 0 && codec_frame_rate.den > 0) {
error = fabs(av_q2d(codec_frame_rate) /
av_q2d(std_fps) - 1);
if (error < best_error) {
diff --git a/libavformat/demux.h b/libavformat/demux.h
index 647011affb..e83d84a201 100644
--- a/libavformat/demux.h
+++ b/libavformat/demux.h
@@ -34,6 +34,11 @@ struct AVDeviceInfoList;
*/
#define FF_INFMT_FLAG_INIT_CLEANUP (1 << 0)
+/*
+ * Prefer the codec framerate for avg_frame_rate computation.
+ */
+#define FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE (1 << 1)
+
typedef struct FFInputFormat {
/**
* The public AVInputFormat. See avformat.h for it.
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 6599cf5c0c..5cfcc20ec3 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -120,11 +120,6 @@ typedef struct FFFormatContext {
* ID3v2 tag useful for MP3 demuxing
*/
AVDictionary *id3v2_meta;
-
- /*
- * Prefer the codec framerate for avg_frame_rate computation.
- */
- int prefer_codec_framerate;
} FFFormatContext;
static av_always_inline FFFormatContext *ffformatcontext(AVFormatContext *s)
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 04565a2011..81481f6f76 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -3113,8 +3113,6 @@ static int mpegts_read_header(AVFormatContext *s)
int64_t pos, probesize = s->probesize;
int64_t seekback = FFMAX(s->probesize, (int64_t)ts->resync_size + PROBE_PACKET_MAX_BUF);
- ffformatcontext(s)->prefer_codec_framerate = 1;
-
if (ffio_ensure_seekback(pb, seekback) < 0)
av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n");
@@ -3446,6 +3444,7 @@ const FFInputFormat ff_mpegts_demuxer = {
.read_packet = mpegts_read_packet,
.read_close = mpegts_read_close,
.read_timestamp = mpegts_get_dts,
+ .flags_internal = FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE,
};
const FFInputFormat ff_mpegtsraw_demuxer = {
@@ -3458,4 +3457,5 @@ const FFInputFormat ff_mpegtsraw_demuxer = {
.read_packet = mpegts_raw_read_packet,
.read_close = mpegts_read_close,
.read_timestamp = mpegts_get_dts,
+ .flags_internal = FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE,
};
--
2.43.0
More information about the ffmpeg-devel
mailing list