[FFmpeg-devel] [PATCH 4/5] vf_fps: move flushing remaining frames in a separate function.
Nicolas George
george at nsup.org
Sun Aug 3 15:15:39 CEST 2014
Also remove unused loop counter, rename obsolete "buf",
and add a comment about a similar function.
Signed-off-by: Nicolas George <george at nsup.org>
---
libavfilter/vf_fps.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
index a38633d..a3ad1bb 100644
--- a/libavfilter/vf_fps.c
+++ b/libavfilter/vf_fps.c
@@ -88,6 +88,7 @@ static av_cold int init(AVFilterContext *ctx)
return 0;
}
+/* FIXME: misnommer, the frames are discarded, not flushed */
static void flush_fifo(AVFifoBuffer *fifo)
{
while (av_fifo_size(fifo)) {
@@ -97,6 +98,24 @@ static void flush_fifo(AVFifoBuffer *fifo)
}
}
+static int flush_fifo_to_out(AVFilterContext *ctx)
+{
+ FPSContext *s = ctx->priv;
+ AVFilterLink *outlink = ctx->outputs[0];
+ AVFrame *frame;
+ int ret;
+
+ while (av_fifo_size(s->fifo)) {
+ av_fifo_generic_read(s->fifo, &frame, sizeof(frame), NULL);
+ frame->pts = av_rescale_q(s->first_pts, ctx->inputs[0]->time_base,
+ outlink->time_base) + s->frames_out;
+ if ((ret = ff_filter_frame(outlink, frame)) < 0)
+ return ret;
+ s->frames_out++;
+ }
+ return 0;
+}
+
static av_cold void uninit(AVFilterContext *ctx)
{
FPSContext *s = ctx->priv;
@@ -133,23 +152,8 @@ static int request_frame(AVFilterLink *outlink)
ret = ff_request_frame(ctx->inputs[0]);
/* flush the fifo */
- if (ret == AVERROR_EOF && av_fifo_size(s->fifo)) {
- int i;
- for (i = 0; av_fifo_size(s->fifo); i++) {
- AVFrame *buf;
-
- av_fifo_generic_read(s->fifo, &buf, sizeof(buf), NULL);
- buf->pts = av_rescale_q(s->first_pts, ctx->inputs[0]->time_base,
- outlink->time_base) + s->frames_out;
-
- if ((ret = ff_filter_frame(outlink, buf)) < 0)
- return ret;
-
- s->frames_out++;
- }
- return 0;
- }
-
+ if (ret == AVERROR_EOF && av_fifo_size(s->fifo))
+ return flush_fifo_to_out(ctx);
return ret;
}
--
2.0.1
More information about the ffmpeg-devel
mailing list