mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-16 03:50:05 +01:00
mux/nut: factorize ff_choose_timebase() out of nut
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -103,6 +103,25 @@ static void frac_add(AVFrac *f, int64_t incr)
|
||||
f->num = num;
|
||||
}
|
||||
|
||||
AVRational ff_choose_timebase(AVFormatContext *s, AVStream *st, int min_precission)
|
||||
{
|
||||
AVRational q;
|
||||
int j;
|
||||
|
||||
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||
q = (AVRational){1, st->codec->sample_rate};
|
||||
} else {
|
||||
q = st->codec->time_base;
|
||||
}
|
||||
for (j=2; j<2000; j+= 1+(j>2))
|
||||
while (q.den / q.num < min_precission && q.num % j == 0)
|
||||
q.num /= j;
|
||||
while (q.den / q.num < min_precission && q.den < (1<<24))
|
||||
q.den <<= 1;
|
||||
|
||||
return q;
|
||||
}
|
||||
|
||||
int avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputFormat *oformat,
|
||||
const char *format, const char *filename)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user