History

lavfi: rename vf_split.c to split.c

This is in preparation for adding an audio split filter.

Justin Ruggles committed 14 years ago

Commit cc300801 parent 13a867a2 files · +1 −1Browse files

Showing the changes to libavfilter/split.c (1 of 2 files). Show all

Unified · Split

libavfilter/split.c+108−0
@@ -0,0 +1,108 @@
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
28static 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
55static 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
63static 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
73static 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
82static 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
93AVFilter 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};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t