1
0
Fork 0

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.
This commit is contained in:
Hendrik Leppkes 2023-09-30 01:08:51 +02:00
parent 08e2f07124
commit 2e9688b4ff
Signed by: hendrik
GPG Key ID: 846079A4B0A7C1B5
1 changed files with 5 additions and 3 deletions

View File

@ -2994,10 +2994,12 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
if (!st->r_frame_rate.num) {
const AVCodecDescriptor *desc = sti->codec_desc;
AVRational mul = (AVRational){ desc && (desc->props & AV_CODEC_PROP_FIELDS) ? 2 : 1, 1 };
AVRational fr = av_mul_q(avctx->framerate, mul);
AVRational time_base = av_inv_q(av_mul_q(avctx->framerate, mul));
if (fr.num && fr.den && av_cmp_q(st->time_base, av_inv_q(fr)) <= 0) {
st->r_frame_rate = fr;
if ( time_base.den * (int64_t) st->time_base.num
<= time_base.num * (uint64_t)mul.num * st->time_base.den) {
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den,
time_base.den, (int64_t)time_base.num * mul.num, INT_MAX);
} else {
st->r_frame_rate.num = st->time_base.den;
st->r_frame_rate.den = st->time_base.num;