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_INTERNAL_H
20 #define AVFILTER_INTERNAL_H
24 * internal API functions
29 #if !FF_API_AVFILTERPAD_PUBLIC
31 * A filter pad used for either input or output.
35 * Pad name. The name is unique among inputs and among outputs, but an
36 * input may have the same name as an output. This may be NULL if this
37 * pad has no need to ever be referenced by name.
44 enum AVMediaType type;
47 * Minimum required permissions on incoming buffers. Any buffer with
48 * insufficient permissions will be automatically copied by the filter
49 * system to a new buffer which provides the needed access permissions.
56 * Permissions which are not accepted on incoming buffers. Any buffer
57 * which has any of these permissions set will be automatically copied
58 * by the filter system to a new buffer which does not have those
59 * permissions. This can be used to easily disallow buffers with
67 * Callback called before passing the first slice of a new frame. If
68 * NULL, the filter layer will default to storing a reference to the
69 * picture inside the link structure.
71 * Input video pads only.
73 void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
76 * Callback function to get a video buffer. If NULL, the filter system will
77 * use avfilter_default_get_video_buffer().
79 * Input video pads only.
81 AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
84 * Callback function to get an audio buffer. If NULL, the filter system will
85 * use avfilter_default_get_audio_buffer().
87 * Input audio pads only.
89 AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
93 * Callback called after the slices of a frame are completely sent. If
94 * NULL, the filter layer will default to releasing the reference stored
95 * in the link structure during start_frame().
97 * Input video pads only.
99 void (*end_frame)(AVFilterLink *link);
102 * Slice drawing callback. This is where a filter receives video data
103 * and should do its processing.
105 * Input video pads only.
107 void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
110 * Samples filtering callback. This is where a filter receives audio data
111 * and should do its processing.
113 * Input audio pads only.
115 void (*filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref);
118 * Frame poll callback. This returns the number of immediately available
119 * samples. It should return a positive value if the next request_frame()
120 * is guaranteed to return one frame (with no delay).
122 * Defaults to just calling the source poll_frame() method.
126 int (*poll_frame)(AVFilterLink *link);
129 * Frame request callback. A call to this should result in at least one
130 * frame being output over the given link. This should return zero on
131 * success, and another value on error.
135 int (*request_frame)(AVFilterLink *link);
138 * Link configuration callback.
140 * For output pads, this should set the link properties such as
141 * width/height. This should NOT set the format property - that is
142 * negotiated between filters by the filter system using the
143 * query_formats() callback before this function is called.
145 * For input pads, this should check the properties of the link, and update
146 * the filter's internal state as necessary.
148 * For both input and output filters, this should return zero on success,
149 * and another value on error.
151 int (*config_props)(AVFilterLink *link);
154 * The filter expects a fifo to be inserted on its input link,
155 * typically because it has a delay.
163 /** default handler for freeing audio/video buffer when there are no references left */
164 void ff_avfilter_default_free_buffer(AVFilterBuffer *buf);
166 /** Tell is a format is contained in the provided list terminated by -1. */
167 int ff_fmt_is_in(int fmt, const int *fmts);
169 #define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func)
171 void ff_dlog_link(void *ctx, AVFilterLink *link, int end);
176 * @param idx Insertion point. Pad is inserted at the end if this point
177 * is beyond the end of the list of pads.
178 * @param count Pointer to the number of pads in the list
179 * @param padidx_off Offset within an AVFilterLink structure to the element
180 * to increment when inserting a new pad causes link
181 * numbering to change
182 * @param pads Pointer to the pointer to the beginning of the list of pads
183 * @param links Pointer to the pointer to the beginning of the list of links
184 * @param newpad The new pad to add. A copy is made when adding.
186 void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
187 AVFilterPad **pads, AVFilterLink ***links,
188 AVFilterPad *newpad);
190 /** Insert a new input pad for the filter. */
191 static inline void ff_insert_inpad(AVFilterContext *f, unsigned index,
194 ff_insert_pad(index, &f->nb_inputs, offsetof(AVFilterLink, dstpad),
195 &f->input_pads, &f->inputs, p);
197 f->input_count = f->nb_inputs;
201 /** Insert a new output pad for the filter. */
202 static inline void ff_insert_outpad(AVFilterContext *f, unsigned index,
205 ff_insert_pad(index, &f->nb_outputs, offsetof(AVFilterLink, srcpad),
206 &f->output_pads, &f->outputs, p);
208 f->output_count = f->nb_outputs;
213 * Poll a frame from the filter chain.
215 * @param link the input link
216 * @return the number of immediately available frames, a negative
217 * number in case of error
219 int ff_poll_frame(AVFilterLink *link);
222 * Request an input frame from the filter at the other end of the link.
224 * @param link the input link
225 * @return zero on success
227 int ff_request_frame(AVFilterLink *link);
229 #endif /* AVFILTER_INTERNAL_H */