aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-10-07 17:35:13 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-10-08 14:18:43 +0200
commit8c0f565ee3ba48b6472cf69064961fd15de80753 (patch)
tree966231e105fce1d6542ea612e90bf4205282fcdc
parent2dce4abe506a1b5056e0ac7a007ac564246463d7 (diff)
downloadffmpeg-8c0f565ee3ba48b6472cf69064961fd15de80753.tar.gz
avformat/movenc: factor out find_fps()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/movenc.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 67fb827756..3b934d6478 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -884,6 +884,19 @@ static int mov_get_dv_codec_tag(AVFormatContext *s, MOVTrack *track)
return tag;
}
+static AVRational find_fps(AVFormatContext *s, AVStream *st)
+{
+ AVRational rate = {st->codec->time_base.den, st->codec->time_base.num};
+ /* if the codec time base makes no sense, try to fallback on stream frame rate */
+ if (av_timecode_check_frame_rate(rate) < 0) {
+ av_log(s, AV_LOG_DEBUG, "timecode: tbc=%d/%d invalid, fallback on %d/%d\n",
+ rate.num, rate.den, st->avg_frame_rate.num, st->avg_frame_rate.den);
+ rate = st->avg_frame_rate;
+ }
+
+ return rate;
+}
+
static const struct {
enum AVPixelFormat pix_fmt;
uint32_t tag;
@@ -3490,14 +3503,7 @@ static int mov_create_timecode_track(AVFormatContext *s, int index, int src_inde
AVStream *src_st = s->streams[src_index];
AVTimecode tc;
AVPacket pkt = {.stream_index = index, .flags = AV_PKT_FLAG_KEY, .size = 4};
- AVRational rate = {src_st->codec->time_base.den, src_st->codec->time_base.num};
-
- /* if the codec time base makes no sense, try to fallback on stream frame rate */
- if (av_timecode_check_frame_rate(rate) < 0) {
- av_log(s, AV_LOG_DEBUG, "timecode: tbc=%d/%d invalid, fallback on %d/%d\n",
- rate.num, rate.den, src_st->avg_frame_rate.num, src_st->avg_frame_rate.den);
- rate = src_st->avg_frame_rate;
- }
+ AVRational rate = find_fps(s, src_st);
/* compute the frame number */
ret = av_timecode_init_from_string(&tc, rate, tcstr, s);