FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/buffersrc.c
Date: 2026-10-28 19:13:44
Exec Total Coverage
Lines: 219 292 75.0%
Functions: 15 16 93.8%
Branches: 169 260 65.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2008 Vitor Sessak
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 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 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 * memory buffer source filter
24 */
25
26 #include <float.h>
27
28 #include "libavutil/channel_layout.h"
29 #include "libavutil/frame.h"
30 #include "libavutil/hwcontext.h"
31 #include "libavutil/internal.h"
32 #include "libavutil/mem.h"
33 #include "libavutil/opt.h"
34 #include "libavutil/pixdesc.h"
35 #include "libavutil/samplefmt.h"
36 #include "libavutil/timestamp.h"
37 #include "avfilter.h"
38 #include "avfilter_internal.h"
39 #include "buffersrc.h"
40 #include "filters.h"
41 #include "formats.h"
42 #include "video.h"
43
44 typedef struct BufferSourceContext {
45 const AVClass *class;
46 AVRational time_base; ///< time_base to set in the output link
47 AVRational frame_rate; ///< frame_rate to set in the output link
48 unsigned nb_failed_requests;
49 unsigned warning_limit;
50
51 /* video only */
52 int w, h, prev_w, prev_h;
53 enum AVPixelFormat pix_fmt, prev_pix_fmt;
54 enum AVColorSpace color_space, prev_color_space;
55 enum AVColorRange color_range, prev_color_range;
56 enum AVAlphaMode alpha_mode, prev_alpha_mode;
57 enum AVChromaLocation chroma_location, prev_chroma_location;
58 AVRational pixel_aspect;
59
60 AVBufferRef *hw_frames_ctx;
61
62 /* audio only */
63 int sample_rate;
64 enum AVSampleFormat sample_fmt;
65 int channels;
66 AVChannelLayout ch_layout;
67 AVFrameSideData **side_data;
68 int nb_side_data;
69
70 int eof;
71 int64_t last_pts;
72 int link_delta, prev_delta;
73
74 int chroma_loc_warned;
75 } BufferSourceContext;
76
77 #define CHECK_VIDEO_PARAM_CHANGE(s, c, width, height, format, csp, range, alpha, chromaloc, pts)\
78 c->link_delta = c->w != width || c->h != height || c->pix_fmt != format ||\
79 c->color_space != csp || c->color_range != range || c->alpha_mode != alpha ||\
80 c->chroma_location != chromaloc;\
81 c->prev_delta = c->prev_w != width || c->prev_h != height || c->prev_pix_fmt != format ||\
82 c->prev_color_space != csp || c->prev_color_range != range || c->prev_alpha_mode != alpha ||\
83 c->prev_chroma_location != chromaloc;\
84 if (c->link_delta) {\
85 int loglevel = c->prev_delta ? AV_LOG_WARNING : AV_LOG_DEBUG;\
86 av_log(s, loglevel, "Changing video frame properties on the fly is not supported by all filters.\n");\
87 av_log(s, loglevel, "filter context - w: %d h: %d fmt: %d csp: %s range: %s alpha: %s chroma_loc: %s, incoming frame - w: %d h: %d fmt: %d csp: %s range: %s alpha: %s chroma_loc: %s pts_time: %s\n",\
88 c->w, c->h, c->pix_fmt, av_color_space_name(c->color_space), av_color_range_name(c->color_range), av_alpha_mode_name(c->alpha_mode),\
89 av_chroma_location_name(c->chroma_location),\
90 width, height, format, av_color_space_name(csp), av_color_range_name(range), av_alpha_mode_name(alpha),\
91 av_chroma_location_name(chromaloc),\
92 av_ts2timestr(pts, &s->outputs[0]->time_base));\
93 }\
94 if (c->prev_delta) {\
95 if (!c->link_delta)\
96 av_log(s, AV_LOG_VERBOSE, "video frame properties congruent with link at pts_time: %s\n", av_ts2timestr(pts, &s->outputs[0]->time_base));\
97 c->prev_w = width;\
98 c->prev_h = height;\
99 c->prev_pix_fmt = format;\
100 c->prev_color_space = csp;\
101 c->prev_color_range = range;\
102 c->prev_alpha_mode = alpha;\
103 c->prev_chroma_location = chromaloc;\
104 }
105
106 #define CHECK_AUDIO_PARAM_CHANGE(s, c, srate, layout, format, pts)\
107 if (c->sample_fmt != format || c->sample_rate != srate ||\
108 av_channel_layout_compare(&c->ch_layout, &layout) || c->channels != layout.nb_channels) {\
109 av_log(s, AV_LOG_INFO, "filter context - fmt: %s r: %d layout: %"PRIX64" ch: %d, incoming frame - fmt: %s r: %d layout: %"PRIX64" ch: %d pts_time: %s\n",\
110 av_get_sample_fmt_name(c->sample_fmt), c->sample_rate, c->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? c->ch_layout.u.mask : 0, c->channels,\
111 av_get_sample_fmt_name(format), srate, layout.order == AV_CHANNEL_ORDER_NATIVE ? layout.u.mask : 0, layout.nb_channels, av_ts2timestr(pts, &s->outputs[0]->time_base));\
112 av_log(s, AV_LOG_ERROR, "Changing audio frame properties on the fly is not supported.\n");\
113 return AVERROR(EINVAL);\
114 }
115
116 7291 AVBufferSrcParameters *av_buffersrc_parameters_alloc(void)
117 {
118 7291 AVBufferSrcParameters *par = av_mallocz(sizeof(*par));
119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7291 times.
7291 if (!par)
120 ✗ return NULL;
121
122 7291 par->format = -1;
123 7291 par->color_range = AVCOL_RANGE_UNSPECIFIED;
124 7291 par->color_space = AVCOL_SPC_UNSPECIFIED;
125 7291 par->alpha_mode = AVALPHA_MODE_UNSPECIFIED;
126 7291 par->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
127
128 7291 return par;
129 }
130
131 7291 int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *param)
132 {
133 7291 BufferSourceContext *s = ctx->priv;
134
135
3/4
✓ Branch 0 taken 5836 times.
✓ Branch 1 taken 1455 times.
✓ Branch 2 taken 5836 times.
✗ Branch 3 not taken.
7291 if (param->time_base.num > 0 && param->time_base.den > 0)
136 5836 s->time_base = param->time_base;
137
138
2/3
✓ Branch 0 taken 5836 times.
✓ Branch 1 taken 1455 times.
✗ Branch 2 not taken.
7291 switch (ctx->filter->outputs[0].type) {
139 5836 case AVMEDIA_TYPE_VIDEO:
140
1/2
✓ Branch 0 taken 5836 times.
✗ Branch 1 not taken.
5836 if (param->format != AV_PIX_FMT_NONE) {
141 5836 s->pix_fmt = s->prev_pix_fmt = param->format;
142 }
143
1/2
✓ Branch 0 taken 5836 times.
✗ Branch 1 not taken.
5836 if (param->width > 0)
144 5836 s->w = s->prev_w = param->width;
145
1/2
✓ Branch 0 taken 5836 times.
✗ Branch 1 not taken.
5836 if (param->height > 0)
146 5836 s->h = s->prev_h = param->height;
147
3/4
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 5102 times.
✓ Branch 2 taken 734 times.
✗ Branch 3 not taken.
5836 if (param->sample_aspect_ratio.num > 0 && param->sample_aspect_ratio.den > 0)
148 734 s->pixel_aspect = param->sample_aspect_ratio;
149
3/4
✓ Branch 0 taken 5831 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5831 times.
✗ Branch 3 not taken.
5836 if (param->frame_rate.num > 0 && param->frame_rate.den > 0)
150 5831 s->frame_rate = param->frame_rate;
151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5836 times.
5836 if (param->hw_frames_ctx) {
152 ✗ av_buffer_unref(&s->hw_frames_ctx);
153 ✗ s->hw_frames_ctx = av_buffer_ref(param->hw_frames_ctx);
154 ✗ if (!s->hw_frames_ctx)
155 ✗ return AVERROR(ENOMEM);
156 }
157
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 5426 times.
5836 if (param->color_space != AVCOL_SPC_UNSPECIFIED)
158 410 s->color_space = s->prev_color_space = param->color_space;
159
2/2
✓ Branch 0 taken 4478 times.
✓ Branch 1 taken 1358 times.
5836 if (param->color_range != AVCOL_RANGE_UNSPECIFIED)
160 4478 s->color_range = s->prev_color_range = param->color_range;
161
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 5758 times.
5836 if (param->alpha_mode != AVALPHA_MODE_UNSPECIFIED)
162 78 s->alpha_mode = s->prev_alpha_mode = param->alpha_mode;
163
2/2
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 4706 times.
5836 if (param->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
164 1130 s->chroma_location = s->prev_chroma_location = param->chroma_location;
165 5836 break;
166 1455 case AVMEDIA_TYPE_AUDIO:
167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1455 times.
1455 if (param->format != AV_SAMPLE_FMT_NONE) {
168 ✗ s->sample_fmt = param->format;
169 }
170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1455 times.
1455 if (param->sample_rate > 0)
171 ✗ s->sample_rate = param->sample_rate;
172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1455 times.
1455 if (param->ch_layout.nb_channels) {
173 ✗ int ret = av_channel_layout_copy(&s->ch_layout, &param->ch_layout);
174 ✗ if (ret < 0)
175 ✗ return ret;
176 }
177 1455 break;
178 ✗ default:
179 ✗ return AVERROR_BUG;
180 }
181
182
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 7019 times.
7291 if (param->nb_side_data > 0)
183 272 av_frame_side_data_free(&s->side_data, &s->nb_side_data);
184
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 7291 times.
7584 for (int i = 0; i < param->nb_side_data; i++) {
185 293 int ret = av_frame_side_data_clone(&s->side_data, &s->nb_side_data,
186 293 param->side_data[i], 0);
187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
293 if (ret < 0) {
188 ✗ av_frame_side_data_free(&s->side_data, &s->nb_side_data);
189 ✗ return ret;
190 }
191 }
192
193 7291 return 0;
194 }
195
196 ✗ int attribute_align_arg av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame)
197 {
198 ✗ return av_buffersrc_add_frame_flags(ctx, (AVFrame *)frame,
199 AV_BUFFERSRC_FLAG_KEEP_REF);
200 }
201
202 163 int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
203 {
204 163 return av_buffersrc_add_frame_flags(ctx, frame, 0);
205 }
206
207 431998 static int push_frame(AVFilterGraph *graph)
208 {
209 int ret;
210
211 while (1) {
212 2710212 ret = ff_filter_graph_run_once(graph);
213
2/2
✓ Branch 0 taken 431998 times.
✓ Branch 1 taken 2278214 times.
2710212 if (ret == AVERROR(EAGAIN))
214 431998 break;
215
3/4
✓ Branch 0 taken 3269 times.
✓ Branch 1 taken 2274945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3269 times.
2278214 if (ret < 0 && ret != FFERROR_BUFFERSRC_EMPTY)
216 ✗ return ret;
217 }
218 431998 return 0;
219 }
220
221 428662 int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
222 {
223 428662 BufferSourceContext *s = ctx->priv;
224 AVFrame *copy;
225 int refcounted, ret;
226
227 428662 s->nb_failed_requests = 0;
228
229
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 428641 times.
428662 if (!frame)
230 21 return av_buffersrc_close(ctx, s->last_pts, flags);
231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 428641 times.
428641 if (s->eof)
232 ✗ return AVERROR_EOF;
233
234 428641 s->last_pts = frame->pts + frame->duration;
235
236 428641 refcounted = !!frame->buf[0];
237
238
1/2
✓ Branch 0 taken 428641 times.
✗ Branch 1 not taken.
428641 if (!(flags & AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)) {
239
240
2/3
✓ Branch 0 taken 119085 times.
✓ Branch 1 taken 309556 times.
✗ Branch 2 not taken.
428641 switch (ctx->outputs[0]->type) {
241 119085 case AVMEDIA_TYPE_VIDEO:
242
26/36
✓ Branch 0 taken 119085 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119085 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119006 times.
✓ Branch 5 taken 79 times.
✓ Branch 6 taken 118989 times.
✓ Branch 7 taken 17 times.
✓ Branch 8 taken 118989 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 118989 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 118989 times.
✓ Branch 14 taken 119085 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 119085 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 119045 times.
✓ Branch 19 taken 40 times.
✓ Branch 20 taken 113619 times.
✓ Branch 21 taken 5426 times.
✓ Branch 22 taken 113619 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 113619 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 113619 times.
✓ Branch 28 taken 96 times.
✓ Branch 29 taken 118989 times.
✓ Branch 30 taken 21 times.
✓ Branch 31 taken 75 times.
✓ Branch 43 taken 5466 times.
✓ Branch 44 taken 113619 times.
✓ Branch 45 taken 5445 times.
✓ Branch 46 taken 21 times.
124626 CHECK_VIDEO_PARAM_CHANGE(ctx, s, frame->width, frame->height,
243 frame->format, frame->colorspace,
244 frame->color_range, frame->alpha_mode,
245 frame->chroma_location, frame->pts);
246 119085 break;
247 309556 case AVMEDIA_TYPE_AUDIO:
248 /* For layouts unknown on input but known on link after negotiation. */
249
3/4
✓ Branch 0 taken 35192 times.
✓ Branch 1 taken 274364 times.
✓ Branch 2 taken 35192 times.
✗ Branch 3 not taken.
309556 if (frame->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC && frame->ch_layout.nb_channels == s->ch_layout.nb_channels) {
250 35192 ret = av_channel_layout_copy(&frame->ch_layout, &s->ch_layout);
251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35192 times.
35192 if (ret < 0)
252 ✗ return ret;
253 }
254
4/12
✓ Branch 0 taken 309556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 309556 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 309556 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 309556 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
309556 CHECK_AUDIO_PARAM_CHANGE(ctx, s, frame->sample_rate, frame->ch_layout,
255 frame->format, frame->pts);
256 309556 break;
257 ✗ default:
258 ✗ return AVERROR(EINVAL);
259 }
260
261 }
262
263
3/4
✓ Branch 0 taken 428641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 428370 times.
✓ Branch 3 taken 271 times.
428641 if (refcounted && !(flags & AV_BUFFERSRC_FLAG_KEEP_REF)) {
264
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 428370 times.
428370 if (!(copy = av_frame_alloc()))
265 ✗ return AVERROR(ENOMEM);
266 428370 av_frame_move_ref(copy, frame);
267 } else {
268 271 copy = av_frame_clone(frame);
269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 271 times.
271 if (!copy)
270 ✗ return AVERROR(ENOMEM);
271 }
272
273
2/2
✓ Branch 0 taken 110763 times.
✓ Branch 1 taken 317878 times.
428641 if (copy->colorspace == AVCOL_SPC_UNSPECIFIED)
274 110763 copy->colorspace = ctx->outputs[0]->colorspace;
275
2/2
✓ Branch 0 taken 366457 times.
✓ Branch 1 taken 62184 times.
428641 if (copy->color_range == AVCOL_RANGE_UNSPECIFIED)
276 366457 copy->color_range = ctx->outputs[0]->color_range;
277
2/2
✓ Branch 0 taken 428486 times.
✓ Branch 1 taken 155 times.
428641 if (copy->alpha_mode == AVALPHA_MODE_UNSPECIFIED)
278 428486 copy->alpha_mode = ctx->outputs[0]->alpha_mode;
279
2/2
✓ Branch 0 taken 379417 times.
✓ Branch 1 taken 49224 times.
428641 if (copy->chroma_location == AVCHROMA_LOC_UNSPECIFIED) {
280 379417 copy->chroma_location = ctx->outputs[0]->chroma_location;
281 /* The input never said where its chroma sits, so it is assumed to be
282 * compatible with whatever the rest of the graph settled on. */
283
2/2
✓ Branch 0 taken 5992 times.
✓ Branch 1 taken 373425 times.
379417 if (copy->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
284 5992 av_log_once(ctx, AV_LOG_WARNING, AV_LOG_VERBOSE, &s->chroma_loc_warned,
285 "Input has no chroma sample location, assuming %s\n",
286 av_chroma_location_name(copy->chroma_location));
287 }
288
289 428641 ret = ff_filter_frame(ctx->outputs[0], copy);
290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 428641 times.
428641 if (ret < 0)
291 ✗ return ret;
292
293
2/2
✓ Branch 0 taken 428499 times.
✓ Branch 1 taken 142 times.
428641 if ((flags & AV_BUFFERSRC_FLAG_PUSH)) {
294 428499 ret = push_frame(ctx->graph);
295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 428499 times.
428499 if (ret < 0)
296 ✗ return ret;
297 }
298
299 428641 FilterLinkInternal *const li = ff_link_internal(ctx->outputs[0]);
300
1/2
✓ Branch 0 taken 428641 times.
✗ Branch 1 not taken.
428641 if (s->warning_limit &&
301
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 428641 times.
428641 ff_framequeue_queued_frames(&li->fifo) >= s->warning_limit) {
302 ✗ av_log(s, AV_LOG_WARNING,
303 "%d buffers queued in %s, something may be wrong.\n",
304 s->warning_limit,
305 ✗ (char *)av_x_if_null(ctx->name, ctx->filter->name));
306 ✗ s->warning_limit *= 10;
307 }
308
309 428641 return 0;
310 }
311
312 3520 int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags)
313 {
314 3520 BufferSourceContext *s = ctx->priv;
315
316 3520 s->eof = 1;
317 3520 ff_avfilter_link_set_in_status(ctx->outputs[0], AVERROR_EOF, pts);
318
2/2
✓ Branch 0 taken 3499 times.
✓ Branch 1 taken 21 times.
3520 return (flags & AV_BUFFERSRC_FLAG_PUSH) ? push_frame(ctx->graph) : 0;
319 }
320
321 442332 int av_buffersrc_get_status(AVFilterContext *ctx)
322 {
323 442332 BufferSourceContext *s = ctx->priv;
324
325
3/4
✓ Branch 0 taken 440586 times.
✓ Branch 1 taken 1746 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 440586 times.
442332 if (!s->eof && ff_outlink_get_status(ctx->outputs[0]))
326 ✗ s->eof = 1;
327
328 442332 return s->eof ? AVERROR(EOF) : 0;
329 }
330
331 7291 static av_cold int common_init(AVFilterContext *ctx)
332 {
333 7291 BufferSourceContext *c = ctx->priv;
334
335 7291 c->warning_limit = 100;
336 7291 return 0;
337 }
338
339 5836 static av_cold int init_video(AVFilterContext *ctx)
340 {
341 5836 BufferSourceContext *c = ctx->priv;
342
343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5836 times.
5836 if (c->pix_fmt == AV_PIX_FMT_NONE) {
344 ✗ av_log(ctx, AV_LOG_ERROR, "Unspecified pixel format\n");
345 ✗ return AVERROR(EINVAL);
346 }
347
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5836 times.
5836 if (av_pix_fmt_desc_get(c->pix_fmt)->flags & AV_PIX_FMT_FLAG_HWACCEL) {
348 ✗ if (!c->hw_frames_ctx) {
349 ✗ av_log(ctx, AV_LOG_ERROR, "Setting BufferSourceContext.pix_fmt "
350 "to a HW format requires hw_frames_ctx to be non-NULL!\n");
351 ✗ return AVERROR(EINVAL);
352 }
353 }
354
2/4
✓ Branch 0 taken 5836 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5836 times.
5836 if (c->w <= 0 || c->h <= 0) {
355 ✗ av_log(ctx, AV_LOG_ERROR, "Invalid size %dx%d\n", c->w, c->h);
356 ✗ return AVERROR(EINVAL);
357 }
358
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5836 times.
5836 if (av_q2d(c->time_base) <= 0) {
359 ✗ av_log(ctx, AV_LOG_ERROR, "Invalid time base %d/%d\n", c->time_base.num, c->time_base.den);
360 ✗ return AVERROR(EINVAL);
361 }
362
363 5836 av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d pixfmt:%s tb:%d/%d fr:%d/%d sar:%d/%d csp:%s range:%s alpha:%s chroma_loc:%s\n",
364 c->w, c->h, av_get_pix_fmt_name(c->pix_fmt),
365 c->time_base.num, c->time_base.den, c->frame_rate.num, c->frame_rate.den,
366 c->pixel_aspect.num, c->pixel_aspect.den,
367 av_color_space_name(c->color_space), av_color_range_name(c->color_range),
368 av_alpha_mode_name(c->alpha_mode), av_chroma_location_name(c->chroma_location));
369
370 5836 return common_init(ctx);
371 }
372
373 439234 unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src)
374 {
375 439234 return ((BufferSourceContext *)buffer_src->priv)->nb_failed_requests;
376 }
377
378 #define OFFSET(x) offsetof(BufferSourceContext, x)
379 #define A AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
380 #define V AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
381
382 static const AVOption buffer_options[] = {
383 { "width", NULL, OFFSET(w), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, V },
384 { "video_size", NULL, OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, .flags = V },
385 { "height", NULL, OFFSET(h), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, V },
386 { "pix_fmt", NULL, OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_NONE }, .min = AV_PIX_FMT_NONE, .max = INT_MAX, .flags = V },
387 { "sar", "sample aspect ratio", OFFSET(pixel_aspect), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
388 { "pixel_aspect", "sample aspect ratio", OFFSET(pixel_aspect), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
389 { "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
390 { "frame_rate", NULL, OFFSET(frame_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
391 { "colorspace", "select colorspace", OFFSET(color_space), AV_OPT_TYPE_INT, {.i64=AVCOL_SPC_UNSPECIFIED}, 0, AVCOL_SPC_NB-1, V, .unit = "colorspace"},
392 { "gbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_RGB}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
393 { "bt709", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT709}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
394 { "unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_UNSPECIFIED}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
395 { "fcc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_FCC}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
396 { "bt470bg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT470BG}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
397 { "smpte170m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE170M}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
398 { "smpte240m", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE240M}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
399 { "ycgco", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
400 { "ycgco-re", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO_RE}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
401 { "ycgco-ro", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_YCGCO_RO}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
402 { "bt2020nc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_NCL}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
403 { "bt2020c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_BT2020_CL}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
404 { "smpte2085", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_SMPTE2085}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
405 { "chroma-derived-nc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_NCL},INT_MIN, INT_MAX, V, .unit = "colorspace"},
406 { "chroma-derived-c", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_CHROMA_DERIVED_CL}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
407 { "ictcp", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_ICTCP}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
408 { "ipt-c2", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_SPC_IPT_C2}, INT_MIN, INT_MAX, V, .unit = "colorspace"},
409 { "range", "select color range", OFFSET(color_range), AV_OPT_TYPE_INT, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, AVCOL_RANGE_NB-1, V, .unit = "range"},
410 { "unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, V, .unit = "range"},
411 { "unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_UNSPECIFIED}, 0, 0, V, .unit = "range"},
412 { "limited", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, .unit = "range"},
413 { "tv", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, .unit = "range"},
414 { "mpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_MPEG}, 0, 0, V, .unit = "range"},
415 { "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, .unit = "range"},
416 { "pc", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, .unit = "range"},
417 { "jpeg", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCOL_RANGE_JPEG}, 0, 0, V, .unit = "range"},
418 { "alpha_mode", "select alpha mode", OFFSET(alpha_mode), AV_OPT_TYPE_INT, {.i64=AVALPHA_MODE_UNSPECIFIED}, 0, AVCOL_RANGE_NB-1, V, .unit = "alpha"},
419 { "unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_UNSPECIFIED}, 0, 0, V, .unit = "alpha"},
420 { "unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_UNSPECIFIED}, 0, 0, V, .unit = "alpha"},
421 { "straight", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_STRAIGHT}, 0, 0, V, .unit = "alpha"},
422 { "premultiplied", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVALPHA_MODE_PREMULTIPLIED}, 0, 0, V, .unit = "alpha"},
423 { "chroma_location", "select chroma sample location", OFFSET(chroma_location), AV_OPT_TYPE_INT, {.i64=AVCHROMA_LOC_UNSPECIFIED}, 0, AVCHROMA_LOC_NB-1, V, .unit = "chroma_loc"},
424 { "unspecified", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, 0, 0, V, .unit = "chroma_loc"},
425 { "unknown", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_UNSPECIFIED}, 0, 0, V, .unit = "chroma_loc"},
426 { "left", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_LEFT}, 0, 0, V, .unit = "chroma_loc"},
427 { "center", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_CENTER}, 0, 0, V, .unit = "chroma_loc"},
428 { "topleft", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOPLEFT}, 0, 0, V, .unit = "chroma_loc"},
429 { "top", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_TOP}, 0, 0, V, .unit = "chroma_loc"},
430 { "bottomleft", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOMLEFT}, 0, 0, V, .unit = "chroma_loc"},
431 { "bottom", NULL, 0, AV_OPT_TYPE_CONST, {.i64=AVCHROMA_LOC_BOTTOM}, 0, 0, V, .unit = "chroma_loc"},
432 { NULL },
433 };
434
435 AVFILTER_DEFINE_CLASS(buffer);
436
437 static const AVOption abuffer_options[] = {
438 { "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, INT_MAX, A },
439 { "sample_rate", NULL, OFFSET(sample_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, A },
440 { "sample_fmt", NULL, OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, { .i64 = AV_SAMPLE_FMT_NONE }, .min = AV_SAMPLE_FMT_NONE, .max = INT_MAX, .flags = A },
441 { "channel_layout", NULL, OFFSET(ch_layout), AV_OPT_TYPE_CHLAYOUT, .flags = A },
442 { "channels", NULL, OFFSET(channels), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, A },
443 { NULL },
444 };
445
446 AVFILTER_DEFINE_CLASS(abuffer);
447
448 1455 static av_cold int init_audio(AVFilterContext *ctx)
449 {
450 1455 BufferSourceContext *s = ctx->priv;
451 char buf[128];
452
453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1455 times.
1455 if (s->sample_fmt == AV_SAMPLE_FMT_NONE) {
454 ✗ av_log(ctx, AV_LOG_ERROR, "Sample format was not set or was invalid\n");
455 ✗ return AVERROR(EINVAL);
456 }
457
458
2/2
✓ Branch 1 taken 1435 times.
✓ Branch 2 taken 20 times.
1455 if (av_channel_layout_check(&s->ch_layout)) {
459 int n;
460
461 1435 n = s->ch_layout.nb_channels;
462 1435 av_channel_layout_describe(&s->ch_layout, buf, sizeof(buf));
463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1435 times.
1435 if (s->channels) {
464 ✗ if (n != s->channels) {
465 ✗ av_log(ctx, AV_LOG_ERROR,
466 "Mismatching channel count %d and layout '%s' "
467 "(%d channels)\n",
468 s->channels, buf, n);
469 ✗ return AVERROR(EINVAL);
470 }
471 }
472 1435 s->channels = n;
473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 } else if (!s->channels) {
474 ✗ av_log(ctx, AV_LOG_ERROR, "Neither number of channels nor "
475 "channel layout specified\n");
476 ✗ return AVERROR(EINVAL);
477 } else {
478 20 s->ch_layout = FF_COUNT2LAYOUT(s->channels);
479 20 av_channel_layout_describe(&s->ch_layout, buf, sizeof(buf));
480 }
481
482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1455 times.
1455 if (s->sample_rate <= 0) {
483 ✗ av_log(ctx, AV_LOG_ERROR, "Sample rate not set\n");
484 ✗ return AVERROR(EINVAL);
485 }
486
487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1455 times.
1455 if (!s->time_base.num)
488 ✗ s->time_base = (AVRational){1, s->sample_rate};
489
490 1455 av_log(ctx, AV_LOG_VERBOSE,
491 "tb:%d/%d samplefmt:%s samplerate:%d chlayout:%s\n",
492 s->time_base.num, s->time_base.den, av_get_sample_fmt_name(s->sample_fmt),
493 s->sample_rate, buf);
494
495 1455 return common_init(ctx);
496 }
497
498 7291 static av_cold void uninit(AVFilterContext *ctx)
499 {
500 7291 BufferSourceContext *s = ctx->priv;
501 7291 av_buffer_unref(&s->hw_frames_ctx);
502 7291 av_channel_layout_uninit(&s->ch_layout);
503 7291 av_frame_side_data_free(&s->side_data, &s->nb_side_data);
504 7291 }
505
506 7291 static int query_formats(const AVFilterContext *ctx,
507 AVFilterFormatsConfig **cfg_in,
508 AVFilterFormatsConfig **cfg_out)
509 {
510 7291 const BufferSourceContext *c = ctx->priv;
511 7291 AVFilterChannelLayouts *channel_layouts = NULL;
512 7291 AVFilterFormats *formats = NULL;
513 7291 AVFilterFormats *samplerates = NULL;
514 7291 AVFilterFormats *color_spaces = NULL;
515 7291 AVFilterFormats *color_ranges = NULL;
516 7291 AVFilterFormats *alpha_modes = NULL;
517 7291 AVFilterFormats *chroma_locations = NULL;
518 int ret;
519
520
2/3
✓ Branch 0 taken 5836 times.
✓ Branch 1 taken 1455 times.
✗ Branch 2 not taken.
7291 switch (ctx->outputs[0]->type) {
521 5836 case AVMEDIA_TYPE_VIDEO: {
522 5836 enum AVPixelFormat swfmt = c->pix_fmt;
523
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5836 times.
5836 if (av_pix_fmt_desc_get(swfmt)->flags & AV_PIX_FMT_FLAG_HWACCEL)
524 ✗ swfmt = ((AVHWFramesContext *) c->hw_frames_ctx->data)->sw_format;
525
2/4
✓ Branch 1 taken 5836 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 5836 times.
11672 if ((ret = ff_add_format (&formats, c->pix_fmt)) < 0 ||
526 5836 (ret = ff_set_common_formats2(ctx, cfg_in, cfg_out, formats)) < 0)
527 ✗ return ret;
528 /* force specific colorspace/range downstream only for ordinary YUV */
529
2/2
✓ Branch 1 taken 5113 times.
✓ Branch 2 taken 723 times.
5836 if (ff_fmt_is_regular_yuv(swfmt)) {
530
2/4
✓ Branch 1 taken 5113 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 5113 times.
10226 if ((ret = ff_add_format(&color_spaces, c->color_space)) < 0 ||
531 5113 (ret = ff_set_common_color_spaces2(ctx, cfg_in, cfg_out, color_spaces)) < 0)
532 ✗ return ret;
533
2/2
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 5032 times.
5113 if (ff_fmt_is_forced_full_range(swfmt)) {
534
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 81 times.
81 if ((ret = ff_add_format(&color_ranges, AVCOL_RANGE_JPEG)) < 0)
535 ✗ return ret;
536 } else {
537
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5032 times.
5032 if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0)
538 ✗ return ret;
539
2/2
✓ Branch 0 taken 726 times.
✓ Branch 1 taken 4306 times.
5032 if (c->color_range == AVCOL_RANGE_UNSPECIFIED) {
540 /* allow implicitly promoting unspecified to mpeg */
541
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 726 times.
726 if ((ret = ff_add_format(&color_ranges, AVCOL_RANGE_MPEG)) < 0)
542 ✗ return ret;
543 }
544 }
545
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5113 times.
5113 if ((ret = ff_set_common_color_ranges2(ctx, cfg_in, cfg_out, color_ranges)) < 0)
546 ✗ return ret;
547 }
548
2/2
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 5519 times.
5836 if (av_pix_fmt_desc_get(swfmt)->flags & AV_PIX_FMT_FLAG_ALPHA) {
549
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
317 if ((ret = ff_add_format(&alpha_modes, c->alpha_mode)) < 0)
550 ✗ return ret;
551
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 70 times.
317 if (c->alpha_mode == AVALPHA_MODE_UNSPECIFIED) {
552 /* allow implicitly promoting unspecified to straight */
553
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
247 if ((ret = ff_add_format(&alpha_modes, AVALPHA_MODE_STRAIGHT)) < 0)
554 ✗ return ret;
555 }
556
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
317 if ((ret = ff_set_common_alpha_modes2(ctx, cfg_in, cfg_out, alpha_modes)) < 0)
557 ✗ return ret;
558 }
559
2/2
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 5004 times.
5836 if (av_pix_fmt_desc_get(swfmt)->log2_chroma_w ||
560
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 827 times.
832 av_pix_fmt_desc_get(swfmt)->log2_chroma_h) {
561
2/2
✓ Branch 0 taken 1088 times.
✓ Branch 1 taken 3921 times.
5009 if (c->chroma_location != AVCHROMA_LOC_UNSPECIFIED) {
562
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1088 times.
1088 if ((ret = ff_add_format(&chroma_locations, c->chroma_location)) < 0)
563 ✗ return ret;
564
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1088 times.
1088 if ((ret = ff_set_common_chroma_locations2(ctx, cfg_in, cfg_out,
565 chroma_locations)) < 0)
566 ✗ return ret;
567 }
568 /* Untagged input places no constraint, there is nothing to convert
569 * from, so whatever the rest of the graph wants is used as is. */
570 }
571 5836 break;
572 }
573 1455 case AVMEDIA_TYPE_AUDIO:
574
2/4
✓ Branch 1 taken 1455 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1455 times.
✗ Branch 4 not taken.
2910 if ((ret = ff_add_format (&formats , c->sample_fmt )) < 0 ||
575
1/2
✓ Branch 1 taken 1455 times.
✗ Branch 2 not taken.
2910 (ret = ff_set_common_formats2 (ctx, cfg_in, cfg_out, formats)) < 0 ||
576
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1455 times.
2910 (ret = ff_add_format (&samplerates, c->sample_rate)) < 0 ||
577 1455 (ret = ff_set_common_samplerates2(ctx, cfg_in, cfg_out, samplerates)) < 0)
578 ✗ return ret;
579
580
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1455 times.
1455 if ((ret = ff_add_channel_layout(&channel_layouts, &c->ch_layout)) < 0)
581 ✗ return ret;
582
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1455 times.
1455 if ((ret = ff_set_common_channel_layouts2(ctx, cfg_in, cfg_out, channel_layouts)) < 0)
583 ✗ return ret;
584 1455 break;
585 ✗ default:
586 ✗ return AVERROR(EINVAL);
587 }
588
589 7291 return 0;
590 }
591
592 7291 static int config_props(AVFilterLink *link)
593 {
594 7291 FilterLink *l = ff_filter_link(link);
595 7291 BufferSourceContext *c = link->src->priv;
596
597
2/3
✓ Branch 0 taken 5836 times.
✓ Branch 1 taken 1455 times.
✗ Branch 2 not taken.
7291 switch (link->type) {
598 5836 case AVMEDIA_TYPE_VIDEO:
599 5836 link->w = c->w;
600 5836 link->h = c->h;
601 5836 link->sample_aspect_ratio = c->pixel_aspect;
602
603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5836 times.
5836 if (c->hw_frames_ctx) {
604 ✗ l->hw_frames_ctx = av_buffer_ref(c->hw_frames_ctx);
605 ✗ if (!l->hw_frames_ctx)
606 ✗ return AVERROR(ENOMEM);
607 }
608 5836 break;
609 1455 case AVMEDIA_TYPE_AUDIO:
610
3/4
✓ Branch 0 taken 1455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 1435 times.
1455 if (!c->ch_layout.nb_channels || c->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
611 20 int ret = av_channel_layout_copy(&c->ch_layout, &link->ch_layout);
612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (ret < 0)
613 ✗ return ret;
614 }
615 1455 break;
616 ✗ default:
617 ✗ return AVERROR(EINVAL);
618 }
619
620
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 7291 times.
7584 for (int i = 0; i < c->nb_side_data; i++) {
621 int ret;
622
623 293 ret = av_frame_side_data_clone(&link->side_data, &link->nb_side_data,
624 293 c->side_data[i], 0);
625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 293 times.
293 if (ret < 0) {
626 ✗ av_frame_side_data_free(&link->side_data, &link->nb_side_data);
627 ✗ return ret;
628 }
629 }
630
631 7291 link->time_base = c->time_base;
632 7291 l->frame_rate = c->frame_rate;
633 7291 return 0;
634 }
635
636 432634 static int activate(AVFilterContext *ctx)
637 {
638 432634 AVFilterLink *outlink = ctx->outputs[0];
639 432634 BufferSourceContext *c = ctx->priv;
640
641
4/4
✓ Branch 0 taken 429786 times.
✓ Branch 1 taken 2848 times.
✓ Branch 3 taken 646 times.
✓ Branch 4 taken 429140 times.
432634 if (!c->eof && ff_outlink_get_status(outlink)) {
642 646 c->eof = 1;
643 646 return 0;
644 }
645
646
2/2
✓ Branch 0 taken 2848 times.
✓ Branch 1 taken 429140 times.
431988 if (c->eof) {
647 2848 ff_outlink_set_status(outlink, AVERROR_EOF, c->last_pts);
648 2848 return 0;
649 }
650 429140 c->nb_failed_requests++;
651 429140 return FFERROR_BUFFERSRC_EMPTY;
652 }
653
654 static const AVFilterPad avfilter_vsrc_buffer_outputs[] = {
655 {
656 .name = "default",
657 .type = AVMEDIA_TYPE_VIDEO,
658 .config_props = config_props,
659 },
660 };
661
662 const FFFilter ff_vsrc_buffer = {
663 .p.name = "buffer",
664 .p.description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them accessible to the filterchain."),
665 .p.priv_class = &buffer_class,
666 .priv_size = sizeof(BufferSourceContext),
667 .activate = activate,
668 .init = init_video,
669 .uninit = uninit,
670
671 FILTER_OUTPUTS(avfilter_vsrc_buffer_outputs),
672 FILTER_QUERY_FUNC2(query_formats),
673 };
674
675 static const AVFilterPad avfilter_asrc_abuffer_outputs[] = {
676 {
677 .name = "default",
678 .type = AVMEDIA_TYPE_AUDIO,
679 .config_props = config_props,
680 },
681 };
682
683 const FFFilter ff_asrc_abuffer = {
684 .p.name = "abuffer",
685 .p.description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them accessible to the filterchain."),
686 .p.priv_class = &abuffer_class,
687 .priv_size = sizeof(BufferSourceContext),
688 .activate = activate,
689 .init = init_audio,
690 .uninit = uninit,
691
692 FILTER_OUTPUTS(avfilter_asrc_abuffer_outputs),
693 FILTER_QUERY_FUNC2(query_formats),
694 };
695