]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/f_loop: fix video loop issues with 0 size or when size is bigger than input
authorMarton Balint <cus@passwd.hu>
Sun, 19 May 2019 19:16:03 +0000 (21:16 +0200)
committerMarton Balint <cus@passwd.hu>
Fri, 24 May 2019 19:39:07 +0000 (21:39 +0200)
Fixes infinte loop with -vf loop=loop=1 and also fixes looping when the input
is less frames than the specified loop size.

Possible regressions since ef1aadffc785b48ed62c45d954289e754f43ef46.

Signed-off-by: Marton Balint <cus@passwd.hu>
libavfilter/f_loop.c

index d9d55f983722fd9339f38765e0da39050916ac22..fcbd742eb46548217913860c1411f16f9dca6925 100644 (file)
@@ -343,7 +343,7 @@ static int activate(AVFilterContext *ctx)
 
     FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
 
-    if (!s->eof && (s->nb_frames < s->size || !s->loop)) {
+    if (!s->eof && (s->nb_frames < s->size || !s->loop || !s->size)) {
         ret = ff_inlink_consume_frame(inlink, &frame);
         if (ret < 0)
             return ret;
@@ -352,11 +352,13 @@ static int activate(AVFilterContext *ctx)
     }
 
     if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
-        if (status == AVERROR_EOF)
+        if (status == AVERROR_EOF) {
+            s->size = s->nb_frames;
             s->eof = 1;
+        }
     }
 
-    if (s->eof && (s->loop == 0 || s->nb_frames < s->size)) {
+    if (s->eof && (!s->loop || !s->size)) {
         ff_outlink_set_status(outlink, AVERROR_EOF, s->duration);
         return 0;
     }