diff mbox

[FFmpeg-devel,2/2] lavfi: make filter_frame non-recursive.

Message ID 20161223102507.GA1492601@phare.normalesup.org
State Accepted
Headers show

Commit Message

Nicolas George Dec. 23, 2016, 10:25 a.m. UTC
Le tridi 3 nivôse, an CCXXV, Nicolas George a écrit :
> Yes, thanks. This is the glitch I am currently working on, and I think
> it is almost fixed cleanly. Note that the actual time is still very
> small, it is only ffmpeg keeps thinking the filter is not ready and
> sleeping.

Actually, it was not exactly the same. Please see the attached patch.

Regards,

Comments

James Almer Dec. 23, 2016, 2:19 p.m. UTC | #1
On 12/23/2016 7:25 AM, Nicolas George wrote:
> Le tridi 3 nivôse, an CCXXV, Nicolas George a écrit :
>> Yes, thanks. This is the glitch I am currently working on, and I think
>> it is almost fixed cleanly. Note that the actual time is still very
>> small, it is only ffmpeg keeps thinking the filter is not ready and
>> sleeping.
> Actually, it was not exactly the same. Please see the attached patch.
> 
> Regards,
> 
> -- Nicolas George
> 
> 
> 0001-lavfi-avfilter_graph_request_oldest-request-a-frame-.patch
> 
> 
> From c7f2f6d8e2ea776dc4c097685dc0e8255051d1ee Mon Sep 17 00:00:00 2001
> From: Nicolas George <george@nsup.org>
> Date: Fri, 23 Dec 2016 11:18:09 +0100
> Subject: [PATCH] lavfi: avfilter_graph_request_oldest: request a frame again
>  before returning.
> 
> With min_samples, if a frame arrives but is too small, it clears
> frame_wanted_out. In most cases, the destination filter would be
> activated again later because of frame_wanted_out on its own
> outputs, but not sinks.
> avfilter_graph_request_oldest() is doing the work of the sink
> itself, and is therefore allowed to use frame_blocked_in.
> 
> Signed-off-by: Nicolas George <george@nsup.org>
> ---
>  libavfilter/avfiltergraph.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
> index 6b5a6f34ec..cb5d618ab1 100644
> --- a/libavfilter/avfiltergraph.c
> +++ b/libavfilter/avfiltergraph.c
> @@ -1407,7 +1407,11 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph)
>      frame_count = oldest->frame_count_out;
>      while (frame_count == oldest->frame_count_out) {
>          r = ff_filter_graph_run_once(graph);
> -        if (r < 0)
> +        if (r == AVERROR(EAGAIN) &&
> +            !oldest->frame_wanted_out && !oldest->frame_blocked_in &&
> +            !oldest->status_in)
> +            ff_request_frame(oldest);
> +        else if (r < 0)
>              return r;
>      }
>      return 0;
> -- 2.11.0

Yes, i can confirm this fixes it.
Nicolas George Dec. 23, 2016, 2:29 p.m. UTC | #2
Le tridi 3 nivôse, an CCXXV, James Almer a écrit :
> Yes, i can confirm this fixes it.

Thanks, pushed.

Regards,
diff mbox

Patch

From c7f2f6d8e2ea776dc4c097685dc0e8255051d1ee Mon Sep 17 00:00:00 2001
From: Nicolas George <george@nsup.org>
Date: Fri, 23 Dec 2016 11:18:09 +0100
Subject: [PATCH] lavfi: avfilter_graph_request_oldest: request a frame again
 before returning.

With min_samples, if a frame arrives but is too small, it clears
frame_wanted_out. In most cases, the destination filter would be
activated again later because of frame_wanted_out on its own
outputs, but not sinks.
avfilter_graph_request_oldest() is doing the work of the sink
itself, and is therefore allowed to use frame_blocked_in.

Signed-off-by: Nicolas George <george@nsup.org>
---
 libavfilter/avfiltergraph.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 6b5a6f34ec..cb5d618ab1 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -1407,7 +1407,11 @@  int avfilter_graph_request_oldest(AVFilterGraph *graph)
     frame_count = oldest->frame_count_out;
     while (frame_count == oldest->frame_count_out) {
         r = ff_filter_graph_run_once(graph);
-        if (r < 0)
+        if (r == AVERROR(EAGAIN) &&
+            !oldest->frame_wanted_out && !oldest->frame_blocked_in &&
+            !oldest->status_in)
+            ff_request_frame(oldest);
+        else if (r < 0)
             return r;
     }
     return 0;
-- 
2.11.0