2 * This file is part of Libav.
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.
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.
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
19 #ifndef AVFILTER_BUFFERSRC_H
20 #define AVFILTER_BUFFERSRC_H
24 * @ingroup lavfi_buffersrc
25 * Memory buffer source API.
31 * @defgroup lavfi_buffersrc Buffer source API
37 * This structure contains the parameters describing the frames that will be
38 * passed to this filter.
40 * It should be allocated with av_buffersrc_parameters_alloc() and freed with
41 * av_free(). All the allocated fields in it remain owned by the caller.
43 typedef struct AVBufferSrcParameters {
45 * video: the pixel format, value corresponds to enum AVPixelFormat
46 * audio: the sample format, value corresponds to enum AVSampleFormat
50 * The timebase to be used for the timestamps on the input frames.
55 * Video only, the display dimensions of the input frames.
60 * Video only, the sample (pixel) aspect ratio.
62 AVRational sample_aspect_ratio;
65 * Video only, the frame rate of the input video. This field must only be
66 * set to a non-zero value if input stream has a known constant framerate
67 * and should be left at its initial value if the framerate is variable or
70 AVRational frame_rate;
73 * Video with a hwaccel pixel format only. This should be a reference to an
74 * AVHWFramesContext instance describing the input frames.
76 AVBufferRef *hw_frames_ctx;
79 * Audio only, the audio sampling rate in samples per secon.
84 * Audio only, the audio channel layout
86 uint64_t channel_layout;
87 } AVBufferSrcParameters;
90 * Allocate a new AVBufferSrcParameters instance. It should be freed by the
91 * caller with av_free().
93 AVBufferSrcParameters *av_buffersrc_parameters_alloc(void);
96 * Initialize the buffersrc or abuffersrc filter with the provided parameters.
97 * This function may be called multiple times, the later calls override the
98 * previous ones. Some of the parameters may also be set through AVOptions, then
99 * whatever method is used last takes precedence.
101 * @param ctx an instance of the buffersrc or abuffersrc filter
102 * @param param the stream parameters. The frames later passed to this filter
103 * must conform to those parameters. All the allocated fields in
104 * param remain owned by the caller, libavfilter will make internal
105 * copies or references when necessary.
106 * @return 0 on success, a negative AVERROR code on failure.
108 int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *param);
111 * Add a frame to the buffer source.
113 * @param ctx an instance of the buffersrc filter
114 * @param frame frame to be added. If the frame is reference counted, this
115 * function will make a new reference to it. Otherwise the frame data will be
118 * @return 0 on success, a negative AVERROR on error
120 int av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame);
123 * Add a frame to the buffer source.
125 * @param ctx an instance of the buffersrc filter
126 * @param frame frame to be added. If the frame is reference counted, this
127 * function will take ownership of the reference(s) and reset the frame.
128 * Otherwise the frame data will be copied. If this function returns an error,
129 * the input frame is not touched.
131 * @return 0 on success, a negative AVERROR on error.
133 * @note the difference between this function and av_buffersrc_write_frame() is
134 * that av_buffersrc_write_frame() creates a new reference to the input frame,
135 * while this function takes ownership of the reference passed to it.
137 int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame);
143 #endif /* AVFILTER_BUFFERSRC_H */