diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-03 21:34:43 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-03 21:34:43 +0200 |
commit | de707bc8bdfff92a1905169ba6054034d464dbb5 (patch) | |
tree | 4115aae2f3c5172d91d752c157e2a76be43c345c /libavformat/mux.c | |
parent | 05e5a24f79fedc36a1addf8a8ed36e9ad5c42d8c (diff) | |
download | ffmpeg-de707bc8bdfff92a1905169ba6054034d464dbb5.tar.gz |
mux/nut: factorize ff_choose_timebase() out of nut
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/mux.c')
-rw-r--r-- | libavformat/mux.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c index debc6a16b9..cd5481f1d2 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -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) { |