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.

1374 lines
51KB

  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. #ifndef AVFILTER_AVFILTER_H
  22. #define AVFILTER_AVFILTER_H
  23. /**
  24. * @file
  25. * @ingroup lavfi
  26. * Main libavfilter public API header
  27. */
  28. /**
  29. * @defgroup lavfi Libavfilter - graph-based frame editing library
  30. * @{
  31. */
  32. #include <stddef.h>
  33. #include "libavutil/attributes.h"
  34. #include "libavutil/avutil.h"
  35. #include "libavutil/dict.h"
  36. #include "libavutil/frame.h"
  37. #include "libavutil/log.h"
  38. #include "libavutil/samplefmt.h"
  39. #include "libavutil/pixfmt.h"
  40. #include "libavutil/rational.h"
  41. #include "libavfilter/version.h"
  42. /**
  43. * Return the LIBAVFILTER_VERSION_INT constant.
  44. */
  45. unsigned avfilter_version(void);
  46. /**
  47. * Return the libavfilter build-time configuration.
  48. */
  49. const char *avfilter_configuration(void);
  50. /**
  51. * Return the libavfilter license.
  52. */
  53. const char *avfilter_license(void);
  54. typedef struct AVFilterContext AVFilterContext;
  55. typedef struct AVFilterLink AVFilterLink;
  56. typedef struct AVFilterPad AVFilterPad;
  57. typedef struct AVFilterFormats AVFilterFormats;
  58. #if FF_API_AVFILTERBUFFER
  59. /**
  60. * A reference-counted buffer data type used by the filter system. Filters
  61. * should not store pointers to this structure directly, but instead use the
  62. * AVFilterBufferRef structure below.
  63. */
  64. typedef struct AVFilterBuffer {
  65. uint8_t *data[8]; ///< buffer data for each plane/channel
  66. /**
  67. * pointers to the data planes/channels.
  68. *
  69. * For video, this should simply point to data[].
  70. *
  71. * For planar audio, each channel has a separate data pointer, and
  72. * linesize[0] contains the size of each channel buffer.
  73. * For packed audio, there is just one data pointer, and linesize[0]
  74. * contains the total size of the buffer for all channels.
  75. *
  76. * Note: Both data and extended_data will always be set, but for planar
  77. * audio with more channels that can fit in data, extended_data must be used
  78. * in order to access all channels.
  79. */
  80. uint8_t **extended_data;
  81. int linesize[8]; ///< number of bytes per line
  82. /** private data to be used by a custom free function */
  83. void *priv;
  84. /**
  85. * A pointer to the function to deallocate this buffer if the default
  86. * function is not sufficient. This could, for example, add the memory
  87. * back into a memory pool to be reused later without the overhead of
  88. * reallocating it from scratch.
  89. */
  90. void (*free)(struct AVFilterBuffer *buf);
  91. int format; ///< media format
  92. int w, h; ///< width and height of the allocated buffer
  93. unsigned refcount; ///< number of references to this buffer
  94. } AVFilterBuffer;
  95. #define AV_PERM_READ 0x01 ///< can read from the buffer
  96. #define AV_PERM_WRITE 0x02 ///< can write to the buffer
  97. #define AV_PERM_PRESERVE 0x04 ///< nobody else can overwrite the buffer
  98. #define AV_PERM_REUSE 0x08 ///< can output the buffer multiple times, with the same contents each time
  99. #define AV_PERM_REUSE2 0x10 ///< can output the buffer multiple times, modified each time
  100. #define AV_PERM_NEG_LINESIZES 0x20 ///< the buffer requested can have negative linesizes
  101. #define AV_PERM_ALIGN 0x40 ///< the buffer must be aligned
  102. #define AVFILTER_ALIGN 16 //not part of ABI
  103. /**
  104. * Audio specific properties in a reference to an AVFilterBuffer. Since
  105. * AVFilterBufferRef is common to different media formats, audio specific
  106. * per reference properties must be separated out.
  107. */
  108. typedef struct AVFilterBufferRefAudioProps {
  109. uint64_t channel_layout; ///< channel layout of audio buffer
  110. int nb_samples; ///< number of audio samples per channel
  111. int sample_rate; ///< audio buffer sample rate
  112. int channels; ///< number of channels (do not access directly)
  113. } AVFilterBufferRefAudioProps;
  114. /**
  115. * Video specific properties in a reference to an AVFilterBuffer. Since
  116. * AVFilterBufferRef is common to different media formats, video specific
  117. * per reference properties must be separated out.
  118. */
  119. typedef struct AVFilterBufferRefVideoProps {
  120. int w; ///< image width
  121. int h; ///< image height
  122. AVRational sample_aspect_ratio; ///< sample aspect ratio
  123. int interlaced; ///< is frame interlaced
  124. int top_field_first; ///< field order
  125. enum AVPictureType pict_type; ///< picture type of the frame
  126. int key_frame; ///< 1 -> keyframe, 0-> not
  127. int qp_table_linesize; ///< qp_table stride
  128. int qp_table_size; ///< qp_table size
  129. int8_t *qp_table; ///< array of Quantization Parameters
  130. } AVFilterBufferRefVideoProps;
  131. /**
  132. * A reference to an AVFilterBuffer. Since filters can manipulate the origin of
  133. * a buffer to, for example, crop image without any memcpy, the buffer origin
  134. * and dimensions are per-reference properties. Linesize is also useful for
  135. * image flipping, frame to field filters, etc, and so is also per-reference.
  136. *
  137. * TODO: add anything necessary for frame reordering
  138. */
  139. typedef struct AVFilterBufferRef {
  140. AVFilterBuffer *buf; ///< the buffer that this is a reference to
  141. uint8_t *data[8]; ///< picture/audio data for each plane
  142. /**
  143. * pointers to the data planes/channels.
  144. *
  145. * For video, this should simply point to data[].
  146. *
  147. * For planar audio, each channel has a separate data pointer, and
  148. * linesize[0] contains the size of each channel buffer.
  149. * For packed audio, there is just one data pointer, and linesize[0]
  150. * contains the total size of the buffer for all channels.
  151. *
  152. * Note: Both data and extended_data will always be set, but for planar
  153. * audio with more channels that can fit in data, extended_data must be used
  154. * in order to access all channels.
  155. */
  156. uint8_t **extended_data;
  157. int linesize[8]; ///< number of bytes per line
  158. AVFilterBufferRefVideoProps *video; ///< video buffer specific properties
  159. AVFilterBufferRefAudioProps *audio; ///< audio buffer specific properties
  160. /**
  161. * presentation timestamp. The time unit may change during
  162. * filtering, as it is specified in the link and the filter code
  163. * may need to rescale the PTS accordingly.
  164. */
  165. int64_t pts;
  166. int64_t pos; ///< byte position in stream, -1 if unknown
  167. int format; ///< media format
  168. int perms; ///< permissions, see the AV_PERM_* flags
  169. enum AVMediaType type; ///< media type of buffer data
  170. AVDictionary *metadata; ///< dictionary containing metadata key=value tags
  171. } AVFilterBufferRef;
  172. /**
  173. * Copy properties of src to dst, without copying the actual data
  174. */
  175. attribute_deprecated
  176. void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, const AVFilterBufferRef *src);
  177. /**
  178. * Add a new reference to a buffer.
  179. *
  180. * @param ref an existing reference to the buffer
  181. * @param pmask a bitmask containing the allowable permissions in the new
  182. * reference
  183. * @return a new reference to the buffer with the same properties as the
  184. * old, excluding any permissions denied by pmask
  185. */
  186. attribute_deprecated
  187. AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
  188. /**
  189. * Remove a reference to a buffer. If this is the last reference to the
  190. * buffer, the buffer itself is also automatically freed.
  191. *
  192. * @param ref reference to the buffer, may be NULL
  193. *
  194. * @note it is recommended to use avfilter_unref_bufferp() instead of this
  195. * function
  196. */
  197. attribute_deprecated
  198. void avfilter_unref_buffer(AVFilterBufferRef *ref);
  199. /**
  200. * Remove a reference to a buffer and set the pointer to NULL.
  201. * If this is the last reference to the buffer, the buffer itself
  202. * is also automatically freed.
  203. *
  204. * @param ref pointer to the buffer reference
  205. */
  206. attribute_deprecated
  207. void avfilter_unref_bufferp(AVFilterBufferRef **ref);
  208. /**
  209. * Get the number of channels of a buffer reference.
  210. */
  211. attribute_deprecated
  212. int avfilter_ref_get_channels(AVFilterBufferRef *ref);
  213. #endif
  214. /**
  215. * Get the number of elements in a NULL-terminated array of AVFilterPads (e.g.
  216. * AVFilter.inputs/outputs).
  217. */
  218. int avfilter_pad_count(const AVFilterPad *pads);
  219. /**
  220. * Get the name of an AVFilterPad.
  221. *
  222. * @param pads an array of AVFilterPads
  223. * @param pad_idx index of the pad in the array it; is the caller's
  224. * responsibility to ensure the index is valid
  225. *
  226. * @return name of the pad_idx'th pad in pads
  227. */
  228. const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx);
  229. /**
  230. * Get the type of an AVFilterPad.
  231. *
  232. * @param pads an array of AVFilterPads
  233. * @param pad_idx index of the pad in the array; it is the caller's
  234. * responsibility to ensure the index is valid
  235. *
  236. * @return type of the pad_idx'th pad in pads
  237. */
  238. enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
  239. /**
  240. * The number of the filter inputs is not determined just by AVFilter.inputs.
  241. * The filter might add additional inputs during initialization depending on the
  242. * options supplied to it.
  243. */
  244. #define AVFILTER_FLAG_DYNAMIC_INPUTS (1 << 0)
  245. /**
  246. * The number of the filter outputs is not determined just by AVFilter.outputs.
  247. * The filter might add additional outputs during initialization depending on
  248. * the options supplied to it.
  249. */
  250. #define AVFILTER_FLAG_DYNAMIC_OUTPUTS (1 << 1)
  251. /**
  252. * The filter supports multithreading by splitting frames into multiple parts
  253. * and processing them concurrently.
  254. */
  255. #define AVFILTER_FLAG_SLICE_THREADS (1 << 2)
  256. /**
  257. * Some filters support a generic "enable" expression option that can be used
  258. * to enable or disable a filter in the timeline. Filters supporting this
  259. * option have this flag set. When the enable expression is false, the default
  260. * no-op filter_frame() function is called in place of the filter_frame()
  261. * callback defined on each input pad, thus the frame is passed unchanged to
  262. * the next filters.
  263. */
  264. #define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC (1 << 16)
  265. /**
  266. * Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will
  267. * have its filter_frame() callback(s) called as usual even when the enable
  268. * expression is false. The filter will disable filtering within the
  269. * filter_frame() callback(s) itself, for example executing code depending on
  270. * the AVFilterContext->is_disabled value.
  271. */
  272. #define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL (1 << 17)
  273. /**
  274. * Handy mask to test whether the filter supports or no the timeline feature
  275. * (internally or generically).
  276. */
  277. #define AVFILTER_FLAG_SUPPORT_TIMELINE (AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL)
  278. /**
  279. * Filter definition. This defines the pads a filter contains, and all the
  280. * callback functions used to interact with the filter.
  281. */
  282. typedef struct AVFilter {
  283. /**
  284. * Filter name. Must be non-NULL and unique among filters.
  285. */
  286. const char *name;
  287. /**
  288. * A description of the filter. May be NULL.
  289. *
  290. * You should use the NULL_IF_CONFIG_SMALL() macro to define it.
  291. */
  292. const char *description;
  293. /**
  294. * List of inputs, terminated by a zeroed element.
  295. *
  296. * NULL if there are no (static) inputs. Instances of filters with
  297. * AVFILTER_FLAG_DYNAMIC_INPUTS set may have more inputs than present in
  298. * this list.
  299. */
  300. const AVFilterPad *inputs;
  301. /**
  302. * List of outputs, terminated by a zeroed element.
  303. *
  304. * NULL if there are no (static) outputs. Instances of filters with
  305. * AVFILTER_FLAG_DYNAMIC_OUTPUTS set may have more outputs than present in
  306. * this list.
  307. */
  308. const AVFilterPad *outputs;
  309. /**
  310. * A class for the private data, used to declare filter private AVOptions.
  311. * This field is NULL for filters that do not declare any options.
  312. *
  313. * If this field is non-NULL, the first member of the filter private data
  314. * must be a pointer to AVClass, which will be set by libavfilter generic
  315. * code to this class.
  316. */
  317. const AVClass *priv_class;
  318. /**
  319. * A combination of AVFILTER_FLAG_*
  320. */
  321. int flags;
  322. /*****************************************************************
  323. * All fields below this line are not part of the public API. They
  324. * may not be used outside of libavfilter and can be changed and
  325. * removed at will.
  326. * New public fields should be added right above.
  327. *****************************************************************
  328. */
  329. /**
  330. * Filter initialization function.
  331. *
  332. * This callback will be called only once during the filter lifetime, after
  333. * all the options have been set, but before links between filters are
  334. * established and format negotiation is done.
  335. *
  336. * Basic filter initialization should be done here. Filters with dynamic
  337. * inputs and/or outputs should create those inputs/outputs here based on
  338. * provided options. No more changes to this filter's inputs/outputs can be
  339. * done after this callback.
  340. *
  341. * This callback must not assume that the filter links exist or frame
  342. * parameters are known.
  343. *
  344. * @ref AVFilter.uninit "uninit" is guaranteed to be called even if
  345. * initialization fails, so this callback does not have to clean up on
  346. * failure.
  347. *
  348. * @return 0 on success, a negative AVERROR on failure
  349. */
  350. int (*init)(AVFilterContext *ctx);
  351. /**
  352. * Should be set instead of @ref AVFilter.init "init" by the filters that
  353. * want to pass a dictionary of AVOptions to nested contexts that are
  354. * allocated during init.
  355. *
  356. * On return, the options dict should be freed and replaced with one that
  357. * contains all the options which could not be processed by this filter (or
  358. * with NULL if all the options were processed).
  359. *
  360. * Otherwise the semantics is the same as for @ref AVFilter.init "init".
  361. */
  362. int (*init_dict)(AVFilterContext *ctx, AVDictionary **options);
  363. /**
  364. * Filter uninitialization function.
  365. *
  366. * Called only once right before the filter is freed. Should deallocate any
  367. * memory held by the filter, release any buffer references, etc. It does
  368. * not need to deallocate the AVFilterContext.priv memory itself.
  369. *
  370. * This callback may be called even if @ref AVFilter.init "init" was not
  371. * called or failed, so it must be prepared to handle such a situation.
  372. */
  373. void (*uninit)(AVFilterContext *ctx);
  374. /**
  375. * Query formats supported by the filter on its inputs and outputs.
  376. *
  377. * This callback is called after the filter is initialized (so the inputs
  378. * and outputs are fixed), shortly before the format negotiation. This
  379. * callback may be called more than once.
  380. *
  381. * This callback must set AVFilterLink.out_formats on every input link and
  382. * AVFilterLink.in_formats on every output link to a list of pixel/sample
  383. * formats that the filter supports on that link. For audio links, this
  384. * filter must also set @ref AVFilterLink.in_samplerates "in_samplerates" /
  385. * @ref AVFilterLink.out_samplerates "out_samplerates" and
  386. * @ref AVFilterLink.in_channel_layouts "in_channel_layouts" /
  387. * @ref AVFilterLink.out_channel_layouts "out_channel_layouts" analogously.
  388. *
  389. * This callback may be NULL for filters with one input, in which case
  390. * libavfilter assumes that it supports all input formats and preserves
  391. * them on output.
  392. *
  393. * @return zero on success, a negative value corresponding to an
  394. * AVERROR code otherwise
  395. */
  396. int (*query_formats)(AVFilterContext *);
  397. int priv_size; ///< size of private data to allocate for the filter
  398. /**
  399. * Used by the filter registration system. Must not be touched by any other
  400. * code.
  401. */
  402. struct AVFilter *next;
  403. /**
  404. * Make the filter instance process a command.
  405. *
  406. * @param cmd the command to process, for handling simplicity all commands must be alphanumeric only
  407. * @param arg the argument for the command
  408. * @param res a buffer with size res_size where the filter(s) can return a response. This must not change when the command is not supported.
  409. * @param flags if AVFILTER_CMD_FLAG_FAST is set and the command would be
  410. * time consuming then a filter should treat it like an unsupported command
  411. *
  412. * @returns >=0 on success otherwise an error code.
  413. * AVERROR(ENOSYS) on unsupported commands
  414. */
  415. int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags);
  416. /**
  417. * Filter initialization function, alternative to the init()
  418. * callback. Args contains the user-supplied parameters, opaque is
  419. * used for providing binary data.
  420. */
  421. int (*init_opaque)(AVFilterContext *ctx, void *opaque);
  422. } AVFilter;
  423. /**
  424. * Process multiple parts of the frame concurrently.
  425. */
  426. #define AVFILTER_THREAD_SLICE (1 << 0)
  427. typedef struct AVFilterInternal AVFilterInternal;
  428. /** An instance of a filter */
  429. struct AVFilterContext {
  430. const AVClass *av_class; ///< needed for av_log() and filters common options
  431. const AVFilter *filter; ///< the AVFilter of which this is an instance
  432. char *name; ///< name of this filter instance
  433. AVFilterPad *input_pads; ///< array of input pads
  434. AVFilterLink **inputs; ///< array of pointers to input links
  435. unsigned nb_inputs; ///< number of input pads
  436. AVFilterPad *output_pads; ///< array of output pads
  437. AVFilterLink **outputs; ///< array of pointers to output links
  438. unsigned nb_outputs; ///< number of output pads
  439. void *priv; ///< private data for use by the filter
  440. struct AVFilterGraph *graph; ///< filtergraph this filter belongs to
  441. /**
  442. * Type of multithreading being allowed/used. A combination of
  443. * AVFILTER_THREAD_* flags.
  444. *
  445. * May be set by the caller before initializing the filter to forbid some
  446. * or all kinds of multithreading for this filter. The default is allowing
  447. * everything.
  448. *
  449. * When the filter is initialized, this field is combined using bit AND with
  450. * AVFilterGraph.thread_type to get the final mask used for determining
  451. * allowed threading types. I.e. a threading type needs to be set in both
  452. * to be allowed.
  453. *
  454. * After the filter is initialized, libavfilter sets this field to the
  455. * threading type that is actually used (0 for no multithreading).
  456. */
  457. int thread_type;
  458. /**
  459. * An opaque struct for libavfilter internal use.
  460. */
  461. AVFilterInternal *internal;
  462. struct AVFilterCommand *command_queue;
  463. char *enable_str; ///< enable expression string
  464. void *enable; ///< parsed expression (AVExpr*)
  465. double *var_values; ///< variable values for the enable expression
  466. int is_disabled; ///< the enabled state from the last expression evaluation
  467. };
  468. /**
  469. * A link between two filters. This contains pointers to the source and
  470. * destination filters between which this link exists, and the indexes of
  471. * the pads involved. In addition, this link also contains the parameters
  472. * which have been negotiated and agreed upon between the filter, such as
  473. * image dimensions, format, etc.
  474. */
  475. struct AVFilterLink {
  476. AVFilterContext *src; ///< source filter
  477. AVFilterPad *srcpad; ///< output pad on the source filter
  478. AVFilterContext *dst; ///< dest filter
  479. AVFilterPad *dstpad; ///< input pad on the dest filter
  480. enum AVMediaType type; ///< filter media type
  481. /* These parameters apply only to video */
  482. int w; ///< agreed upon image width
  483. int h; ///< agreed upon image height
  484. AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
  485. /* These parameters apply only to audio */
  486. uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/channel_layout.h)
  487. int sample_rate; ///< samples per second
  488. int format; ///< agreed upon media format
  489. /**
  490. * Define the time base used by the PTS of the frames/samples
  491. * which will pass through this link.
  492. * During the configuration stage, each filter is supposed to
  493. * change only the output timebase, while the timebase of the
  494. * input link is assumed to be an unchangeable property.
  495. */
  496. AVRational time_base;
  497. /*****************************************************************
  498. * All fields below this line are not part of the public API. They
  499. * may not be used outside of libavfilter and can be changed and
  500. * removed at will.
  501. * New public fields should be added right above.
  502. *****************************************************************
  503. */
  504. /**
  505. * Lists of formats and channel layouts supported by the input and output
  506. * filters respectively. These lists are used for negotiating the format
  507. * to actually be used, which will be loaded into the format and
  508. * channel_layout members, above, when chosen.
  509. *
  510. */
  511. AVFilterFormats *in_formats;
  512. AVFilterFormats *out_formats;
  513. /**
  514. * Lists of channel layouts and sample rates used for automatic
  515. * negotiation.
  516. */
  517. AVFilterFormats *in_samplerates;
  518. AVFilterFormats *out_samplerates;
  519. struct AVFilterChannelLayouts *in_channel_layouts;
  520. struct AVFilterChannelLayouts *out_channel_layouts;
  521. /**
  522. * Audio only, the destination filter sets this to a non-zero value to
  523. * request that buffers with the given number of samples should be sent to
  524. * it. AVFilterPad.needs_fifo must also be set on the corresponding input
  525. * pad.
  526. * Last buffer before EOF will be padded with silence.
  527. */
  528. int request_samples;
  529. /** stage of the initialization of the link properties (dimensions, etc) */
  530. enum {
  531. AVLINK_UNINIT = 0, ///< not started
  532. AVLINK_STARTINIT, ///< started, but incomplete
  533. AVLINK_INIT ///< complete
  534. } init_state;
  535. #if FF_API_AVFILTERBUFFER
  536. struct AVFilterPool *pool;
  537. #endif
  538. /**
  539. * Graph the filter belongs to.
  540. */
  541. struct AVFilterGraph *graph;
  542. /**
  543. * Current timestamp of the link, as defined by the most recent
  544. * frame(s), in AV_TIME_BASE units.
  545. */
  546. int64_t current_pts;
  547. /**
  548. * Index in the age array.
  549. */
  550. int age_index;
  551. /**
  552. * Frame rate of the stream on the link, or 1/0 if unknown;
  553. * if left to 0/0, will be automatically be copied from the first input
  554. * of the source filter if it exists.
  555. *
  556. * Sources should set it to the best estimation of the real frame rate.
  557. * Filters should update it if necessary depending on their function.
  558. * Sinks can use it to set a default output frame rate.
  559. * It is similar to the r_frame_rate field in AVStream.
  560. */
  561. AVRational frame_rate;
  562. /**
  563. * Buffer partially filled with samples to achieve a fixed/minimum size.
  564. */
  565. AVFrame *partial_buf;
  566. /**
  567. * Size of the partial buffer to allocate.
  568. * Must be between min_samples and max_samples.
  569. */
  570. int partial_buf_size;
  571. /**
  572. * Minimum number of samples to filter at once. If filter_frame() is
  573. * called with fewer samples, it will accumulate them in partial_buf.
  574. * This field and the related ones must not be changed after filtering
  575. * has started.
  576. * If 0, all related fields are ignored.
  577. */
  578. int min_samples;
  579. /**
  580. * Maximum number of samples to filter at once. If filter_frame() is
  581. * called with more samples, it will split them.
  582. */
  583. int max_samples;
  584. #if FF_API_AVFILTERBUFFER
  585. /**
  586. * The buffer reference currently being received across the link by the
  587. * destination filter. This is used internally by the filter system to
  588. * allow automatic copying of buffers which do not have sufficient
  589. * permissions for the destination. This should not be accessed directly
  590. * by the filters.
  591. */
  592. AVFilterBufferRef *cur_buf_copy;
  593. #endif
  594. /**
  595. * True if the link is closed.
  596. * If set, all attempts of start_frame, filter_frame or request_frame
  597. * will fail with AVERROR_EOF, and if necessary the reference will be
  598. * destroyed.
  599. * If request_frame returns AVERROR_EOF, this flag is set on the
  600. * corresponding link.
  601. * It can be set also be set by either the source or the destination
  602. * filter.
  603. */
  604. int closed;
  605. /**
  606. * Number of channels.
  607. */
  608. int channels;
  609. /**
  610. * True if a frame is being requested on the link.
  611. * Used internally by the framework.
  612. */
  613. unsigned frame_requested;
  614. /**
  615. * Link processing flags.
  616. */
  617. unsigned flags;
  618. /**
  619. * Number of past frames sent through the link.
  620. */
  621. int64_t frame_count;
  622. };
  623. /**
  624. * Link two filters together.
  625. *
  626. * @param src the source filter
  627. * @param srcpad index of the output pad on the source filter
  628. * @param dst the destination filter
  629. * @param dstpad index of the input pad on the destination filter
  630. * @return zero on success
  631. */
  632. int avfilter_link(AVFilterContext *src, unsigned srcpad,
  633. AVFilterContext *dst, unsigned dstpad);
  634. /**
  635. * Free the link in *link, and set its pointer to NULL.
  636. */
  637. void avfilter_link_free(AVFilterLink **link);
  638. /**
  639. * Get the number of channels of a link.
  640. */
  641. int avfilter_link_get_channels(AVFilterLink *link);
  642. /**
  643. * Set the closed field of a link.
  644. */
  645. void avfilter_link_set_closed(AVFilterLink *link, int closed);
  646. /**
  647. * Negotiate the media format, dimensions, etc of all inputs to a filter.
  648. *
  649. * @param filter the filter to negotiate the properties for its inputs
  650. * @return zero on successful negotiation
  651. */
  652. int avfilter_config_links(AVFilterContext *filter);
  653. #if FF_API_AVFILTERBUFFER
  654. /**
  655. * Create a buffer reference wrapped around an already allocated image
  656. * buffer.
  657. *
  658. * @param data pointers to the planes of the image to reference
  659. * @param linesize linesizes for the planes of the image to reference
  660. * @param perms the required access permissions
  661. * @param w the width of the image specified by the data and linesize arrays
  662. * @param h the height of the image specified by the data and linesize arrays
  663. * @param format the pixel format of the image specified by the data and linesize arrays
  664. */
  665. attribute_deprecated
  666. AVFilterBufferRef *
  667. avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int linesize[4], int perms,
  668. int w, int h, enum AVPixelFormat format);
  669. /**
  670. * Create an audio buffer reference wrapped around an already
  671. * allocated samples buffer.
  672. *
  673. * See avfilter_get_audio_buffer_ref_from_arrays_channels() for a version
  674. * that can handle unknown channel layouts.
  675. *
  676. * @param data pointers to the samples plane buffers
  677. * @param linesize linesize for the samples plane buffers
  678. * @param perms the required access permissions
  679. * @param nb_samples number of samples per channel
  680. * @param sample_fmt the format of each sample in the buffer to allocate
  681. * @param channel_layout the channel layout of the buffer
  682. */
  683. attribute_deprecated
  684. AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data,
  685. int linesize,
  686. int perms,
  687. int nb_samples,
  688. enum AVSampleFormat sample_fmt,
  689. uint64_t channel_layout);
  690. /**
  691. * Create an audio buffer reference wrapped around an already
  692. * allocated samples buffer.
  693. *
  694. * @param data pointers to the samples plane buffers
  695. * @param linesize linesize for the samples plane buffers
  696. * @param perms the required access permissions
  697. * @param nb_samples number of samples per channel
  698. * @param sample_fmt the format of each sample in the buffer to allocate
  699. * @param channels the number of channels of the buffer
  700. * @param channel_layout the channel layout of the buffer,
  701. * must be either 0 or consistent with channels
  702. */
  703. attribute_deprecated
  704. AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays_channels(uint8_t **data,
  705. int linesize,
  706. int perms,
  707. int nb_samples,
  708. enum AVSampleFormat sample_fmt,
  709. int channels,
  710. uint64_t channel_layout);
  711. #endif
  712. #define AVFILTER_CMD_FLAG_ONE 1 ///< Stop once a filter understood the command (for target=all for example), fast filters are favored automatically
  713. #define AVFILTER_CMD_FLAG_FAST 2 ///< Only execute command when its fast (like a video out that supports contrast adjustment in hw)
  714. /**
  715. * Make the filter instance process a command.
  716. * It is recommended to use avfilter_graph_send_command().
  717. */
  718. int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags);
  719. /** Initialize the filter system. Register all builtin filters. */
  720. void avfilter_register_all(void);
  721. #if FF_API_OLD_FILTER_REGISTER
  722. /** Uninitialize the filter system. Unregister all filters. */
  723. attribute_deprecated
  724. void avfilter_uninit(void);
  725. #endif
  726. /**
  727. * Register a filter. This is only needed if you plan to use
  728. * avfilter_get_by_name later to lookup the AVFilter structure by name. A
  729. * filter can still by instantiated with avfilter_graph_alloc_filter even if it
  730. * is not registered.
  731. *
  732. * @param filter the filter to register
  733. * @return 0 if the registration was successful, a negative value
  734. * otherwise
  735. */
  736. int avfilter_register(AVFilter *filter);
  737. /**
  738. * Get a filter definition matching the given name.
  739. *
  740. * @param name the filter name to find
  741. * @return the filter definition, if any matching one is registered.
  742. * NULL if none found.
  743. */
  744. #if !FF_API_NOCONST_GET_NAME
  745. const
  746. #endif
  747. AVFilter *avfilter_get_by_name(const char *name);
  748. /**
  749. * Iterate over all registered filters.
  750. * @return If prev is non-NULL, next registered filter after prev or NULL if
  751. * prev is the last filter. If prev is NULL, return the first registered filter.
  752. */
  753. const AVFilter *avfilter_next(const AVFilter *prev);
  754. #if FF_API_OLD_FILTER_REGISTER
  755. /**
  756. * If filter is NULL, returns a pointer to the first registered filter pointer,
  757. * if filter is non-NULL, returns the next pointer after filter.
  758. * If the returned pointer points to NULL, the last registered filter
  759. * was already reached.
  760. * @deprecated use avfilter_next()
  761. */
  762. attribute_deprecated
  763. AVFilter **av_filter_next(AVFilter **filter);
  764. #endif
  765. #if FF_API_AVFILTER_OPEN
  766. /**
  767. * Create a filter instance.
  768. *
  769. * @param filter_ctx put here a pointer to the created filter context
  770. * on success, NULL on failure
  771. * @param filter the filter to create an instance of
  772. * @param inst_name Name to give to the new instance. Can be NULL for none.
  773. * @return >= 0 in case of success, a negative error code otherwise
  774. * @deprecated use avfilter_graph_alloc_filter() instead
  775. */
  776. attribute_deprecated
  777. int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
  778. #endif
  779. #if FF_API_AVFILTER_INIT_FILTER
  780. /**
  781. * Initialize a filter.
  782. *
  783. * @param filter the filter to initialize
  784. * @param args A string of parameters to use when initializing the filter.
  785. * The format and meaning of this string varies by filter.
  786. * @param opaque Any extra non-string data needed by the filter. The meaning
  787. * of this parameter varies by filter.
  788. * @return zero on success
  789. */
  790. attribute_deprecated
  791. int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
  792. #endif
  793. /**
  794. * Initialize a filter with the supplied parameters.
  795. *
  796. * @param ctx uninitialized filter context to initialize
  797. * @param args Options to initialize the filter with. This must be a
  798. * ':'-separated list of options in the 'key=value' form.
  799. * May be NULL if the options have been set directly using the
  800. * AVOptions API or there are no options that need to be set.
  801. * @return 0 on success, a negative AVERROR on failure
  802. */
  803. int avfilter_init_str(AVFilterContext *ctx, const char *args);
  804. /**
  805. * Initialize a filter with the supplied dictionary of options.
  806. *
  807. * @param ctx uninitialized filter context to initialize
  808. * @param options An AVDictionary filled with options for this filter. On
  809. * return this parameter will be destroyed and replaced with
  810. * a dict containing options that were not found. This dictionary
  811. * must be freed by the caller.
  812. * May be NULL, then this function is equivalent to
  813. * avfilter_init_str() with the second parameter set to NULL.
  814. * @return 0 on success, a negative AVERROR on failure
  815. *
  816. * @note This function and avfilter_init_str() do essentially the same thing,
  817. * the difference is in manner in which the options are passed. It is up to the
  818. * calling code to choose whichever is more preferable. The two functions also
  819. * behave differently when some of the provided options are not declared as
  820. * supported by the filter. In such a case, avfilter_init_str() will fail, but
  821. * this function will leave those extra options in the options AVDictionary and
  822. * continue as usual.
  823. */
  824. int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options);
  825. /**
  826. * Free a filter context. This will also remove the filter from its
  827. * filtergraph's list of filters.
  828. *
  829. * @param filter the filter to free
  830. */
  831. void avfilter_free(AVFilterContext *filter);
  832. /**
  833. * Insert a filter in the middle of an existing link.
  834. *
  835. * @param link the link into which the filter should be inserted
  836. * @param filt the filter to be inserted
  837. * @param filt_srcpad_idx the input pad on the filter to connect
  838. * @param filt_dstpad_idx the output pad on the filter to connect
  839. * @return zero on success
  840. */
  841. int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
  842. unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
  843. #if FF_API_AVFILTERBUFFER
  844. /**
  845. * Copy the frame properties of src to dst, without copying the actual
  846. * image data.
  847. *
  848. * @return 0 on success, a negative number on error.
  849. */
  850. attribute_deprecated
  851. int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
  852. /**
  853. * Copy the frame properties and data pointers of src to dst, without copying
  854. * the actual data.
  855. *
  856. * @return 0 on success, a negative number on error.
  857. */
  858. attribute_deprecated
  859. int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src);
  860. #endif
  861. /**
  862. * @return AVClass for AVFilterContext.
  863. *
  864. * @see av_opt_find().
  865. */
  866. const AVClass *avfilter_get_class(void);
  867. typedef struct AVFilterGraphInternal AVFilterGraphInternal;
  868. /**
  869. * A function pointer passed to the @ref AVFilterGraph.execute callback to be
  870. * executed multiple times, possibly in parallel.
  871. *
  872. * @param ctx the filter context the job belongs to
  873. * @param arg an opaque parameter passed through from @ref
  874. * AVFilterGraph.execute
  875. * @param jobnr the index of the job being executed
  876. * @param nb_jobs the total number of jobs
  877. *
  878. * @return 0 on success, a negative AVERROR on error
  879. */
  880. typedef int (avfilter_action_func)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
  881. /**
  882. * A function executing multiple jobs, possibly in parallel.
  883. *
  884. * @param ctx the filter context to which the jobs belong
  885. * @param func the function to be called multiple times
  886. * @param arg the argument to be passed to func
  887. * @param ret a nb_jobs-sized array to be filled with return values from each
  888. * invocation of func
  889. * @param nb_jobs the number of jobs to execute
  890. *
  891. * @return 0 on success, a negative AVERROR on error
  892. */
  893. typedef int (avfilter_execute_func)(AVFilterContext *ctx, avfilter_action_func *func,
  894. void *arg, int *ret, int nb_jobs);
  895. typedef struct AVFilterGraph {
  896. const AVClass *av_class;
  897. AVFilterContext **filters;
  898. unsigned nb_filters;
  899. char *scale_sws_opts; ///< sws options to use for the auto-inserted scale filters
  900. char *resample_lavr_opts; ///< libavresample options to use for the auto-inserted resample filters
  901. /**
  902. * Type of multithreading allowed for filters in this graph. A combination
  903. * of AVFILTER_THREAD_* flags.
  904. *
  905. * May be set by the caller at any point, the setting will apply to all
  906. * filters initialized after that. The default is allowing everything.
  907. *
  908. * When a filter in this graph is initialized, this field is combined using
  909. * bit AND with AVFilterContext.thread_type to get the final mask used for
  910. * determining allowed threading types. I.e. a threading type needs to be
  911. * set in both to be allowed.
  912. */
  913. int thread_type;
  914. /**
  915. * Maximum number of threads used by filters in this graph. May be set by
  916. * the caller before adding any filters to the filtergraph. Zero (the
  917. * default) means that the number of threads is determined automatically.
  918. */
  919. int nb_threads;
  920. /**
  921. * Opaque object for libavfilter internal use.
  922. */
  923. AVFilterGraphInternal *internal;
  924. /**
  925. * Opaque user data. May be set by the caller to an arbitrary value, e.g. to
  926. * be used from callbacks like @ref AVFilterGraph.execute.
  927. * Libavfilter will not touch this field in any way.
  928. */
  929. void *opaque;
  930. /**
  931. * This callback may be set by the caller immediately after allocating the
  932. * graph and before adding any filters to it, to provide a custom
  933. * multithreading implementation.
  934. *
  935. * If set, filters with slice threading capability will call this callback
  936. * to execute multiple jobs in parallel.
  937. *
  938. * If this field is left unset, libavfilter will use its internal
  939. * implementation, which may or may not be multithreaded depending on the
  940. * platform and build options.
  941. */
  942. avfilter_execute_func *execute;
  943. char *aresample_swr_opts; ///< swr options to use for the auto-inserted aresample filters, Access ONLY through AVOptions
  944. /**
  945. * Private fields
  946. *
  947. * The following fields are for internal use only.
  948. * Their type, offset, number and semantic can change without notice.
  949. */
  950. AVFilterLink **sink_links;
  951. int sink_links_count;
  952. unsigned disable_auto_convert;
  953. } AVFilterGraph;
  954. /**
  955. * Allocate a filter graph.
  956. *
  957. * @return the allocated filter graph on success or NULL.
  958. */
  959. AVFilterGraph *avfilter_graph_alloc(void);
  960. /**
  961. * Create a new filter instance in a filter graph.
  962. *
  963. * @param graph graph in which the new filter will be used
  964. * @param filter the filter to create an instance of
  965. * @param name Name to give to the new instance (will be copied to
  966. * AVFilterContext.name). This may be used by the caller to identify
  967. * different filters, libavfilter itself assigns no semantics to
  968. * this parameter. May be NULL.
  969. *
  970. * @return the context of the newly created filter instance (note that it is
  971. * also retrievable directly through AVFilterGraph.filters or with
  972. * avfilter_graph_get_filter()) on success or NULL on failure.
  973. */
  974. AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph,
  975. const AVFilter *filter,
  976. const char *name);
  977. /**
  978. * Get a filter instance identified by instance name from graph.
  979. *
  980. * @param graph filter graph to search through.
  981. * @param name filter instance name (should be unique in the graph).
  982. * @return the pointer to the found filter instance or NULL if it
  983. * cannot be found.
  984. */
  985. AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, const char *name);
  986. #if FF_API_AVFILTER_OPEN
  987. /**
  988. * Add an existing filter instance to a filter graph.
  989. *
  990. * @param graphctx the filter graph
  991. * @param filter the filter to be added
  992. *
  993. * @deprecated use avfilter_graph_alloc_filter() to allocate a filter in a
  994. * filter graph
  995. */
  996. attribute_deprecated
  997. int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter);
  998. #endif
  999. /**
  1000. * Create and add a filter instance into an existing graph.
  1001. * The filter instance is created from the filter filt and inited
  1002. * with the parameters args and opaque.
  1003. *
  1004. * In case of success put in *filt_ctx the pointer to the created
  1005. * filter instance, otherwise set *filt_ctx to NULL.
  1006. *
  1007. * @param name the instance name to give to the created filter instance
  1008. * @param graph_ctx the filter graph
  1009. * @return a negative AVERROR error code in case of failure, a non
  1010. * negative value otherwise
  1011. */
  1012. int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt,
  1013. const char *name, const char *args, void *opaque,
  1014. AVFilterGraph *graph_ctx);
  1015. /**
  1016. * Enable or disable automatic format conversion inside the graph.
  1017. *
  1018. * Note that format conversion can still happen inside explicitly inserted
  1019. * scale and aresample filters.
  1020. *
  1021. * @param flags any of the AVFILTER_AUTO_CONVERT_* constants
  1022. */
  1023. void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags);
  1024. enum {
  1025. AVFILTER_AUTO_CONVERT_ALL = 0, /**< all automatic conversions enabled */
  1026. AVFILTER_AUTO_CONVERT_NONE = -1, /**< all automatic conversions disabled */
  1027. };
  1028. /**
  1029. * Check validity and configure all the links and formats in the graph.
  1030. *
  1031. * @param graphctx the filter graph
  1032. * @param log_ctx context used for logging
  1033. * @return >= 0 in case of success, a negative AVERROR code otherwise
  1034. */
  1035. int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx);
  1036. /**
  1037. * Free a graph, destroy its links, and set *graph to NULL.
  1038. * If *graph is NULL, do nothing.
  1039. */
  1040. void avfilter_graph_free(AVFilterGraph **graph);
  1041. /**
  1042. * A linked-list of the inputs/outputs of the filter chain.
  1043. *
  1044. * This is mainly useful for avfilter_graph_parse() / avfilter_graph_parse2(),
  1045. * where it is used to communicate open (unlinked) inputs and outputs from and
  1046. * to the caller.
  1047. * This struct specifies, per each not connected pad contained in the graph, the
  1048. * filter context and the pad index required for establishing a link.
  1049. */
  1050. typedef struct AVFilterInOut {
  1051. /** unique name for this input/output in the list */
  1052. char *name;
  1053. /** filter context associated to this input/output */
  1054. AVFilterContext *filter_ctx;
  1055. /** index of the filt_ctx pad to use for linking */
  1056. int pad_idx;
  1057. /** next input/input in the list, NULL if this is the last */
  1058. struct AVFilterInOut *next;
  1059. } AVFilterInOut;
  1060. /**
  1061. * Allocate a single AVFilterInOut entry.
  1062. * Must be freed with avfilter_inout_free().
  1063. * @return allocated AVFilterInOut on success, NULL on failure.
  1064. */
  1065. AVFilterInOut *avfilter_inout_alloc(void);
  1066. /**
  1067. * Free the supplied list of AVFilterInOut and set *inout to NULL.
  1068. * If *inout is NULL, do nothing.
  1069. */
  1070. void avfilter_inout_free(AVFilterInOut **inout);
  1071. #if AV_HAVE_INCOMPATIBLE_LIBAV_ABI || !FF_API_OLD_GRAPH_PARSE
  1072. /**
  1073. * Add a graph described by a string to a graph.
  1074. *
  1075. * @note The caller must provide the lists of inputs and outputs,
  1076. * which therefore must be known before calling the function.
  1077. *
  1078. * @note The inputs parameter describes inputs of the already existing
  1079. * part of the graph; i.e. from the point of view of the newly created
  1080. * part, they are outputs. Similarly the outputs parameter describes
  1081. * outputs of the already existing filters, which are provided as
  1082. * inputs to the parsed filters.
  1083. *
  1084. * @param graph the filter graph where to link the parsed graph context
  1085. * @param filters string to be parsed
  1086. * @param inputs linked list to the inputs of the graph
  1087. * @param outputs linked list to the outputs of the graph
  1088. * @return zero on success, a negative AVERROR code on error
  1089. */
  1090. int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
  1091. AVFilterInOut *inputs, AVFilterInOut *outputs,
  1092. void *log_ctx);
  1093. #else
  1094. /**
  1095. * Add a graph described by a string to a graph.
  1096. *
  1097. * @param graph the filter graph where to link the parsed graph context
  1098. * @param filters string to be parsed
  1099. * @param inputs pointer to a linked list to the inputs of the graph, may be NULL.
  1100. * If non-NULL, *inputs is updated to contain the list of open inputs
  1101. * after the parsing, should be freed with avfilter_inout_free().
  1102. * @param outputs pointer to a linked list to the outputs of the graph, may be NULL.
  1103. * If non-NULL, *outputs is updated to contain the list of open outputs
  1104. * after the parsing, should be freed with avfilter_inout_free().
  1105. * @return non negative on success, a negative AVERROR code on error
  1106. * @deprecated Use avfilter_graph_parse_ptr() instead.
  1107. */
  1108. attribute_deprecated
  1109. int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
  1110. AVFilterInOut **inputs, AVFilterInOut **outputs,
  1111. void *log_ctx);
  1112. #endif
  1113. /**
  1114. * Add a graph described by a string to a graph.
  1115. *
  1116. * In the graph filters description, if the input label of the first
  1117. * filter is not specified, "in" is assumed; if the output label of
  1118. * the last filter is not specified, "out" is assumed.
  1119. *
  1120. * @param graph the filter graph where to link the parsed graph context
  1121. * @param filters string to be parsed
  1122. * @param inputs pointer to a linked list to the inputs of the graph, may be NULL.
  1123. * If non-NULL, *inputs is updated to contain the list of open inputs
  1124. * after the parsing, should be freed with avfilter_inout_free().
  1125. * @param outputs pointer to a linked list to the outputs of the graph, may be NULL.
  1126. * If non-NULL, *outputs is updated to contain the list of open outputs
  1127. * after the parsing, should be freed with avfilter_inout_free().
  1128. * @return non negative on success, a negative AVERROR code on error
  1129. */
  1130. int avfilter_graph_parse_ptr(AVFilterGraph *graph, const char *filters,
  1131. AVFilterInOut **inputs, AVFilterInOut **outputs,
  1132. void *log_ctx);
  1133. /**
  1134. * Add a graph described by a string to a graph.
  1135. *
  1136. * @param[in] graph the filter graph where to link the parsed graph context
  1137. * @param[in] filters string to be parsed
  1138. * @param[out] inputs a linked list of all free (unlinked) inputs of the
  1139. * parsed graph will be returned here. It is to be freed
  1140. * by the caller using avfilter_inout_free().
  1141. * @param[out] outputs a linked list of all free (unlinked) outputs of the
  1142. * parsed graph will be returned here. It is to be freed by the
  1143. * caller using avfilter_inout_free().
  1144. * @return zero on success, a negative AVERROR code on error
  1145. *
  1146. * @note This function returns the inputs and outputs that are left
  1147. * unlinked after parsing the graph and the caller then deals with
  1148. * them.
  1149. * @note This function makes no reference whatsoever to already
  1150. * existing parts of the graph and the inputs parameter will on return
  1151. * contain inputs of the newly parsed part of the graph. Analogously
  1152. * the outputs parameter will contain outputs of the newly created
  1153. * filters.
  1154. */
  1155. int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters,
  1156. AVFilterInOut **inputs,
  1157. AVFilterInOut **outputs);
  1158. /**
  1159. * Send a command to one or more filter instances.
  1160. *
  1161. * @param graph the filter graph
  1162. * @param target the filter(s) to which the command should be sent
  1163. * "all" sends to all filters
  1164. * otherwise it can be a filter or filter instance name
  1165. * which will send the command to all matching filters.
  1166. * @param cmd the command to send, for handling simplicity all commands must be alphanumeric only
  1167. * @param arg the argument for the command
  1168. * @param res a buffer with size res_size where the filter(s) can return a response.
  1169. *
  1170. * @returns >=0 on success otherwise an error code.
  1171. * AVERROR(ENOSYS) on unsupported commands
  1172. */
  1173. int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags);
  1174. /**
  1175. * Queue a command for one or more filter instances.
  1176. *
  1177. * @param graph the filter graph
  1178. * @param target the filter(s) to which the command should be sent
  1179. * "all" sends to all filters
  1180. * otherwise it can be a filter or filter instance name
  1181. * which will send the command to all matching filters.
  1182. * @param cmd the command to sent, for handling simplicity all commands must be alphanumeric only
  1183. * @param arg the argument for the command
  1184. * @param ts time at which the command should be sent to the filter
  1185. *
  1186. * @note As this executes commands after this function returns, no return code
  1187. * from the filter is provided, also AVFILTER_CMD_FLAG_ONE is not supported.
  1188. */
  1189. int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts);
  1190. /**
  1191. * Dump a graph into a human-readable string representation.
  1192. *
  1193. * @param graph the graph to dump
  1194. * @param options formatting options; currently ignored
  1195. * @return a string, or NULL in case of memory allocation failure;
  1196. * the string must be freed using av_free
  1197. */
  1198. char *avfilter_graph_dump(AVFilterGraph *graph, const char *options);
  1199. /**
  1200. * Request a frame on the oldest sink link.
  1201. *
  1202. * If the request returns AVERROR_EOF, try the next.
  1203. *
  1204. * Note that this function is not meant to be the sole scheduling mechanism
  1205. * of a filtergraph, only a convenience function to help drain a filtergraph
  1206. * in a balanced way under normal circumstances.
  1207. *
  1208. * Also note that AVERROR_EOF does not mean that frames did not arrive on
  1209. * some of the sinks during the process.
  1210. * When there are multiple sink links, in case the requested link
  1211. * returns an EOF, this may cause a filter to flush pending frames
  1212. * which are sent to another sink link, although unrequested.
  1213. *
  1214. * @return the return value of ff_request_frame(),
  1215. * or AVERROR_EOF if all links returned AVERROR_EOF
  1216. */
  1217. int avfilter_graph_request_oldest(AVFilterGraph *graph);
  1218. /**
  1219. * @}
  1220. */
  1221. #endif /* AVFILTER_AVFILTER_H */