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 | #include "libavutil/internal.h" | 28 | #include "libavutil/internal.h" |
| 29 | #include "libavutil/mem.h" | 29 | #include "libavutil/mem.h" |
| 30 | #include "libavutil/opt.h" | ||
| 31 | |||
| 30 | #include "avfilter.h" | 32 | #include "avfilter.h" |
| 31 | #include "audio.h" | 33 | #include "audio.h" |
| 32 | #include "internal.h" | 34 | #include "internal.h" |
| 33 | #include "video.h" | 35 | #include "video.h" |
| 34 | 36 | ||
| 37 | typedef struct SplitContext { | ||
| 38 | const AVClass *class; | ||
| 39 | int nb_outputs; | ||
| 40 | } SplitContext; | ||
| 41 | |||
| 35 | static int split_init(AVFilterContext *ctx, const char *args) | 42 | static int split_init(AVFilterContext *ctx, const char *args) |
| 36 | { | 43 | { |
| 37 | int i, nb_outputs = 2; | 44 | SplitContext *s = ctx->priv; |
| 38 | 45 | int i; | |
| 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 | } | ||
| 47 | 46 | ||
| 48 | for (i = 0; i < nb_outputs; i++) { | 47 | for (i = 0; i < s->nb_outputs; i++) { |
| 49 | char name[32]; | 48 | char name[32]; |
| 50 | AVFilterPad pad = { 0 }; | 49 | AVFilterPad pad = { 0 }; |
| 51 | 50 | ||
| @@ -87,6 +86,27 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) · 35 unmodified lines | |||
| 87 | return ret; | 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 | static const AVFilterPad avfilter_vf_split_inputs[] = { | 110 | static const AVFilterPad avfilter_vf_split_inputs[] = { |
| 91 | { | 111 | { |
| 92 | .name = "default", | 112 | .name = "default", |
| @@ -101,6 +121,9 @@ AVFilter avfilter_vf_split = { · 8 unmodified lines | |||
| 101 | .name = "split", | 121 | .name = "split", |
| 102 | .description = NULL_IF_CONFIG_SMALL("Pass on the input to two outputs."), | 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 | .init = split_init, | 127 | .init = split_init, |
| 105 | .uninit = split_uninit, | 128 | .uninit = split_uninit, |
| 106 | 129 | ||
| @@ -122,6 +145,9 @@ AVFilter avfilter_af_asplit = { · 15 unmodified lines | |||
| 122 | .name = "asplit", | 145 | .name = "asplit", |
| 123 | .description = NULL_IF_CONFIG_SMALL("Pass on the audio input to N audio outputs."), | 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 | .init = split_init, | 151 | .init = split_init, |
| 126 | .uninit = split_uninit, | 152 | .uninit = split_uninit, |
| 127 | 153 | ||