1 /*
2 * Copyright (c) 2013 Nicolas George
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 License
8 * 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 License
17 * along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
26
27 #define OFFSET(member) offsetof(FFFrameSync, member)
28
30 {
31 return "framesync";
32 }
33
36 .class_name = "framesync",
39 .option = NULL,
40 .parent_log_context_offset =
OFFSET(parent),
41 };
42
43 enum {
47 };
48
50 {
54 }
55
57 {
58 unsigned i,
level = 0;
59
60 for (i = 0; i < fs->
nb_in; i++)
64 if (level < fs->sync_level)
66 if (level)
68 else
70 }
71
73 {
74 unsigned i;
75 int64_t gcd, lcm;
76
78 for (i = 0; i < fs->
nb_in; i++) {
87 } else {
90 break;
91 }
92 } else {
94 }
95 }
96 }
100 }
103 }
104
105 for (i = 0; i < fs->
nb_in; i++)
109
110 return 0;
111 }
112
114 {
115 int latest;
116 unsigned i;
117 int64_t pts;
118
120 return;
122 latest = -1;
123 for (i = 0; i < fs->
nb_in; i++) {
125 if (latest < 0 || fs->
in[i].pts < fs->
in[latest].pts)
126 latest = i;
127 }
128 }
129 if (latest >= 0) {
131 break;
132 }
133
135 for (i = 1; i < fs->
nb_in; i++)
138 if (pts == INT64_MAX) {
140 break;
141 }
142 for (i = 0; i < fs->
nb_in; i++) {
158 }
159 }
163 for (i = 0; i < fs->
nb_in; i++)
168 }
169 }
170
172 int64_t pts)
173 {
174 /* Possible enhancement: use the link's frame rate */
175 return pts + 1;
176 }
177
179 {
180 int64_t pts;
181
183 if (frame) {
186 } else {
191 }
195 }
196
198 {
202 else
204 return 0;
205 }
206
208 {
209 unsigned i;
210
212 for (i = 0; i < fs->
nb_in; i++)
217 }
218
220 {
222 }
223
225 unsigned get)
226 {
228 unsigned need_copy = 0, i;
229 int64_t pts_next;
231
233 *rframe = NULL;
234 return 0;
235 }
237 if (get) {
238 /* Find out if we need to copy the frame: is there another sync
239 stream, and do we know if its current frame will outlast this one? */
241 for (i = 0; i < fs->
nb_in && !need_copy; i++)
242 if (i != in && fs->
in[i].
sync &&
244 need_copy = 1;
245 if (need_copy) {
251 }
252 } else {
254 }
256 }
258 return 0;
259 }
260
262 {
263 unsigned i;
264
265 for (i = 0; i < fs->
nb_in; i++) {
269 }
270 }
271
273 {
275
277 while (1) {
280 break;
284 count++;
285 if (!all)
286 break;
287 }
288 if (!count && fs->
eof)
291 }
292
295 {
297
304 return 0;
305 }
306
308 {
311
314 if (ret > 0)
315 return 0;
326 ret = 0;
327 }
329 }