aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-03-07 15:11:32 +0100
committerPaul B Mahol <onemda@gmail.com>2022-03-07 15:29:40 +0100
commit328247076c7e77dea53ab59341ff1d85a1ad43cf (patch)
tree1826ead998244ce0684adaacfde70acee784c37d /libavfilter
parenta1f2e42ebf4c5af0f0975947fa40aa8679b82052 (diff)
downloadffmpeg-328247076c7e77dea53ab59341ff1d85a1ad43cf.tar.gz
avfilter/af_channelsplit: switch to activate()
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/af_channelsplit.c79
1 files changed, 61 insertions, 18 deletions
diff --git a/libavfilter/af_channelsplit.c b/libavfilter/af_channelsplit.c
index 1a2519dd32..e0b7839084 100644
--- a/libavfilter/af_channelsplit.c
+++ b/libavfilter/af_channelsplit.c
@@ -30,6 +30,7 @@
#include "audio.h"
#include "avfilter.h"
+#include "filters.h"
#include "formats.h"
#include "internal.h"
@@ -131,38 +132,79 @@ static int query_formats(AVFilterContext *ctx)
return 0;
}
-static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
+static int filter_frame(AVFilterLink *outlink, AVFrame *buf)
{
- AVFilterContext *ctx = inlink->dst;
+ AVFilterContext *ctx = outlink->src;
ChannelSplitContext *s = ctx->priv;
- int i, ret = 0;
+ const int i = FF_OUTLINK_IDX(outlink);
- for (i = 0; i < ctx->nb_outputs; i++) {
- AVFrame *buf_out = av_frame_clone(buf);
+ AVFrame *buf_out = av_frame_clone(buf);
+ if (!buf_out)
+ return AVERROR(ENOMEM);
- if (!buf_out) {
- ret = AVERROR(ENOMEM);
- break;
- }
+ buf_out->data[0] = buf_out->extended_data[0] = buf_out->extended_data[s->map[i]];
+ buf_out->channel_layout =
+ av_channel_layout_extract_channel(buf->channel_layout, s->map[i]);
+ buf_out->channels = 1;
+
+ return ff_filter_frame(ctx->outputs[i], buf_out);
+}
+
+static int activate(AVFilterContext *ctx)
+{
+ AVFilterLink *inlink = ctx->inputs[0];
+ int status, ret;
+ AVFrame *in;
+ int64_t pts;
+
+ for (int i = 0; i < ctx->nb_outputs; i++) {
+ FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[i], ctx);
+ }
- buf_out->data[0] = buf_out->extended_data[0] = buf_out->extended_data[s->map[i]];
- buf_out->channel_layout =
- av_channel_layout_extract_channel(buf->channel_layout, s->map[i]);
- buf_out->channels = 1;
+ ret = ff_inlink_consume_frame(inlink, &in);
+ if (ret < 0)
+ return ret;
+ if (ret > 0) {
+ for (int i = 0; i < ctx->nb_outputs; i++) {
+ if (ff_outlink_get_status(ctx->outputs[i]))
+ continue;
+
+ ret = filter_frame(ctx->outputs[i], in);
+ if (ret < 0)
+ break;
+ }
- ret = ff_filter_frame(ctx->outputs[i], buf_out);
+ av_frame_free(&in);
if (ret < 0)
- break;
+ return ret;
}
- av_frame_free(&buf);
- return ret;
+
+ if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
+ for (int i = 0; i < ctx->nb_outputs; i++) {
+ if (ff_outlink_get_status(ctx->outputs[i]))
+ continue;
+ ff_outlink_set_status(ctx->outputs[i], status, pts);
+ }
+ return 0;
+ }
+
+ for (int i = 0; i < ctx->nb_outputs; i++) {
+ if (ff_outlink_get_status(ctx->outputs[i]))
+ continue;
+
+ if (ff_outlink_frame_wanted(ctx->outputs[i])) {
+ ff_inlink_request_frame(inlink);
+ return 0;
+ }
+ }
+
+ return FFERROR_NOT_READY;
}
static const AVFilterPad avfilter_af_channelsplit_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
- .filter_frame = filter_frame,
},
};
@@ -172,6 +214,7 @@ const AVFilter ff_af_channelsplit = {
.priv_size = sizeof(ChannelSplitContext),
.priv_class = &channelsplit_class,
.init = init,
+ .activate = activate,
FILTER_INPUTS(avfilter_af_channelsplit_inputs),
.outputs = NULL,
FILTER_QUERY_FUNC(query_formats),