FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/framesync.c
Date: 2022-12-05 20:26:17
Exec Total Coverage
Lines: 200 235 85.1%
Functions: 17 18 94.4%
Branches: 131 188 69.7%

Line Branch Exec Source
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
21 #include "libavutil/avassert.h"
22 #include "libavutil/opt.h"
23 #include "avfilter.h"
24 #include "filters.h"
25 #include "framesync.h"
26 #include "internal.h"
27
28 #define OFFSET(member) offsetof(FFFrameSync, member)
29 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
30
31 static const char *framesync_name(void *ptr)
32 {
33 return "framesync";
34 }
35
36 static const AVOption framesync_options[] = {
37 { "eof_action", "Action to take when encountering EOF from secondary input ",
38 OFFSET(opt_eof_action), AV_OPT_TYPE_INT, { .i64 = EOF_ACTION_REPEAT },
39 EOF_ACTION_REPEAT, EOF_ACTION_PASS, .flags = FLAGS, "eof_action" },
40 { "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, "eof_action" },
41 { "endall", "End both streams.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, "eof_action" },
42 { "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, "eof_action" },
43 { "shortest", "force termination when the shortest input terminates", OFFSET(opt_shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
44 { "repeatlast", "extend last frame of secondary streams beyond EOF", OFFSET(opt_repeatlast), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
45 { "ts_sync_mode", "How strictly to sync streams based on secondary input timestamps",
46 OFFSET(opt_ts_sync_mode), AV_OPT_TYPE_INT, { .i64 = TS_DEFAULT },
47 TS_DEFAULT, TS_NEAREST, .flags = FLAGS, "ts_sync_mode" },
48 { "default", "Frame from secondary input with the nearest lower or equal timestamp to the primary input frame",
49 0, AV_OPT_TYPE_CONST, { .i64 = TS_DEFAULT }, .flags = FLAGS, "ts_sync_mode" },
50 { "nearest", "Frame from secondary input with the absolute nearest timestamp to the primary input frame",
51 0, AV_OPT_TYPE_CONST, { .i64 = TS_NEAREST }, .flags = FLAGS, "ts_sync_mode" },
52 { NULL }
53 };
54 static const AVClass framesync_class = {
55 .version = LIBAVUTIL_VERSION_INT,
56 .class_name = "framesync",
57 .item_name = framesync_name,
58 .category = AV_CLASS_CATEGORY_FILTER,
59 .option = framesync_options,
60 .parent_log_context_offset = OFFSET(parent),
61 };
62
63 132 const AVClass *ff_framesync_child_class_iterate(void **iter)
64 {
65
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 66 times.
132 const AVClass *c = *iter ? NULL : &framesync_class;
66 132 *iter = (void *)(uintptr_t)c;
67 132 return c;
68 }
69
70 enum {
71 STATE_BOF,
72 STATE_RUN,
73 STATE_EOF,
74 };
75
76 static int consume_from_fifos(FFFrameSync *fs);
77
78 99 void ff_framesync_preinit(FFFrameSync *fs)
79 {
80
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 65 times.
99 if (fs->class)
81 34 return;
82 65 fs->class = &framesync_class;
83 65 av_opt_set_defaults(fs);
84 }
85
86 41 int ff_framesync_init(FFFrameSync *fs, AVFilterContext *parent, unsigned nb_in)
87 {
88 /* For filters with several outputs, we will not be able to assume which
89 output is relevant for ff_outlink_frame_wanted() and
90 ff_outlink_set_status(). To be designed when needed. */
91
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 av_assert0(parent->nb_outputs == 1);
92
93 41 ff_framesync_preinit(fs);
94 41 fs->parent = parent;
95 41 fs->nb_in = nb_in;
96
97 41 fs->in = av_calloc(nb_in, sizeof(*fs->in));
98
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if (!fs->in)
99 return AVERROR(ENOMEM);
100 41 return 0;
101 }
102
103 60 static void framesync_eof(FFFrameSync *fs)
104 {
105 60 fs->eof = 1;
106 60 fs->frame_ready = 0;
107 60 ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE);
108 60 }
109
110 111 static void framesync_sync_level_update(FFFrameSync *fs)
111 {
112 111 unsigned i, level = 0;
113
114
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 111 times.
331 for (i = 0; i < fs->nb_in; i++)
115
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 if (fs->in[i].state != STATE_EOF)
116 220 level = FFMAX(level, fs->in[i].sync);
117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 av_assert0(level <= fs->sync_level);
118
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 23 times.
111 if (level < fs->sync_level)
119 88 av_log(fs, AV_LOG_VERBOSE, "Sync level %u\n", level);
120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if (fs->opt_ts_sync_mode > TS_DEFAULT) {
121 for (i = 0; i < fs->nb_in; i++) {
122 if (fs->in[i].sync < level)
123 fs->in[i].ts_mode = fs->opt_ts_sync_mode;
124 else
125 fs->in[i].ts_mode = TS_DEFAULT;
126 }
127 }
128
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 30 times.
111 if (level)
129 81 fs->sync_level = level;
130 else
131 30 framesync_eof(fs);
132 111 }
133
134 41 int ff_framesync_configure(FFFrameSync *fs)
135 {
136 unsigned i;
137
138
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
41 if (!fs->opt_repeatlast || fs->opt_eof_action == EOF_ACTION_PASS) {
139 fs->opt_repeatlast = 0;
140 fs->opt_eof_action = EOF_ACTION_PASS;
141 }
142
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
41 if (fs->opt_shortest || fs->opt_eof_action == EOF_ACTION_ENDALL) {
143 fs->opt_shortest = 1;
144 fs->opt_eof_action = EOF_ACTION_ENDALL;
145 }
146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if (!fs->opt_repeatlast) {
147 for (i = 1; i < fs->nb_in; i++) {
148 fs->in[i].after = EXT_NULL;
149 fs->in[i].sync = 0;
150 }
151 }
152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if (fs->opt_shortest) {
153 for (i = 0; i < fs->nb_in; i++)
154 fs->in[i].after = EXT_STOP;
155 }
156
157
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if (!fs->time_base.num) {
158
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 41 times.
122 for (i = 0; i < fs->nb_in; i++) {
159
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if (fs->in[i].sync) {
160
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 41 times.
81 if (fs->time_base.num) {
161 40 fs->time_base = av_gcd_q(fs->time_base, fs->in[i].time_base,
162 40 AV_TIME_BASE / 2, AV_TIME_BASE_Q);
163 } else {
164 41 fs->time_base = fs->in[i].time_base;
165 }
166 }
167 }
168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 if (!fs->time_base.num) {
169 av_log(fs, AV_LOG_ERROR, "Impossible to set time base\n");
170 return AVERROR(EINVAL);
171 }
172 41 av_log(fs, AV_LOG_VERBOSE, "Selected %d/%d time base\n",
173 fs->time_base.num, fs->time_base.den);
174 }
175
176
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 41 times.
122 for (i = 0; i < fs->nb_in; i++)
177 81 fs->in[i].pts = fs->in[i].pts_next = AV_NOPTS_VALUE;
178 41 fs->sync_level = UINT_MAX;
179 41 framesync_sync_level_update(fs);
180
181 41 return 0;
182 }
183
184 3650 static int framesync_advance(FFFrameSync *fs)
185 {
186 unsigned i;
187 int64_t pts;
188 int ret;
189
190
4/4
✓ Branch 0 taken 3877 times.
✓ Branch 1 taken 1387 times.
✓ Branch 2 taken 3864 times.
✓ Branch 3 taken 13 times.
5264 while (!(fs->frame_ready || fs->eof)) {
191 3864 ret = consume_from_fifos(fs);
192
2/2
✓ Branch 0 taken 2221 times.
✓ Branch 1 taken 1643 times.
3864 if (ret <= 0)
193 2221 return ret;
194
195 1643 pts = INT64_MAX;
196
2/2
✓ Branch 0 taken 3235 times.
✓ Branch 1 taken 1643 times.
4878 for (i = 0; i < fs->nb_in; i++)
197
3/4
✓ Branch 0 taken 3235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1840 times.
✓ Branch 3 taken 1395 times.
3235 if (fs->in[i].have_next && fs->in[i].pts_next < pts)
198 1840 pts = fs->in[i].pts_next;
199
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 1614 times.
1643 if (pts == INT64_MAX) {
200 29 framesync_eof(fs);
201 29 break;
202 }
203
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 1614 times.
4791 for (i = 0; i < fs->nb_in; i++) {
204
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 2333 times.
3177 if (fs->in[i].pts_next == pts ||
205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 (fs->in[i].ts_mode == TS_NEAREST &&
206 fs->in[i].have_next &&
207 fs->in[i].pts_next != INT64_MAX && fs->in[i].pts != AV_NOPTS_VALUE &&
208 fs->in[i].pts_next - pts < pts - fs->in[i].pts) ||
209
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 564 times.
844 (fs->in[i].before == EXT_INFINITY &&
210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 fs->in[i].state == STATE_BOF)) {
211 2333 av_frame_free(&fs->in[i].frame);
212 2333 fs->in[i].frame = fs->in[i].frame_next;
213 2333 fs->in[i].pts = fs->in[i].pts_next;
214 2333 fs->in[i].frame_next = NULL;
215 2333 fs->in[i].pts_next = AV_NOPTS_VALUE;
216 2333 fs->in[i].have_next = 0;
217
2/2
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 1 times.
2333 fs->in[i].state = fs->in[i].frame ? STATE_RUN : STATE_EOF;
218
3/4
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 846 times.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
2333 if (fs->in[i].sync == fs->sync_level && fs->in[i].frame)
219 1487 fs->frame_ready = 1;
220
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2332 times.
2333 if (fs->in[i].state == STATE_EOF &&
221
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 fs->in[i].after == EXT_STOP)
222 1 framesync_eof(fs);
223 }
224 }
225
2/2
✓ Branch 0 taken 1387 times.
✓ Branch 1 taken 227 times.
1614 if (fs->frame_ready)
226
2/2
✓ Branch 0 taken 2724 times.
✓ Branch 1 taken 1387 times.
4111 for (i = 0; i < fs->nb_in; i++)
227
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2720 times.
2724 if ((fs->in[i].state == STATE_BOF &&
228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 fs->in[i].before == EXT_STOP))
229 fs->frame_ready = 0;
230 1614 fs->pts = pts;
231 }
232 1429 return 0;
233 }
234
235 1 static int64_t framesync_pts_extrapolate(FFFrameSync *fs, unsigned in,
236 int64_t pts)
237 {
238 /* Possible enhancement: use the link's frame rate */
239 1 return pts + 1;
240 }
241
242 2332 static void framesync_inject_frame(FFFrameSync *fs, unsigned in, AVFrame *frame)
243 {
244 int64_t pts;
245
246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2332 times.
2332 av_assert0(!fs->in[in].have_next);
247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2332 times.
2332 av_assert0(frame);
248 2332 pts = av_rescale_q(frame->pts, fs->in[in].time_base, fs->time_base);
249 2332 frame->pts = pts;
250 2332 fs->in[in].frame_next = frame;
251 2332 fs->in[in].pts_next = pts;
252 2332 fs->in[in].have_next = 1;
253 2332 }
254
255 70 static void framesync_inject_status(FFFrameSync *fs, unsigned in, int status, int64_t pts)
256 {
257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 av_assert0(!fs->in[in].have_next);
258
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 69 times.
70 pts = fs->in[in].state != STATE_RUN || fs->in[in].after == EXT_INFINITY
259
1/2
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
140 ? INT64_MAX : framesync_pts_extrapolate(fs, in, fs->in[in].pts);
260 70 fs->in[in].sync = 0;
261 70 framesync_sync_level_update(fs);
262 70 fs->in[in].frame_next = NULL;
263 70 fs->in[in].pts_next = pts;
264 70 fs->in[in].have_next = 1;
265 70 }
266
267 2724 int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe,
268 unsigned get)
269 {
270 AVFrame *frame;
271 2724 unsigned need_copy = 0, i;
272 int64_t pts_next;
273 int ret;
274
275
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2720 times.
2724 if (!fs->in[in].frame) {
276 4 *rframe = NULL;
277 4 return 0;
278 }
279 2720 frame = fs->in[in].frame;
280
2/2
✓ Branch 0 taken 1237 times.
✓ Branch 1 taken 1483 times.
2720 if (get) {
281 /* Find out if we need to copy the frame: is there another sync
282 stream, and do we know if its current frame will outlast this one? */
283
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 1152 times.
1237 pts_next = fs->in[in].have_next ? fs->in[in].pts_next : INT64_MAX;
284
3/4
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 1237 times.
✓ Branch 2 taken 2474 times.
✗ Branch 3 not taken.
3711 for (i = 0; i < fs->nb_in && !need_copy; i++)
285
4/4
✓ Branch 0 taken 1237 times.
✓ Branch 1 taken 1237 times.
✓ Branch 2 taken 937 times.
✓ Branch 3 taken 300 times.
2474 if (i != in && fs->in[i].sync &&
286
3/4
✓ Branch 0 taken 233 times.
✓ Branch 1 taken 704 times.
✓ Branch 2 taken 233 times.
✗ Branch 3 not taken.
937 (!fs->in[i].have_next || fs->in[i].pts_next < pts_next))
287 937 need_copy = 1;
288
2/2
✓ Branch 0 taken 937 times.
✓ Branch 1 taken 300 times.
1237 if (need_copy) {
289
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 937 times.
937 if (!(frame = av_frame_clone(frame)))
290 return AVERROR(ENOMEM);
291
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 937 times.
937 if ((ret = av_frame_make_writable(frame)) < 0) {
292 av_frame_free(&frame);
293 return ret;
294 }
295 } else {
296 300 fs->in[in].frame = NULL;
297 }
298 1237 fs->frame_ready = 0;
299 }
300 2720 *rframe = frame;
301 2720 return 0;
302 }
303
304 73 void ff_framesync_uninit(FFFrameSync *fs)
305 {
306 unsigned i;
307
308
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 73 times.
154 for (i = 0; i < fs->nb_in; i++) {
309 81 av_frame_free(&fs->in[i].frame);
310 81 av_frame_free(&fs->in[i].frame_next);
311 }
312
313 73 av_freep(&fs->in);
314 73 }
315
316 3864 static int consume_from_fifos(FFFrameSync *fs)
317 {
318 3864 AVFilterContext *ctx = fs->parent;
319 3864 AVFrame *frame = NULL;
320 int64_t pts;
321 unsigned i, nb_active, nb_miss;
322 int ret, status;
323
324 3864 nb_active = nb_miss = 0;
325
2/2
✓ Branch 0 taken 7627 times.
✓ Branch 1 taken 3864 times.
11491 for (i = 0; i < fs->nb_in; i++) {
326
3/4
✓ Branch 0 taken 5434 times.
✓ Branch 1 taken 2193 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5434 times.
7627 if (fs->in[i].have_next || fs->in[i].state == STATE_EOF)
327 2193 continue;
328 5434 nb_active++;
329 5434 ret = ff_inlink_consume_frame(ctx->inputs[i], &frame);
330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5434 times.
5434 if (ret < 0)
331 return ret;
332
2/2
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 3102 times.
5434 if (ret) {
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2332 times.
2332 av_assert0(frame);
334 2332 framesync_inject_frame(fs, i, frame);
335 } else {
336 3102 ret = ff_inlink_acknowledge_status(ctx->inputs[i], &status, &pts);
337
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 3032 times.
3102 if (ret > 0) {
338 70 framesync_inject_status(fs, i, status, pts);
339
1/2
✓ Branch 0 taken 3032 times.
✗ Branch 1 not taken.
3032 } else if (!ret) {
340 3032 nb_miss++;
341 }
342 }
343 }
344
2/2
✓ Branch 0 taken 2221 times.
✓ Branch 1 taken 1643 times.
3864 if (nb_miss) {
345
4/4
✓ Branch 0 taken 1630 times.
✓ Branch 1 taken 591 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1628 times.
2221 if (nb_miss == nb_active && !ff_outlink_frame_wanted(ctx->outputs[0]))
346 2 return FFERROR_NOT_READY;
347
2/2
✓ Branch 0 taken 4388 times.
✓ Branch 1 taken 2219 times.
6607 for (i = 0; i < fs->nb_in; i++)
348
3/4
✓ Branch 0 taken 3030 times.
✓ Branch 1 taken 1358 times.
✓ Branch 2 taken 3030 times.
✗ Branch 3 not taken.
4388 if (!fs->in[i].have_next && fs->in[i].state != STATE_EOF)
349 3030 ff_inlink_request_frame(ctx->inputs[i]);
350 2219 return 0;
351 }
352 1643 return 1;
353 }
354
355 3650 int ff_framesync_activate(FFFrameSync *fs)
356 {
357 int ret;
358
359 3650 ret = framesync_advance(fs);
360
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3648 times.
3650 if (ret < 0)
361 2 return ret;
362
4/4
✓ Branch 0 taken 3606 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 2219 times.
✓ Branch 3 taken 1387 times.
3648 if (fs->eof || !fs->frame_ready)
363 2261 return 0;
364 1387 ret = fs->on_event(fs);
365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1387 times.
1387 if (ret < 0)
366 return ret;
367 1387 fs->frame_ready = 0;
368
369 1387 return 0;
370 }
371
372 38 int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
373 {
374 int ret;
375
376 38 ret = ff_framesync_init(fs, parent, 2);
377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if (ret < 0)
378 return ret;
379 38 fs->in[0].time_base = parent->inputs[0]->time_base;
380 38 fs->in[1].time_base = parent->inputs[1]->time_base;
381 38 fs->in[0].sync = 2;
382 38 fs->in[0].before = EXT_STOP;
383 38 fs->in[0].after = EXT_INFINITY;
384 38 fs->in[1].sync = 1;
385 38 fs->in[1].before = EXT_NULL;
386 38 fs->in[1].after = EXT_INFINITY;
387 38 return 0;
388 }
389
390 1237 int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
391 {
392 1237 AVFilterContext *ctx = fs->parent;
393 1237 AVFrame *mainpic = NULL, *secondpic = NULL;
394 int ret;
395
396
2/4
✓ Branch 1 taken 1237 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1237 times.
2474 if ((ret = ff_framesync_get_frame(fs, 0, &mainpic, 1)) < 0 ||
397 1237 (ret = ff_framesync_get_frame(fs, 1, &secondpic, 0)) < 0) {
398 av_frame_free(&mainpic);
399 return ret;
400 }
401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1237 times.
1237 av_assert0(mainpic);
402 1237 mainpic->pts = av_rescale_q(fs->pts, fs->time_base, ctx->outputs[0]->time_base);
403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1237 times.
1237 if (ctx->is_disabled)
404 secondpic = NULL;
405 1237 *f0 = mainpic;
406 1237 *f1 = secondpic;
407 1237 return 0;
408 }
409
410 1213 int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
411 {
412 int ret;
413
414 1213 ret = ff_framesync_dualinput_get(fs, f0, f1);
415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 if (ret < 0)
416 return ret;
417 1213 ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0);
418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 if (ret < 0) {
419 av_frame_free(f0);
420 *f1 = NULL;
421 return ret;
422 }
423 1213 return 0;
424 }
425