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.

1367 lines
49KB

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