diff mbox

[FFmpeg-devel,1/2] avfilter/f_loop: fix video loop issues with 0 size or when size is bigger than input

Message ID 20190523213718.31673-1-cus@passwd.hu
State Accepted
Commit 87e0247a6c0f281158425d0f4958f1f1090bc15b
Headers show

Commit Message

Marton Balint May 23, 2019, 9:37 p.m. UTC
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 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Paul B Mahol May 24, 2019, 8 a.m. UTC | #1
On 5/23/19, Marton Balint <cus@passwd.hu> wrote:
> 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 | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
> index d9d55f9837..fcbd742eb4 100644
> --- a/libavfilter/f_loop.c
> +++ b/libavfilter/f_loop.c
> @@ -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;
>      }
> --
> 2.16.4
>

lgtm

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Marton Balint May 24, 2019, 8:45 p.m. UTC | #2
On Fri, 24 May 2019, Paul B Mahol wrote:

> On 5/23/19, Marton Balint <cus@passwd.hu> wrote:
>> 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 | 8 +++++---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
>> index d9d55f9837..fcbd742eb4 100644
>> --- a/libavfilter/f_loop.c
>> +++ b/libavfilter/f_loop.c
>> @@ -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;
>>      }
>> --
>> 2.16.4
>>
>
> lgtm

Thanks, applied the series.

Regards,
Marton
diff mbox

Patch

diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
index d9d55f9837..fcbd742eb4 100644
--- a/libavfilter/f_loop.c
+++ b/libavfilter/f_loop.c
@@ -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;
     }