diff mbox

[FFmpeg-devel,PATCHv2] avfilter/vf_framerate: always request input if no output is provided in request_frame

Message ID 20170407045552.4259-1-cus@passwd.hu
State Superseded
Headers show

Commit Message

Marton Balint April 7, 2017, 4:55 a.m. UTC
Fixes ticket #6285.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavfilter/vf_framerate.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Nicolas George April 7, 2017, 8:20 a.m. UTC | #1
L'octidi 18 germinal, an CCXXV, Marton Balint a écrit :
> Fixes ticket #6285.
> 
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavfilter/vf_framerate.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Still LGTM, of course.

But since the questions of elegance have been raised, here are my two
zorkmids:

Another solution that I personally find more elegant (but it is only a
matter of taste) would be to have process_work_frame() return to the
caller whether a frame was sent:

    static int process_work_frame(AVFilterContext *ctx, int stop, int *frame_sent)
	...
	*frame_sent = 1;
	return ff_filter_frame(ctx->outputs[0], s->work);

And then check this variable and call ff_request_frame() from
request_frame() rather than calling it directly from
process_work_frame():

	ret = process_work_frame(ctx, 0, &frame_sent);
	return frame_sent ? ret : ff_request_frame(...)

But it is only a matter of personal preference, and I mention it only in
case you share it; the patch as is looks fine to me.

Regards,
diff mbox

Patch

diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index b4a74f7..0093f78 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -341,7 +341,7 @@  static int blend_frames8(AVFilterContext *ctx, float interpolate,
     return 0;
 }
 
-static int process_work_frame(AVFilterContext *ctx, int stop)
+static int process_work_frame(AVFilterContext *ctx, int in_filter_frame)
 {
     FrameRateContext *s = ctx->priv;
     int64_t work_next_pts;
@@ -360,7 +360,7 @@  static int process_work_frame(AVFilterContext *ctx, int stop)
         // the filter cannot do anything
         ff_dlog(ctx, "process_work_frame() no current frame cached: move on to next frame, do not output a frame\n");
         next_source(ctx);
-        return 0;
+        return in_filter_frame ? 0 : ff_request_frame(ctx->inputs[0]);
     }
 
     work_next_pts = s->pts + s->average_dest_pts_delta;
@@ -384,7 +384,7 @@  static int process_work_frame(AVFilterContext *ctx, int stop)
         ff_dlog(ctx, "process_work_frame() work crnt pts >= srce next pts: SKIP FRAME, move on to next frame, do not output a frame\n");
         next_source(ctx);
         s->pending_srce_frames--;
-        return 0;
+        return in_filter_frame ? 0 : ff_request_frame(ctx->inputs[0]);
     }
 
     // calculate interpolation
@@ -436,7 +436,7 @@  copy_done:
     }
     ff_dlog(ctx, "process_work_frame() output a frame\n");
     s->dest_frame_num++;
-    if (stop)
+    if (in_filter_frame)
         s->pending_end_frame = 0;
     s->last_dest_frame_pts = s->work->pts;