You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

659 lines
21KB

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