There is no reason for this to be a dynamic property, as the only demuxer using this sets it unconditionally.
Showing the changes to libavformat (4 of 4 files). Show all
Unified · Split
| @@ -2946,7 +2946,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 2945 unmodified lines | ||
| 2946 | 2946 | best_fps = std_fps.num; |
| 2947 | 2947 | } |
| 2948 | 2948 | |
| 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) { | |
| 2950 | 2951 | error = fabs(av_q2d(codec_frame_rate) / |
| 2951 | 2952 | av_q2d(std_fps) - 1); |
| 2952 | 2953 | if (error < best_error) { |
| @@ -34,6 +34,11 @@ struct AVDeviceInfoList; · 33 unmodified lines | ||
| 34 | 34 | */ |
| 35 | 35 | #define FF_INFMT_FLAG_INIT_CLEANUP (1 << 0) |
| 36 | 36 | |
| 37 | +/* | |
| 38 | + * Prefer the codec framerate for avg_frame_rate computation. | |
| 39 | + */ | |
| 40 | +#define FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE (1 << 1) | |
| 41 | + | |
| 37 | 42 | typedef struct FFInputFormat { |
| 38 | 43 | /** |
| 39 | 44 | * The public AVInputFormat. See avformat.h for it. |
| @@ -120,11 +120,6 @@ typedef struct FFFormatContext { · 119 unmodified lines | ||
| 120 | 120 | * ID3v2 tag useful for MP3 demuxing |
| 121 | 121 | */ |
| 122 | 122 | AVDictionary *id3v2_meta; |
| 123 | − | |
| 124 | − /* | |
| 125 | − * Prefer the codec framerate for avg_frame_rate computation. | |
| 126 | − */ | |
| 127 | − int prefer_codec_framerate; | |
| 128 | 123 | } FFFormatContext; |
| 129 | 124 | |
| 130 | 125 | static av_always_inline FFFormatContext *ffformatcontext(AVFormatContext *s) |
| @@ -3113,8 +3113,6 @@ static int mpegts_read_header(AVFormatContext *s) · 3112 unmodified lines | ||
| 3113 | 3113 | int64_t pos, probesize = s->probesize; |
| 3114 | 3114 | int64_t seekback = FFMAX(s->probesize, (int64_t)ts->resync_size + PROBE_PACKET_MAX_BUF); |
| 3115 | 3115 | |
| 3116 | − ffformatcontext(s)->prefer_codec_framerate = 1; | |
| 3117 | − | |
| 3118 | 3116 | if (ffio_ensure_seekback(pb, seekback) < 0) |
| 3119 | 3117 | av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n"); |
| 3120 | 3118 | |
| @@ -3446,6 +3444,7 @@ const FFInputFormat ff_mpegts_demuxer = { · 325 unmodified lines | ||
| 3446 | 3444 | .read_packet = mpegts_read_packet, |
| 3447 | 3445 | .read_close = mpegts_read_close, |
| 3448 | 3446 | .read_timestamp = mpegts_get_dts, |
| 3447 | + .flags_internal = FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE, | |
| 3449 | 3448 | }; |
| 3450 | 3449 | |
| 3451 | 3450 | const FFInputFormat ff_mpegtsraw_demuxer = { |
| @@ -3458,4 +3457,5 @@ const FFInputFormat ff_mpegtsraw_demuxer = { · 6 unmodified lines | ||
| 3458 | 3457 | .read_packet = mpegts_raw_read_packet, |
| 3459 | 3458 | .read_close = mpegts_read_close, |
| 3460 | 3459 | .read_timestamp = mpegts_get_dts, |
| 3460 | + .flags_internal = FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE, | |
| 3461 | 3461 | }; |