avfilter/af_afftdn: add alias for sample_noise end
[ffmpeg.git] / libavfilter / split.c
index 7268ec1..8b260a9 100644 (file)
 
 #include <stdio.h>
 
+#include "libavutil/attributes.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
 
+#define FF_INTERNAL_FIELDS 1
+#include "framequeue.h"
+
 #include "avfilter.h"
 #include "audio.h"
+#include "formats.h"
 #include "internal.h"
 #include "video.h"
 
@@ -39,10 +44,10 @@ typedef struct SplitContext {
     int nb_outputs;
 } SplitContext;
 
-static int split_init(AVFilterContext *ctx)
+static av_cold int split_init(AVFilterContext *ctx)
 {
     SplitContext *s = ctx->priv;
-    int i;
+    int i, ret;
 
     for (i = 0; i < s->nb_outputs; i++) {
         char name[32];
@@ -51,14 +56,19 @@ static int split_init(AVFilterContext *ctx)
         snprintf(name, sizeof(name), "output%d", i);
         pad.type = ctx->filter->inputs[0].type;
         pad.name = av_strdup(name);
+        if (!pad.name)
+            return AVERROR(ENOMEM);
 
-        ff_insert_outpad(ctx, i, &pad);
+        if ((ret = ff_insert_outpad(ctx, i, &pad)) < 0) {
+            av_freep(&pad.name);
+            return ret;
+        }
     }
 
     return 0;
 }
 
-static void split_uninit(AVFilterContext *ctx)
+static av_cold void split_uninit(AVFilterContext *ctx)
 {
     int i;
 
@@ -74,7 +84,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     for (i = 0; i < ctx->nb_outputs; i++) {
         AVFrame *buf_out;
 
-        if (ctx->outputs[i]->closed)
+        if (ctx->outputs[i]->status_in)
             continue;
         buf_out = av_frame_clone(frame);
         if (!buf_out) {
@@ -91,74 +101,56 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
 }
 
 #define OFFSET(x) offsetof(SplitContext, x)
-#define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_VIDEO_PARAM
+#define FLAGS (AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
 static const AVOption options[] = {
-    { "outputs", "Number of outputs", OFFSET(nb_outputs), AV_OPT_TYPE_INT, { .i64 = 2 }, 1, INT_MAX, FLAGS },
-    { NULL },
+    { "outputs", "set number of outputs", OFFSET(nb_outputs), AV_OPT_TYPE_INT, { .i64 = 2 }, 1, INT_MAX, FLAGS },
+    { NULL }
 };
 
-static const AVClass split_class = {
-    .class_name = "split",
-    .item_name  = av_default_item_name,
-    .option     = options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
+#define split_options options
+AVFILTER_DEFINE_CLASS(split);
 
-static const AVClass asplit_class = {
-    .class_name = "asplit",
-    .item_name  = av_default_item_name,
-    .option     = options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
+#define asplit_options options
+AVFILTER_DEFINE_CLASS(asplit);
 
 static const AVFilterPad avfilter_vf_split_inputs[] = {
     {
-        .name             = "default",
-        .type             = AVMEDIA_TYPE_VIDEO,
-        .get_video_buffer = ff_null_get_video_buffer,
-        .filter_frame     = filter_frame,
+        .name         = "default",
+        .type         = AVMEDIA_TYPE_VIDEO,
+        .filter_frame = filter_frame,
     },
     { NULL }
 };
 
-AVFilter avfilter_vf_split = {
-    .name      = "split",
-    .description = NULL_IF_CONFIG_SMALL("Pass on the input video to N outputs."),
-
-    .priv_size  = sizeof(SplitContext),
-    .priv_class = &split_class,
-
-    .init   = split_init,
-    .uninit = split_uninit,
-
-    .inputs    = avfilter_vf_split_inputs,
-    .outputs   = NULL,
-
-    .flags     = AVFILTER_FLAG_DYNAMIC_OUTPUTS,
+AVFilter ff_vf_split = {
+    .name        = "split",
+    .description = NULL_IF_CONFIG_SMALL("Pass on the input to N video outputs."),
+    .priv_size   = sizeof(SplitContext),
+    .priv_class  = &split_class,
+    .init        = split_init,
+    .uninit      = split_uninit,
+    .inputs      = avfilter_vf_split_inputs,
+    .outputs     = NULL,
+    .flags       = AVFILTER_FLAG_DYNAMIC_OUTPUTS,
 };
 
 static const AVFilterPad avfilter_af_asplit_inputs[] = {
     {
-        .name             = "default",
-        .type             = AVMEDIA_TYPE_AUDIO,
-        .get_audio_buffer = ff_null_get_audio_buffer,
-        .filter_frame     = filter_frame,
+        .name         = "default",
+        .type         = AVMEDIA_TYPE_AUDIO,
+        .filter_frame = filter_frame,
     },
     { NULL }
 };
 
-AVFilter avfilter_af_asplit = {
+AVFilter ff_af_asplit = {
     .name        = "asplit",
     .description = NULL_IF_CONFIG_SMALL("Pass on the audio input to N audio outputs."),
-
-    .priv_size  = sizeof(SplitContext),
-    .priv_class = &asplit_class,
-
-    .init   = split_init,
-    .uninit = split_uninit,
-
-    .inputs  = avfilter_af_asplit_inputs,
-    .outputs = NULL,
-
-    .flags   = AVFILTER_FLAG_DYNAMIC_OUTPUTS,
+    .priv_size   = sizeof(SplitContext),
+    .priv_class  = &asplit_class,
+    .init        = split_init,
+    .uninit      = split_uninit,
+    .inputs      = avfilter_af_asplit_inputs,
+    .outputs     = NULL,
+    .flags       = AVFILTER_FLAG_DYNAMIC_OUTPUTS,
 };