buffersink.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. /*
  2. * Copyright (c) 2011 Stefano Sabatini
  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. * @file
  22. * buffer sink
  23. */
  24. #include "libavutil/audio_fifo.h"
  25. #include "libavutil/avassert.h"
  26. #include "libavutil/channel_layout.h"
  27. #include "libavutil/common.h"
  28. #include "libavutil/internal.h"
  29. #include "libavutil/mathematics.h"
  30. #include "libavutil/opt.h"
  31. #include "audio.h"
  32. #include "avfilter.h"
  33. #include "buffersink.h"
  34. #include "internal.h"
  35. typedef struct BufferSinkContext {
  36. const AVClass *class;
  37. AVFifoBuffer *fifo; ///< FIFO buffer of video frame references
  38. unsigned warning_limit;
  39. /* only used for video */
  40. enum AVPixelFormat *pixel_fmts; ///< list of accepted pixel formats, must be terminated with -1
  41. int pixel_fmts_size;
  42. /* only used for audio */
  43. enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE
  44. int sample_fmts_size;
  45. int64_t *channel_layouts; ///< list of accepted channel layouts, terminated by -1
  46. int channel_layouts_size;
  47. int *channel_counts; ///< list of accepted channel counts, terminated by -1
  48. int channel_counts_size;
  49. int all_channel_counts;
  50. int *sample_rates; ///< list of accepted sample rates, terminated by -1
  51. int sample_rates_size;
  52. /* only used for compat API */
  53. AVAudioFifo *audio_fifo; ///< FIFO for audio samples
  54. int64_t next_pts; ///< interpolating audio pts
  55. } BufferSinkContext;
  56. #define NB_ITEMS(list) (list ## _size / sizeof(*list))
  57. static av_cold void uninit(AVFilterContext *ctx)
  58. {
  59. BufferSinkContext *sink = ctx->priv;
  60. AVFrame *frame;
  61. if (sink->audio_fifo)
  62. av_audio_fifo_free(sink->audio_fifo);
  63. if (sink->fifo) {
  64. while (av_fifo_size(sink->fifo) >= sizeof(AVFilterBufferRef *)) {
  65. av_fifo_generic_read(sink->fifo, &frame, sizeof(frame), NULL);
  66. av_frame_free(&frame);
  67. }
  68. av_fifo_freep(&sink->fifo);
  69. }
  70. }
  71. static int add_buffer_ref(AVFilterContext *ctx, AVFrame *ref)
  72. {
  73. BufferSinkContext *buf = ctx->priv;
  74. if (av_fifo_space(buf->fifo) < sizeof(AVFilterBufferRef *)) {
  75. /* realloc fifo size */
  76. if (av_fifo_realloc2(buf->fifo, av_fifo_size(buf->fifo) * 2) < 0) {
  77. av_log(ctx, AV_LOG_ERROR,
  78. "Cannot buffer more frames. Consume some available frames "
  79. "before adding new ones.\n");
  80. return AVERROR(ENOMEM);
  81. }
  82. }
  83. /* cache frame */
  84. av_fifo_generic_write(buf->fifo, &ref, sizeof(AVFilterBufferRef *), NULL);
  85. return 0;
  86. }
  87. static int filter_frame(AVFilterLink *link, AVFrame *frame)
  88. {
  89. AVFilterContext *ctx = link->dst;
  90. BufferSinkContext *buf = link->dst->priv;
  91. int ret;
  92. if ((ret = add_buffer_ref(ctx, frame)) < 0)
  93. return ret;
  94. if (buf->warning_limit &&
  95. av_fifo_size(buf->fifo) / sizeof(AVFilterBufferRef *) >= buf->warning_limit) {
  96. av_log(ctx, AV_LOG_WARNING,
  97. "%d buffers queued in %s, something may be wrong.\n",
  98. buf->warning_limit,
  99. (char *)av_x_if_null(ctx->name, ctx->filter->name));
  100. buf->warning_limit *= 10;
  101. }
  102. return 0;
  103. }
  104. int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame)
  105. {
  106. return av_buffersink_get_frame_flags(ctx, frame, 0);
  107. }
  108. int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
  109. {
  110. BufferSinkContext *buf = ctx->priv;
  111. AVFilterLink *inlink = ctx->inputs[0];
  112. int ret;
  113. AVFrame *cur_frame;
  114. /* no picref available, fetch it from the filterchain */
  115. if (!av_fifo_size(buf->fifo)) {
  116. if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST)
  117. return AVERROR(EAGAIN);
  118. if ((ret = ff_request_frame(inlink)) < 0)
  119. return ret;
  120. }
  121. if (!av_fifo_size(buf->fifo))
  122. return AVERROR(EINVAL);
  123. if (flags & AV_BUFFERSINK_FLAG_PEEK) {
  124. cur_frame = *((AVFrame **)av_fifo_peek2(buf->fifo, 0));
  125. if ((ret = av_frame_ref(frame, cur_frame)) < 0)
  126. return ret;
  127. } else {
  128. av_fifo_generic_read(buf->fifo, &cur_frame, sizeof(cur_frame), NULL);
  129. av_frame_move_ref(frame, cur_frame);
  130. av_frame_free(&cur_frame);
  131. }
  132. return 0;
  133. }
  134. static int read_from_fifo(AVFilterContext *ctx, AVFrame *frame,
  135. int nb_samples)
  136. {
  137. BufferSinkContext *s = ctx->priv;
  138. AVFilterLink *link = ctx->inputs[0];
  139. AVFrame *tmp;
  140. if (!(tmp = ff_get_audio_buffer(link, nb_samples)))
  141. return AVERROR(ENOMEM);
  142. av_audio_fifo_read(s->audio_fifo, (void**)tmp->extended_data, nb_samples);
  143. tmp->pts = s->next_pts;
  144. if (s->next_pts != AV_NOPTS_VALUE)
  145. s->next_pts += av_rescale_q(nb_samples, (AVRational){1, link->sample_rate},
  146. link->time_base);
  147. av_frame_move_ref(frame, tmp);
  148. av_frame_free(&tmp);
  149. return 0;
  150. }
  151. int attribute_align_arg av_buffersink_get_samples(AVFilterContext *ctx,
  152. AVFrame *frame, int nb_samples)
  153. {
  154. BufferSinkContext *s = ctx->priv;
  155. AVFilterLink *link = ctx->inputs[0];
  156. AVFrame *cur_frame;
  157. int ret = 0;
  158. if (!s->audio_fifo) {
  159. int nb_channels = link->channels;
  160. if (!(s->audio_fifo = av_audio_fifo_alloc(link->format, nb_channels, nb_samples)))
  161. return AVERROR(ENOMEM);
  162. }
  163. while (ret >= 0) {
  164. if (av_audio_fifo_size(s->audio_fifo) >= nb_samples)
  165. return read_from_fifo(ctx, frame, nb_samples);
  166. if (!(cur_frame = av_frame_alloc()))
  167. return AVERROR(ENOMEM);
  168. ret = av_buffersink_get_frame_flags(ctx, cur_frame, 0);
  169. if (ret == AVERROR_EOF && av_audio_fifo_size(s->audio_fifo)) {
  170. av_frame_free(&cur_frame);
  171. return read_from_fifo(ctx, frame, av_audio_fifo_size(s->audio_fifo));
  172. } else if (ret < 0) {
  173. av_frame_free(&cur_frame);
  174. return ret;
  175. }
  176. if (cur_frame->pts != AV_NOPTS_VALUE) {
  177. s->next_pts = cur_frame->pts -
  178. av_rescale_q(av_audio_fifo_size(s->audio_fifo),
  179. (AVRational){ 1, link->sample_rate },
  180. link->time_base);
  181. }
  182. ret = av_audio_fifo_write(s->audio_fifo, (void**)cur_frame->extended_data,
  183. cur_frame->nb_samples);
  184. av_frame_free(&cur_frame);
  185. }
  186. return ret;
  187. }
  188. AVBufferSinkParams *av_buffersink_params_alloc(void)
  189. {
  190. static const int pixel_fmts[] = { AV_PIX_FMT_NONE };
  191. AVBufferSinkParams *params = av_malloc(sizeof(AVBufferSinkParams));
  192. if (!params)
  193. return NULL;
  194. params->pixel_fmts = pixel_fmts;
  195. return params;
  196. }
  197. AVABufferSinkParams *av_abuffersink_params_alloc(void)
  198. {
  199. AVABufferSinkParams *params = av_mallocz(sizeof(AVABufferSinkParams));
  200. if (!params)
  201. return NULL;
  202. return params;
  203. }
  204. #define FIFO_INIT_SIZE 8
  205. static av_cold int common_init(AVFilterContext *ctx)
  206. {
  207. BufferSinkContext *buf = ctx->priv;
  208. buf->fifo = av_fifo_alloc_array(FIFO_INIT_SIZE, sizeof(AVFilterBufferRef *));
  209. if (!buf->fifo) {
  210. av_log(ctx, AV_LOG_ERROR, "Failed to allocate fifo\n");
  211. return AVERROR(ENOMEM);
  212. }
  213. buf->warning_limit = 100;
  214. buf->next_pts = AV_NOPTS_VALUE;
  215. return 0;
  216. }
  217. void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
  218. {
  219. AVFilterLink *inlink = ctx->inputs[0];
  220. inlink->min_samples = inlink->max_samples =
  221. inlink->partial_buf_size = frame_size;
  222. }
  223. #if FF_API_AVFILTERBUFFER
  224. FF_DISABLE_DEPRECATION_WARNINGS
  225. static void compat_free_buffer(AVFilterBuffer *buf)
  226. {
  227. AVFrame *frame = buf->priv;
  228. av_frame_free(&frame);
  229. av_free(buf);
  230. }
  231. static int compat_read(AVFilterContext *ctx,
  232. AVFilterBufferRef **pbuf, int nb_samples, int flags)
  233. {
  234. AVFilterBufferRef *buf;
  235. AVFrame *frame;
  236. int ret;
  237. if (!pbuf)
  238. return ff_poll_frame(ctx->inputs[0]);
  239. frame = av_frame_alloc();
  240. if (!frame)
  241. return AVERROR(ENOMEM);
  242. if (!nb_samples)
  243. ret = av_buffersink_get_frame_flags(ctx, frame, flags);
  244. else
  245. ret = av_buffersink_get_samples(ctx, frame, nb_samples);
  246. if (ret < 0)
  247. goto fail;
  248. AV_NOWARN_DEPRECATED(
  249. if (ctx->inputs[0]->type == AVMEDIA_TYPE_VIDEO) {
  250. buf = avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize,
  251. AV_PERM_READ,
  252. frame->width, frame->height,
  253. frame->format);
  254. } else {
  255. buf = avfilter_get_audio_buffer_ref_from_arrays(frame->extended_data,
  256. frame->linesize[0], AV_PERM_READ,
  257. frame->nb_samples,
  258. frame->format,
  259. frame->channel_layout);
  260. }
  261. if (!buf) {
  262. ret = AVERROR(ENOMEM);
  263. goto fail;
  264. }
  265. avfilter_copy_frame_props(buf, frame);
  266. )
  267. buf->buf->priv = frame;
  268. buf->buf->free = compat_free_buffer;
  269. *pbuf = buf;
  270. return 0;
  271. fail:
  272. av_frame_free(&frame);
  273. return ret;
  274. }
  275. int attribute_align_arg av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf)
  276. {
  277. return compat_read(ctx, buf, 0, 0);
  278. }
  279. int attribute_align_arg av_buffersink_read_samples(AVFilterContext *ctx, AVFilterBufferRef **buf,
  280. int nb_samples)
  281. {
  282. return compat_read(ctx, buf, nb_samples, 0);
  283. }
  284. int attribute_align_arg av_buffersink_get_buffer_ref(AVFilterContext *ctx,
  285. AVFilterBufferRef **bufref, int flags)
  286. {
  287. *bufref = NULL;
  288. av_assert0( !strcmp(ctx->filter->name, "buffersink")
  289. || !strcmp(ctx->filter->name, "abuffersink")
  290. || !strcmp(ctx->filter->name, "ffbuffersink")
  291. || !strcmp(ctx->filter->name, "ffabuffersink"));
  292. return compat_read(ctx, bufref, 0, flags);
  293. }
  294. FF_ENABLE_DEPRECATION_WARNINGS
  295. #endif
  296. AVRational av_buffersink_get_frame_rate(AVFilterContext *ctx)
  297. {
  298. av_assert0( !strcmp(ctx->filter->name, "buffersink")
  299. || !strcmp(ctx->filter->name, "ffbuffersink"));
  300. return ctx->inputs[0]->frame_rate;
  301. }
  302. int attribute_align_arg av_buffersink_poll_frame(AVFilterContext *ctx)
  303. {
  304. BufferSinkContext *buf = ctx->priv;
  305. AVFilterLink *inlink = ctx->inputs[0];
  306. av_assert0( !strcmp(ctx->filter->name, "buffersink")
  307. || !strcmp(ctx->filter->name, "abuffersink")
  308. || !strcmp(ctx->filter->name, "ffbuffersink")
  309. || !strcmp(ctx->filter->name, "ffabuffersink"));
  310. return av_fifo_size(buf->fifo)/sizeof(AVFilterBufferRef *) + ff_poll_frame(inlink);
  311. }
  312. static av_cold int vsink_init(AVFilterContext *ctx, void *opaque)
  313. {
  314. BufferSinkContext *buf = ctx->priv;
  315. AVBufferSinkParams *params = opaque;
  316. int ret;
  317. if (params) {
  318. if ((ret = av_opt_set_int_list(buf, "pix_fmts", params->pixel_fmts, AV_PIX_FMT_NONE, 0)) < 0)
  319. return ret;
  320. }
  321. return common_init(ctx);
  322. }
  323. #define CHECK_LIST_SIZE(field) \
  324. if (buf->field ## _size % sizeof(*buf->field)) { \
  325. av_log(ctx, AV_LOG_ERROR, "Invalid size for " #field ": %d, " \
  326. "should be multiple of %d\n", \
  327. buf->field ## _size, (int)sizeof(*buf->field)); \
  328. return AVERROR(EINVAL); \
  329. }
  330. static int vsink_query_formats(AVFilterContext *ctx)
  331. {
  332. BufferSinkContext *buf = ctx->priv;
  333. AVFilterFormats *formats = NULL;
  334. unsigned i;
  335. int ret;
  336. CHECK_LIST_SIZE(pixel_fmts)
  337. if (buf->pixel_fmts_size) {
  338. for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++)
  339. if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0) {
  340. ff_formats_unref(&formats);
  341. return ret;
  342. }
  343. ff_set_common_formats(ctx, formats);
  344. } else {
  345. ff_default_query_formats(ctx);
  346. }
  347. return 0;
  348. }
  349. static av_cold int asink_init(AVFilterContext *ctx, void *opaque)
  350. {
  351. BufferSinkContext *buf = ctx->priv;
  352. AVABufferSinkParams *params = opaque;
  353. int ret;
  354. if (params) {
  355. if ((ret = av_opt_set_int_list(buf, "sample_fmts", params->sample_fmts, AV_SAMPLE_FMT_NONE, 0)) < 0 ||
  356. (ret = av_opt_set_int_list(buf, "sample_rates", params->sample_rates, -1, 0)) < 0 ||
  357. (ret = av_opt_set_int_list(buf, "channel_layouts", params->channel_layouts, -1, 0)) < 0 ||
  358. (ret = av_opt_set_int_list(buf, "channel_counts", params->channel_counts, -1, 0)) < 0 ||
  359. (ret = av_opt_set_int(buf, "all_channel_counts", params->all_channel_counts, 0)) < 0)
  360. return ret;
  361. }
  362. return common_init(ctx);
  363. }
  364. static int asink_query_formats(AVFilterContext *ctx)
  365. {
  366. BufferSinkContext *buf = ctx->priv;
  367. AVFilterFormats *formats = NULL;
  368. AVFilterChannelLayouts *layouts = NULL;
  369. unsigned i;
  370. int ret;
  371. CHECK_LIST_SIZE(sample_fmts)
  372. CHECK_LIST_SIZE(sample_rates)
  373. CHECK_LIST_SIZE(channel_layouts)
  374. CHECK_LIST_SIZE(channel_counts)
  375. if (buf->sample_fmts_size) {
  376. for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++)
  377. if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0) {
  378. ff_formats_unref(&formats);
  379. return ret;
  380. }
  381. ff_set_common_formats(ctx, formats);
  382. }
  383. if (buf->channel_layouts_size || buf->channel_counts_size ||
  384. buf->all_channel_counts) {
  385. for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++)
  386. if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0) {
  387. ff_channel_layouts_unref(&layouts);
  388. return ret;
  389. }
  390. for (i = 0; i < NB_ITEMS(buf->channel_counts); i++)
  391. if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0) {
  392. ff_channel_layouts_unref(&layouts);
  393. return ret;
  394. }
  395. if (buf->all_channel_counts) {
  396. if (layouts)
  397. av_log(ctx, AV_LOG_WARNING,
  398. "Conflicting all_channel_counts and list in options\n");
  399. else if (!(layouts = ff_all_channel_counts()))
  400. return AVERROR(ENOMEM);
  401. }
  402. ff_set_common_channel_layouts(ctx, layouts);
  403. }
  404. if (buf->sample_rates_size) {
  405. formats = NULL;
  406. for (i = 0; i < NB_ITEMS(buf->sample_rates); i++)
  407. if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0) {
  408. ff_formats_unref(&formats);
  409. return ret;
  410. }
  411. ff_set_common_samplerates(ctx, formats);
  412. }
  413. return 0;
  414. }
  415. #define OFFSET(x) offsetof(BufferSinkContext, x)
  416. #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
  417. static const AVOption buffersink_options[] = {
  418. { "pix_fmts", "set the supported pixel formats", OFFSET(pixel_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
  419. { NULL },
  420. };
  421. #undef FLAGS
  422. #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
  423. static const AVOption abuffersink_options[] = {
  424. { "sample_fmts", "set the supported sample formats", OFFSET(sample_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
  425. { "sample_rates", "set the supported sample rates", OFFSET(sample_rates), AV_OPT_TYPE_BINARY, .flags = FLAGS },
  426. { "channel_layouts", "set the supported channel layouts", OFFSET(channel_layouts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
  427. { "channel_counts", "set the supported channel counts", OFFSET(channel_counts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
  428. { "all_channel_counts", "accept all channel counts", OFFSET(all_channel_counts), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, FLAGS },
  429. { NULL },
  430. };
  431. #undef FLAGS
  432. AVFILTER_DEFINE_CLASS(buffersink);
  433. AVFILTER_DEFINE_CLASS(abuffersink);
  434. #if FF_API_AVFILTERBUFFER
  435. #define ffbuffersink_options buffersink_options
  436. #define ffabuffersink_options abuffersink_options
  437. AVFILTER_DEFINE_CLASS(ffbuffersink);
  438. AVFILTER_DEFINE_CLASS(ffabuffersink);
  439. static const AVFilterPad ffbuffersink_inputs[] = {
  440. {
  441. .name = "default",
  442. .type = AVMEDIA_TYPE_VIDEO,
  443. .filter_frame = filter_frame,
  444. },
  445. { NULL },
  446. };
  447. AVFilter ff_vsink_ffbuffersink = {
  448. .name = "ffbuffersink",
  449. .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them available to the end of the filter graph."),
  450. .priv_size = sizeof(BufferSinkContext),
  451. .priv_class = &ffbuffersink_class,
  452. .init_opaque = vsink_init,
  453. .uninit = uninit,
  454. .query_formats = vsink_query_formats,
  455. .inputs = ffbuffersink_inputs,
  456. .outputs = NULL,
  457. };
  458. static const AVFilterPad ffabuffersink_inputs[] = {
  459. {
  460. .name = "default",
  461. .type = AVMEDIA_TYPE_AUDIO,
  462. .filter_frame = filter_frame,
  463. },
  464. { NULL },
  465. };
  466. AVFilter ff_asink_ffabuffersink = {
  467. .name = "ffabuffersink",
  468. .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."),
  469. .init_opaque = asink_init,
  470. .uninit = uninit,
  471. .priv_size = sizeof(BufferSinkContext),
  472. .priv_class = &ffabuffersink_class,
  473. .query_formats = asink_query_formats,
  474. .inputs = ffabuffersink_inputs,
  475. .outputs = NULL,
  476. };
  477. #endif /* FF_API_AVFILTERBUFFER */
  478. static const AVFilterPad avfilter_vsink_buffer_inputs[] = {
  479. {
  480. .name = "default",
  481. .type = AVMEDIA_TYPE_VIDEO,
  482. .filter_frame = filter_frame,
  483. },
  484. { NULL }
  485. };
  486. AVFilter ff_vsink_buffer = {
  487. .name = "buffersink",
  488. .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them available to the end of the filter graph."),
  489. .priv_size = sizeof(BufferSinkContext),
  490. .priv_class = &buffersink_class,
  491. .init_opaque = vsink_init,
  492. .uninit = uninit,
  493. .query_formats = vsink_query_formats,
  494. .inputs = avfilter_vsink_buffer_inputs,
  495. .outputs = NULL,
  496. };
  497. static const AVFilterPad avfilter_asink_abuffer_inputs[] = {
  498. {
  499. .name = "default",
  500. .type = AVMEDIA_TYPE_AUDIO,
  501. .filter_frame = filter_frame,
  502. },
  503. { NULL }
  504. };
  505. AVFilter ff_asink_abuffer = {
  506. .name = "abuffersink",
  507. .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."),
  508. .priv_class = &abuffersink_class,
  509. .priv_size = sizeof(BufferSinkContext),
  510. .init_opaque = asink_init,
  511. .uninit = uninit,
  512. .query_formats = asink_query_formats,
  513. .inputs = avfilter_asink_abuffer_inputs,
  514. .outputs = NULL,
  515. };