History

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.

Anton Khirnov committed 2 years ago

Commit 31da5221 parent 12e51164 files · +9 −8Browse files

Unified · Split

4 files
  1. libavformat/demux.c +2 −1
  2. libavformat/demux.h +5 −0
  3. libavformat/internal.h +0 −5
  4. libavformat/mpegts.c +2 −2
libavformat/demux.c+2−1
@@ -2946,7 +2946,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 2945 unmodified lines
29462946 best_fps = std_fps.num;
29472947 }
29482948
2949− if (si->prefer_codec_framerate && codec_frame_rate.num > 0 && codec_frame_rate.den > 0) {
2949+ if ((ffifmt(ic->iformat)->flags_internal & FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE) &&
2950+ codec_frame_rate.num > 0 && codec_frame_rate.den > 0) {
29502951 error = fabs(av_q2d(codec_frame_rate) /
29512952 av_q2d(std_fps) - 1);
29522953 if (error < best_error) {
libavformat/demux.h+5−0
@@ -34,6 +34,11 @@ struct AVDeviceInfoList; · 33 unmodified lines
3434 */
3535 #define FF_INFMT_FLAG_INIT_CLEANUP (1 << 0)
3636
37+/*
38+ * Prefer the codec framerate for avg_frame_rate computation.
39+ */
40+#define FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE (1 << 1)
41+
3742 typedef struct FFInputFormat {
3843 /**
3944 * The public AVInputFormat. See avformat.h for it.
libavformat/internal.h+0−5
@@ -120,11 +120,6 @@ typedef struct FFFormatContext { · 119 unmodified lines
120120 * ID3v2 tag useful for MP3 demuxing
121121 */
122122 AVDictionary *id3v2_meta;
123−
124− /*
125− * Prefer the codec framerate for avg_frame_rate computation.
126− */
127− int prefer_codec_framerate;
128123 } FFFormatContext;
129124
130125 static av_always_inline FFFormatContext *ffformatcontext(AVFormatContext *s)
libavformat/mpegts.c+2−2
@@ -3113,8 +3113,6 @@ static int mpegts_read_header(AVFormatContext *s) · 3112 unmodified lines
31133113 int64_t pos, probesize = s->probesize;
31143114 int64_t seekback = FFMAX(s->probesize, (int64_t)ts->resync_size + PROBE_PACKET_MAX_BUF);
31153115
3116− ffformatcontext(s)->prefer_codec_framerate = 1;
3117−
31183116 if (ffio_ensure_seekback(pb, seekback) < 0)
31193117 av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n");
31203118
@@ -3446,6 +3444,7 @@ const FFInputFormat ff_mpegts_demuxer = { · 325 unmodified lines
34463444 .read_packet = mpegts_read_packet,
34473445 .read_close = mpegts_read_close,
34483446 .read_timestamp = mpegts_get_dts,
3447+ .flags_internal = FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE,
34493448 };
34503449
34513450 const FFInputFormat ff_mpegtsraw_demuxer = {
@@ -3458,4 +3457,5 @@ const FFInputFormat ff_mpegtsraw_demuxer = { · 6 unmodified lines
34583457 .read_packet = mpegts_raw_read_packet,
34593458 .read_close = mpegts_read_close,
34603459 .read_timestamp = mpegts_get_dts,
3460+ .flags_internal = FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE,
34613461 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t