[FFmpeg-cvslog] vf_overlay: get rid of pointless messing with timebase.

Anton Khirnov git at videolan.org
Thu Oct 4 13:18:04 CEST 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun Sep 30 09:49:53 2012 +0200| [ab35ec29a4071871934856c00da7d6ebcc0c095b] | committer: Anton Khirnov

vf_overlay: get rid of pointless messing with timebase.

Output frames correspond 1:1 to input frames on the main input.
So use the main input timebase for output.

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

 libavfilter/vf_overlay.c |   25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
index 6dd9be4..74c356e 100644
--- a/libavfilter/vf_overlay.c
+++ b/libavfilter/vf_overlay.c
@@ -181,24 +181,10 @@ fail:
 static int config_output(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
-    int exact;
-    // common timebase computation:
-    AVRational tb1 = ctx->inputs[MAIN   ]->time_base;
-    AVRational tb2 = ctx->inputs[OVERLAY]->time_base;
-    AVRational *tb = &ctx->outputs[0]->time_base;
-    exact = av_reduce(&tb->num, &tb->den,
-                      av_gcd((int64_t)tb1.num * tb2.den,
-                             (int64_t)tb2.num * tb1.den),
-                      (int64_t)tb1.den * tb2.den, INT_MAX);
-    av_log(ctx, AV_LOG_VERBOSE,
-           "main_tb:%d/%d overlay_tb:%d/%d -> tb:%d/%d exact:%d\n",
-           tb1.num, tb1.den, tb2.num, tb2.den, tb->num, tb->den, exact);
-    if (!exact)
-        av_log(ctx, AV_LOG_WARNING,
-               "Timestamp conversion inexact, timestamp information loss may occurr\n");
 
     outlink->w = ctx->inputs[MAIN]->w;
     outlink->h = ctx->inputs[MAIN]->h;
+    outlink->time_base = ctx->inputs[MAIN]->time_base;
 
     return 0;
 }
@@ -217,10 +203,9 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
     if (!outpicref)
         return AVERROR(ENOMEM);
 
-    outpicref->pts = av_rescale_q(outpicref->pts, ctx->inputs[MAIN]->time_base,
-                                  ctx->outputs[0]->time_base);
-
-    if (!over->overpicref || over->overpicref->pts < outpicref->pts) {
+    if (!over->overpicref ||
+        av_compare_ts(over->overpicref->pts, inlink->time_base,
+                      outpicref->pts, ctx->inputs[OVERLAY]->time_base) < 0) {
         AVFilterBufferRef *old = over->overpicref;
         over->overpicref = NULL;
         ff_request_frame(ctx->inputs[OVERLAY]);
@@ -242,8 +227,6 @@ static int start_frame_overlay(AVFilterLink *inlink, AVFilterBufferRef *inpicref
     inlink->cur_buf  = NULL;
     avfilter_unref_bufferp(&over->overpicref);
     over->overpicref = inpicref;
-    over->overpicref->pts = av_rescale_q(inpicref->pts, ctx->inputs[OVERLAY]->time_base,
-                                         ctx->outputs[0]->time_base);
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list