mirror of
https://github.com/mpv-player/mpv
synced 2025-01-11 17:39:38 +00:00
av_common: always make sure to return a valid timebase
av_reduce(&num, &den, 1, 14112000, 1000000) can return num=0, den=1. This means a 1/14112000 timebase (as used by the mp3 demuxer) would become invalid. The intention of mp_get_codec_timebase() is to always return a valid timebase. av_reduce() probably does the logically correct thing - so add a fallback to the safe default timebase. Also, increase the av_reduce() parameter to INT_MAX. Let's just pray this doesn't cause any actual problems. libavformat does the same, but might be in a different position due to using av_rescale() etc., while we convert between fractional timestamps and floats.
This commit is contained in:
parent
ca175871cd
commit
98e7b4e538
@ -17,6 +17,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <libavutil/common.h>
|
||||
#include <libavutil/log.h>
|
||||
@ -104,7 +105,10 @@ AVRational mp_get_codec_timebase(struct mp_codec_params *c)
|
||||
tb.den *= (r.num + r.den - 1) / r.den;
|
||||
}
|
||||
|
||||
av_reduce(&tb.num, &tb.den, tb.num, tb.den, 1000000);
|
||||
av_reduce(&tb.num, &tb.den, tb.num, tb.den, INT_MAX);
|
||||
|
||||
if (tb.num < 1 || tb.den < 1)
|
||||
tb = AV_TIME_BASE_Q;
|
||||
|
||||
return tb;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user