avfiltergraph.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Filter graphs
  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 FFMPEG_AVFILTERGRAPH_H
  22. #define FFMPEG_AVFILTERGRAPH_H
  23. #include "avfilter.h"
  24. /** Linked-list of filters to create for an AVFilterGraphDesc */
  25. typedef struct AVFilterGraphDescFilter
  26. {
  27. char *name; ///< filter instance name
  28. char *filter; ///< name of filter type
  29. char *args; ///< filter parameters
  30. struct AVFilterGraphDescFilter *next;
  31. } AVFilterGraphDescFilter;
  32. /** Linked-list of links between filters */
  33. typedef struct AVFilterGraphDescLink
  34. {
  35. /* TODO: allow referencing pads by name, not just by index */
  36. char *src; ///< name of the source filter
  37. unsigned srcpad; ///< index of the output pad on the source filter
  38. char *dst; ///< name of the dest filter
  39. unsigned dstpad; ///< index of the input pad on the dest filter
  40. struct AVFilterGraphDescLink *next;
  41. } AVFilterGraphDescLink;
  42. /** Linked-list of filter pads to be exported from the graph */
  43. typedef struct AVFilterGraphDescExport
  44. {
  45. /* TODO: allow referencing pads by name, not just by index */
  46. char *name; ///< name of the exported pad
  47. char *filter; ///< name of the filter
  48. unsigned pad; ///< index of the pad to be exported
  49. struct AVFilterGraphDescExport *next;
  50. } AVFilterGraphDescExport;
  51. /** Sections of a filter graph description */
  52. typedef enum
  53. {
  54. SEC_NONE = 0,
  55. SEC_FILTERS,
  56. SEC_LINKS,
  57. SEC_INPUTS,
  58. SEC_OUTPUTS
  59. } AVFilterGraphDescSection;
  60. /** Description of a graph to be loaded from a file, etc */
  61. typedef struct
  62. {
  63. AVFilterGraphDescFilter *filters; ///< filters in the graph
  64. AVFilterGraphDescLink *links; ///< links between the filters
  65. AVFilterGraphDescExport *inputs; ///< inputs to export
  66. AVFilterGraphDescExport *outputs; ///< outputs to export
  67. } AVFilterGraphDesc;
  68. typedef struct
  69. {
  70. AVFilterGraphDescSection section; ///< current section being parsed
  71. AVFilterGraphDescFilter **filterp; ///< last parsed filter
  72. AVFilterGraphDescLink **linkp; ///< last parsed link
  73. AVFilterGraphDescExport **inputp; ///< last parsed exported input
  74. AVFilterGraphDescExport **outputp; ///< last parsed exported output
  75. } AVFilterGraphDescParser;
  76. /**
  77. * Parse a graph composed of a simple chain of filters which is described by
  78. * a single string.
  79. * @param filters String listing filters and their arguments.
  80. * @return The parsed graph description.
  81. */
  82. AVFilterGraphDesc *avfilter_graph_parse_chain(const char *filters);
  83. /** Parse a line of a filter graph description.
  84. * @param desc Pointer to an AVFilterGraphDesc pointer. If *desc is NULL,
  85. * a new AVFilterGraphDesc structure will be created for you.
  86. * Must be the same between multiple invocations when parsing
  87. * the same description.
  88. * @param parser Parser state. Must be the same between multiple invocations
  89. * when parsing the same description
  90. * @param line Line of the graph description to parse.
  91. * @return Zero on success, negative on error.
  92. */
  93. int avfilter_graph_parse_desc(AVFilterGraphDesc **desc,
  94. AVFilterGraphDescParser **parser,
  95. char *line);
  96. /**
  97. * Load a filter graph description from a file
  98. * @param filename Name of the file from which to load the description
  99. * @return Pointer to the description on success. NULL on failure
  100. */
  101. AVFilterGraphDesc *avfilter_graph_load_desc(const char *filename);
  102. /**
  103. * Free a filter graph description
  104. * @param desc The graph description to free
  105. */
  106. void avfilter_graph_free_desc(AVFilterGraphDesc *desc);
  107. /**
  108. * Add an existing filter instance to a filter graph.
  109. * @param graph The filter graph
  110. * @param filter The filter to be added
  111. */
  112. void avfilter_graph_add_filter(AVFilterContext *graphctx, AVFilterContext *filter);
  113. /**
  114. * Configure the formats of all the links in the graph
  115. */
  116. int avfilter_graph_config_formats(AVFilterContext *graphctx);
  117. /**
  118. * Configure the resolution, etc of all links in the graph
  119. */
  120. int avfilter_graph_config_links(AVFilterContext *graphctx);
  121. #endif /* FFMPEG_AVFILTERGRAPH_H */