1 /*
2 * Copyright (c) 2011 Nicolas George <nicolas.george@normalesup.org>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg 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 * FFmpeg 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
14 * GNU 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 FFmpeg; 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 * Stream (de)synchronization filter
24 */
25
31
33
35 "b1", "b2",
36 "s1", "s2",
37 "t1", "t2",
38 NULL
39 };
40
46 };
47
56 /* buf[tail] is the oldest,
57 buf[(tail + nb) % QUEUE_SIZE] is where the next is added */
58 } queue[2];
61 int eof;
/* bitmask, one bit for each stream */
63
64 #define OFFSET(x) offsetof(AStreamSyncContext, x)
65 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
69 { NULL }
70 };
71
73
75 {
78
80 NULL, NULL, NULL, NULL, 0, ctx);
81 if (r < 0) {
84 }
85 for (i = 0; i < 42; i++)
87 return 0;
88 }
89
91 {
92 int i;
95
96 for (i = 0; i < 2; i++) {
106 }
107 return 0;
108 }
109
111 {
113 int id = outlink == ctx->
outputs[1];
114
117 return 0;
118 }
119
121 {
123 struct buf_queue *queue = &as->
queue[out_id];
126
127 queue->buf[queue->tail] = NULL;
136 queue->nb--;
141 }
142
144 {
146 int i;
147
148 while (1) {
150 break;
154 }
155 for (i = 0; i < 2; i++)
158 }
159
161 {
164 int id = outlink == ctx->
outputs[1];
165
167 while (as->
req[
id] && !(as->
eof & (1 <<
id))) {
170 } else {
175 }
176 }
177 return 0;
178 }
179
181 {
184 int id = inlink == ctx->
inputs[1];
185
187 insamples;
188 as->
eof &= ~(1 <<
id);
190 return 0;
191 }
192
194 {
196
199 }
200
202 {
206 },{
207 .name = "in2",
210 },
211 { NULL }
212 };
213
215 {
220 },{
221 .name = "out2",
225 },
226 { NULL }
227 };
228
230 .
name =
"astreamsync",
232 "in a configurable order."),
237 .
inputs = astreamsync_inputs,
238 .
outputs = astreamsync_outputs,
239 .priv_class = &astreamsync_class,
240 };