aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-10-13 12:35:31 +0200
committerAnton Khirnov <anton@khirnov.net>2024-10-16 16:46:29 +0200
commit31da5222a400a385c0633c54e20b0ae1b30730df (patch)
tree943ba935ae8a5f495f73209df6eb73755fced600
parent12e5116872557c8d9cea9408d05867ef08e0bfc4 (diff)
downloadffmpeg-31da5222a400a385c0633c54e20b0ae1b30730df.tar.gz
lavf: replace FFFormatContext.prefer_codec_framerate with FF_INFMT_FLAG
There is no reason for this to be a dynamic property, as the only demuxer using this sets it unconditionally.
-rw-r--r--libavformat/demux.c3
-rw-r--r--libavformat/demux.h5
-rw-r--r--libavformat/internal.h5
-rw-r--r--libavformat/mpegts.c4
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,
};