[FFmpeg-cvslog] testsrc: set output framerate

Stefano Sabatini git at videolan.org
Wed Nov 11 14:53:28 CET 2015


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Tue Nov  3 09:57:22 2015 -0800| [5e91a5c5cf1db88f254b4c358eb1b06ff6ca274f] | committer: Anton Khirnov

testsrc: set output framerate

(cherry picked from ffmpeg commit 7cd5fa35fecc2717223459d04822faed6bbd40fa)

Signed-off-by: Anton Khirnov <anton at khirnov.net>

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

 libavfilter/vsrc_testsrc.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index e41625e..5bd458c 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -46,7 +46,7 @@ typedef struct TestSourceContext {
     const AVClass *class;
     int h, w;
     unsigned int nb_frame;
-    AVRational time_base;
+    AVRational time_base, frame_rate;
     int64_t pts, max_pts;
     char *size;                 ///< video frame size
     char *rate;                 ///< video frame rate
@@ -75,7 +75,6 @@ static const AVOption testsrc_options[] = {
 static av_cold int init_common(AVFilterContext *ctx)
 {
     TestSourceContext *test = ctx->priv;
-    AVRational frame_rate_q;
     int64_t duration = -1;
     int ret = 0;
 
@@ -84,8 +83,7 @@ static av_cold int init_common(AVFilterContext *ctx)
         return ret;
     }
 
-    if ((ret = av_parse_video_rate(&frame_rate_q, test->rate)) < 0 ||
-        frame_rate_q.den <= 0 || frame_rate_q.num <= 0) {
+    if ((ret = av_parse_video_rate(&test->frame_rate, test->rate)) < 0) {
         av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", test->rate);
         return ret;
     }
@@ -95,15 +93,14 @@ static av_cold int init_common(AVFilterContext *ctx)
         return ret;
     }
 
-    test->time_base.num = frame_rate_q.den;
-    test->time_base.den = frame_rate_q.num;
+    test->time_base = av_inv_q(test->frame_rate);
     test->max_pts = duration >= 0 ?
         av_rescale_q(duration, AV_TIME_BASE_Q, test->time_base) : -1;
     test->nb_frame = 0;
     test->pts = 0;
 
     av_log(ctx, AV_LOG_DEBUG, "size:%dx%d rate:%d/%d duration:%f sar:%d/%d\n",
-           test->w, test->h, frame_rate_q.num, frame_rate_q.den,
+           test->w, test->h, test->frame_rate.num, test->frame_rate.den,
            duration < 0 ? -1 : test->max_pts * av_q2d(test->time_base),
            test->sar.num, test->sar.den);
     return 0;
@@ -116,7 +113,8 @@ static int config_props(AVFilterLink *outlink)
     outlink->w = test->w;
     outlink->h = test->h;
     outlink->sample_aspect_ratio = test->sar;
-    outlink->time_base = test->time_base;
+    outlink->frame_rate = test->frame_rate;
+    outlink->time_base  = test->time_base;
 
     return 0;
 }



More information about the ffmpeg-cvslog mailing list