FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/framesync.c
Date: 2024-04-25 15:36:26
Exec Total Coverage
Lines: 198 237 83.5%
Functions: 16 18 88.9%
Branches: 133 192 69.3%

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/mem.h"
23 #include "libavutil/opt.h"
24 #include "avfilter.h"
25 #include "filters.h"
26 #include "framesync.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, .unit = "eof_action" },
40 { "repeat", "Repeat the previous frame.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_REPEAT }, .flags = FLAGS, .unit = "eof_action" },
41 { "endall", "End both streams.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_ENDALL }, .flags = FLAGS, .unit = "eof_action" },
42 { "pass", "Pass through the main input.", 0, AV_OPT_TYPE_CONST, { .i64 = EOF_ACTION_PASS }, .flags = FLAGS, .unit = "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, .unit = "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, .unit = "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, .unit = "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 const AVClass *ff_framesync_child_class_iterate(void **iter)
64 {
65 const AVClass *c = *iter ? NULL : &framesync_class;
66 *iter = (void *)(uintptr_t)c;
67 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 113 void ff_framesync_preinit(FFFrameSync *fs)
79 {
80
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 78 times.
113 if (fs->class)
81 35 return;
82 78 fs->class = &framesync_class;
83 78 av_opt_set_defaults(fs);
84 }
85
86 43 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 43 times.
43 av_assert0(parent->nb_outputs == 1);
92
93 43 ff_framesync_preinit(fs);
94 43 fs->parent = parent;
95 43 fs->nb_in = nb_in;
96
97 43 fs->in = av_calloc(nb_in, sizeof(*fs->in));
98
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if (!fs->in)
99 return AVERROR(ENOMEM);
100 43 return 0;
101 }
102
103 58 static void framesync_eof(FFFrameSync *fs)
104 {
105 58 fs->eof = 1;
106 58 fs->frame_ready = 0;
107 58 ff_outlink_set_status(fs->parent->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE);
108 58 }
109
110 101 static void framesync_sync_level_update(FFFrameSync *fs)
111 {
112 101 unsigned i, level = 0;
113
114
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 101 times.
301 for (i = 0; i < fs->nb_in; i++)
115
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if (fs->in[i].state != STATE_EOF)
116 200 level = FFMAX(level, fs->in[i].sync);
117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 av_assert0(level <= fs->sync_level);
118
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 14 times.
101 if (level < fs->sync_level)
119 87 av_log(fs, AV_LOG_VERBOSE, "Sync level %u\n", level);
120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 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 72 times.
✓ Branch 1 taken 29 times.
101 if (level)
129 72 fs->sync_level = level;
130 else
131 29 framesync_eof(fs);
132 101 }
133
134 43 int ff_framesync_configure(FFFrameSync *fs)
135 {
136 unsigned i;
137
138
2/4
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
43 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 43 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
43 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 43 times.
43 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 43 times.
43 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 43 times.
✗ Branch 1 not taken.
43 if (!fs->time_base.num) {
158
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 43 times.
128 for (i = 0; i < fs->nb_in; i++) {
159
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if (fs->in[i].sync) {
160
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 43 times.
85 if (fs->time_base.num) {
161 42 fs->time_base = av_gcd_q(fs->time_base, fs->in[i].time_base,
162 42 AV_TIME_BASE / 2, AV_TIME_BASE_Q);
163 } else {
164 43 fs->time_base = fs->in[i].time_base;
165 }
166 }
167 }
168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if (!fs->time_base.num) {
169 av_log(fs, AV_LOG_ERROR, "Impossible to set time base\n");
170 return AVERROR(EINVAL);
171 }
172 43 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 85 times.
✓ Branch 1 taken 43 times.
128 for (i = 0; i < fs->nb_in; i++)
177 85 fs->in[i].pts = fs->in[i].pts_next = AV_NOPTS_VALUE;
178 43 fs->sync_level = UINT_MAX;
179 43 framesync_sync_level_update(fs);
180
181 43 return 0;
182 }
183
184 3651 static int framesync_advance(FFFrameSync *fs)
185 {
186 unsigned i;
187 int64_t pts;
188 int ret;
189
190
4/4
✓ Branch 0 taken 3740 times.
✓ Branch 1 taken 1432 times.
✓ Branch 2 taken 3739 times.
✓ Branch 3 taken 1 times.
5172 while (!(fs->frame_ready || fs->eof)) {
191 3739 ret = consume_from_fifos(fs);
192
2/2
✓ Branch 0 taken 2190 times.
✓ Branch 1 taken 1549 times.
3739 if (ret <= 0)
193 2190 return ret;
194
195 1549 pts = INT64_MAX;
196
2/2
✓ Branch 0 taken 3047 times.
✓ Branch 1 taken 1549 times.
4596 for (i = 0; i < fs->nb_in; i++)
197
3/4
✓ Branch 0 taken 3047 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1609 times.
✓ Branch 3 taken 1438 times.
3047 if (fs->in[i].have_next && fs->in[i].pts_next < pts)
198 1609 pts = fs->in[i].pts_next;
199
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 1521 times.
1549 if (pts == INT64_MAX) {
200 28 framesync_eof(fs);
201 28 break;
202 }
203
2/2
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1521 times.
4512 for (i = 0; i < fs->nb_in; i++) {
204
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 2270 times.
2991 if (fs->in[i].pts_next == pts ||
205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 721 times.
721 (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 441 times.
721 (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 2270 av_frame_free(&fs->in[i].frame);
212 2270 fs->in[i].frame = fs->in[i].frame_next;
213 2270 fs->in[i].pts = fs->in[i].pts_next;
214 2270 fs->in[i].frame_next = NULL;
215 2270 fs->in[i].pts_next = AV_NOPTS_VALUE;
216 2270 fs->in[i].have_next = 0;
217
2/2
✓ Branch 0 taken 2269 times.
✓ Branch 1 taken 1 times.
2270 fs->in[i].state = fs->in[i].frame ? STATE_RUN : STATE_EOF;
218
3/4
✓ Branch 0 taken 1582 times.
✓ Branch 1 taken 688 times.
✓ Branch 2 taken 1582 times.
✗ Branch 3 not taken.
2270 if (fs->in[i].sync == fs->sync_level && fs->in[i].frame)
219 1582 fs->frame_ready = 1;
220
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2269 times.
2270 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 1432 times.
✓ Branch 1 taken 89 times.
1521 if (fs->frame_ready)
226
2/2
✓ Branch 0 taken 2814 times.
✓ Branch 1 taken 1432 times.
4246 for (i = 0; i < fs->nb_in; i++)
227
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2811 times.
2814 if ((fs->in[i].state == STATE_BOF &&
228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 fs->in[i].before == EXT_STOP))
229 fs->frame_ready = 0;
230 1521 fs->pts = pts;
231 }
232 1461 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 2269 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 2269 times.
2269 av_assert0(!fs->in[in].have_next);
247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2269 times.
2269 av_assert0(frame);
248 2269 pts = av_rescale_q(frame->pts, fs->in[in].time_base, fs->time_base);
249 2269 frame->pts = pts;
250 2269 fs->in[in].frame_next = frame;
251 2269 fs->in[in].pts_next = pts;
252 2269 fs->in[in].have_next = 1;
253 2269 }
254
255 58 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 58 times.
58 av_assert0(!fs->in[in].have_next);
258
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 57 times.
58 pts = fs->in[in].state != STATE_RUN || fs->in[in].after == EXT_INFINITY
259
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
116 ? INT64_MAX : framesync_pts_extrapolate(fs, in, fs->in[in].pts);
260 58 fs->in[in].sync = 0;
261 58 framesync_sync_level_update(fs);
262 58 fs->in[in].frame_next = NULL;
263 58 fs->in[in].pts_next = pts;
264 58 fs->in[in].have_next = 1;
265 58 }
266
267 2814 int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe,
268 unsigned get)
269 {
270 AVFrame *frame;
271 2814 unsigned need_copy = 0, i;
272 int64_t pts_next;
273 int ret;
274
275
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2811 times.
2814 if (!fs->in[in].frame) {
276 3 *rframe = NULL;
277 3 return 0;
278 }
279 2811 frame = fs->in[in].frame;
280
2/2
✓ Branch 0 taken 1232 times.
✓ Branch 1 taken 1579 times.
2811 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 88 times.
✓ Branch 1 taken 1144 times.
1232 pts_next = fs->in[in].have_next ? fs->in[in].pts_next : INT64_MAX;
284
3/4
✓ Branch 0 taken 2464 times.
✓ Branch 1 taken 1232 times.
✓ Branch 2 taken 2464 times.
✗ Branch 3 not taken.
3696 for (i = 0; i < fs->nb_in && !need_copy; i++)
285
4/4
✓ Branch 0 taken 1232 times.
✓ Branch 1 taken 1232 times.
✓ Branch 2 taken 943 times.
✓ Branch 3 taken 289 times.
2464 if (i != in && fs->in[i].sync &&
286
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
943 (!fs->in[i].have_next || fs->in[i].pts_next < pts_next))
287 943 need_copy = 1;
288
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 289 times.
1232 if (need_copy) {
289
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 943 times.
943 if (!(frame = av_frame_clone(frame)))
290 return AVERROR(ENOMEM);
291
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 943 times.
943 if ((ret = ff_inlink_make_frame_writable(fs->parent->inputs[in], &frame)) < 0) {
292 av_frame_free(&frame);
293 return ret;
294 }
295 } else {
296 289 fs->in[in].frame = NULL;
297 }
298 1232 fs->frame_ready = 0;
299 }
300 2811 *rframe = frame;
301 2811 return 0;
302 }
303
304 88 void ff_framesync_uninit(FFFrameSync *fs)
305 {
306 unsigned i;
307
308
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 88 times.
173 for (i = 0; i < fs->nb_in; i++) {
309 85 av_frame_free(&fs->in[i].frame);
310 85 av_frame_free(&fs->in[i].frame_next);
311 }
312
313 88 av_freep(&fs->in);
314 88 }
315
316 3739 static int consume_from_fifos(FFFrameSync *fs)
317 {
318 3739 AVFilterContext *ctx = fs->parent;
319 3739 AVFrame *frame = NULL;
320 int64_t pts;
321 unsigned i, nb_active, nb_miss;
322 int ret, status;
323
324 3739 nb_active = nb_miss = 0;
325
2/2
✓ Branch 0 taken 7377 times.
✓ Branch 1 taken 3739 times.
11116 for (i = 0; i < fs->nb_in; i++) {
326
3/4
✓ Branch 0 taken 5160 times.
✓ Branch 1 taken 2217 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5160 times.
7377 if (fs->in[i].have_next || fs->in[i].state == STATE_EOF)
327 2217 continue;
328 5160 nb_active++;
329 5160 ret = ff_inlink_consume_frame(ctx->inputs[i], &frame);
330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5160 times.
5160 if (ret < 0)
331 return ret;
332
2/2
✓ Branch 0 taken 2269 times.
✓ Branch 1 taken 2891 times.
5160 if (ret) {
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2269 times.
2269 av_assert0(frame);
334 2269 framesync_inject_frame(fs, i, frame);
335 } else {
336 2891 ret = ff_inlink_acknowledge_status(ctx->inputs[i], &status, &pts);
337
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 2833 times.
2891 if (ret > 0) {
338 58 framesync_inject_status(fs, i, status, pts);
339
1/2
✓ Branch 0 taken 2833 times.
✗ Branch 1 not taken.
2833 } else if (!ret) {
340 2833 nb_miss++;
341 }
342 }
343 }
344
2/2
✓ Branch 0 taken 2190 times.
✓ Branch 1 taken 1549 times.
3739 if (nb_miss) {
345
4/4
✓ Branch 0 taken 1580 times.
✓ Branch 1 taken 610 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 1572 times.
2190 if (nb_miss == nb_active && !ff_outlink_frame_wanted(ctx->outputs[0]))
346 8 return FFERROR_NOT_READY;
347
2/2
✓ Branch 0 taken 4314 times.
✓ Branch 1 taken 2182 times.
6496 for (i = 0; i < fs->nb_in; i++)
348
3/4
✓ Branch 0 taken 2825 times.
✓ Branch 1 taken 1489 times.
✓ Branch 2 taken 2825 times.
✗ Branch 3 not taken.
4314 if (!fs->in[i].have_next && fs->in[i].state != STATE_EOF)
349 2825 ff_inlink_request_frame(ctx->inputs[i]);
350 2182 return 0;
351 }
352 1549 return 1;
353 }
354
355 3662 int ff_framesync_activate(FFFrameSync *fs)
356 {
357 3662 AVFilterContext *ctx = fs->parent;
358 int ret;
359
360
4/4
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 3651 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 11 times.
3684 FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[0], ctx);
361
362 3651 ret = framesync_advance(fs);
363
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3643 times.
3651 if (ret < 0)
364 8 return ret;
365
4/4
✓ Branch 0 taken 3614 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 2182 times.
✓ Branch 3 taken 1432 times.
3643 if (fs->eof || !fs->frame_ready)
366 2211 return 0;
367 1432 ret = fs->on_event(fs);
368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1432 times.
1432 if (ret < 0)
369 return ret;
370 1432 fs->frame_ready = 0;
371
372 1432 return 0;
373 }
374
375 39 int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
376 {
377 int ret;
378
379 39 ret = ff_framesync_init(fs, parent, 2);
380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if (ret < 0)
381 return ret;
382 39 fs->in[0].time_base = parent->inputs[0]->time_base;
383 39 fs->in[1].time_base = parent->inputs[1]->time_base;
384 39 fs->in[0].sync = 2;
385 39 fs->in[0].before = EXT_STOP;
386 39 fs->in[0].after = EXT_INFINITY;
387 39 fs->in[1].sync = 1;
388 39 fs->in[1].before = EXT_NULL;
389 39 fs->in[1].after = EXT_INFINITY;
390 39 return 0;
391 }
392
393 1232 int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
394 {
395 1232 AVFilterContext *ctx = fs->parent;
396 1232 AVFrame *mainpic = NULL, *secondpic = NULL;
397 int ret;
398
399
2/4
✓ Branch 1 taken 1232 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1232 times.
2464 if ((ret = ff_framesync_get_frame(fs, 0, &mainpic, 1)) < 0 ||
400 1232 (ret = ff_framesync_get_frame(fs, 1, &secondpic, 0)) < 0) {
401 av_frame_free(&mainpic);
402 return ret;
403 }
404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1232 times.
1232 av_assert0(mainpic);
405 1232 mainpic->pts = av_rescale_q(fs->pts, fs->time_base, ctx->outputs[0]->time_base);
406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1232 times.
1232 if (ctx->is_disabled)
407 secondpic = NULL;
408 1232 *f0 = mainpic;
409 1232 *f1 = secondpic;
410 1232 return 0;
411 }
412
413 1208 int ff_framesync_dualinput_get_writable(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
414 {
415 int ret;
416
417 1208 ret = ff_framesync_dualinput_get(fs, f0, f1);
418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1208 times.
1208 if (ret < 0)
419 return ret;
420 1208 ret = ff_inlink_make_frame_writable(fs->parent->inputs[0], f0);
421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1208 times.
1208 if (ret < 0) {
422 av_frame_free(f0);
423 *f1 = NULL;
424 return ret;
425 }
426 1208 return 0;
427 }
428