avfilter.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*
  2. * filter layer
  3. * Copyright (c) 2007 Bobby Bingham
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /* #define DEBUG */
  22. #include "libavutil/pixdesc.h"
  23. #include "libavutil/rational.h"
  24. #include "libavcore/imgutils.h"
  25. #include "avfilter.h"
  26. #include "internal.h"
  27. unsigned avfilter_version(void) {
  28. return LIBAVFILTER_VERSION_INT;
  29. }
  30. const char *avfilter_configuration(void)
  31. {
  32. return FFMPEG_CONFIGURATION;
  33. }
  34. const char *avfilter_license(void)
  35. {
  36. #define LICENSE_PREFIX "libavfilter license: "
  37. return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
  38. }
  39. AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
  40. {
  41. AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef));
  42. if (!ret)
  43. return NULL;
  44. *ret = *ref;
  45. if (ref->type == AVMEDIA_TYPE_VIDEO) {
  46. ret->video = av_malloc(sizeof(AVFilterBufferRefVideoProps));
  47. if (!ret->video) {
  48. av_free(ret);
  49. return NULL;
  50. }
  51. *ret->video = *ref->video;
  52. } else if (ref->type == AVMEDIA_TYPE_AUDIO) {
  53. ret->audio = av_malloc(sizeof(AVFilterBufferRefAudioProps));
  54. if (!ret->audio) {
  55. av_free(ret);
  56. return NULL;
  57. }
  58. *ret->audio = *ref->audio;
  59. }
  60. ret->perms &= pmask;
  61. ret->buf->refcount ++;
  62. return ret;
  63. }
  64. void avfilter_unref_buffer(AVFilterBufferRef *ref)
  65. {
  66. if (!(--ref->buf->refcount))
  67. ref->buf->free(ref->buf);
  68. av_free(ref->video);
  69. av_free(ref->audio);
  70. av_free(ref);
  71. }
  72. void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
  73. AVFilterPad **pads, AVFilterLink ***links,
  74. AVFilterPad *newpad)
  75. {
  76. unsigned i;
  77. idx = FFMIN(idx, *count);
  78. *pads = av_realloc(*pads, sizeof(AVFilterPad) * (*count + 1));
  79. *links = av_realloc(*links, sizeof(AVFilterLink*) * (*count + 1));
  80. memmove(*pads +idx+1, *pads +idx, sizeof(AVFilterPad) * (*count-idx));
  81. memmove(*links+idx+1, *links+idx, sizeof(AVFilterLink*) * (*count-idx));
  82. memcpy(*pads+idx, newpad, sizeof(AVFilterPad));
  83. (*links)[idx] = NULL;
  84. (*count)++;
  85. for (i = idx+1; i < *count; i++)
  86. if (*links[i])
  87. (*(unsigned *)((uint8_t *) *links[i] + padidx_off))++;
  88. }
  89. int avfilter_link(AVFilterContext *src, unsigned srcpad,
  90. AVFilterContext *dst, unsigned dstpad)
  91. {
  92. AVFilterLink *link;
  93. if (src->output_count <= srcpad || dst->input_count <= dstpad ||
  94. src->outputs[srcpad] || dst->inputs[dstpad])
  95. return -1;
  96. src->outputs[srcpad] =
  97. dst-> inputs[dstpad] = link = av_mallocz(sizeof(AVFilterLink));
  98. link->src = src;
  99. link->dst = dst;
  100. link->srcpad = &src->output_pads[srcpad];
  101. link->dstpad = &dst->input_pads[dstpad];
  102. link->type = src->output_pads[srcpad].type;
  103. assert(PIX_FMT_NONE == -1 && AV_SAMPLE_FMT_NONE == -1);
  104. link->format = -1;
  105. return 0;
  106. }
  107. int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
  108. unsigned filt_srcpad_idx, unsigned filt_dstpad_idx)
  109. {
  110. int ret;
  111. unsigned dstpad_idx = link->dstpad - link->dst->input_pads;
  112. av_log(link->dst, AV_LOG_INFO, "auto-inserting filter '%s' "
  113. "between the filter '%s' and the filter '%s'\n",
  114. filt->name, link->src->name, link->dst->name);
  115. link->dst->inputs[dstpad_idx] = NULL;
  116. if ((ret = avfilter_link(filt, filt_dstpad_idx, link->dst, dstpad_idx)) < 0) {
  117. /* failed to link output filter to new filter */
  118. link->dst->inputs[dstpad_idx] = link;
  119. return ret;
  120. }
  121. /* re-hookup the link to the new destination filter we inserted */
  122. link->dst = filt;
  123. link->dstpad = &filt->input_pads[filt_srcpad_idx];
  124. filt->inputs[filt_srcpad_idx] = link;
  125. /* if any information on supported media formats already exists on the
  126. * link, we need to preserve that */
  127. if (link->out_formats)
  128. avfilter_formats_changeref(&link->out_formats,
  129. &filt->outputs[filt_dstpad_idx]->out_formats);
  130. return 0;
  131. }
  132. int avfilter_config_links(AVFilterContext *filter)
  133. {
  134. int (*config_link)(AVFilterLink *);
  135. unsigned i;
  136. int ret;
  137. for (i = 0; i < filter->input_count; i ++) {
  138. AVFilterLink *link = filter->inputs[i];
  139. if (!link) continue;
  140. switch (link->init_state) {
  141. case AVLINK_INIT:
  142. continue;
  143. case AVLINK_STARTINIT:
  144. av_log(filter, AV_LOG_INFO, "circular filter chain detected\n");
  145. return 0;
  146. case AVLINK_UNINIT:
  147. link->init_state = AVLINK_STARTINIT;
  148. if ((ret = avfilter_config_links(link->src)) < 0)
  149. return ret;
  150. if (!(config_link = link->srcpad->config_props))
  151. config_link = avfilter_default_config_output_link;
  152. if ((ret = config_link(link)) < 0)
  153. return ret;
  154. if (link->time_base.num == 0 && link->time_base.den == 0)
  155. link->time_base = link->src && link->src->input_count ?
  156. link->src->inputs[0]->time_base : AV_TIME_BASE_Q;
  157. if ((config_link = link->dstpad->config_props))
  158. if ((ret = config_link(link)) < 0)
  159. return ret;
  160. link->init_state = AVLINK_INIT;
  161. }
  162. }
  163. return 0;
  164. }
  165. char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms)
  166. {
  167. snprintf(buf, buf_size, "%s%s%s%s%s",
  168. perms & AV_PERM_READ ? "r" : "",
  169. perms & AV_PERM_WRITE ? "w" : "",
  170. perms & AV_PERM_PRESERVE ? "p" : "",
  171. perms & AV_PERM_REUSE ? "u" : "",
  172. perms & AV_PERM_REUSE2 ? "U" : "");
  173. return buf;
  174. }
  175. void ff_dprintf_ref(void *ctx, AVFilterBufferRef *ref, int end)
  176. {
  177. av_unused char buf[16];
  178. dprintf(ctx,
  179. "ref[%p buf:%p refcount:%d perms:%s data:%p linesize[%d, %d, %d, %d] pts:%"PRId64" pos:%"PRId64,
  180. ref, ref->buf, ref->buf->refcount, ff_get_ref_perms_string(buf, sizeof(buf), ref->perms), ref->data[0],
  181. ref->linesize[0], ref->linesize[1], ref->linesize[2], ref->linesize[3],
  182. ref->pts, ref->pos);
  183. if (ref->video) {
  184. dprintf(ctx, " a:%d/%d s:%dx%d i:%c",
  185. ref->video->pixel_aspect.num, ref->video->pixel_aspect.den,
  186. ref->video->w, ref->video->h,
  187. !ref->video->interlaced ? 'P' : /* Progressive */
  188. ref->video->top_field_first ? 'T' : 'B'); /* Top / Bottom */
  189. }
  190. if (ref->audio) {
  191. dprintf(ctx, " cl:%"PRId64"d sn:%d s:%d sr:%d p:%d",
  192. ref->audio->channel_layout,
  193. ref->audio->samples_nb,
  194. ref->audio->size,
  195. ref->audio->sample_rate,
  196. ref->audio->planar);
  197. }
  198. dprintf(ctx, "]%s", end ? "\n" : "");
  199. }
  200. void ff_dprintf_link(void *ctx, AVFilterLink *link, int end)
  201. {
  202. dprintf(ctx,
  203. "link[%p s:%dx%d fmt:%-16s %-16s->%-16s]%s",
  204. link, link->w, link->h,
  205. av_pix_fmt_descriptors[link->format].name,
  206. link->src ? link->src->filter->name : "",
  207. link->dst ? link->dst->filter->name : "",
  208. end ? "\n" : "");
  209. }
  210. AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
  211. {
  212. AVFilterBufferRef *ret = NULL;
  213. av_unused char buf[16];
  214. FF_DPRINTF_START(NULL, get_video_buffer); ff_dprintf_link(NULL, link, 0);
  215. dprintf(NULL, " perms:%s w:%d h:%d\n", ff_get_ref_perms_string(buf, sizeof(buf), perms), w, h);
  216. if (link->dstpad->get_video_buffer)
  217. ret = link->dstpad->get_video_buffer(link, perms, w, h);
  218. if (!ret)
  219. ret = avfilter_default_get_video_buffer(link, perms, w, h);
  220. if (ret)
  221. ret->type = AVMEDIA_TYPE_VIDEO;
  222. FF_DPRINTF_START(NULL, get_video_buffer); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " returning "); ff_dprintf_ref(NULL, ret, 1);
  223. return ret;
  224. }
  225. AVFilterBufferRef *
  226. avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
  227. int w, int h, enum PixelFormat format)
  228. {
  229. AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer));
  230. AVFilterBufferRef *picref = av_mallocz(sizeof(AVFilterBufferRef));
  231. if (!pic || !picref)
  232. goto fail;
  233. picref->buf = pic;
  234. picref->buf->free = ff_avfilter_default_free_buffer;
  235. if (!(picref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps))))
  236. goto fail;
  237. picref->video->w = w;
  238. picref->video->h = h;
  239. /* make sure the buffer gets read permission or it's useless for output */
  240. picref->perms = perms | AV_PERM_READ;
  241. pic->refcount = 1;
  242. picref->type = AVMEDIA_TYPE_VIDEO;
  243. picref->format = format;
  244. memcpy(pic->data, data, sizeof(pic->data));
  245. memcpy(pic->linesize, linesize, sizeof(pic->linesize));
  246. memcpy(picref->data, pic->data, sizeof(picref->data));
  247. memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
  248. return picref;
  249. fail:
  250. if (picref && picref->video)
  251. av_free(picref->video);
  252. av_free(picref);
  253. av_free(pic);
  254. return NULL;
  255. }
  256. AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
  257. enum AVSampleFormat sample_fmt, int size,
  258. int64_t channel_layout, int planar)
  259. {
  260. AVFilterBufferRef *ret = NULL;
  261. if (link->dstpad->get_audio_buffer)
  262. ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar);
  263. if (!ret)
  264. ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, size, channel_layout, planar);
  265. if (ret)
  266. ret->type = AVMEDIA_TYPE_AUDIO;
  267. return ret;
  268. }
  269. int avfilter_request_frame(AVFilterLink *link)
  270. {
  271. FF_DPRINTF_START(NULL, request_frame); ff_dprintf_link(NULL, link, 1);
  272. if (link->srcpad->request_frame)
  273. return link->srcpad->request_frame(link);
  274. else if (link->src->inputs[0])
  275. return avfilter_request_frame(link->src->inputs[0]);
  276. else return -1;
  277. }
  278. int avfilter_poll_frame(AVFilterLink *link)
  279. {
  280. int i, min = INT_MAX;
  281. if (link->srcpad->poll_frame)
  282. return link->srcpad->poll_frame(link);
  283. for (i = 0; i < link->src->input_count; i++) {
  284. int val;
  285. if (!link->src->inputs[i])
  286. return -1;
  287. val = avfilter_poll_frame(link->src->inputs[i]);
  288. min = FFMIN(min, val);
  289. }
  290. return min;
  291. }
  292. /* XXX: should we do the duplicating of the picture ref here, instead of
  293. * forcing the source filter to do it? */
  294. void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
  295. {
  296. void (*start_frame)(AVFilterLink *, AVFilterBufferRef *);
  297. AVFilterPad *dst = link->dstpad;
  298. FF_DPRINTF_START(NULL, start_frame); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " "); ff_dprintf_ref(NULL, picref, 1);
  299. if (!(start_frame = dst->start_frame))
  300. start_frame = avfilter_default_start_frame;
  301. /* prepare to copy the picture if it has insufficient permissions */
  302. if ((dst->min_perms & picref->perms) != dst->min_perms ||
  303. dst->rej_perms & picref->perms) {
  304. av_log(link->dst, AV_LOG_DEBUG,
  305. "frame copy needed (have perms %x, need %x, reject %x)\n",
  306. picref->perms,
  307. link->dstpad->min_perms, link->dstpad->rej_perms);
  308. link->cur_buf = avfilter_get_video_buffer(link, dst->min_perms, link->w, link->h);
  309. link->src_buf = picref;
  310. avfilter_copy_buffer_ref_props(link->cur_buf, link->src_buf);
  311. }
  312. else
  313. link->cur_buf = picref;
  314. start_frame(link, link->cur_buf);
  315. }
  316. void avfilter_end_frame(AVFilterLink *link)
  317. {
  318. void (*end_frame)(AVFilterLink *);
  319. if (!(end_frame = link->dstpad->end_frame))
  320. end_frame = avfilter_default_end_frame;
  321. end_frame(link);
  322. /* unreference the source picture if we're feeding the destination filter
  323. * a copied version dues to permission issues */
  324. if (link->src_buf) {
  325. avfilter_unref_buffer(link->src_buf);
  326. link->src_buf = NULL;
  327. }
  328. }
  329. void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
  330. {
  331. uint8_t *src[4], *dst[4];
  332. int i, j, vsub;
  333. void (*draw_slice)(AVFilterLink *, int, int, int);
  334. FF_DPRINTF_START(NULL, draw_slice); ff_dprintf_link(NULL, link, 0); dprintf(NULL, " y:%d h:%d dir:%d\n", y, h, slice_dir);
  335. /* copy the slice if needed for permission reasons */
  336. if (link->src_buf) {
  337. vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h;
  338. for (i = 0; i < 4; i++) {
  339. if (link->src_buf->data[i]) {
  340. src[i] = link->src_buf-> data[i] +
  341. (y >> (i==0 ? 0 : vsub)) * link->src_buf-> linesize[i];
  342. dst[i] = link->cur_buf->data[i] +
  343. (y >> (i==0 ? 0 : vsub)) * link->cur_buf->linesize[i];
  344. } else
  345. src[i] = dst[i] = NULL;
  346. }
  347. for (i = 0; i < 4; i++) {
  348. int planew =
  349. av_image_get_linesize(link->format, link->cur_buf->video->w, i);
  350. if (!src[i]) continue;
  351. for (j = 0; j < h >> (i==0 ? 0 : vsub); j++) {
  352. memcpy(dst[i], src[i], planew);
  353. src[i] += link->src_buf->linesize[i];
  354. dst[i] += link->cur_buf->linesize[i];
  355. }
  356. }
  357. }
  358. if (!(draw_slice = link->dstpad->draw_slice))
  359. draw_slice = avfilter_default_draw_slice;
  360. draw_slice(link, y, h, slice_dir);
  361. }
  362. void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
  363. {
  364. void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *);
  365. AVFilterPad *dst = link->dstpad;
  366. if (!(filter_samples = dst->filter_samples))
  367. filter_samples = avfilter_default_filter_samples;
  368. /* prepare to copy the samples if the buffer has insufficient permissions */
  369. if ((dst->min_perms & samplesref->perms) != dst->min_perms ||
  370. dst->rej_perms & samplesref->perms) {
  371. av_log(link->dst, AV_LOG_DEBUG,
  372. "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n",
  373. samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms);
  374. link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms,
  375. samplesref->format,
  376. samplesref->audio->size,
  377. samplesref->audio->channel_layout,
  378. samplesref->audio->planar);
  379. link->cur_buf->pts = samplesref->pts;
  380. link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate;
  381. /* Copy actual data into new samples buffer */
  382. memcpy(link->cur_buf->data[0], samplesref->data[0], samplesref->audio->size);
  383. avfilter_unref_buffer(samplesref);
  384. } else
  385. link->cur_buf = samplesref;
  386. filter_samples(link, link->cur_buf);
  387. }
  388. #define MAX_REGISTERED_AVFILTERS_NB 64
  389. static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1];
  390. static int next_registered_avfilter_idx = 0;
  391. AVFilter *avfilter_get_by_name(const char *name)
  392. {
  393. int i;
  394. for (i = 0; registered_avfilters[i]; i++)
  395. if (!strcmp(registered_avfilters[i]->name, name))
  396. return registered_avfilters[i];
  397. return NULL;
  398. }
  399. int avfilter_register(AVFilter *filter)
  400. {
  401. if (next_registered_avfilter_idx == MAX_REGISTERED_AVFILTERS_NB)
  402. return -1;
  403. registered_avfilters[next_registered_avfilter_idx++] = filter;
  404. return 0;
  405. }
  406. AVFilter **av_filter_next(AVFilter **filter)
  407. {
  408. return filter ? ++filter : &registered_avfilters[0];
  409. }
  410. void avfilter_uninit(void)
  411. {
  412. memset(registered_avfilters, 0, sizeof(registered_avfilters));
  413. next_registered_avfilter_idx = 0;
  414. }
  415. static int pad_count(const AVFilterPad *pads)
  416. {
  417. int count;
  418. for(count = 0; pads->name; count ++) pads ++;
  419. return count;
  420. }
  421. static const char *filter_name(void *p)
  422. {
  423. AVFilterContext *filter = p;
  424. return filter->filter->name;
  425. }
  426. static const AVClass avfilter_class = {
  427. "AVFilter",
  428. filter_name,
  429. NULL,
  430. LIBAVUTIL_VERSION_INT,
  431. };
  432. int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
  433. {
  434. AVFilterContext *ret;
  435. *filter_ctx = NULL;
  436. if (!filter)
  437. return AVERROR(EINVAL);
  438. ret = av_mallocz(sizeof(AVFilterContext));
  439. ret->av_class = &avfilter_class;
  440. ret->filter = filter;
  441. ret->name = inst_name ? av_strdup(inst_name) : NULL;
  442. ret->priv = av_mallocz(filter->priv_size);
  443. ret->input_count = pad_count(filter->inputs);
  444. if (ret->input_count) {
  445. ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count);
  446. memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->input_count);
  447. ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count);
  448. }
  449. ret->output_count = pad_count(filter->outputs);
  450. if (ret->output_count) {
  451. ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count);
  452. memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->output_count);
  453. ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count);
  454. }
  455. *filter_ctx = ret;
  456. return 0;
  457. }
  458. void avfilter_free(AVFilterContext *filter)
  459. {
  460. int i;
  461. AVFilterLink *link;
  462. if (filter->filter->uninit)
  463. filter->filter->uninit(filter);
  464. for (i = 0; i < filter->input_count; i++) {
  465. if ((link = filter->inputs[i])) {
  466. if (link->src)
  467. link->src->outputs[link->srcpad - link->src->output_pads] = NULL;
  468. avfilter_formats_unref(&link->in_formats);
  469. avfilter_formats_unref(&link->out_formats);
  470. }
  471. av_freep(&link);
  472. }
  473. for (i = 0; i < filter->output_count; i++) {
  474. if ((link = filter->outputs[i])) {
  475. if (link->dst)
  476. link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;
  477. avfilter_formats_unref(&link->in_formats);
  478. avfilter_formats_unref(&link->out_formats);
  479. }
  480. av_freep(&link);
  481. }
  482. av_freep(&filter->name);
  483. av_freep(&filter->input_pads);
  484. av_freep(&filter->output_pads);
  485. av_freep(&filter->inputs);
  486. av_freep(&filter->outputs);
  487. av_freep(&filter->priv);
  488. av_free(filter);
  489. }
  490. int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque)
  491. {
  492. int ret=0;
  493. if (filter->filter->init)
  494. ret = filter->filter->init(filter, args, opaque);
  495. return ret;
  496. }