yading@10
|
1 /*
|
yading@10
|
2 * This file is part of FFmpeg.
|
yading@10
|
3 *
|
yading@10
|
4 * FFmpeg is free software; you can redistribute it and/or
|
yading@10
|
5 * modify it under the terms of the GNU Lesser General Public
|
yading@10
|
6 * License as published by the Free Software Foundation; either
|
yading@10
|
7 * version 2.1 of the License, or (at your option) any later version.
|
yading@10
|
8 *
|
yading@10
|
9 * FFmpeg is distributed in the hope that it will be useful,
|
yading@10
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@10
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@10
|
12 * Lesser General Public License for more details.
|
yading@10
|
13 *
|
yading@10
|
14 * You should have received a copy of the GNU Lesser General Public
|
yading@10
|
15 * License along with FFmpeg; if not, write to the Free Software
|
yading@10
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@10
|
17 */
|
yading@10
|
18
|
yading@10
|
19 #ifndef AVFILTER_BUFFERSINK_H
|
yading@10
|
20 #define AVFILTER_BUFFERSINK_H
|
yading@10
|
21
|
yading@10
|
22 /**
|
yading@10
|
23 * @file
|
yading@10
|
24 * memory buffer sink API for audio and video
|
yading@10
|
25 */
|
yading@10
|
26
|
yading@10
|
27 #include "avfilter.h"
|
yading@10
|
28
|
yading@10
|
29 #if FF_API_AVFILTERBUFFER
|
yading@10
|
30 /**
|
yading@10
|
31 * Get an audio/video buffer data from buffer_sink and put it in bufref.
|
yading@10
|
32 *
|
yading@10
|
33 * This function works with both audio and video buffer sinks.
|
yading@10
|
34 *
|
yading@10
|
35 * @param buffer_sink pointer to a buffersink or abuffersink context
|
yading@10
|
36 * @param flags a combination of AV_BUFFERSINK_FLAG_* flags
|
yading@10
|
37 * @return >= 0 in case of success, a negative AVERROR code in case of
|
yading@10
|
38 * failure
|
yading@10
|
39 */
|
yading@10
|
40 attribute_deprecated
|
yading@10
|
41 int av_buffersink_get_buffer_ref(AVFilterContext *buffer_sink,
|
yading@10
|
42 AVFilterBufferRef **bufref, int flags);
|
yading@10
|
43
|
yading@10
|
44 /**
|
yading@10
|
45 * Get the number of immediately available frames.
|
yading@10
|
46 */
|
yading@10
|
47 attribute_deprecated
|
yading@10
|
48 int av_buffersink_poll_frame(AVFilterContext *ctx);
|
yading@10
|
49
|
yading@10
|
50 /**
|
yading@10
|
51 * Get a buffer with filtered data from sink and put it in buf.
|
yading@10
|
52 *
|
yading@10
|
53 * @param ctx pointer to a context of a buffersink or abuffersink AVFilter.
|
yading@10
|
54 * @param buf pointer to the buffer will be written here if buf is non-NULL. buf
|
yading@10
|
55 * must be freed by the caller using avfilter_unref_buffer().
|
yading@10
|
56 * Buf may also be NULL to query whether a buffer is ready to be
|
yading@10
|
57 * output.
|
yading@10
|
58 *
|
yading@10
|
59 * @return >= 0 in case of success, a negative AVERROR code in case of
|
yading@10
|
60 * failure.
|
yading@10
|
61 */
|
yading@10
|
62 attribute_deprecated
|
yading@10
|
63 int av_buffersink_read(AVFilterContext *ctx, AVFilterBufferRef **buf);
|
yading@10
|
64
|
yading@10
|
65 /**
|
yading@10
|
66 * Same as av_buffersink_read, but with the ability to specify the number of
|
yading@10
|
67 * samples read. This function is less efficient than av_buffersink_read(),
|
yading@10
|
68 * because it copies the data around.
|
yading@10
|
69 *
|
yading@10
|
70 * @param ctx pointer to a context of the abuffersink AVFilter.
|
yading@10
|
71 * @param buf pointer to the buffer will be written here if buf is non-NULL. buf
|
yading@10
|
72 * must be freed by the caller using avfilter_unref_buffer(). buf
|
yading@10
|
73 * will contain exactly nb_samples audio samples, except at the end
|
yading@10
|
74 * of stream, when it can contain less than nb_samples.
|
yading@10
|
75 * Buf may also be NULL to query whether a buffer is ready to be
|
yading@10
|
76 * output.
|
yading@10
|
77 *
|
yading@10
|
78 * @warning do not mix this function with av_buffersink_read(). Use only one or
|
yading@10
|
79 * the other with a single sink, not both.
|
yading@10
|
80 */
|
yading@10
|
81 attribute_deprecated
|
yading@10
|
82 int av_buffersink_read_samples(AVFilterContext *ctx, AVFilterBufferRef **buf,
|
yading@10
|
83 int nb_samples);
|
yading@10
|
84 #endif
|
yading@10
|
85
|
yading@10
|
86 /**
|
yading@10
|
87 * Get a frame with filtered data from sink and put it in frame.
|
yading@10
|
88 *
|
yading@10
|
89 * @param ctx pointer to a buffersink or abuffersink filter context.
|
yading@10
|
90 * @param frame pointer to an allocated frame that will be filled with data.
|
yading@10
|
91 * The data must be freed using av_frame_unref() / av_frame_free()
|
yading@10
|
92 * @param flags a combination of AV_BUFFERSINK_FLAG_* flags
|
yading@10
|
93 *
|
yading@10
|
94 * @return >= 0 in for success, a negative AVERROR code for failure.
|
yading@10
|
95 */
|
yading@10
|
96 int av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags);
|
yading@10
|
97
|
yading@10
|
98 /**
|
yading@10
|
99 * Tell av_buffersink_get_buffer_ref() to read video/samples buffer
|
yading@10
|
100 * reference, but not remove it from the buffer. This is useful if you
|
yading@10
|
101 * need only to read a video/samples buffer, without to fetch it.
|
yading@10
|
102 */
|
yading@10
|
103 #define AV_BUFFERSINK_FLAG_PEEK 1
|
yading@10
|
104
|
yading@10
|
105 /**
|
yading@10
|
106 * Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
|
yading@10
|
107 * If a frame is already buffered, it is read (and removed from the buffer),
|
yading@10
|
108 * but if no frame is present, return AVERROR(EAGAIN).
|
yading@10
|
109 */
|
yading@10
|
110 #define AV_BUFFERSINK_FLAG_NO_REQUEST 2
|
yading@10
|
111
|
yading@10
|
112 /**
|
yading@10
|
113 * Struct to use for initializing a buffersink context.
|
yading@10
|
114 */
|
yading@10
|
115 typedef struct {
|
yading@10
|
116 const enum AVPixelFormat *pixel_fmts; ///< list of allowed pixel formats, terminated by AV_PIX_FMT_NONE
|
yading@10
|
117 } AVBufferSinkParams;
|
yading@10
|
118
|
yading@10
|
119 /**
|
yading@10
|
120 * Create an AVBufferSinkParams structure.
|
yading@10
|
121 *
|
yading@10
|
122 * Must be freed with av_free().
|
yading@10
|
123 */
|
yading@10
|
124 AVBufferSinkParams *av_buffersink_params_alloc(void);
|
yading@10
|
125
|
yading@10
|
126 /**
|
yading@10
|
127 * Struct to use for initializing an abuffersink context.
|
yading@10
|
128 */
|
yading@10
|
129 typedef struct {
|
yading@10
|
130 const enum AVSampleFormat *sample_fmts; ///< list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE
|
yading@10
|
131 const int64_t *channel_layouts; ///< list of allowed channel layouts, terminated by -1
|
yading@10
|
132 const int *channel_counts; ///< list of allowed channel counts, terminated by -1
|
yading@10
|
133 int all_channel_counts; ///< if not 0, accept any channel count or layout
|
yading@10
|
134 int *sample_rates; ///< list of allowed sample rates, terminated by -1
|
yading@10
|
135 } AVABufferSinkParams;
|
yading@10
|
136
|
yading@10
|
137 /**
|
yading@10
|
138 * Create an AVABufferSinkParams structure.
|
yading@10
|
139 *
|
yading@10
|
140 * Must be freed with av_free().
|
yading@10
|
141 */
|
yading@10
|
142 AVABufferSinkParams *av_abuffersink_params_alloc(void);
|
yading@10
|
143
|
yading@10
|
144 /**
|
yading@10
|
145 * Set the frame size for an audio buffer sink.
|
yading@10
|
146 *
|
yading@10
|
147 * All calls to av_buffersink_get_buffer_ref will return a buffer with
|
yading@10
|
148 * exactly the specified number of samples, or AVERROR(EAGAIN) if there is
|
yading@10
|
149 * not enough. The last buffer at EOF will be padded with 0.
|
yading@10
|
150 */
|
yading@10
|
151 void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size);
|
yading@10
|
152
|
yading@10
|
153 /**
|
yading@10
|
154 * Get the frame rate of the input.
|
yading@10
|
155 */
|
yading@10
|
156 AVRational av_buffersink_get_frame_rate(AVFilterContext *ctx);
|
yading@10
|
157
|
yading@10
|
158 /**
|
yading@10
|
159 * Get a frame with filtered data from sink and put it in frame.
|
yading@10
|
160 *
|
yading@10
|
161 * @param ctx pointer to a context of a buffersink or abuffersink AVFilter.
|
yading@10
|
162 * @param frame pointer to an allocated frame that will be filled with data.
|
yading@10
|
163 * The data must be freed using av_frame_unref() / av_frame_free()
|
yading@10
|
164 *
|
yading@10
|
165 * @return >= 0 in case of success, a negative AVERROR code in case of
|
yading@10
|
166 * failure.
|
yading@10
|
167 */
|
yading@10
|
168 int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame);
|
yading@10
|
169
|
yading@10
|
170 /**
|
yading@10
|
171 * Same as av_buffersink_get_frame(), but with the ability to specify the number
|
yading@10
|
172 * of samples read. This function is less efficient than
|
yading@10
|
173 * av_buffersink_get_frame(), because it copies the data around.
|
yading@10
|
174 *
|
yading@10
|
175 * @param ctx pointer to a context of the abuffersink AVFilter.
|
yading@10
|
176 * @param frame pointer to an allocated frame that will be filled with data.
|
yading@10
|
177 * The data must be freed using av_frame_unref() / av_frame_free()
|
yading@10
|
178 * frame will contain exactly nb_samples audio samples, except at
|
yading@10
|
179 * the end of stream, when it can contain less than nb_samples.
|
yading@10
|
180 *
|
yading@10
|
181 * @warning do not mix this function with av_buffersink_get_frame(). Use only one or
|
yading@10
|
182 * the other with a single sink, not both.
|
yading@10
|
183 */
|
yading@10
|
184 int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int nb_samples);
|
yading@10
|
185
|
yading@10
|
186 #endif /* AVFILTER_BUFFERSINK_H */
|