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. #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 trace functions */
  110. /* #define FF_AVFILTER_TRACE */
  111. #ifdef FF_AVFILTER_TRACE
  112. # define ff_tlog(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
  113. #else
  114. # define ff_tlog(pctx, ...) do { if (0) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
  115. #endif
  116. #define FF_TPRINTF_START(ctx, func) ff_tlog(NULL, "%-16s: ", #func)
  117. char *ff_get_ref_perms_string(char *buf, size_t buf_size, int perms);
  118. void ff_tlog_ref(void *ctx, AVFilterBufferRef *ref, int end);
  119. void ff_tlog_link(void *ctx, AVFilterLink *link, int end);
  120. /**
  121. * Insert a new pad.
  122. *
  123. * @param idx Insertion point. Pad is inserted at the end if this point
  124. * is beyond the end of the list of pads.
  125. * @param count Pointer to the number of pads in the list
  126. * @param padidx_off Offset within an AVFilterLink structure to the element
  127. * to increment when inserting a new pad causes link
  128. * numbering to change
  129. * @param pads Pointer to the pointer to the beginning of the list of pads
  130. * @param links Pointer to the pointer to the beginning of the list of links
  131. * @param newpad The new pad to add. A copy is made when adding.
  132. */
  133. void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
  134. AVFilterPad **pads, AVFilterLink ***links,
  135. AVFilterPad *newpad);
  136. /** Insert a new input pad for the filter. */
  137. static inline void ff_insert_inpad(AVFilterContext *f, unsigned index,
  138. AVFilterPad *p)
  139. {
  140. ff_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
  141. &f->input_pads, &f->inputs, p);
  142. }
  143. /** Insert a new output pad for the filter. */
  144. static inline void ff_insert_outpad(AVFilterContext *f, unsigned index,
  145. AVFilterPad *p)
  146. {
  147. ff_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
  148. &f->output_pads, &f->outputs, p);
  149. }
  150. /**
  151. * Poll a frame from the filter chain.
  152. *
  153. * @param link the input link
  154. * @return the number of immediately available frames, a negative
  155. * number in case of error
  156. */
  157. int ff_poll_frame(AVFilterLink *link);
  158. /**
  159. * Request an input frame from the filter at the other end of the link.
  160. *
  161. * @param link the input link
  162. * @return zero on success
  163. */
  164. int ff_request_frame(AVFilterLink *link);
  165. #endif /* AVFILTER_INTERNAL_H */