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.

677 lines
22KB

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