This is in preparation for adding an audio split filter.
| ... | ... |
@@ -68,7 +68,7 @@ OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o |
| 68 | 68 |
OBJS-$(CONFIG_SETTB_FILTER) += vf_settb.o |
| 69 | 69 |
OBJS-$(CONFIG_SHOWINFO_FILTER) += vf_showinfo.o |
| 70 | 70 |
OBJS-$(CONFIG_SLICIFY_FILTER) += vf_slicify.o |
| 71 |
-OBJS-$(CONFIG_SPLIT_FILTER) += vf_split.o |
|
| 71 |
+OBJS-$(CONFIG_SPLIT_FILTER) += split.o |
|
| 72 | 72 |
OBJS-$(CONFIG_TRANSPOSE_FILTER) += vf_transpose.o |
| 73 | 73 |
OBJS-$(CONFIG_UNSHARP_FILTER) += vf_unsharp.o |
| 74 | 74 |
OBJS-$(CONFIG_VFLIP_FILTER) += vf_vflip.o |
| 75 | 75 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,108 @@ |
| 0 |
+/* |
|
| 1 |
+ * Copyright (c) 2007 Bobby Bingham |
|
| 2 |
+ * |
|
| 3 |
+ * This file is part of Libav. |
|
| 4 |
+ * |
|
| 5 |
+ * Libav is free software; you can redistribute it and/or |
|
| 6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
| 7 |
+ * License as published by the Free Software Foundation; either |
|
| 8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
| 9 |
+ * |
|
| 10 |
+ * Libav is distributed in the hope that it will be useful, |
|
| 11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 13 |
+ * Lesser General Public License for more details. |
|
| 14 |
+ * |
|
| 15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
| 16 |
+ * License along with Libav; if not, write to the Free Software |
|
| 17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
| 18 |
+ */ |
|
| 19 |
+ |
|
| 20 |
+/** |
|
| 21 |
+ * @file |
|
| 22 |
+ * Video splitter |
|
| 23 |
+ */ |
|
| 24 |
+ |
|
| 25 |
+#include "avfilter.h" |
|
| 26 |
+ |
|
| 27 |
+static int split_init(AVFilterContext *ctx, const char *args, void *opaque) |
|
| 28 |
+{
|
|
| 29 |
+ int i, nb_outputs = 2; |
|
| 30 |
+ |
|
| 31 |
+ if (args) {
|
|
| 32 |
+ nb_outputs = strtol(args, NULL, 0); |
|
| 33 |
+ if (nb_outputs <= 0) {
|
|
| 34 |
+ av_log(ctx, AV_LOG_ERROR, "Invalid number of outputs specified: %d.\n", |
|
| 35 |
+ nb_outputs); |
|
| 36 |
+ return AVERROR(EINVAL); |
|
| 37 |
+ } |
|
| 38 |
+ } |
|
| 39 |
+ |
|
| 40 |
+ for (i = 0; i < nb_outputs; i++) {
|
|
| 41 |
+ char name[32]; |
|
| 42 |
+ AVFilterPad pad = { 0 };
|
|
| 43 |
+ |
|
| 44 |
+ snprintf(name, sizeof(name), "output%d", i); |
|
| 45 |
+ pad.type = AVMEDIA_TYPE_VIDEO; |
|
| 46 |
+ pad.name = av_strdup(name); |
|
| 47 |
+ |
|
| 48 |
+ avfilter_insert_outpad(ctx, i, &pad); |
|
| 49 |
+ } |
|
| 50 |
+ |
|
| 51 |
+ return 0; |
|
| 52 |
+} |
|
| 53 |
+ |
|
| 54 |
+static void split_uninit(AVFilterContext *ctx) |
|
| 55 |
+{
|
|
| 56 |
+ int i; |
|
| 57 |
+ |
|
| 58 |
+ for (i = 0; i < ctx->output_count; i++) |
|
| 59 |
+ av_freep(&ctx->output_pads[i].name); |
|
| 60 |
+} |
|
| 61 |
+ |
|
| 62 |
+static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
|
| 63 |
+{
|
|
| 64 |
+ AVFilterContext *ctx = inlink->dst; |
|
| 65 |
+ int i; |
|
| 66 |
+ |
|
| 67 |
+ for (i = 0; i < ctx->output_count; i++) |
|
| 68 |
+ avfilter_start_frame(ctx->outputs[i], |
|
| 69 |
+ avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); |
|
| 70 |
+} |
|
| 71 |
+ |
|
| 72 |
+static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
|
| 73 |
+{
|
|
| 74 |
+ AVFilterContext *ctx = inlink->dst; |
|
| 75 |
+ int i; |
|
| 76 |
+ |
|
| 77 |
+ for (i = 0; i < ctx->output_count; i++) |
|
| 78 |
+ avfilter_draw_slice(ctx->outputs[i], y, h, slice_dir); |
|
| 79 |
+} |
|
| 80 |
+ |
|
| 81 |
+static void end_frame(AVFilterLink *inlink) |
|
| 82 |
+{
|
|
| 83 |
+ AVFilterContext *ctx = inlink->dst; |
|
| 84 |
+ int i; |
|
| 85 |
+ |
|
| 86 |
+ for (i = 0; i < ctx->output_count; i++) |
|
| 87 |
+ avfilter_end_frame(ctx->outputs[i]); |
|
| 88 |
+ |
|
| 89 |
+ avfilter_unref_buffer(inlink->cur_buf); |
|
| 90 |
+} |
|
| 91 |
+ |
|
| 92 |
+AVFilter avfilter_vf_split = {
|
|
| 93 |
+ .name = "split", |
|
| 94 |
+ .description = NULL_IF_CONFIG_SMALL("Pass on the input to two outputs."),
|
|
| 95 |
+ |
|
| 96 |
+ .init = split_init, |
|
| 97 |
+ .uninit = split_uninit, |
|
| 98 |
+ |
|
| 99 |
+ .inputs = (AVFilterPad[]) {{ .name = "default",
|
|
| 100 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
| 101 |
+ .get_video_buffer= avfilter_null_get_video_buffer, |
|
| 102 |
+ .start_frame = start_frame, |
|
| 103 |
+ .draw_slice = draw_slice, |
|
| 104 |
+ .end_frame = end_frame, }, |
|
| 105 |
+ { .name = NULL}},
|
|
| 106 |
+ .outputs = (AVFilterPad[]) {{ .name = NULL}},
|
|
| 107 |
+}; |
| 0 | 108 |
deleted file mode 100644 |
| ... | ... |
@@ -1,108 +0,0 @@ |
| 1 |
-/* |
|
| 2 |
- * Copyright (c) 2007 Bobby Bingham |
|
| 3 |
- * |
|
| 4 |
- * This file is part of Libav. |
|
| 5 |
- * |
|
| 6 |
- * Libav is free software; you can redistribute it and/or |
|
| 7 |
- * modify it under the terms of the GNU Lesser General Public |
|
| 8 |
- * License as published by the Free Software Foundation; either |
|
| 9 |
- * version 2.1 of the License, or (at your option) any later version. |
|
| 10 |
- * |
|
| 11 |
- * Libav is distributed in the hope that it will be useful, |
|
| 12 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 14 |
- * Lesser General Public License for more details. |
|
| 15 |
- * |
|
| 16 |
- * You should have received a copy of the GNU Lesser General Public |
|
| 17 |
- * License along with Libav; if not, write to the Free Software |
|
| 18 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
| 19 |
- */ |
|
| 20 |
- |
|
| 21 |
-/** |
|
| 22 |
- * @file |
|
| 23 |
- * Video splitter |
|
| 24 |
- */ |
|
| 25 |
- |
|
| 26 |
-#include "avfilter.h" |
|
| 27 |
- |
|
| 28 |
-static int split_init(AVFilterContext *ctx, const char *args, void *opaque) |
|
| 29 |
-{
|
|
| 30 |
- int i, nb_outputs = 2; |
|
| 31 |
- |
|
| 32 |
- if (args) {
|
|
| 33 |
- nb_outputs = strtol(args, NULL, 0); |
|
| 34 |
- if (nb_outputs <= 0) {
|
|
| 35 |
- av_log(ctx, AV_LOG_ERROR, "Invalid number of outputs specified: %d.\n", |
|
| 36 |
- nb_outputs); |
|
| 37 |
- return AVERROR(EINVAL); |
|
| 38 |
- } |
|
| 39 |
- } |
|
| 40 |
- |
|
| 41 |
- for (i = 0; i < nb_outputs; i++) {
|
|
| 42 |
- char name[32]; |
|
| 43 |
- AVFilterPad pad = { 0 };
|
|
| 44 |
- |
|
| 45 |
- snprintf(name, sizeof(name), "output%d", i); |
|
| 46 |
- pad.type = AVMEDIA_TYPE_VIDEO; |
|
| 47 |
- pad.name = av_strdup(name); |
|
| 48 |
- |
|
| 49 |
- avfilter_insert_outpad(ctx, i, &pad); |
|
| 50 |
- } |
|
| 51 |
- |
|
| 52 |
- return 0; |
|
| 53 |
-} |
|
| 54 |
- |
|
| 55 |
-static void split_uninit(AVFilterContext *ctx) |
|
| 56 |
-{
|
|
| 57 |
- int i; |
|
| 58 |
- |
|
| 59 |
- for (i = 0; i < ctx->output_count; i++) |
|
| 60 |
- av_freep(&ctx->output_pads[i].name); |
|
| 61 |
-} |
|
| 62 |
- |
|
| 63 |
-static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) |
|
| 64 |
-{
|
|
| 65 |
- AVFilterContext *ctx = inlink->dst; |
|
| 66 |
- int i; |
|
| 67 |
- |
|
| 68 |
- for (i = 0; i < ctx->output_count; i++) |
|
| 69 |
- avfilter_start_frame(ctx->outputs[i], |
|
| 70 |
- avfilter_ref_buffer(picref, ~AV_PERM_WRITE)); |
|
| 71 |
-} |
|
| 72 |
- |
|
| 73 |
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) |
|
| 74 |
-{
|
|
| 75 |
- AVFilterContext *ctx = inlink->dst; |
|
| 76 |
- int i; |
|
| 77 |
- |
|
| 78 |
- for (i = 0; i < ctx->output_count; i++) |
|
| 79 |
- avfilter_draw_slice(ctx->outputs[i], y, h, slice_dir); |
|
| 80 |
-} |
|
| 81 |
- |
|
| 82 |
-static void end_frame(AVFilterLink *inlink) |
|
| 83 |
-{
|
|
| 84 |
- AVFilterContext *ctx = inlink->dst; |
|
| 85 |
- int i; |
|
| 86 |
- |
|
| 87 |
- for (i = 0; i < ctx->output_count; i++) |
|
| 88 |
- avfilter_end_frame(ctx->outputs[i]); |
|
| 89 |
- |
|
| 90 |
- avfilter_unref_buffer(inlink->cur_buf); |
|
| 91 |
-} |
|
| 92 |
- |
|
| 93 |
-AVFilter avfilter_vf_split = {
|
|
| 94 |
- .name = "split", |
|
| 95 |
- .description = NULL_IF_CONFIG_SMALL("Pass on the input to two outputs."),
|
|
| 96 |
- |
|
| 97 |
- .init = split_init, |
|
| 98 |
- .uninit = split_uninit, |
|
| 99 |
- |
|
| 100 |
- .inputs = (AVFilterPad[]) {{ .name = "default",
|
|
| 101 |
- .type = AVMEDIA_TYPE_VIDEO, |
|
| 102 |
- .get_video_buffer= avfilter_null_get_video_buffer, |
|
| 103 |
- .start_frame = start_frame, |
|
| 104 |
- .draw_slice = draw_slice, |
|
| 105 |
- .end_frame = end_frame, }, |
|
| 106 |
- { .name = NULL}},
|
|
| 107 |
- .outputs = (AVFilterPad[]) {{ .name = NULL}},
|
|
| 108 |
-}; |