FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/buffersrc.c
Date: 2026-10-06 20:08:58
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 7220 AVBufferSrcParameters *av_buffersrc_parameters_alloc(void)
117 {
118 7220 AVBufferSrcParameters *par = av_mallocz(sizeof(*par));
119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7220 times.
7220 if (!par)
120 ✗ return NULL;
121
122 7220 par->format = -1;
123 7220 par->color_range = AVCOL_RANGE_UNSPECIFIED;
124 7220 par->color_space = AVCOL_SPC_UNSPECIFIED;
125 7220 par->alpha_mode = AVALPHA_MODE_UNSPECIFIED;
126 7220 par->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
127
128 7220 return par;
129 }
130
131 7220 int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *param)
132 {
133 7220 BufferSourceContext *s = ctx->priv;
134
135
3/4
✓ Branch 0 taken 5817 times.
✓ Branch 1 taken 1403 times.
✓ Branch 2 taken 5817 times.
✗ Branch 3 not taken.
7220 if (param->time_base.num > 0 && param->time_base.den > 0)
136 5817 s->time_base = param->time_base;
137
138
2/3
✓ Branch 0 taken 5817 times.
✓ Branch 1 taken 1403 times.
✗ Branch 2 not taken.
7220 switch (ctx->filter->outputs[0].type) {
139 5817 case AVMEDIA_TYPE_VIDEO:
140
1/2
✓ Branch 0 taken 5817 times.
✗ Branch 1 not taken.
5817 if (param->format != AV_PIX_FMT_NONE) {
141 5817 s->pix_fmt = s->prev_pix_fmt = param->format;
142 }
143
1/2
✓ Branch 0 taken 5817 times.
✗ Branch 1 not taken.
5817 if (param->width > 0)
144 5817 s->w = s->prev_w = param->width;
145
1/2
✓ Branch 0 taken 5817 times.
✗ Branch 1 not taken.
5817 if (param->height > 0)
146 5817 s->h = s->prev_h = param->height;
147
3/4
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 5089 times.
✓ Branch 2 taken 728 times.
✗ Branch 3 not taken.
5817 if (param->sample_aspect_ratio.num > 0 && param->sample_aspect_ratio.den > 0)
148 728 s->pixel_aspect = param->sample_aspect_ratio;
149
3/4
✓ Branch 0 taken 5812 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5812 times.
✗ Branch 3 not taken.
5817 if (param->frame_rate.num > 0 && param->frame_rate.den > 0)
150 5812 s->frame_rate = param->frame_rate;
151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5817 times.
5817 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 399 times.
✓ Branch 1 taken 5418 times.
5817 if (param->color_space != AVCOL_SPC_UNSPECIFIED)
158 399 s->color_space = s->prev_color_space = param->color_space;
159
2/2
✓ Branch 0 taken 4461 times.
✓ Branch 1 taken 1356 times.
5817 if (param->color_range != AVCOL_RANGE_UNSPECIFIED)
160 4461 s->color_range = s->prev_color_range = param->color_range;
161
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 5739 times.
5817 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 1119 times.
✓ Branch 1 taken 4698 times.
5817 if (param->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
164 1119 s->chroma_location = s->prev_chroma_location = param->chroma_location;
165 5817 break;
166 1403 case AVMEDIA_TYPE_AUDIO:
167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1403 times.
1403 if (param->format != AV_SAMPLE_FMT_NONE) {
168 ✗ s->sample_fmt = param->format;
169 }
170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1403 times.
1403 if (param->sample_rate > 0)
171 ✗ s->sample_rate = param->sample_rate;
172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1403 times.
1403 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 1403 break;
178 ✗ default:
179 ✗ return AVERROR_BUG;
180 }
181
182
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6950 times.
7220 if (param->nb_side_data > 0)
183 270 av_frame_side_data_free(&s->side_data, &s->nb_side_data);
184
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 7220 times.
7511 for (int i = 0; i < param->nb_side_data; i++) {
185 291 int ret = av_frame_side_data_clone(&s->side_data, &s->nb_side_data,
186 291 param->side_data[i], 0);
187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291 times.
291 if (ret < 0) {
188 ✗ av_frame_side_data_free(&s->side_data, &s->nb_side_data);
189 ✗ return ret;
190 }
191 }
192
193 7220 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 169 int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
203 {
204 169 return av_buffersrc_add_frame_flags(ctx, frame, 0);
205 }
206
207 430747 static int push_frame(AVFilterGraph *graph)
208 {
209 int ret;
210
211 while (1) {
212 2702384 ret = ff_filter_graph_run_once(graph);
213
2/2
✓ Branch 0 taken 430747 times.
✓ Branch 1 taken 2271637 times.
2702384 if (ret == AVERROR(EAGAIN))
214 430747 break;
215
3/4
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 2268662 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2975 times.
2271637 if (ret < 0 && ret != FFERROR_BUFFERSRC_EMPTY)
216 ✗ return ret;
217 }
218 430747 return 0;
219 }
220
221 427446 int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
222 {
223 427446 BufferSourceContext *s = ctx->priv;
224 AVFrame *copy;
225 int refcounted, ret;
226
227 427446 s->nb_failed_requests = 0;
228
229
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 427425 times.
427446 if (!frame)
230 21 return av_buffersrc_close(ctx, s->last_pts, flags);
231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427425 times.
427425 if (s->eof)
232 ✗ return AVERROR_EOF;
233
234 427425 s->last_pts = frame->pts + frame->duration;
235
236 427425 refcounted = !!frame->buf[0];
237
238
1/2
✓ Branch 0 taken 427425 times.
✗ Branch 1 not taken.
427425 if (!(flags & AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)) {
239
240
2/3
✓ Branch 0 taken 118644 times.
✓ Branch 1 taken 308781 times.
✗ Branch 2 not taken.
427425 switch (ctx->outputs[0]->type) {
241 118644 case AVMEDIA_TYPE_VIDEO:
242
26/36
✓ Branch 0 taken 118644 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118644 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 118565 times.
✓ Branch 5 taken 79 times.
✓ Branch 6 taken 118548 times.
✓ Branch 7 taken 17 times.
✓ Branch 8 taken 118548 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 118548 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 118548 times.
✓ Branch 14 taken 118644 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 118644 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 118604 times.
✓ Branch 19 taken 40 times.
✓ Branch 20 taken 113186 times.
✓ Branch 21 taken 5418 times.
✓ Branch 22 taken 113186 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 113186 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 113186 times.
✓ Branch 28 taken 96 times.
✓ Branch 29 taken 118548 times.
✓ Branch 30 taken 21 times.
✓ Branch 31 taken 75 times.
✓ Branch 43 taken 5458 times.
✓ Branch 44 taken 113186 times.
✓ Branch 45 taken 5437 times.
✓ Branch 46 taken 21 times.
124177 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 118644 break;
247 308781 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 273589 times.
✓ Branch 2 taken 35192 times.
✗ Branch 3 not taken.
308781 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 308781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 308781 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 308781 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 308781 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
308781 CHECK_AUDIO_PARAM_CHANGE(ctx, s, frame->sample_rate, frame->ch_layout,
255 frame->format, frame->pts);
256 308781 break;
257 ✗ default:
258 ✗ return AVERROR(EINVAL);
259 }
260
261 }
262
263
3/4
✓ Branch 0 taken 427425 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 427154 times.
✓ Branch 3 taken 271 times.
427425 if (refcounted && !(flags & AV_BUFFERSRC_FLAG_KEEP_REF)) {
264
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 427154 times.
427154 if (!(copy = av_frame_alloc()))
265 ✗ return AVERROR(ENOMEM);
266 427154 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 110553 times.
✓ Branch 1 taken 316872 times.
427425 if (copy->colorspace == AVCOL_SPC_UNSPECIFIED)
274 110553 copy->colorspace = ctx->outputs[0]->colorspace;
275
2/2
✓ Branch 0 taken 365679 times.
✓ Branch 1 taken 61746 times.
427425 if (copy->color_range == AVCOL_RANGE_UNSPECIFIED)
276 365679 copy->color_range = ctx->outputs[0]->color_range;
277
2/2
✓ Branch 0 taken 427270 times.
✓ Branch 1 taken 155 times.
427425 if (copy->alpha_mode == AVALPHA_MODE_UNSPECIFIED)
278 427270 copy->alpha_mode = ctx->outputs[0]->alpha_mode;
279
2/2
✓ Branch 0 taken 378612 times.
✓ Branch 1 taken 48813 times.
427425 if (copy->chroma_location == AVCHROMA_LOC_UNSPECIFIED) {
280 378612 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 372620 times.
378612 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 427425 ret = ff_filter_frame(ctx->outputs[0], copy);
290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427425 times.
427425 if (ret < 0)
291 ✗ return ret;
292
293
2/2
✓ Branch 0 taken 427277 times.
✓ Branch 1 taken 148 times.
427425 if ((flags & AV_BUFFERSRC_FLAG_PUSH)) {
294 427277 ret = push_frame(ctx->graph);
295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427277 times.
427277 if (ret < 0)
296 ✗ return ret;
297 }
298
299 427425 FilterLinkInternal *const li = ff_link_internal(ctx->outputs[0]);
300
1/2
✓ Branch 0 taken 427425 times.
✗ Branch 1 not taken.
427425 if (s->warning_limit &&
301
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 427425 times.
427425 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 427425 return 0;
310 }
311
312 3491 int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags)
313 {
314 3491 BufferSourceContext *s = ctx->priv;
315
316 3491 s->eof = 1;
317 3491 ff_avfilter_link_set_in_status(ctx->outputs[0], AVERROR_EOF, pts);
318
2/2
✓ Branch 0 taken 3470 times.
✓ Branch 1 taken 21 times.
3491 return (flags & AV_BUFFERSRC_FLAG_PUSH) ? push_frame(ctx->graph) : 0;
319 }
320
321 441050 int av_buffersrc_get_status(AVFilterContext *ctx)
322 {
323 441050 BufferSourceContext *s = ctx->priv;
324
325
3/4
✓ Branch 0 taken 439311 times.
✓ Branch 1 taken 1739 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 439311 times.
441050 if (!s->eof && ff_outlink_get_status(ctx->outputs[0]))
326 ✗ s->eof = 1;
327
328 441050 return s->eof ? AVERROR(EOF) : 0;
329 }
330
331 7220 static av_cold int common_init(AVFilterContext *ctx)
332 {
333 7220 BufferSourceContext *c = ctx->priv;
334
335 7220 c->warning_limit = 100;
336 7220 return 0;
337 }
338
339 5817 static av_cold int init_video(AVFilterContext *ctx)
340 {
341 5817 BufferSourceContext *c = ctx->priv;
342
343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5817 times.
5817 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 5817 times.
5817 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 5817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5817 times.
5817 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 5817 times.
5817 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 5817 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 5817 return common_init(ctx);
371 }
372
373 437951 unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src)
374 {
375 437951 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 1403 static av_cold int init_audio(AVFilterContext *ctx)
449 {
450 1403 BufferSourceContext *s = ctx->priv;
451 char buf[128];
452
453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1403 times.
1403 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 1383 times.
✓ Branch 2 taken 20 times.
1403 if (av_channel_layout_check(&s->ch_layout)) {
459 int n;
460
461 1383 n = s->ch_layout.nb_channels;
462 1383 av_channel_layout_describe(&s->ch_layout, buf, sizeof(buf));
463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1383 times.
1383 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 1383 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 1403 times.
1403 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 1403 times.
1403 if (!s->time_base.num)
488 ✗ s->time_base = (AVRational){1, s->sample_rate};
489
490 1403 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 1403 return common_init(ctx);
496 }
497
498 7220 static av_cold void uninit(AVFilterContext *ctx)
499 {
500 7220 BufferSourceContext *s = ctx->priv;
501 7220 av_buffer_unref(&s->hw_frames_ctx);
502 7220 av_channel_layout_uninit(&s->ch_layout);
503 7220 av_frame_side_data_free(&s->side_data, &s->nb_side_data);
504 7220 }
505
506 7220 static int query_formats(const AVFilterContext *ctx,
507 AVFilterFormatsConfig **cfg_in,
508 AVFilterFormatsConfig **cfg_out)
509 {
510 7220 const BufferSourceContext *c = ctx->priv;
511 7220 AVFilterChannelLayouts *channel_layouts = NULL;
512 7220 AVFilterFormats *formats = NULL;
513 7220 AVFilterFormats *samplerates = NULL;
514 7220 AVFilterFormats *color_spaces = NULL;
515 7220 AVFilterFormats *color_ranges = NULL;
516 7220 AVFilterFormats *alpha_modes = NULL;
517 7220 AVFilterFormats *chroma_locations = NULL;
518 int ret;
519
520
2/3
✓ Branch 0 taken 5817 times.
✓ Branch 1 taken 1403 times.
✗ Branch 2 not taken.
7220 switch (ctx->outputs[0]->type) {
521 5817 case AVMEDIA_TYPE_VIDEO: {
522 5817 enum AVPixelFormat swfmt = c->pix_fmt;
523
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 5817 times.
5817 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 5817 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 5817 times.
11634 if ((ret = ff_add_format (&formats, c->pix_fmt)) < 0 ||
526 5817 (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 5099 times.
✓ Branch 2 taken 718 times.
5817 if (ff_fmt_is_regular_yuv(swfmt)) {
530
2/4
✓ Branch 1 taken 5099 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 5099 times.
10198 if ((ret = ff_add_format(&color_spaces, c->color_space)) < 0 ||
531 5099 (ret = ff_set_common_color_spaces2(ctx, cfg_in, cfg_out, color_spaces)) < 0)
532 ✗ return ret;
533
2/2
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 5024 times.
5099 if (ff_fmt_is_forced_full_range(swfmt)) {
534
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
75 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 5024 times.
5024 if ((ret = ff_add_format(&color_ranges, c->color_range)) < 0)
538 ✗ return ret;
539
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 4300 times.
5024 if (c->color_range == AVCOL_RANGE_UNSPECIFIED) {
540 /* allow implicitly promoting unspecified to mpeg */
541
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 724 times.
724 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 5099 times.
5099 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 314 times.
✓ Branch 2 taken 5503 times.
5817 if (av_pix_fmt_desc_get(swfmt)->flags & AV_PIX_FMT_FLAG_ALPHA) {
549
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 314 times.
314 if ((ret = ff_add_format(&alpha_modes, c->alpha_mode)) < 0)
550 ✗ return ret;
551
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 70 times.
314 if (c->alpha_mode == AVALPHA_MODE_UNSPECIFIED) {
552 /* allow implicitly promoting unspecified to straight */
553
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 244 times.
244 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 314 times.
314 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 825 times.
✓ Branch 2 taken 4992 times.
5817 if (av_pix_fmt_desc_get(swfmt)->log2_chroma_w ||
560
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 820 times.
825 av_pix_fmt_desc_get(swfmt)->log2_chroma_h) {
561
2/2
✓ Branch 0 taken 1079 times.
✓ Branch 1 taken 3918 times.
4997 if (c->chroma_location != AVCHROMA_LOC_UNSPECIFIED) {
562
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1079 times.
1079 if ((ret = ff_add_format(&chroma_locations, c->chroma_location)) < 0)
563 ✗ return ret;
564
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1079 times.
1079 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 5817 break;
572 }
573 1403 case AVMEDIA_TYPE_AUDIO:
574
2/4
✓ Branch 1 taken 1403 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1403 times.
✗ Branch 4 not taken.
2806 if ((ret = ff_add_format (&formats , c->sample_fmt )) < 0 ||
575
1/2
✓ Branch 1 taken 1403 times.
✗ Branch 2 not taken.
2806 (ret = ff_set_common_formats2 (ctx, cfg_in, cfg_out, formats)) < 0 ||
576
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1403 times.
2806 (ret = ff_add_format (&samplerates, c->sample_rate)) < 0 ||
577 1403 (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 1403 times.
1403 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 1403 times.
1403 if ((ret = ff_set_common_channel_layouts2(ctx, cfg_in, cfg_out, channel_layouts)) < 0)
583 ✗ return ret;
584 1403 break;
585 ✗ default:
586 ✗ return AVERROR(EINVAL);
587 }
588
589 7220 return 0;
590 }
591
592 7220 static int config_props(AVFilterLink *link)
593 {
594 7220 FilterLink *l = ff_filter_link(link);
595 7220 BufferSourceContext *c = link->src->priv;
596
597
2/3
✓ Branch 0 taken 5817 times.
✓ Branch 1 taken 1403 times.
✗ Branch 2 not taken.
7220 switch (link->type) {
598 5817 case AVMEDIA_TYPE_VIDEO:
599 5817 link->w = c->w;
600 5817 link->h = c->h;
601 5817 link->sample_aspect_ratio = c->pixel_aspect;
602
603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5817 times.
5817 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 5817 break;
609 1403 case AVMEDIA_TYPE_AUDIO:
610
3/4
✓ Branch 0 taken 1403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 1383 times.
1403 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 1403 break;
616 ✗ default:
617 ✗ return AVERROR(EINVAL);
618 }
619
620
2/2
✓ Branch 0 taken 291 times.
✓ Branch 1 taken 7220 times.
7511 for (int i = 0; i < c->nb_side_data; i++) {
621 int ret;
622
623 291 ret = av_frame_side_data_clone(&link->side_data, &link->nb_side_data,
624 291 c->side_data[i], 0);
625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291 times.
291 if (ret < 0) {
626 ✗ av_frame_side_data_free(&link->side_data, &link->nb_side_data);
627 ✗ return ret;
628 }
629 }
630
631 7220 link->time_base = c->time_base;
632 7220 l->frame_rate = c->frame_rate;
633 7220 return 0;
634 }
635
636 431091 static int activate(AVFilterContext *ctx)
637 {
638 431091 AVFilterLink *outlink = ctx->outputs[0];
639 431091 BufferSourceContext *c = ctx->priv;
640
641
4/4
✓ Branch 0 taken 428259 times.
✓ Branch 1 taken 2832 times.
✓ Branch 3 taken 605 times.
✓ Branch 4 taken 427654 times.
431091 if (!c->eof && ff_outlink_get_status(outlink)) {
642 605 c->eof = 1;
643 605 return 0;
644 }
645
646
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 427654 times.
430486 if (c->eof) {
647 2832 ff_outlink_set_status(outlink, AVERROR_EOF, c->last_pts);
648 2832 return 0;
649 }
650 427654 c->nb_failed_requests++;
651 427654 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