[FFmpeg-cvslog] avfilter/vf_tpad: handle case when no frame was ever received

Paul B Mahol git at videolan.org
Thu Feb 24 22:30:40 EET 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Feb 24 20:44:46 2022 +0100| [6f04b43c221c1bf825b18f7e2dcc599476ae7b94] | committer: Paul B Mahol

avfilter/vf_tpad: handle case when no frame was ever received

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

 libavfilter/vf_tpad.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index 120dbcb4d3..c870478158 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -79,6 +79,18 @@ static int activate(AVFilterContext *ctx)
 
     FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
 
+    if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
+        if (status == AVERROR_EOF) {
+            pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
+            if (!s->pad_stop && !s->pad_start) {
+                ff_outlink_set_status(outlink, status, pts);
+                return 0;
+            }
+            s->eof = 1;
+            s->pts += pts;
+        }
+    }
+
     if (s->start_mode == 0 && s->pad_start > 0 && ff_outlink_frame_wanted(outlink)) {
         frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
         if (!frame)
@@ -93,7 +105,10 @@ static int activate(AVFilterContext *ctx)
     }
 
     if (s->start_mode == 1 && s->pad_start > 0) {
-        if (!s->cache_start && ff_inlink_queued_frames(inlink)) {
+        if (s->eof) {
+            ff_outlink_set_status(outlink, AVERROR_EOF, 0);
+            return 0;
+        } else if (!s->cache_start && ff_inlink_queued_frames(inlink)) {
             s->cache_start = ff_inlink_peek_frame(inlink, 0);
         } else if (!s->cache_start) {
             FF_FILTER_FORWARD_WANTED(outlink, inlink);
@@ -123,18 +138,6 @@ static int activate(AVFilterContext *ctx)
         }
     }
 
-    if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
-        if (status == AVERROR_EOF) {
-            pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
-            if (!s->pad_stop) {
-                ff_outlink_set_status(outlink, status, pts);
-                return 0;
-            }
-            s->eof = 1;
-            s->pts += pts;
-        }
-    }
-
     if (s->eof) {
         if (!s->pad_stop) {
             ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);



More information about the ffmpeg-cvslog mailing list