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.

164 lines
4.8KB

  1. /*
  2. *
  3. * This file is part of FFmpeg.
  4. *
  5. * FFmpeg is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * FFmpeg is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with FFmpeg; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #ifndef AVFILTER_BUFFERSRC_H
  20. #define AVFILTER_BUFFERSRC_H
  21. /**
  22. * @file
  23. * @ingroup lavfi_buffersrc
  24. * Memory buffer source API.
  25. */
  26. #include "libavcodec/avcodec.h"
  27. #include "avfilter.h"
  28. /**
  29. * @defgroup lavfi_buffersrc Buffer source API
  30. * @ingroup lavfi
  31. * @{
  32. */
  33. enum {
  34. /**
  35. * Do not check for format changes.
  36. */
  37. AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT = 1,
  38. #if FF_API_AVFILTERBUFFER
  39. /**
  40. * Ignored
  41. */
  42. AV_BUFFERSRC_FLAG_NO_COPY = 2,
  43. #endif
  44. /**
  45. * Immediately push the frame to the output.
  46. */
  47. AV_BUFFERSRC_FLAG_PUSH = 4,
  48. /**
  49. * Keep a reference to the frame.
  50. * If the frame if reference-counted, create a new reference; otherwise
  51. * copy the frame data.
  52. */
  53. AV_BUFFERSRC_FLAG_KEEP_REF = 8,
  54. };
  55. #if FF_API_AVFILTERBUFFER
  56. /**
  57. * Add buffer data in picref to buffer_src.
  58. *
  59. * @param buffer_src pointer to a buffer source context
  60. * @param picref a buffer reference, or NULL to mark EOF
  61. * @param flags a combination of AV_BUFFERSRC_FLAG_*
  62. * @return >= 0 in case of success, a negative AVERROR code
  63. * in case of failure
  64. */
  65. attribute_deprecated
  66. int av_buffersrc_add_ref(AVFilterContext *buffer_src,
  67. AVFilterBufferRef *picref, int flags);
  68. #endif
  69. /**
  70. * Get the number of failed requests.
  71. *
  72. * A failed request is when the request_frame method is called while no
  73. * frame is present in the buffer.
  74. * The number is reset when a frame is added.
  75. */
  76. unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src);
  77. #if FF_API_AVFILTERBUFFER
  78. /**
  79. * Add a buffer to a filtergraph.
  80. *
  81. * @param ctx an instance of the buffersrc filter
  82. * @param buf buffer containing frame data to be passed down the filtergraph.
  83. * This function will take ownership of buf, the user must not free it.
  84. * A NULL buf signals EOF -- i.e. no more frames will be sent to this filter.
  85. *
  86. * @deprecated use av_buffersrc_write_frame() or av_buffersrc_add_frame()
  87. */
  88. attribute_deprecated
  89. int av_buffersrc_buffer(AVFilterContext *ctx, AVFilterBufferRef *buf);
  90. #endif
  91. /**
  92. * Add a frame to the buffer source.
  93. *
  94. * @param ctx an instance of the buffersrc filter
  95. * @param frame frame to be added. If the frame is reference counted, this
  96. * function will make a new reference to it. Otherwise the frame data will be
  97. * copied.
  98. *
  99. * @return 0 on success, a negative AVERROR on error
  100. *
  101. * This function is equivalent to av_buffersrc_add_frame_flags() with the
  102. * AV_BUFFERSRC_FLAG_KEEP_REF flag.
  103. */
  104. int av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame);
  105. /**
  106. * Add a frame to the buffer source.
  107. *
  108. * @param ctx an instance of the buffersrc filter
  109. * @param frame frame to be added. If the frame is reference counted, this
  110. * function will take ownership of the reference(s) and reset the frame.
  111. * Otherwise the frame data will be copied. If this function returns an error,
  112. * the input frame is not touched.
  113. *
  114. * @return 0 on success, a negative AVERROR on error.
  115. *
  116. * @note the difference between this function and av_buffersrc_write_frame() is
  117. * that av_buffersrc_write_frame() creates a new reference to the input frame,
  118. * while this function takes ownership of the reference passed to it.
  119. *
  120. * This function is equivalent to av_buffersrc_add_frame_flags() without the
  121. * AV_BUFFERSRC_FLAG_KEEP_REF flag.
  122. */
  123. int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame);
  124. /**
  125. * Add a frame to the buffer source.
  126. *
  127. * By default, if the frame is reference-counted, this function will take
  128. * ownership of the reference(s) and reset the frame. This can be controlled
  129. * using the flags.
  130. *
  131. * If this function returns an error, the input frame is not touched.
  132. *
  133. * @param buffer_src pointer to a buffer source context
  134. * @param frame a frame, or NULL to mark EOF
  135. * @param flags a combination of AV_BUFFERSRC_FLAG_*
  136. * @return >= 0 in case of success, a negative AVERROR code
  137. * in case of failure
  138. */
  139. int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src,
  140. AVFrame *frame, int flags);
  141. /**
  142. * @}
  143. */
  144. #endif /* AVFILTER_BUFFERSRC_H */