FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
buffersink.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_BUFFERSINK_H
20 #define AVFILTER_BUFFERSINK_H
21 
22 /**
23  * @file
24  * @ingroup lavfi_buffersink
25  * memory buffer sink API for audio and video
26  */
27 
28 #include "avfilter.h"
29 
30 /**
31  * @defgroup lavfi_buffersink Buffer sink API
32  * @ingroup lavfi
33  * @{
34  */
35 
36 /**
37  * Get a frame with filtered data from sink and put it in frame.
38  *
39  * @param ctx pointer to a buffersink or abuffersink filter context.
40  * @param frame pointer to an allocated frame that will be filled with data.
41  * The data must be freed using av_frame_unref() / av_frame_free()
42  * @param flags a combination of AV_BUFFERSINK_FLAG_* flags
43  *
44  * @return >= 0 in for success, a negative AVERROR code for failure.
45  */
47 
48 /**
49  * Tell av_buffersink_get_buffer_ref() to read video/samples buffer
50  * reference, but not remove it from the buffer. This is useful if you
51  * need only to read a video/samples buffer, without to fetch it.
52  */
53 #define AV_BUFFERSINK_FLAG_PEEK 1
54 
55 /**
56  * Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
57  * If a frame is already buffered, it is read (and removed from the buffer),
58  * but if no frame is present, return AVERROR(EAGAIN).
59  */
60 #define AV_BUFFERSINK_FLAG_NO_REQUEST 2
61 
62 /**
63  * Struct to use for initializing a buffersink context.
64  */
65 typedef struct {
66  const enum AVPixelFormat *pixel_fmts; ///< list of allowed pixel formats, terminated by AV_PIX_FMT_NONE
68 
69 /**
70  * Create an AVBufferSinkParams structure.
71  *
72  * Must be freed with av_free().
73  */
75 
76 /**
77  * Struct to use for initializing an abuffersink context.
78  */
79 typedef struct {
80  const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE
81  const int64_t *channel_layouts; ///< list of allowed channel layouts, terminated by -1
82  const int *channel_counts; ///< list of allowed channel counts, terminated by -1
83  int all_channel_counts; ///< if not 0, accept any channel count or layout
84  int *sample_rates; ///< list of allowed sample rates, terminated by -1
86 
87 /**
88  * Create an AVABufferSinkParams structure.
89  *
90  * Must be freed with av_free().
91  */
93 
94 /**
95  * Set the frame size for an audio buffer sink.
96  *
97  * All calls to av_buffersink_get_buffer_ref will return a buffer with
98  * exactly the specified number of samples, or AVERROR(EAGAIN) if there is
99  * not enough. The last buffer at EOF will be padded with 0.
100  */
102 
103 /**
104  * Get the frame rate of the input.
105  */
107 
108 /**
109  * Get a frame with filtered data from sink and put it in frame.
110  *
111  * @param ctx pointer to a context of a buffersink or abuffersink AVFilter.
112  * @param frame pointer to an allocated frame that will be filled with data.
113  * The data must be freed using av_frame_unref() / av_frame_free()
114  *
115  * @return
116  * - >= 0 if a frame was successfully returned.
117  * - AVERROR(EAGAIN) if no frames are available at this point; more
118  * input frames must be added to the filtergraph to get more output.
119  * - AVERROR_EOF if there will be no more output frames on this sink.
120  * - A different negative AVERROR code in other failure cases.
121  */
123 
124 /**
125  * Same as av_buffersink_get_frame(), but with the ability to specify the number
126  * of samples read. This function is less efficient than
127  * av_buffersink_get_frame(), because it copies the data around.
128  *
129  * @param ctx pointer to a context of the abuffersink AVFilter.
130  * @param frame pointer to an allocated frame that will be filled with data.
131  * The data must be freed using av_frame_unref() / av_frame_free()
132  * frame will contain exactly nb_samples audio samples, except at
133  * the end of stream, when it can contain less than nb_samples.
134  *
135  * @return The return codes have the same meaning as for
136  * av_buffersink_get_samples().
137  *
138  * @warning do not mix this function with av_buffersink_get_frame(). Use only one or
139  * the other with a single sink, not both.
140  */
142 
143 /**
144  * @}
145  */
146 
147 #endif /* AVFILTER_BUFFERSINK_H */
This structure describes decoded (raw) audio or video data.
Definition: frame.h:181
AVFormatContext * ctx
Definition: movenc-test.c:48
AVBufferSinkParams * av_buffersink_params_alloc(void)
Create an AVBufferSinkParams structure.
Definition: buffersink.c:229
Main libavfilter public API header.
const int * channel_counts
list of allowed channel counts, terminated by -1
Definition: buffersink.h:82
AVABufferSinkParams * av_abuffersink_params_alloc(void)
Create an AVABufferSinkParams structure.
Definition: buffersink.c:240
enum AVSampleFormat * sample_fmts
list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE
Definition: buffersink.h:80
static AVFrame * frame
int * sample_rates
list of allowed sample rates, terminated by -1
Definition: buffersink.h:84
int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Get a frame with filtered data from sink and put it in frame.
Definition: buffersink.c:128
Struct to use for initializing an abuffersink context.
Definition: buffersink.h:79
int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int nb_samples)
Same as av_buffersink_get_frame(), but with the ability to specify the number of samples read...
Definition: buffersink.c:185
Struct to use for initializing a buffersink context.
Definition: buffersink.h:65
int frame_size
Definition: mxfenc.c:1821
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:59
int all_channel_counts
if not 0, accept any channel count or layout
Definition: buffersink.h:83
rational number numerator/denominator
Definition: rational.h:43
AVRational av_buffersink_get_frame_rate(AVFilterContext *ctx)
Get the frame rate of the input.
Definition: buffersink.c:271
static int flags
Definition: cpu.c:47
enum AVPixelFormat * pixel_fmts
list of allowed pixel formats, terminated by AV_PIX_FMT_NONE
Definition: buffersink.h:66
void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
Set the frame size for an audio buffer sink.
Definition: buffersink.c:263
An instance of a filter.
Definition: avfilter.h:304
int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame)
Get a frame with filtered data from sink and put it in frame.
Definition: buffersink.c:123
const int64_t * channel_layouts
list of allowed channel layouts, terminated by -1
Definition: buffersink.h:81
AVPixelFormat
Pixel format.
Definition: pixfmt.h:61