avconv: pass the actually selected decoder to filter_codec_opts().
[FFMpeg-mirror/mplayer-patches.git] / libavfilter / internal.h
blob216a3554fc9cfba10552e7ee933fe5a104710651
1 /*
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
22 /**
23 * @file
24 * internal API functions
27 #include "avfilter.h"
29 #if !FF_API_AVFILTERPAD_PUBLIC
30 /**
31 * A filter pad used for either input or output.
33 struct AVFilterPad {
34 /**
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.
39 const char *name;
41 /**
42 * AVFilterPad type.
44 enum AVMediaType type;
46 /**
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.
51 * Input pads only.
53 int min_perms;
55 /**
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
60 * AV_PERM_REUSE.
62 * Input pads only.
64 int rej_perms;
66 /**
67 * Callback function to get a video buffer. If NULL, the filter system will
68 * use avfilter_default_get_video_buffer().
70 * Input video pads only.
72 AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
74 /**
75 * Callback function to get an audio buffer. If NULL, the filter system will
76 * use avfilter_default_get_audio_buffer().
78 * Input audio pads only.
80 AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
81 int nb_samples);
83 /**
84 * Filtering callback. This is where a filter receives a frame with
85 * audio/video data and should do its processing.
87 * Input pads only.
89 * @return >= 0 on success, a negative AVERROR on error. This function
90 * must ensure that samplesref is properly unreferenced on error if it
91 * hasn't been passed on to another filter.
93 int (*filter_frame)(AVFilterLink *link, AVFilterBufferRef *frame);
95 /**
96 * Frame poll callback. This returns the number of immediately available
97 * samples. It should return a positive value if the next request_frame()
98 * is guaranteed to return one frame (with no delay).
100 * Defaults to just calling the source poll_frame() method.
102 * Output pads only.
104 int (*poll_frame)(AVFilterLink *link);
107 * Frame request callback. A call to this should result in at least one
108 * frame being output over the given link. This should return zero on
109 * success, and another value on error.
111 * Output pads only.
113 int (*request_frame)(AVFilterLink *link);
116 * Link configuration callback.
118 * For output pads, this should set the link properties such as
119 * width/height. This should NOT set the format property - that is
120 * negotiated between filters by the filter system using the
121 * query_formats() callback before this function is called.
123 * For input pads, this should check the properties of the link, and update
124 * the filter's internal state as necessary.
126 * For both input and output filters, this should return zero on success,
127 * and another value on error.
129 int (*config_props)(AVFilterLink *link);
132 * The filter expects a fifo to be inserted on its input link,
133 * typically because it has a delay.
135 * input pads only.
137 int needs_fifo;
139 #endif
141 /** default handler for freeing audio/video buffer when there are no references left */
142 void ff_avfilter_default_free_buffer(AVFilterBuffer *buf);
144 /** Tell is a format is contained in the provided list terminated by -1. */
145 int ff_fmt_is_in(int fmt, const int *fmts);
147 #define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func)
149 void ff_dlog_link(void *ctx, AVFilterLink *link, int end);
152 * Insert a new pad.
154 * @param idx Insertion point. Pad is inserted at the end if this point
155 * is beyond the end of the list of pads.
156 * @param count Pointer to the number of pads in the list
157 * @param padidx_off Offset within an AVFilterLink structure to the element
158 * to increment when inserting a new pad causes link
159 * numbering to change
160 * @param pads Pointer to the pointer to the beginning of the list of pads
161 * @param links Pointer to the pointer to the beginning of the list of links
162 * @param newpad The new pad to add. A copy is made when adding.
164 void ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
165 AVFilterPad **pads, AVFilterLink ***links,
166 AVFilterPad *newpad);
168 /** Insert a new input pad for the filter. */
169 static inline void ff_insert_inpad(AVFilterContext *f, unsigned index,
170 AVFilterPad *p)
172 ff_insert_pad(index, &f->nb_inputs, offsetof(AVFilterLink, dstpad),
173 &f->input_pads, &f->inputs, p);
174 #if FF_API_FOO_COUNT
175 f->input_count = f->nb_inputs;
176 #endif
179 /** Insert a new output pad for the filter. */
180 static inline void ff_insert_outpad(AVFilterContext *f, unsigned index,
181 AVFilterPad *p)
183 ff_insert_pad(index, &f->nb_outputs, offsetof(AVFilterLink, srcpad),
184 &f->output_pads, &f->outputs, p);
185 #if FF_API_FOO_COUNT
186 f->output_count = f->nb_outputs;
187 #endif
191 * Poll a frame from the filter chain.
193 * @param link the input link
194 * @return the number of immediately available frames, a negative
195 * number in case of error
197 int ff_poll_frame(AVFilterLink *link);
200 * Request an input frame from the filter at the other end of the link.
202 * @param link the input link
203 * @return zero on success
205 int ff_request_frame(AVFilterLink *link);
208 * Send a frame of data to the next filter.
210 * @param link the output link over which the data is being sent
211 * @param frame a reference to the buffer of data being sent. The
212 * receiving filter will free this reference when it no longer
213 * needs it or pass it on to the next filter.
215 * @return >= 0 on success, a negative AVERROR on error. The receiving filter
216 * is responsible for unreferencing frame in case of error.
218 int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame);
220 #endif /* AVFILTER_INTERNAL_H */