[FFmpeg-cvslog] avformat/movenc: factor out find_fps()

Michael Niedermayer git at videolan.org
Tue Oct 8 14:38:56 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Oct  7 17:35:13 2013 +0200| [8c0f565ee3ba48b6472cf69064961fd15de80753] | committer: Michael Niedermayer

avformat/movenc: factor out find_fps()

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8c0f565ee3ba48b6472cf69064961fd15de80753
---

 libavformat/movenc.c |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 67fb827..3b934d6 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);



More information about the ffmpeg-cvslog mailing list