mux/nut: factorize ff_choose_timebase() out of nut

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer
2012-10-03 21:34:43 +02:00
parent 05e5a24f79
commit de707bc8bd
3 changed files with 28 additions and 5 deletions

View File

@@ -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)
{