]> git.sesse.net Git - ffmpeg/blob - libavfilter/src_buffer.c
4a280613a46c84cdefd496dbdb6ace2bbf2d4126
[ffmpeg] / libavfilter / src_buffer.c
1 /*
2  * Copyright (c) 2008 Vitor Sessak
3  * Copyright (c) 2010 S.N. Hemanth Meenakshisundaram
4  * Copyright (c) 2011 Mina Nagy Zaki
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22
23 /**
24  * @file
25  * memory buffer source filter
26  */
27
28 #include "avfilter.h"
29 #include "internal.h"
30 #include "avcodec.h"
31 #include "buffersrc.h"
32 #include "vsrc_buffer.h"
33 #include "asrc_abuffer.h"
34 #include "libavutil/audioconvert.h"
35 #include "libavutil/avstring.h"
36 #include "libavutil/fifo.h"
37 #include "libavutil/imgutils.h"
38
39 typedef struct {
40     AVFifoBuffer     *fifo;
41     AVRational        time_base;     ///< time_base to set in the output link
42     int eof;
43     unsigned          nb_failed_requests;
44
45     /* Video only */
46     AVFilterContext  *scale;
47     int               h, w;
48     enum PixelFormat  pix_fmt;
49     AVRational        sample_aspect_ratio;
50     char              sws_param[256];
51
52     /* Audio only */
53     // Audio format of incoming buffers
54     int sample_rate;
55     unsigned int sample_format;
56     int64_t channel_layout;
57     int packing_format;
58
59     // Normalization filters
60     AVFilterContext *aconvert;
61     AVFilterContext *aresample;
62 } BufferSourceContext;
63
64 #define FIFO_SIZE 8
65
66 #define CHECK_PARAM_CHANGE(s, c, width, height, format)\
67     if (c->w != width || c->h != height || c->pix_fmt != format) {\
68         av_log(s, AV_LOG_ERROR, "Changing frame properties on the fly is not supported.\n");\
69         return AVERROR(EINVAL);\
70     }
71
72 static void buf_free(AVFilterBuffer *ptr)
73 {
74     av_free(ptr);
75     return;
76 }
77
78 static void set_link_source(AVFilterContext *src, AVFilterLink *link)
79 {
80     link->src       = src;
81     link->srcpad    = &(src->output_pads[0]);
82     src->outputs[0] = link;
83 }
84
85 static int reconfigure_filter(BufferSourceContext *abuffer, AVFilterContext *filt_ctx)
86 {
87     int ret;
88     AVFilterLink * const inlink  = filt_ctx->inputs[0];
89     AVFilterLink * const outlink = filt_ctx->outputs[0];
90
91     inlink->format         = abuffer->sample_format;
92     inlink->channel_layout = abuffer->channel_layout;
93     inlink->planar         = abuffer->packing_format;
94     inlink->sample_rate    = abuffer->sample_rate;
95
96     filt_ctx->filter->uninit(filt_ctx);
97     memset(filt_ctx->priv, 0, filt_ctx->filter->priv_size);
98     if ((ret = filt_ctx->filter->init(filt_ctx, NULL , NULL)) < 0)
99         return ret;
100     if ((ret = inlink->srcpad->config_props(inlink)) < 0)
101         return ret;
102     return outlink->srcpad->config_props(outlink);
103 }
104
105 static int insert_filter(BufferSourceContext *abuffer,
106                          AVFilterLink *link, AVFilterContext **filt_ctx,
107                          const char *filt_name)
108 {
109     int ret;
110
111     if ((ret = avfilter_open(filt_ctx, avfilter_get_by_name(filt_name), NULL)) < 0)
112         return ret;
113
114     link->src->outputs[0] = NULL;
115     if ((ret = avfilter_link(link->src, 0, *filt_ctx, 0)) < 0) {
116         link->src->outputs[0] = link;
117         return ret;
118     }
119
120     set_link_source(*filt_ctx, link);
121
122     if ((ret = reconfigure_filter(abuffer, *filt_ctx)) < 0) {
123         avfilter_free(*filt_ctx);
124         return ret;
125     }
126
127     return 0;
128 }
129
130 static void remove_filter(AVFilterContext **filt_ctx)
131 {
132     AVFilterLink *outlink = (*filt_ctx)->outputs[0];
133     AVFilterContext *src  = (*filt_ctx)->inputs[0]->src;
134
135     (*filt_ctx)->outputs[0] = NULL;
136     avfilter_free(*filt_ctx);
137     *filt_ctx = NULL;
138
139     set_link_source(src, outlink);
140 }
141
142 static inline void log_input_change(void *ctx, AVFilterLink *link, AVFilterBufferRef *ref)
143 {
144     char old_layout_str[16], new_layout_str[16];
145     av_get_channel_layout_string(old_layout_str, sizeof(old_layout_str),
146                                  -1, link->channel_layout);
147     av_get_channel_layout_string(new_layout_str, sizeof(new_layout_str),
148                                  -1, ref->audio->channel_layout);
149     av_log(ctx, AV_LOG_INFO,
150            "Audio input format changed: "
151            "%s:%s:%d -> %s:%s:%d, normalizing\n",
152            av_get_sample_fmt_name(link->format),
153            old_layout_str, (int)link->sample_rate,
154            av_get_sample_fmt_name(ref->format),
155            new_layout_str, ref->audio->sample_rate);
156 }
157
158 static int check_format_change_video(AVFilterContext *buffer_filter,
159                                      AVFilterBufferRef *picref)
160 {
161     BufferSourceContext *c = buffer_filter->priv;
162     int ret;
163
164     if (picref->video->w != c->w || picref->video->h != c->h || picref->format != c->pix_fmt) {
165         AVFilterContext *scale = buffer_filter->outputs[0]->dst;
166         AVFilterLink *link;
167         char scale_param[1024];
168
169         av_log(buffer_filter, AV_LOG_INFO,
170                "Buffer video input changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
171                c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
172                picref->video->w, picref->video->h, av_pix_fmt_descriptors[picref->format].name);
173
174         if (!scale || strcmp(scale->filter->name, "scale")) {
175             AVFilter *f = avfilter_get_by_name("scale");
176
177             av_log(buffer_filter, AV_LOG_INFO, "Inserting scaler filter\n");
178             if ((ret = avfilter_open(&scale, f, "Input equalizer")) < 0)
179                 return ret;
180
181             c->scale = scale;
182
183             snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s", c->w, c->h, c->sws_param);
184             if ((ret = avfilter_init_filter(scale, scale_param, NULL)) < 0) {
185                 return ret;
186             }
187
188             if ((ret = avfilter_insert_filter(buffer_filter->outputs[0], scale, 0, 0)) < 0) {
189                 return ret;
190             }
191             scale->outputs[0]->time_base = scale->inputs[0]->time_base;
192
193             scale->outputs[0]->format= c->pix_fmt;
194         } else if (!strcmp(scale->filter->name, "scale")) {
195             snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s",
196                      scale->outputs[0]->w, scale->outputs[0]->h, c->sws_param);
197             scale->filter->init(scale, scale_param, NULL);
198         }
199
200         c->pix_fmt = scale->inputs[0]->format = picref->format;
201         c->w       = scale->inputs[0]->w      = picref->video->w;
202         c->h       = scale->inputs[0]->h      = picref->video->h;
203
204         link = scale->outputs[0];
205         if ((ret =  link->srcpad->config_props(link)) < 0)
206             return ret;
207     }
208     return 0;
209 }
210
211 static int check_format_change_audio(AVFilterContext *ctx,
212                                      AVFilterBufferRef *samplesref)
213 {
214     BufferSourceContext *abuffer = ctx->priv;
215     AVFilterLink *link;
216     int ret, logged = 0;
217
218     link = ctx->outputs[0];
219     if (samplesref->audio->sample_rate != link->sample_rate) {
220
221         log_input_change(ctx, link, samplesref);
222         logged = 1;
223
224         abuffer->sample_rate = samplesref->audio->sample_rate;
225
226         if (!abuffer->aresample) {
227             ret = insert_filter(abuffer, link, &abuffer->aresample, "aresample");
228             if (ret < 0) return ret;
229         } else {
230             link = abuffer->aresample->outputs[0];
231             if (samplesref->audio->sample_rate == link->sample_rate)
232                 remove_filter(&abuffer->aresample);
233             else
234                 if ((ret = reconfigure_filter(abuffer, abuffer->aresample)) < 0)
235                     return ret;
236         }
237     }
238
239     link = ctx->outputs[0];
240     if (samplesref->format                != link->format         ||
241         samplesref->audio->channel_layout != link->channel_layout ||
242         samplesref->audio->planar         != link->planar) {
243
244         if (!logged) log_input_change(ctx, link, samplesref);
245
246         abuffer->sample_format  = samplesref->format;
247         abuffer->channel_layout = samplesref->audio->channel_layout;
248         abuffer->packing_format = samplesref->audio->planar;
249
250         if (!abuffer->aconvert) {
251             ret = insert_filter(abuffer, link, &abuffer->aconvert, "aconvert");
252             if (ret < 0) return ret;
253         } else {
254             link = abuffer->aconvert->outputs[0];
255             if (samplesref->format                == link->format         &&
256                 samplesref->audio->channel_layout == link->channel_layout &&
257                 samplesref->audio->planar         == link->planar
258                )
259                 remove_filter(&abuffer->aconvert);
260             else
261                 if ((ret = reconfigure_filter(abuffer, abuffer->aconvert)) < 0)
262                     return ret;
263         }
264     }
265
266     return 0;
267 }
268
269 static int check_format_change(AVFilterContext *buffer_filter,
270                                AVFilterBufferRef *picref)
271 {
272     switch (buffer_filter->outputs[0]->type) {
273     case AVMEDIA_TYPE_VIDEO:
274         return check_format_change_video(buffer_filter, picref);
275     case AVMEDIA_TYPE_AUDIO:
276         return check_format_change_audio(buffer_filter, picref);
277     default:
278         return AVERROR(ENOSYS);
279     }
280 }
281
282 static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,
283                                           AVFilterBufferRef *ref)
284 {
285     AVFilterLink *outlink = ctx->outputs[0];
286     AVFilterBufferRef *buf;
287     int channels, data_size, i;
288
289     switch (outlink->type) {
290
291     case AVMEDIA_TYPE_VIDEO:
292         buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,
293                                         ref->video->w, ref->video->h);
294         av_image_copy(buf->data, buf->linesize,
295                       (void*)ref->data, ref->linesize,
296                       ref->format, ref->video->w, ref->video->h);
297         break;
298
299     case AVMEDIA_TYPE_AUDIO:
300         buf = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE,
301                                         ref->audio->nb_samples);
302         channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout);
303         data_size = av_samples_get_buffer_size(NULL, channels,
304                                                ref->audio->nb_samples,
305                                                ref->format, 1);
306         for (i = 0; i < FF_ARRAY_ELEMS(ref->buf->data) && ref->buf->data[i]; i++)
307             memcpy(buf->buf->data[i], ref->buf->data[i], data_size);
308         break;
309
310     default:
311         return NULL;
312     }
313     avfilter_copy_buffer_ref_props(buf, ref);
314     return buf;
315 }
316
317 int av_buffersrc_add_ref(AVFilterContext *buffer_filter,
318                          AVFilterBufferRef *picref, int flags)
319 {
320     BufferSourceContext *c = buffer_filter->priv;
321     AVFilterBufferRef *buf;
322     int ret;
323
324     if (!picref) {
325         c->eof = 1;
326         return 0;
327     } else if (c->eof)
328         return AVERROR(EINVAL);
329
330     if (!av_fifo_space(c->fifo) &&
331         (ret = av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo) +
332                                          sizeof(buf))) < 0)
333         return ret;
334
335     if (!(flags & AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)) {
336         ret = check_format_change(buffer_filter, picref);
337         if (ret < 0)
338             return ret;
339     }
340     if (flags & AV_BUFFERSRC_FLAG_NO_COPY)
341         buf = picref;
342     else
343         buf = copy_buffer_ref(buffer_filter, picref);
344
345     if ((ret = av_fifo_generic_write(c->fifo, &buf, sizeof(buf), NULL)) < 0) {
346         if (buf != picref)
347             avfilter_unref_buffer(buf);
348         return ret;
349     }
350     c->nb_failed_requests = 0;
351
352     return 0;
353 }
354
355 int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter,
356                                         AVFilterBufferRef *picref, int flags)
357 {
358     return av_buffersrc_add_ref(buffer_filter, picref, 0);
359 }
360
361 #if CONFIG_AVCODEC
362 #include "avcodec.h"
363
364 int av_buffersrc_add_frame(AVFilterContext *buffer_src,
365                            const AVFrame *frame, int flags)
366 {
367     AVFilterBufferRef *picref;
368     int ret;
369
370     if (!frame) /* NULL for EOF */
371         return av_buffersrc_add_ref(buffer_src, NULL, flags);
372
373     switch (buffer_src->outputs[0]->type) {
374     case AVMEDIA_TYPE_VIDEO:
375         picref = avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE);
376         break;
377     case AVMEDIA_TYPE_AUDIO:
378         picref = avfilter_get_audio_buffer_ref_from_frame(frame, AV_PERM_WRITE);
379         break;
380     default:
381         return AVERROR(ENOSYS);
382     }
383     if (!picref)
384         return AVERROR(ENOMEM);
385     ret = av_buffersrc_add_ref(buffer_src, picref, flags);
386     picref->buf->data[0] = NULL;
387     avfilter_unref_buffer(picref);
388     return ret;
389 }
390
391 int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src,
392                              const AVFrame *frame, int flags)
393 {
394     return av_buffersrc_add_frame(buffer_src, frame, 0);
395 }
396 #endif
397
398 unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src)
399 {
400     return ((BufferSourceContext *)buffer_src->priv)->nb_failed_requests;
401 }
402
403 unsigned av_vsrc_buffer_get_nb_failed_requests(AVFilterContext *buffer_src)
404 {
405     return ((BufferSourceContext *)buffer_src->priv)->nb_failed_requests;
406 }
407
408 static av_cold int init_video(AVFilterContext *ctx, const char *args, void *opaque)
409 {
410     BufferSourceContext *c = ctx->priv;
411     char pix_fmt_str[128];
412     int ret, n = 0;
413     *c->sws_param = 0;
414
415     if (!args ||
416         (n = sscanf(args, "%d:%d:%127[^:]:%d:%d:%d:%d:%255c", &c->w, &c->h, pix_fmt_str,
417                     &c->time_base.num, &c->time_base.den,
418                     &c->sample_aspect_ratio.num, &c->sample_aspect_ratio.den, c->sws_param)) < 7) {
419         av_log(ctx, AV_LOG_ERROR, "Expected at least 7 arguments, but only %d found in '%s'\n", n, args);
420         return AVERROR(EINVAL);
421     }
422
423     if ((ret = ff_parse_pixel_format(&c->pix_fmt, pix_fmt_str, ctx)) < 0)
424         return ret;
425
426     if (!(c->fifo = av_fifo_alloc(sizeof(AVFilterBufferRef*))))
427         return AVERROR(ENOMEM);
428
429     av_log(ctx, AV_LOG_INFO, "w:%d h:%d pixfmt:%s tb:%d/%d sar:%d/%d sws_param:%s\n",
430            c->w, c->h, av_pix_fmt_descriptors[c->pix_fmt].name,
431            c->time_base.num, c->time_base.den,
432            c->sample_aspect_ratio.num, c->sample_aspect_ratio.den, c->sws_param);
433     return 0;
434 }
435
436 static av_cold int init_audio(AVFilterContext *ctx, const char *args0, void *opaque)
437 {
438     BufferSourceContext *abuffer = ctx->priv;
439     char *arg = NULL, *ptr, chlayout_str[16];
440     char *args = av_strdup(args0);
441     int ret;
442
443     arg = av_strtok(args, ":", &ptr);
444
445 #define ADD_FORMAT(fmt_name)                                            \
446     if (!arg)                                                           \
447         goto arg_fail;                                                  \
448     if ((ret = ff_parse_##fmt_name(&abuffer->fmt_name, arg, ctx)) < 0) { \
449         av_freep(&args);                                                \
450         return ret;                                                     \
451     }                                                                   \
452     if (*args)                                                          \
453         arg = av_strtok(NULL, ":", &ptr)
454
455     ADD_FORMAT(sample_rate);
456     ADD_FORMAT(sample_format);
457     ADD_FORMAT(channel_layout);
458     ADD_FORMAT(packing_format);
459
460     abuffer->fifo = av_fifo_alloc(FIFO_SIZE*sizeof(AVFilterBufferRef*));
461     if (!abuffer->fifo) {
462         av_log(ctx, AV_LOG_ERROR, "Failed to allocate fifo, filter init failed.\n");
463         return AVERROR(ENOMEM);
464     }
465
466     av_get_channel_layout_string(chlayout_str, sizeof(chlayout_str),
467                                  -1, abuffer->channel_layout);
468     av_log(ctx, AV_LOG_INFO, "format:%s layout:%s rate:%d\n",
469            av_get_sample_fmt_name(abuffer->sample_format), chlayout_str,
470            abuffer->sample_rate);
471     av_freep(&args);
472
473     return 0;
474
475 arg_fail:
476     av_log(ctx, AV_LOG_ERROR, "Invalid arguments, must be of the form "
477                               "sample_rate:sample_fmt:channel_layout:packing\n");
478     av_freep(&args);
479     return AVERROR(EINVAL);
480 }
481
482 static av_cold void uninit(AVFilterContext *ctx)
483 {
484     BufferSourceContext *s = ctx->priv;
485     while (s->fifo && av_fifo_size(s->fifo)) {
486         AVFilterBufferRef *buf;
487         av_fifo_generic_read(s->fifo, &buf, sizeof(buf), NULL);
488         avfilter_unref_buffer(buf);
489     }
490     av_fifo_free(s->fifo);
491     s->fifo = NULL;
492     avfilter_free(s->scale);
493     s->scale = NULL;
494 }
495
496 static int query_formats_video(AVFilterContext *ctx)
497 {
498     BufferSourceContext *c = ctx->priv;
499     enum PixelFormat pix_fmts[] = { c->pix_fmt, PIX_FMT_NONE };
500
501     avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts));
502     return 0;
503 }
504
505 static int query_formats_audio(AVFilterContext *ctx)
506 {
507     BufferSourceContext *abuffer = ctx->priv;
508     AVFilterFormats *formats;
509
510     formats = NULL;
511     avfilter_add_format(&formats, abuffer->sample_format);
512     avfilter_set_common_sample_formats(ctx, formats);
513
514     formats = NULL;
515     avfilter_add_format(&formats, abuffer->channel_layout);
516     avfilter_set_common_channel_layouts(ctx, formats);
517
518     formats = NULL;
519     avfilter_add_format(&formats, abuffer->packing_format);
520     avfilter_set_common_packing_formats(ctx, formats);
521
522     return 0;
523 }
524
525 static int config_output_video(AVFilterLink *link)
526 {
527     BufferSourceContext *c = link->src->priv;
528
529     link->w = c->w;
530     link->h = c->h;
531     link->sample_aspect_ratio = c->sample_aspect_ratio;
532     link->time_base = c->time_base;
533
534     return 0;
535 }
536
537 static int config_output_audio(AVFilterLink *outlink)
538 {
539     BufferSourceContext *abuffer = outlink->src->priv;
540     outlink->sample_rate = abuffer->sample_rate;
541     return 0;
542 }
543
544 static int request_frame(AVFilterLink *link)
545 {
546     BufferSourceContext *c = link->src->priv;
547     AVFilterBufferRef *buf;
548
549     if (!av_fifo_size(c->fifo)) {
550         if (c->eof)
551             return AVERROR_EOF;
552         c->nb_failed_requests++;
553         return AVERROR(EAGAIN);
554     }
555     av_fifo_generic_read(c->fifo, &buf, sizeof(buf), NULL);
556
557     switch (link->type) {
558     case AVMEDIA_TYPE_VIDEO:
559         avfilter_start_frame(link, avfilter_ref_buffer(buf, ~0));
560         avfilter_draw_slice(link, 0, link->h, 1);
561         avfilter_end_frame(link);
562         avfilter_unref_buffer(buf);
563         break;
564     case AVMEDIA_TYPE_AUDIO:
565         avfilter_filter_samples(link, avfilter_ref_buffer(buf, ~0));
566         avfilter_unref_buffer(buf);
567         break;
568     default:
569         return AVERROR(ENOSYS);
570     }
571     return 0;
572 }
573
574 static int poll_frame(AVFilterLink *link)
575 {
576     BufferSourceContext *c = link->src->priv;
577     int size = av_fifo_size(c->fifo);
578     if (!size && c->eof)
579         return AVERROR_EOF;
580     return size/sizeof(AVFilterBufferRef*);
581 }
582
583 int av_asrc_buffer_add_audio_buffer_ref(AVFilterContext *ctx,
584                                         AVFilterBufferRef *samplesref,
585                                         int av_unused flags)
586 {
587     return av_buffersrc_add_ref(ctx, samplesref, AV_BUFFERSRC_FLAG_NO_COPY);
588 }
589
590 int av_asrc_buffer_add_samples(AVFilterContext *ctx,
591                                uint8_t *data[8], int linesize[8],
592                                int nb_samples, int sample_rate,
593                                int sample_fmt, int64_t channel_layout, int planar,
594                                int64_t pts, int av_unused flags)
595 {
596     AVFilterBufferRef *samplesref;
597
598     samplesref = avfilter_get_audio_buffer_ref_from_arrays(
599                      data, linesize, AV_PERM_WRITE,
600                      nb_samples,
601                      sample_fmt, channel_layout, planar);
602     if (!samplesref)
603         return AVERROR(ENOMEM);
604
605     samplesref->buf->free  = buf_free;
606     samplesref->pts = pts;
607     samplesref->audio->sample_rate = sample_rate;
608
609     AV_NOWARN_DEPRECATED(
610     return av_asrc_buffer_add_audio_buffer_ref(ctx, samplesref, 0);
611     )
612 }
613
614 int av_asrc_buffer_add_buffer(AVFilterContext *ctx,
615                               uint8_t *buf, int buf_size, int sample_rate,
616                               int sample_fmt, int64_t channel_layout, int planar,
617                               int64_t pts, int av_unused flags)
618 {
619     uint8_t *data[8] = {0};
620     int linesize[8];
621     int nb_channels = av_get_channel_layout_nb_channels(channel_layout),
622         nb_samples  = buf_size / nb_channels / av_get_bytes_per_sample(sample_fmt);
623
624     av_samples_fill_arrays(data, linesize,
625                            buf, nb_channels, nb_samples,
626                            sample_fmt, 16);
627
628     AV_NOWARN_DEPRECATED(
629     return av_asrc_buffer_add_samples(ctx,
630                                       data, linesize, nb_samples,
631                                       sample_rate,
632                                       sample_fmt, channel_layout, planar,
633                                       pts, flags);
634     )
635 }
636
637 AVFilter avfilter_vsrc_buffer = {
638     .name      = "buffer",
639     .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them accessible to the filterchain."),
640     .priv_size = sizeof(BufferSourceContext),
641     .query_formats = query_formats_video,
642
643     .init      = init_video,
644     .uninit    = uninit,
645
646     .inputs    = (const AVFilterPad[]) {{ .name = NULL }},
647     .outputs   = (const AVFilterPad[]) {{ .name      = "default",
648                                     .type            = AVMEDIA_TYPE_VIDEO,
649                                     .request_frame   = request_frame,
650                                     .poll_frame      = poll_frame,
651                                     .config_props    = config_output_video, },
652                                   { .name = NULL}},
653 };
654
655 #ifdef CONFIG_ABUFFER_FILTER
656
657 AVFilter avfilter_asrc_abuffer = {
658     .name        = "abuffer",
659     .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them accessible to the filterchain."),
660     .priv_size   = sizeof(BufferSourceContext),
661     .query_formats = query_formats_audio,
662
663     .init        = init_audio,
664     .uninit      = uninit,
665
666     .inputs      = (const AVFilterPad[]) {{ .name = NULL }},
667     .outputs     = (const AVFilterPad[]) {{ .name      = "default",
668                                       .type            = AVMEDIA_TYPE_AUDIO,
669                                       .request_frame   = request_frame,
670                                       .poll_frame      = poll_frame,
671                                       .config_props    = config_output_audio, },
672                                     { .name = NULL}},
673 };
674
675 #endif