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.

746 lines
27KB

  1. /*
  2. * filter layer
  3. * Copyright (c) 2007 Bobby Bingham
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef AVFILTER_AVFILTER_H
  22. #define AVFILTER_AVFILTER_H
  23. #include "libavutil/avutil.h"
  24. #include "libavutil/log.h"
  25. #include "libavutil/samplefmt.h"
  26. #include "libavutil/pixfmt.h"
  27. #include "libavutil/rational.h"
  28. #include "libavcodec/avcodec.h"
  29. #include <stddef.h>
  30. #include "libavfilter/version.h"
  31. /**
  32. * Return the LIBAVFILTER_VERSION_INT constant.
  33. */
  34. unsigned avfilter_version(void);
  35. /**
  36. * Return the libavfilter build-time configuration.
  37. */
  38. const char *avfilter_configuration(void);
  39. /**
  40. * Return the libavfilter license.
  41. */
  42. const char *avfilter_license(void);
  43. typedef struct AVFilterContext AVFilterContext;
  44. typedef struct AVFilterLink AVFilterLink;
  45. typedef struct AVFilterPad AVFilterPad;
  46. typedef struct AVFilterFormats AVFilterFormats;
  47. /**
  48. * A reference-counted buffer data type used by the filter system. Filters
  49. * should not store pointers to this structure directly, but instead use the
  50. * AVFilterBufferRef structure below.
  51. */
  52. typedef struct AVFilterBuffer {
  53. uint8_t *data[8]; ///< buffer data for each plane/channel
  54. int linesize[8]; ///< number of bytes per line
  55. unsigned refcount; ///< number of references to this buffer
  56. /** private data to be used by a custom free function */
  57. void *priv;
  58. /**
  59. * A pointer to the function to deallocate this buffer if the default
  60. * function is not sufficient. This could, for example, add the memory
  61. * back into a memory pool to be reused later without the overhead of
  62. * reallocating it from scratch.
  63. */
  64. void (*free)(struct AVFilterBuffer *buf);
  65. int format; ///< media format
  66. int w, h; ///< width and height of the allocated buffer
  67. /**
  68. * pointers to the data planes/channels.
  69. *
  70. * For video, this should simply point to data[].
  71. *
  72. * For planar audio, each channel has a separate data pointer, and
  73. * linesize[0] contains the size of each channel buffer.
  74. * For packed audio, there is just one data pointer, and linesize[0]
  75. * contains the total size of the buffer for all channels.
  76. *
  77. * Note: Both data and extended_data will always be set, but for planar
  78. * audio with more channels that can fit in data, extended_data must be used
  79. * in order to access all channels.
  80. */
  81. uint8_t **extended_data;
  82. } AVFilterBuffer;
  83. #define AV_PERM_READ 0x01 ///< can read from the buffer
  84. #define AV_PERM_WRITE 0x02 ///< can write to the buffer
  85. #define AV_PERM_PRESERVE 0x04 ///< nobody else can overwrite the buffer
  86. #define AV_PERM_REUSE 0x08 ///< can output the buffer multiple times, with the same contents each time
  87. #define AV_PERM_REUSE2 0x10 ///< can output the buffer multiple times, modified each time
  88. #define AV_PERM_NEG_LINESIZES 0x20 ///< the buffer requested can have negative linesizes
  89. /**
  90. * Audio specific properties in a reference to an AVFilterBuffer. Since
  91. * AVFilterBufferRef is common to different media formats, audio specific
  92. * per reference properties must be separated out.
  93. */
  94. typedef struct AVFilterBufferRefAudioProps {
  95. uint64_t channel_layout; ///< channel layout of audio buffer
  96. int nb_samples; ///< number of audio samples
  97. int sample_rate; ///< audio buffer sample rate
  98. int planar; ///< audio buffer - planar or packed
  99. } AVFilterBufferRefAudioProps;
  100. /**
  101. * Video specific properties in a reference to an AVFilterBuffer. Since
  102. * AVFilterBufferRef is common to different media formats, video specific
  103. * per reference properties must be separated out.
  104. */
  105. typedef struct AVFilterBufferRefVideoProps {
  106. int w; ///< image width
  107. int h; ///< image height
  108. AVRational pixel_aspect; ///< pixel aspect ratio
  109. int interlaced; ///< is frame interlaced
  110. int top_field_first; ///< field order
  111. enum AVPictureType pict_type; ///< picture type of the frame
  112. int key_frame; ///< 1 -> keyframe, 0-> not
  113. } AVFilterBufferRefVideoProps;
  114. /**
  115. * A reference to an AVFilterBuffer. Since filters can manipulate the origin of
  116. * a buffer to, for example, crop image without any memcpy, the buffer origin
  117. * and dimensions are per-reference properties. Linesize is also useful for
  118. * image flipping, frame to field filters, etc, and so is also per-reference.
  119. *
  120. * TODO: add anything necessary for frame reordering
  121. */
  122. typedef struct AVFilterBufferRef {
  123. AVFilterBuffer *buf; ///< the buffer that this is a reference to
  124. uint8_t *data[8]; ///< picture/audio data for each plane
  125. int linesize[8]; ///< number of bytes per line
  126. int format; ///< media format
  127. /**
  128. * presentation timestamp. The time unit may change during
  129. * filtering, as it is specified in the link and the filter code
  130. * may need to rescale the PTS accordingly.
  131. */
  132. int64_t pts;
  133. int64_t pos; ///< byte position in stream, -1 if unknown
  134. int perms; ///< permissions, see the AV_PERM_* flags
  135. enum AVMediaType type; ///< media type of buffer data
  136. AVFilterBufferRefVideoProps *video; ///< video buffer specific properties
  137. AVFilterBufferRefAudioProps *audio; ///< audio buffer specific properties
  138. /**
  139. * pointers to the data planes/channels.
  140. *
  141. * For video, this should simply point to data[].
  142. *
  143. * For planar audio, each channel has a separate data pointer, and
  144. * linesize[0] contains the size of each channel buffer.
  145. * For packed audio, there is just one data pointer, and linesize[0]
  146. * contains the total size of the buffer for all channels.
  147. *
  148. * Note: Both data and extended_data will always be set, but for planar
  149. * audio with more channels that can fit in data, extended_data must be used
  150. * in order to access all channels.
  151. */
  152. uint8_t **extended_data;
  153. } AVFilterBufferRef;
  154. /**
  155. * Copy properties of src to dst, without copying the actual data
  156. */
  157. void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src);
  158. /**
  159. * Add a new reference to a buffer.
  160. *
  161. * @param ref an existing reference to the buffer
  162. * @param pmask a bitmask containing the allowable permissions in the new
  163. * reference
  164. * @return a new reference to the buffer with the same properties as the
  165. * old, excluding any permissions denied by pmask
  166. */
  167. AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
  168. /**
  169. * Remove a reference to a buffer. If this is the last reference to the
  170. * buffer, the buffer itself is also automatically freed.
  171. *
  172. * @param ref reference to the buffer, may be NULL
  173. */
  174. void avfilter_unref_buffer(AVFilterBufferRef *ref);
  175. #if FF_API_FILTERS_PUBLIC
  176. /**
  177. * @addtogroup lavfi_deprecated
  178. * @deprecated Those functions are only useful inside filters and
  179. * user filters are not supported at this point.
  180. * @{
  181. */
  182. struct AVFilterFormats {
  183. unsigned format_count; ///< number of formats
  184. int *formats; ///< list of media formats
  185. unsigned refcount; ///< number of references to this list
  186. struct AVFilterFormats ***refs; ///< references to this list
  187. };
  188. attribute_deprecated
  189. AVFilterFormats *avfilter_make_format_list(const int *fmts);
  190. attribute_deprecated
  191. int avfilter_add_format(AVFilterFormats **avff, int fmt);
  192. attribute_deprecated
  193. AVFilterFormats *avfilter_all_formats(enum AVMediaType type);
  194. attribute_deprecated
  195. AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b);
  196. attribute_deprecated
  197. void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref);
  198. attribute_deprecated
  199. void avfilter_formats_unref(AVFilterFormats **ref);
  200. attribute_deprecated
  201. void avfilter_formats_changeref(AVFilterFormats **oldref,
  202. AVFilterFormats **newref);
  203. attribute_deprecated
  204. void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats);
  205. /**
  206. * @}
  207. */
  208. #endif
  209. /**
  210. * A filter pad used for either input or output.
  211. */
  212. struct AVFilterPad {
  213. /**
  214. * Pad name. The name is unique among inputs and among outputs, but an
  215. * input may have the same name as an output. This may be NULL if this
  216. * pad has no need to ever be referenced by name.
  217. */
  218. const char *name;
  219. /**
  220. * AVFilterPad type.
  221. */
  222. enum AVMediaType type;
  223. /**
  224. * Minimum required permissions on incoming buffers. Any buffer with
  225. * insufficient permissions will be automatically copied by the filter
  226. * system to a new buffer which provides the needed access permissions.
  227. *
  228. * Input pads only.
  229. */
  230. int min_perms;
  231. /**
  232. * Permissions which are not accepted on incoming buffers. Any buffer
  233. * which has any of these permissions set will be automatically copied
  234. * by the filter system to a new buffer which does not have those
  235. * permissions. This can be used to easily disallow buffers with
  236. * AV_PERM_REUSE.
  237. *
  238. * Input pads only.
  239. */
  240. int rej_perms;
  241. /**
  242. * Callback called before passing the first slice of a new frame. If
  243. * NULL, the filter layer will default to storing a reference to the
  244. * picture inside the link structure.
  245. *
  246. * Input video pads only.
  247. */
  248. void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
  249. /**
  250. * Callback function to get a video buffer. If NULL, the filter system will
  251. * use avfilter_default_get_video_buffer().
  252. *
  253. * Input video pads only.
  254. */
  255. AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
  256. /**
  257. * Callback function to get an audio buffer. If NULL, the filter system will
  258. * use avfilter_default_get_audio_buffer().
  259. *
  260. * Input audio pads only.
  261. */
  262. AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
  263. int nb_samples);
  264. /**
  265. * Callback called after the slices of a frame are completely sent. If
  266. * NULL, the filter layer will default to releasing the reference stored
  267. * in the link structure during start_frame().
  268. *
  269. * Input video pads only.
  270. */
  271. void (*end_frame)(AVFilterLink *link);
  272. /**
  273. * Slice drawing callback. This is where a filter receives video data
  274. * and should do its processing.
  275. *
  276. * Input video pads only.
  277. */
  278. void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
  279. /**
  280. * Samples filtering callback. This is where a filter receives audio data
  281. * and should do its processing.
  282. *
  283. * Input audio pads only.
  284. */
  285. void (*filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref);
  286. /**
  287. * Frame poll callback. This returns the number of immediately available
  288. * samples. It should return a positive value if the next request_frame()
  289. * is guaranteed to return one frame (with no delay).
  290. *
  291. * Defaults to just calling the source poll_frame() method.
  292. *
  293. * Output pads only.
  294. */
  295. int (*poll_frame)(AVFilterLink *link);
  296. /**
  297. * Frame request callback. A call to this should result in at least one
  298. * frame being output over the given link. This should return zero on
  299. * success, and another value on error.
  300. *
  301. * Output pads only.
  302. */
  303. int (*request_frame)(AVFilterLink *link);
  304. /**
  305. * Link configuration callback.
  306. *
  307. * For output pads, this should set the link properties such as
  308. * width/height. This should NOT set the format property - that is
  309. * negotiated between filters by the filter system using the
  310. * query_formats() callback before this function is called.
  311. *
  312. * For input pads, this should check the properties of the link, and update
  313. * the filter's internal state as necessary.
  314. *
  315. * For both input and output filters, this should return zero on success,
  316. * and another value on error.
  317. */
  318. int (*config_props)(AVFilterLink *link);
  319. };
  320. #if FF_API_FILTERS_PUBLIC
  321. /** default handler for start_frame() for video inputs */
  322. attribute_deprecated
  323. void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
  324. /** default handler for draw_slice() for video inputs */
  325. attribute_deprecated
  326. void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
  327. /** default handler for end_frame() for video inputs */
  328. attribute_deprecated
  329. void avfilter_default_end_frame(AVFilterLink *link);
  330. #if FF_API_DEFAULT_CONFIG_OUTPUT_LINK
  331. /** default handler for config_props() for audio/video outputs */
  332. attribute_deprecated
  333. int avfilter_default_config_output_link(AVFilterLink *link);
  334. #endif
  335. /** default handler for get_video_buffer() for video inputs */
  336. attribute_deprecated
  337. AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
  338. int perms, int w, int h);
  339. /** Default handler for query_formats() */
  340. attribute_deprecated
  341. int avfilter_default_query_formats(AVFilterContext *ctx);
  342. #endif
  343. #if FF_API_FILTERS_PUBLIC
  344. /** start_frame() handler for filters which simply pass video along */
  345. attribute_deprecated
  346. void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
  347. /** draw_slice() handler for filters which simply pass video along */
  348. attribute_deprecated
  349. void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
  350. /** end_frame() handler for filters which simply pass video along */
  351. attribute_deprecated
  352. void avfilter_null_end_frame(AVFilterLink *link);
  353. /** get_video_buffer() handler for filters which simply pass video along */
  354. attribute_deprecated
  355. AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
  356. int perms, int w, int h);
  357. #endif
  358. /**
  359. * Filter definition. This defines the pads a filter contains, and all the
  360. * callback functions used to interact with the filter.
  361. */
  362. typedef struct AVFilter {
  363. const char *name; ///< filter name
  364. int priv_size; ///< size of private data to allocate for the filter
  365. /**
  366. * Filter initialization function. Args contains the user-supplied
  367. * parameters. FIXME: maybe an AVOption-based system would be better?
  368. * opaque is data provided by the code requesting creation of the filter,
  369. * and is used to pass data to the filter.
  370. */
  371. int (*init)(AVFilterContext *ctx, const char *args, void *opaque);
  372. /**
  373. * Filter uninitialization function. Should deallocate any memory held
  374. * by the filter, release any buffer references, etc. This does not need
  375. * to deallocate the AVFilterContext->priv memory itself.
  376. */
  377. void (*uninit)(AVFilterContext *ctx);
  378. /**
  379. * Queries formats supported by the filter and its pads, and sets the
  380. * in_formats for links connected to its output pads, and out_formats
  381. * for links connected to its input pads.
  382. *
  383. * @return zero on success, a negative value corresponding to an
  384. * AVERROR code otherwise
  385. */
  386. int (*query_formats)(AVFilterContext *);
  387. const AVFilterPad *inputs; ///< NULL terminated list of inputs. NULL if none
  388. const AVFilterPad *outputs; ///< NULL terminated list of outputs. NULL if none
  389. /**
  390. * A description for the filter. You should use the
  391. * NULL_IF_CONFIG_SMALL() macro to define it.
  392. */
  393. const char *description;
  394. } AVFilter;
  395. /** An instance of a filter */
  396. struct AVFilterContext {
  397. const AVClass *av_class; ///< needed for av_log()
  398. AVFilter *filter; ///< the AVFilter of which this is an instance
  399. char *name; ///< name of this filter instance
  400. unsigned input_count; ///< number of input pads
  401. AVFilterPad *input_pads; ///< array of input pads
  402. AVFilterLink **inputs; ///< array of pointers to input links
  403. unsigned output_count; ///< number of output pads
  404. AVFilterPad *output_pads; ///< array of output pads
  405. AVFilterLink **outputs; ///< array of pointers to output links
  406. void *priv; ///< private data for use by the filter
  407. };
  408. /**
  409. * A link between two filters. This contains pointers to the source and
  410. * destination filters between which this link exists, and the indexes of
  411. * the pads involved. In addition, this link also contains the parameters
  412. * which have been negotiated and agreed upon between the filter, such as
  413. * image dimensions, format, etc.
  414. */
  415. struct AVFilterLink {
  416. AVFilterContext *src; ///< source filter
  417. AVFilterPad *srcpad; ///< output pad on the source filter
  418. AVFilterContext *dst; ///< dest filter
  419. AVFilterPad *dstpad; ///< input pad on the dest filter
  420. /** stage of the initialization of the link properties (dimensions, etc) */
  421. enum {
  422. AVLINK_UNINIT = 0, ///< not started
  423. AVLINK_STARTINIT, ///< started, but incomplete
  424. AVLINK_INIT ///< complete
  425. } init_state;
  426. enum AVMediaType type; ///< filter media type
  427. /* These parameters apply only to video */
  428. int w; ///< agreed upon image width
  429. int h; ///< agreed upon image height
  430. AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
  431. /* These two parameters apply only to audio */
  432. uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/audioconvert.h)
  433. #if FF_API_SAMPLERATE64
  434. int64_t sample_rate; ///< samples per second
  435. #else
  436. int sample_rate; ///< samples per second
  437. #endif
  438. int format; ///< agreed upon media format
  439. /**
  440. * Lists of formats supported by the input and output filters respectively.
  441. * These lists are used for negotiating the format to actually be used,
  442. * which will be loaded into the format member, above, when chosen.
  443. */
  444. AVFilterFormats *in_formats;
  445. AVFilterFormats *out_formats;
  446. /**
  447. * The buffer reference currently being sent across the link by the source
  448. * filter. This is used internally by the filter system to allow
  449. * automatic copying of buffers which do not have sufficient permissions
  450. * for the destination. This should not be accessed directly by the
  451. * filters.
  452. */
  453. AVFilterBufferRef *src_buf;
  454. AVFilterBufferRef *cur_buf;
  455. AVFilterBufferRef *out_buf;
  456. /**
  457. * Define the time base used by the PTS of the frames/samples
  458. * which will pass through this link.
  459. * During the configuration stage, each filter is supposed to
  460. * change only the output timebase, while the timebase of the
  461. * input link is assumed to be an unchangeable property.
  462. */
  463. AVRational time_base;
  464. /*****************************************************************
  465. * All fields below this line are not part of the public API. They
  466. * may not be used outside of libavfilter and can be changed and
  467. * removed at will.
  468. * New public fields should be added right above.
  469. *****************************************************************
  470. */
  471. /**
  472. * Lists of channel layouts and sample rates used for automatic
  473. * negotiation.
  474. */
  475. AVFilterFormats *in_samplerates;
  476. AVFilterFormats *out_samplerates;
  477. struct AVFilterChannelLayouts *in_channel_layouts;
  478. struct AVFilterChannelLayouts *out_channel_layouts;
  479. };
  480. /**
  481. * Link two filters together.
  482. *
  483. * @param src the source filter
  484. * @param srcpad index of the output pad on the source filter
  485. * @param dst the destination filter
  486. * @param dstpad index of the input pad on the destination filter
  487. * @return zero on success
  488. */
  489. int avfilter_link(AVFilterContext *src, unsigned srcpad,
  490. AVFilterContext *dst, unsigned dstpad);
  491. /**
  492. * Negotiate the media format, dimensions, etc of all inputs to a filter.
  493. *
  494. * @param filter the filter to negotiate the properties for its inputs
  495. * @return zero on successful negotiation
  496. */
  497. int avfilter_config_links(AVFilterContext *filter);
  498. /**
  499. * Request a picture buffer with a specific set of permissions.
  500. *
  501. * @param link the output link to the filter from which the buffer will
  502. * be requested
  503. * @param perms the required access permissions
  504. * @param w the minimum width of the buffer to allocate
  505. * @param h the minimum height of the buffer to allocate
  506. * @return A reference to the buffer. This must be unreferenced with
  507. * avfilter_unref_buffer when you are finished with it.
  508. */
  509. AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms,
  510. int w, int h);
  511. /**
  512. * Create a buffer reference wrapped around an already allocated image
  513. * buffer.
  514. *
  515. * @param data pointers to the planes of the image to reference
  516. * @param linesize linesizes for the planes of the image to reference
  517. * @param perms the required access permissions
  518. * @param w the width of the image specified by the data and linesize arrays
  519. * @param h the height of the image specified by the data and linesize arrays
  520. * @param format the pixel format of the image specified by the data and linesize arrays
  521. */
  522. AVFilterBufferRef *
  523. avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
  524. int w, int h, enum PixelFormat format);
  525. /**
  526. * Create an audio buffer reference wrapped around an already
  527. * allocated samples buffer.
  528. *
  529. * @param data pointers to the samples plane buffers
  530. * @param linesize linesize for the samples plane buffers
  531. * @param perms the required access permissions
  532. * @param nb_samples number of samples per channel
  533. * @param sample_fmt the format of each sample in the buffer to allocate
  534. * @param channel_layout the channel layout of the buffer
  535. */
  536. AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
  537. int linesize,
  538. int perms,
  539. int nb_samples,
  540. enum AVSampleFormat sample_fmt,
  541. uint64_t channel_layout);
  542. #if FF_API_FILTERS_PUBLIC
  543. attribute_deprecated
  544. int avfilter_request_frame(AVFilterLink *link);
  545. attribute_deprecated
  546. int avfilter_poll_frame(AVFilterLink *link);
  547. attribute_deprecated
  548. void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
  549. attribute_deprecated
  550. void avfilter_end_frame(AVFilterLink *link);
  551. attribute_deprecated
  552. void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
  553. #endif
  554. /** Initialize the filter system. Register all builtin filters. */
  555. void avfilter_register_all(void);
  556. /** Uninitialize the filter system. Unregister all filters. */
  557. void avfilter_uninit(void);
  558. /**
  559. * Register a filter. This is only needed if you plan to use
  560. * avfilter_get_by_name later to lookup the AVFilter structure by name. A
  561. * filter can still by instantiated with avfilter_open even if it is not
  562. * registered.
  563. *
  564. * @param filter the filter to register
  565. * @return 0 if the registration was succesfull, a negative value
  566. * otherwise
  567. */
  568. int avfilter_register(AVFilter *filter);
  569. /**
  570. * Get a filter definition matching the given name.
  571. *
  572. * @param name the filter name to find
  573. * @return the filter definition, if any matching one is registered.
  574. * NULL if none found.
  575. */
  576. AVFilter *avfilter_get_by_name(const char *name);
  577. /**
  578. * If filter is NULL, returns a pointer to the first registered filter pointer,
  579. * if filter is non-NULL, returns the next pointer after filter.
  580. * If the returned pointer points to NULL, the last registered filter
  581. * was already reached.
  582. */
  583. AVFilter **av_filter_next(AVFilter **filter);
  584. /**
  585. * Create a filter instance.
  586. *
  587. * @param filter_ctx put here a pointer to the created filter context
  588. * on success, NULL on failure
  589. * @param filter the filter to create an instance of
  590. * @param inst_name Name to give to the new instance. Can be NULL for none.
  591. * @return >= 0 in case of success, a negative error code otherwise
  592. */
  593. int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
  594. /**
  595. * Initialize a filter.
  596. *
  597. * @param filter the filter to initialize
  598. * @param args A string of parameters to use when initializing the filter.
  599. * The format and meaning of this string varies by filter.
  600. * @param opaque Any extra non-string data needed by the filter. The meaning
  601. * of this parameter varies by filter.
  602. * @return zero on success
  603. */
  604. int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
  605. /**
  606. * Free a filter context.
  607. *
  608. * @param filter the filter to free
  609. */
  610. void avfilter_free(AVFilterContext *filter);
  611. /**
  612. * Insert a filter in the middle of an existing link.
  613. *
  614. * @param link the link into which the filter should be inserted
  615. * @param filt the filter to be inserted
  616. * @param filt_srcpad_idx the input pad on the filter to connect
  617. * @param filt_dstpad_idx the output pad on the filter to connect
  618. * @return zero on success
  619. */
  620. int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
  621. unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
  622. #if FF_API_FILTERS_PUBLIC
  623. attribute_deprecated
  624. void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
  625. AVFilterPad **pads, AVFilterLink ***links,
  626. AVFilterPad *newpad);
  627. attribute_deprecated
  628. void avfilter_insert_inpad(AVFilterContext *f, unsigned index,
  629. AVFilterPad *p);
  630. attribute_deprecated
  631. void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
  632. AVFilterPad *p);
  633. #endif
  634. /**
  635. * Copy the frame properties of src to dst, without copying the actual
  636. * image data.
  637. *
  638. * @return 0 on success, a negative number on error.
  639. */
  640. int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
  641. /**
  642. * Copy the frame properties and data pointers of src to dst, without copying
  643. * the actual data.
  644. *
  645. * @return 0 on success, a negative number on error.
  646. */
  647. int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src);
  648. #endif /* AVFILTER_AVFILTER_H */