Fix trac ticket #7351.
Signed-off-by: Nicolas George
---
libavfilter/avf_concat.c | 156 +++
1 file changed, 78 insertions(+), 78 deletions(-)
diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c
index 46bd42359b..1d0c2de290 100644
--- a/libavfilter/avf_concat.c
+++ b/libavfilter/avf_concat.c
@@ -28,8 +28,7 @@
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "avfilter.h"
-#define FF_BUFQUEUE_SIZE 256
-#include "bufferqueue.h"
+#include "filters.h"
#include "internal.h"
#include "video.h"
#include "audio.h"
@@ -48,7 +47,6 @@ typedef struct ConcatContext {
int64_t pts;
int64_t nb_frames;
unsigned eof;
-struct FFBufQueue queue;
} *in;
} ConcatContext;
@@ -185,24 +183,6 @@ static int push_frame(AVFilterContext *ctx, unsigned
in_no, AVFrame *buf)
return ff_filter_frame(outlink, buf);
}
-static int process_frame(AVFilterLink *inlink, AVFrame *buf)
-{
-AVFilterContext *ctx = inlink->dst;
-ConcatContext *cat= ctx->priv;
-unsigned in_no = FF_INLINK_IDX(inlink);
-
-if (in_no < cat->cur_idx) {
-av_log(ctx, AV_LOG_ERROR, "Frame after EOF on input %s\n",
- ctx->input_pads[in_no].name);
-av_frame_free();
-} else if (in_no >= cat->cur_idx + ctx->nb_outputs) {
-ff_bufqueue_add(ctx, >in[in_no].queue, buf);
-} else {
-return push_frame(ctx, in_no, buf);
-}
-return 0;
-}
-
static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h)
{
AVFilterContext *ctx = inlink->dst;
@@ -221,11 +201,6 @@ static AVFrame *get_audio_buffer(AVFilterLink *inlink, int
nb_samples)
return ff_get_audio_buffer(outlink, nb_samples);
}
-static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
-{
-return process_frame(inlink, buf);
-}
-
static void close_input(AVFilterContext *ctx, unsigned in_no)
{
ConcatContext *cat = ctx->priv;
@@ -306,57 +281,10 @@ static int flush_segment(AVFilterContext *ctx)
if (ret < 0)
return ret;
}
-/* flush queued buffers */
-/* possible enhancement: flush in PTS order */
-str_max = cat->cur_idx + ctx->nb_outputs;
-for (str = cat->cur_idx; str < str_max; str++) {
-while (cat->in[str].queue.available) {
-ret = push_frame(ctx, str,
ff_bufqueue_get(>in[str].queue));
-if (ret < 0)
-return ret;
-}
-}
}
return 0;
}
-static int request_frame(AVFilterLink *outlink)
-{
-AVFilterContext *ctx = outlink->src;
-ConcatContext *cat = ctx->priv;
-unsigned out_no = FF_OUTLINK_IDX(outlink);
-unsigned in_no = out_no + cat->cur_idx;
-unsigned str, str_max;
-int ret;
-
-while (1) {
-if (in_no >= ctx->nb_inputs)
-return AVERROR_EOF;
-if (!cat->in[in_no].eof) {
-ret = ff_request_frame(ctx->inputs[in_no]);
-if (ret != AVERROR_EOF)
-return ret;
-close_input(ctx, in_no);
-}
-/* cycle on all inputs to finish the segment */
-/* possible enhancement: request in PTS order */
-str_max = cat->cur_idx + ctx->nb_outputs - 1;
-for (str = cat->cur_idx; cat->nb_in_active;
- str = str == str_max ? cat->cur_idx : str + 1) {
-if (cat->in[str].eof)
-continue;
-ret = ff_request_frame(ctx->inputs[str]);
-if (ret != AVERROR_EOF)
-return ret;
-close_input(ctx, str);
-}
-ret = flush_segment(ctx);
-if (ret < 0)
-return ret;
-in_no += ctx->nb_outputs;
-}
-}
-
static av_cold int init(AVFilterContext *ctx)
{
ConcatContext *cat = ctx->priv;
@@ -371,7 +299,6 @@ static av_cold int init(AVFilterContext *ctx)
.type = type,
.get_video_buffer = get_video_buffer,
.get_audio_buffer = get_audio_buffer,
-.filter_frame = filter_frame,
};
pad.name = av_asprintf("in%d:%c%d", seg, "va"[type], str);
if ((ret = ff_insert_inpad(ctx, ctx->nb_inputs, )) < 0) {
@@ -387,7 +314,6 @@ static av_cold int init(AVFilterContext *ctx)
AVFilterPad pad = {
.type = type,
.config_props = config_output,
-.request_frame = request_frame,
};
pad.name = av_asprintf("out:%c%d", "va"[type], str);
if ((ret = ff_insert_outpad(ctx, ctx->nb_outputs, )) < 0) {
@@ -409,15 +335,88 @@ static av_cold void uninit(AVFilterContext *ctx)
ConcatContext *cat = ctx->priv;
unsigned i;
-for (i = 0; i < ctx->nb_inputs; i++) {
+for (i = 0; i < ctx->nb_inputs; i++)
av_freep(>input_pads[i].name);
-