FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
buffersrc.h
Go to the documentation of this file.
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 
19 #ifndef AVFILTER_BUFFERSRC_H
20 #define AVFILTER_BUFFERSRC_H
21 
22 /**
23  * @file
24  * @ingroup lavfi_buffersrc
25  * Memory buffer source API.
26  */
27 
28 #include "libavcodec/avcodec.h"
29 #include "avfilter.h"
30 
31 /**
32  * @defgroup lavfi_buffersrc Buffer source API
33  * @ingroup lavfi
34  * @{
35  */
36 
37 enum {
38 
39  /**
40  * Do not check for format changes.
41  */
43 
44  /**
45  * Immediately push the frame to the output.
46  */
48 
49  /**
50  * Keep a reference to the frame.
51  * If the frame if reference-counted, create a new reference; otherwise
52  * copy the frame data.
53  */
55 
56 };
57 
58 /**
59  * Get the number of failed requests.
60  *
61  * A failed request is when the request_frame method is called while no
62  * frame is present in the buffer.
63  * The number is reset when a frame is added.
64  */
66 
67 /**
68  * This structure contains the parameters describing the frames that will be
69  * passed to this filter.
70  *
71  * It should be allocated with av_buffersrc_parameters_alloc() and freed with
72  * av_free(). All the allocated fields in it remain owned by the caller.
73  */
74 typedef struct AVBufferSrcParameters {
75  /**
76  * video: the pixel format, value corresponds to enum AVPixelFormat
77  * audio: the sample format, value corresponds to enum AVSampleFormat
78  */
79  int format;
80  /**
81  * The timebase to be used for the timestamps on the input frames.
82  */
84 
85  /**
86  * Video only, the display dimensions of the input frames.
87  */
88  int width, height;
89 
90  /**
91  * Video only, the sample (pixel) aspect ratio.
92  */
94 
95  /**
96  * Video only, the frame rate of the input video. This field must only be
97  * set to a non-zero value if input stream has a known constant framerate
98  * and should be left at its initial value if the framerate is variable or
99  * unknown.
100  */
102 
103  /**
104  * Video with a hwaccel pixel format only. This should be a reference to an
105  * AVHWFramesContext instance describing the input frames.
106  */
108 
109  /**
110  * Audio only, the audio sampling rate in samples per secon.
111  */
113 
114  /**
115  * Audio only, the audio channel layout
116  */
117  uint64_t channel_layout;
119 
120 /**
121  * Allocate a new AVBufferSrcParameters instance. It should be freed by the
122  * caller with av_free().
123  */
125 
126 /**
127  * Initialize the buffersrc or abuffersrc filter with the provided parameters.
128  * This function may be called multiple times, the later calls override the
129  * previous ones. Some of the parameters may also be set through AVOptions, then
130  * whatever method is used last takes precedence.
131  *
132  * @param ctx an instance of the buffersrc or abuffersrc filter
133  * @param param the stream parameters. The frames later passed to this filter
134  * must conform to those parameters. All the allocated fields in
135  * param remain owned by the caller, libavfilter will make internal
136  * copies or references when necessary.
137  * @return 0 on success, a negative AVERROR code on failure.
138  */
140 
141 /**
142  * Add a frame to the buffer source.
143  *
144  * @param ctx an instance of the buffersrc filter
145  * @param frame frame to be added. If the frame is reference counted, this
146  * function will make a new reference to it. Otherwise the frame data will be
147  * copied.
148  *
149  * @return 0 on success, a negative AVERROR on error
150  *
151  * This function is equivalent to av_buffersrc_add_frame_flags() with the
152  * AV_BUFFERSRC_FLAG_KEEP_REF flag.
153  */
156 
157 /**
158  * Add a frame to the buffer source.
159  *
160  * @param ctx an instance of the buffersrc filter
161  * @param frame frame to be added. If the frame is reference counted, this
162  * function will take ownership of the reference(s) and reset the frame.
163  * Otherwise the frame data will be copied. If this function returns an error,
164  * the input frame is not touched.
165  *
166  * @return 0 on success, a negative AVERROR on error.
167  *
168  * @note the difference between this function and av_buffersrc_write_frame() is
169  * that av_buffersrc_write_frame() creates a new reference to the input frame,
170  * while this function takes ownership of the reference passed to it.
171  *
172  * This function is equivalent to av_buffersrc_add_frame_flags() without the
173  * AV_BUFFERSRC_FLAG_KEEP_REF flag.
174  */
177 
178 /**
179  * Add a frame to the buffer source.
180  *
181  * By default, if the frame is reference-counted, this function will take
182  * ownership of the reference(s) and reset the frame. This can be controlled
183  * using the flags.
184  *
185  * If this function returns an error, the input frame is not touched.
186  *
187  * @param buffer_src pointer to a buffer source context
188  * @param frame a frame, or NULL to mark EOF
189  * @param flags a combination of AV_BUFFERSRC_FLAG_*
190  * @return >= 0 in case of success, a negative AVERROR code
191  * in case of failure
192  */
195  AVFrame *frame, int flags);
196 
197 
198 /**
199  * @}
200  */
201 
202 #endif /* AVFILTER_BUFFERSRC_H */
This structure describes decoded (raw) audio or video data.
Definition: frame.h:184
Main libavfilter public API header.
AVRational frame_rate
Video only, the frame rate of the input video.
Definition: buffersrc.h:101
AVRational sample_aspect_ratio
Video only, the sample (pixel) aspect ratio.
Definition: buffersrc.h:93
Do not check for format changes.
Definition: buffersrc.h:42
AVRational time_base
The timebase to be used for the timestamps on the input frames.
Definition: buffersrc.h:83
static AVFrame * frame
int sample_rate
Audio only, the audio sampling rate in samples per secon.
Definition: buffersrc.h:112
uint64_t channel_layout
Audio only, the audio channel layout.
Definition: buffersrc.h:117
int format
video: the pixel format, value corresponds to enum AVPixelFormat audio: the sample format...
Definition: buffersrc.h:79
Immediately push the frame to the output.
Definition: buffersrc.h:47
This structure contains the parameters describing the frames that will be passed to this filter...
Definition: buffersrc.h:74
AVFormatContext * ctx
Definition: movenc.c:48
AVBufferRef * hw_frames_ctx
Video with a hwaccel pixel format only.
Definition: buffersrc.h:107
Libavcodec external API header.
Keep a reference to the frame.
Definition: buffersrc.h:54
rational number numerator/denominator
Definition: rational.h:43
unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src)
Get the number of failed requests.
Definition: buffersrc.c:266
static int flags
Definition: cpu.c:47
#define av_warn_unused_result
Definition: attributes.h:56
av_warn_unused_result int av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame)
Add a frame to the buffer source.
Definition: buffersrc.c:138
A reference to a data buffer.
Definition: buffer.h:81
int av_buffersrc_parameters_set(AVFilterContext *ctx, AVBufferSrcParameters *param)
Initialize the buffersrc or abuffersrc filter with the provided parameters.
Definition: buffersrc.c:93
av_warn_unused_result int av_buffersrc_add_frame_flags(AVFilterContext *buffer_src, AVFrame *frame, int flags)
Add a frame to the buffer source.
Definition: buffersrc.c:152
AVBufferSrcParameters * av_buffersrc_parameters_alloc(void)
Allocate a new AVBufferSrcParameters instance.
Definition: buffersrc.c:82
An instance of a filter.
Definition: avfilter.h:305
int width
Video only, the display dimensions of the input frames.
Definition: buffersrc.h:88
av_warn_unused_result int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
Definition: buffersrc.c:144