Showing the changes to libavfilter/split.c (1 of 1 file). Show all
Unified · Split
| @@ -27,25 +27,24 @@ · 26 unmodified lines | ||
| 27 | 27 | |
| 28 | 28 | #include "libavutil/internal.h" |
| 29 | 29 | #include "libavutil/mem.h" |
| 30 | +#include "libavutil/opt.h" | |
| 31 | + | |
| 30 | 32 | #include "avfilter.h" |
| 31 | 33 | #include "audio.h" |
| 32 | 34 | #include "internal.h" |
| 33 | 35 | #include "video.h" |
| 34 | 36 | |
| 37 | +typedef struct SplitContext { | |
| 38 | + const AVClass *class; | |
| 39 | + int nb_outputs; | |
| 40 | +} SplitContext; | |
| 41 | + | |
| 35 | 42 | static int split_init(AVFilterContext *ctx, const char *args) |
| 36 | 43 | { |
| 37 | − int i, nb_outputs = 2; | |
| 38 | − | |
| 39 | − if (args) { | |
| 40 | − nb_outputs = strtol(args, NULL, 0); | |
| 41 | − if (nb_outputs <= 0) { | |
| 42 | − av_log(ctx, AV_LOG_ERROR, "Invalid number of outputs specified: %d.\n", | |
| 43 | − nb_outputs); | |
| 44 | − return AVERROR(EINVAL); | |
| 45 | − } | |
| 46 | − } | |
| 44 | + SplitContext *s = ctx->priv; | |
| 45 | + int i; | |
| 47 | 46 | |
| 48 | − for (i = 0; i < nb_outputs; i++) { | |
| 47 | + for (i = 0; i < s->nb_outputs; i++) { | |
| 49 | 48 | char name[32]; |
| 50 | 49 | AVFilterPad pad = { 0 }; |
| 51 | 50 | |
| @@ -87,6 +86,27 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 35 unmodified lines | ||
| 87 | 86 | return ret; |
| 88 | 87 | } |
| 89 | 88 | |
| 89 | +#define OFFSET(x) offsetof(SplitContext, x) | |
| 90 | +#define FLAGS AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_VIDEO_PARAM | |
| 91 | +static const AVOption options[] = { | |
| 92 | + { "outputs", "Number of outputs", OFFSET(nb_outputs), AV_OPT_TYPE_INT, { .i64 = 2 }, 1, INT_MAX, FLAGS }, | |
| 93 | + { NULL }, | |
| 94 | +}; | |
| 95 | + | |
| 96 | +static const AVClass split_class = { | |
| 97 | + .class_name = "split", | |
| 98 | + .item_name = av_default_item_name, | |
| 99 | + .option = options, | |
| 100 | + .version = LIBAVUTIL_VERSION_INT, | |
| 101 | +}; | |
| 102 | + | |
| 103 | +static const AVClass asplit_class = { | |
| 104 | + .class_name = "asplit", | |
| 105 | + .item_name = av_default_item_name, | |
| 106 | + .option = options, | |
| 107 | + .version = LIBAVUTIL_VERSION_INT, | |
| 108 | +}; | |
| 109 | + | |
| 90 | 110 | static const AVFilterPad avfilter_vf_split_inputs[] = { |
| 91 | 111 | { |
| 92 | 112 | .name = "default", |
| @@ -101,6 +121,9 @@ AVFilter avfilter_vf_split = { · 8 unmodified lines | ||
| 101 | 121 | .name = "split", |
| 102 | 122 | .description = NULL_IF_CONFIG_SMALL("Pass on the input to two outputs."), |
| 103 | 123 | |
| 124 | + .priv_size = sizeof(SplitContext), | |
| 125 | + .priv_class = &split_class, | |
| 126 | + | |
| 104 | 127 | .init = split_init, |
| 105 | 128 | .uninit = split_uninit, |
| 106 | 129 | |
| @@ -122,6 +145,9 @@ AVFilter avfilter_af_asplit = { · 15 unmodified lines | ||
| 122 | 145 | .name = "asplit", |
| 123 | 146 | .description = NULL_IF_CONFIG_SMALL("Pass on the audio input to N audio outputs."), |
| 124 | 147 | |
| 148 | + .priv_size = sizeof(SplitContext), | |
| 149 | + .priv_class = &asplit_class, | |
| 150 | + | |
| 125 | 151 | .init = split_init, |
| 126 | 152 | .uninit = split_uninit, |
| 127 | 153 | |