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