buffersrc.h 4.5 KB

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