buffersrc.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. *
  3. * This file is part of Libav.
  4. *
  5. * Libav 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. * Libav 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 Libav; 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 "avfilter.h"
  27. /**
  28. * @defgroup lavfi_buffersrc Buffer source API
  29. * @ingroup lavfi
  30. * @{
  31. */
  32. /**
  33. * This structure contains the parameters describing the frames that will be
  34. * passed to this filter.
  35. *
  36. * It should be allocated with av_buffersrc_parameters_alloc() and freed with
  37. * av_free(). All the allocated fields in it remain owned by the caller.
  38. */
  39. typedef struct AVBufferSrcParameters {
  40. /**
  41. * video: the pixel format, value corresponds to enum AVPixelFormat
  42. * audio: the sample format, value corresponds to enum AVSampleFormat
  43. */
  44. int format;
  45. /**
  46. * The timebase to be used for the timestamps on the input frames.
  47. */
  48. AVRational time_base;
  49. /**
  50. * Video only, the display dimensions of the input frames.
  51. */
  52. int width, height;
  53. /**
  54. * Video only, the sample (pixel) aspect ratio.
  55. */
  56. AVRational sample_aspect_ratio;
  57. /**
  58. * Video only, the frame rate of the input video. This field must only be
  59. * set to a non-zero value if input stream has a known constant framerate
  60. * and should be left at its initial value if the framerate is variable or
  61. * unknown.
  62. */
  63. AVRational frame_rate;
  64. /**
  65. * Video with a hwaccel pixel format only. This should be a reference to an
  66. * AVHWFramesContext instance describing the input frames.
  67. */
  68. AVBufferRef *hw_frames_ctx;
  69. /**
  70. * Audio only, the audio sampling rate in samples per secon.
  71. */
  72. int sample_rate;
  73. /**
  74. * Audio only, the audio channel layout
  75. */
  76. uint64_t channel_layout;
  77. } AVBufferSrcParameters;
  78. /**
  79. * Allocate a new AVBufferSrcParameters instance. It should be freed by the
  80. * caller with av_free().
  81. */
  82. AVBufferSrcParameters *av_buffersrc_parameters_alloc(void);
  83. /**
  84. * Initialize the buffersrc or abuffersrc filter with the provided parameters.
  85. * This function may be called multiple times, the later calls override the
  86. * previous ones. Some of the parameters may also be set through AVOptions, then
  87. * whatever method is used last takes precedence.
  88. *
  89. * @param ctx an instance of the buffersrc or abuffersrc filter
  90. * @param param the stream parameters. The frames later passed to this filter
  91. * must conform to those parameters. All the allocated fields in
  92. * param remain owned by the caller, libavfilter will make internal
  93. * copies or references when necessary.
  94. * @return 0 on success, a negative AVERROR code on failure.
  95. */
  96. int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *param);
  97. /**
  98. * Add a frame to the buffer source.
  99. *
  100. * @param ctx an instance of the buffersrc filter
  101. * @param frame frame to be added. If the frame is reference counted, this
  102. * function will make a new reference to it. Otherwise the frame data will be
  103. * copied.
  104. *
  105. * @return 0 on success, a negative AVERROR on error
  106. */
  107. int av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame);
  108. /**
  109. * Add a frame to the buffer source.
  110. *
  111. * @param ctx an instance of the buffersrc filter
  112. * @param frame frame to be added. If the frame is reference counted, this
  113. * function will take ownership of the reference(s) and reset the frame.
  114. * Otherwise the frame data will be copied. If this function returns an error,
  115. * the input frame is not touched.
  116. *
  117. * @return 0 on success, a negative AVERROR on error.
  118. *
  119. * @note the difference between this function and av_buffersrc_write_frame() is
  120. * that av_buffersrc_write_frame() creates a new reference to the input frame,
  121. * while this function takes ownership of the reference passed to it.
  122. */
  123. int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame);
  124. /**
  125. * @}
  126. */
  127. #endif /* AVFILTER_BUFFERSRC_H */