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.

198 lines
6.2KB

  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. #define POOL_SIZE 32
  28. typedef struct AVFilterPool {
  29. AVFilterBufferRef *pic[POOL_SIZE];
  30. int count;
  31. int refcount;
  32. int draining;
  33. } AVFilterPool;
  34. typedef struct AVFilterCommand {
  35. double time; ///< time expressed in seconds
  36. char *command; ///< command
  37. char *arg; ///< optional argument for the command
  38. int flags;
  39. struct AVFilterCommand *next;
  40. } AVFilterCommand;
  41. /**
  42. * Update the position of a link in the age heap.
  43. */
  44. void ff_avfilter_graph_update_heap(AVFilterGraph *graph, AVFilterLink *link);
  45. /** default handler for freeing audio/video buffer when there are no references left */
  46. void ff_avfilter_default_free_buffer(AVFilterBuffer *buf);
  47. /** Tell is a format is contained in the provided list terminated by -1. */
  48. int ff_fmt_is_in(int fmt, const int *fmts);
  49. /**
  50. * Return a copy of a list of integers terminated by -1, or NULL in
  51. * case of copy failure.
  52. */
  53. int *ff_copy_int_list(const int * const list);
  54. /**
  55. * Return a copy of a list of 64-bit integers, or NULL in case of
  56. * copy failure.
  57. */
  58. int64_t *ff_copy_int64_list(const int64_t * const list);
  59. /* Functions to parse audio format arguments */
  60. /**
  61. * Parse a pixel format.
  62. *
  63. * @param ret pixel format pointer to where the value should be written
  64. * @param arg string to parse
  65. * @param log_ctx log context
  66. * @return 0 in case of success, a negative AVERROR code on error
  67. */
  68. int ff_parse_pixel_format(enum PixelFormat *ret, const char *arg, void *log_ctx);
  69. /**
  70. * Parse a sample rate.
  71. *
  72. * @param ret unsigned integer pointer to where the value should be written
  73. * @param arg string to parse
  74. * @param log_ctx log context
  75. * @return 0 in case of success, a negative AVERROR code on error
  76. */
  77. int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx);
  78. /**
  79. * Parse a time base.
  80. *
  81. * @param ret unsigned AVRational pointer to where the value should be written
  82. * @param arg string to parse
  83. * @param log_ctx log context
  84. * @return 0 in case of success, a negative AVERROR code on error
  85. */
  86. int ff_parse_time_base(AVRational *ret, const char *arg, void *log_ctx);
  87. /**
  88. * Parse a sample format name or a corresponding integer representation.
  89. *
  90. * @param ret integer pointer to where the value should be written
  91. * @param arg string to parse
  92. * @param log_ctx log context
  93. * @return 0 in case of success, a negative AVERROR code on error
  94. */
  95. int ff_parse_sample_format(int *ret, const char *arg, void *log_ctx);
  96. /**
  97. * Parse a channel layout or a corresponding integer representation.
  98. *
  99. * @param ret 64bit integer pointer to where the value should be written.
  100. * @param arg string to parse
  101. * @param log_ctx log context
  102. * @return 0 in case of success, a negative AVERROR code on error
  103. */
  104. int ff_parse_channel_layout(int64_t *ret, const char *arg, void *log_ctx);
  105. /**
  106. * Pass video frame along and keep an internal reference for later use.
  107. */
  108. static inline void ff_null_start_frame_keep_ref(AVFilterLink *inlink,
  109. AVFilterBufferRef *picref)
  110. {
  111. avfilter_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0));
  112. }
  113. void ff_update_link_current_pts(AVFilterLink *link, int64_t pts);
  114. void ff_free_pool(AVFilterPool *pool);
  115. void ff_command_queue_pop(AVFilterContext *filter);
  116. /* misc debug functions */
  117. #define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func)
  118. char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms);
  119. void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end);
  120. void ff_dlog_link(void *ctx, AVFilterLink *link, int end);
  121. /**
  122. * Insert a new pad.
  123. *
  124. * @param idx Insertion point. Pad is inserted at the end if this point
  125. * is beyond the end of the list of pads.
  126. * @param count Pointer to the number of pads in the list
  127. * @param padidx_off Offset within an AVFilterLink structure to the element
  128. * to increment when inserting a new pad causes link
  129. * numbering to change
  130. * @param pads Pointer to the pointer to the beginning of the list of pads
  131. * @param links Pointer to the pointer to the beginning of the list of links
  132. * @param newpad The new pad to add. A copy is made when adding.
  133. */
  134. void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
  135. AVFilterPad **pads, AVFilterLink ***links,
  136. AVFilterPad *newpad);
  137. /** Insert a new input pad for the filter. */
  138. static inline void ff_insert_inpad(AVFilterContext *f, unsigned index,
  139. AVFilterPad *p)
  140. {
  141. ff_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
  142. &f->input_pads, &f->inputs, p);
  143. }
  144. /** Insert a new output pad for the filter. */
  145. static inline void ff_insert_outpad(AVFilterContext *f, unsigned index,
  146. AVFilterPad *p)
  147. {
  148. ff_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
  149. &f->output_pads, &f->outputs, p);
  150. }
  151. /**
  152. * Poll a frame from the filter chain.
  153. *
  154. * @param link the input link
  155. * @return the number of immediately available frames, a negative
  156. * number in case of error
  157. */
  158. int ff_poll_frame(AVFilterLink *link);
  159. /**
  160. * Request an input frame from the filter at the other end of the link.
  161. *
  162. * @param link the input link
  163. * @return zero on success
  164. */
  165. int ff_request_frame(AVFilterLink *link);
  166. #endif /* AVFILTER_INTERNAL_H */