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.

190 lines
5.9KB

  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVFILTER_INTERNAL_H
  19. #define AVFILTER_INTERNAL_H
  20. /**
  21. * @file
  22. * internal API functions
  23. */
  24. #include "avfilter.h"
  25. #include "avfiltergraph.h"
  26. #include "formats.h"
  27. #include "video.h"
  28. #define POOL_SIZE 32
  29. typedef struct AVFilterPool {
  30. AVFilterBufferRef *pic[POOL_SIZE];
  31. int count;
  32. int refcount;
  33. int draining;
  34. } AVFilterPool;
  35. typedef struct AVFilterCommand {
  36. double time; ///< time expressed in seconds
  37. char *command; ///< command
  38. char *arg; ///< optional argument for the command
  39. int flags;
  40. struct AVFilterCommand *next;
  41. } AVFilterCommand;
  42. /**
  43. * Update the position of a link in the age heap.
  44. */
  45. void ff_avfilter_graph_update_heap(AVFilterGraph *graph, AVFilterLink *link);
  46. /** default handler for freeing audio/video buffer when there are no references left */
  47. void ff_avfilter_default_free_buffer(AVFilterBuffer *buf);
  48. /** Tell is a format is contained in the provided list terminated by -1. */
  49. int ff_fmt_is_in(int fmt, const int *fmts);
  50. /**
  51. * Return a copy of a list of integers terminated by -1, or NULL in
  52. * case of copy failure.
  53. */
  54. int *ff_copy_int_list(const int * const list);
  55. /**
  56. * Return a copy of a list of 64-bit integers, or NULL in case of
  57. * copy failure.
  58. */
  59. int64_t *ff_copy_int64_list(const int64_t * const list);
  60. /* Functions to parse audio format arguments */
  61. /**
  62. * Parse a pixel format.
  63. *
  64. * @param ret pixel format pointer to where the value should be written
  65. * @param arg string to parse
  66. * @param log_ctx log context
  67. * @return 0 in case of success, a negative AVERROR code on error
  68. */
  69. int ff_parse_pixel_format(enum PixelFormat *ret, const char *arg, void *log_ctx);
  70. /**
  71. * Parse a sample rate.
  72. *
  73. * @param ret unsigned integer pointer to where the value should be written
  74. * @param arg string to parse
  75. * @param log_ctx log context
  76. * @return 0 in case of success, a negative AVERROR code on error
  77. */
  78. int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx);
  79. /**
  80. * Parse a time base.
  81. *
  82. * @param ret unsigned AVRational pointer to where the value should be written
  83. * @param arg string to parse
  84. * @param log_ctx log context
  85. * @return 0 in case of success, a negative AVERROR code on error
  86. */
  87. int ff_parse_time_base(AVRational *ret, const char *arg, void *log_ctx);
  88. /**
  89. * Parse a sample format name or a corresponding integer representation.
  90. *
  91. * @param ret integer pointer to where the value should be written
  92. * @param arg string to parse
  93. * @param log_ctx log context
  94. * @return 0 in case of success, a negative AVERROR code on error
  95. */
  96. int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx);
  97. /**
  98. * Parse a channel layout or a corresponding integer representation.
  99. *
  100. * @param ret 64bit integer pointer to where the value should be written.
  101. * @param arg string to parse
  102. * @param log_ctx log context
  103. * @return 0 in case of success, a negative AVERROR code on error
  104. */
  105. int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx);
  106. void ff_update_link_current_pts(AVFilterLink *link, int64_t pts);
  107. void ff_free_pool(AVFilterPool *pool);
  108. void ff_command_queue_pop(AVFilterContext *filter);
  109. /* misc debug functions */
  110. #define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func)
  111. char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms);
  112. void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end);
  113. void ff_dlog_link(void *ctx, AVFilterLink *link, int end);
  114. /**
  115. * Insert a new pad.
  116. *
  117. * @param idx Insertion point. Pad is inserted at the end if this point
  118. * is beyond the end of the list of pads.
  119. * @param count Pointer to the number of pads in the list
  120. * @param padidx_off Offset within an AVFilterLink structure to the element
  121. * to increment when inserting a new pad causes link
  122. * numbering to change
  123. * @param pads Pointer to the pointer to the beginning of the list of pads
  124. * @param links Pointer to the pointer to the beginning of the list of links
  125. * @param newpad The new pad to add. A copy is made when adding.
  126. */
  127. void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
  128. AVFilterPad **pads, AVFilterLink ***links,
  129. AVFilterPad *newpad);
  130. /** Insert a new input pad for the filter. */
  131. static inline void ff_insert_inpad(AVFilterContext *f, unsigned index,
  132. AVFilterPad *p)
  133. {
  134. ff_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
  135. &f->input_pads, &f->inputs, p);
  136. }
  137. /** Insert a new output pad for the filter. */
  138. static inline void ff_insert_outpad(AVFilterContext *f, unsigned index,
  139. AVFilterPad *p)
  140. {
  141. ff_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
  142. &f->output_pads, &f->outputs, p);
  143. }
  144. /**
  145. * Poll a frame from the filter chain.
  146. *
  147. * @param link the input link
  148. * @return the number of immediately available frames, a negative
  149. * number in case of error
  150. */
  151. int ff_poll_frame(AVFilterLink *link);
  152. /**
  153. * Request an input frame from the filter at the other end of the link.
  154. *
  155. * @param link the input link
  156. * @return zero on success
  157. */
  158. int ff_request_frame(AVFilterLink *link);
  159. #endif /* AVFILTER_INTERNAL_H */