Statistics
| Branch: | Revision:

ffmpeg / libavfilter / avfilter.h @ a242ac36

History | View | Annotate | Download (33 KB)

1 a5cbb2f4 Vitor Sessak
/*
2 664f6595 Vitor Sessak
 * filter layer
3 3fa77bde Stefano Sabatini
 * Copyright (c) 2007 Bobby Bingham
4 a5cbb2f4 Vitor Sessak
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21
22 98790382 Stefano Sabatini
#ifndef AVFILTER_AVFILTER_H
23
#define AVFILTER_AVFILTER_H
24 a5cbb2f4 Vitor Sessak
25 1f20782c Diego Biurrun
#include "libavutil/avutil.h"
26 c61cdd0a Stefano Sabatini
#include "libavcore/avcore.h"
27
#include "libavcore/samplefmt.h"
28 1f20782c Diego Biurrun
29 0eb4ff9e Stefano Sabatini
#define LIBAVFILTER_VERSION_MAJOR  1
30 a242ac36 Stefano Sabatini
#define LIBAVFILTER_VERSION_MINOR 74
31
#define LIBAVFILTER_VERSION_MICRO  0
32 be19d752 Vitor Sessak
33
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
34
                                               LIBAVFILTER_VERSION_MINOR, \
35
                                               LIBAVFILTER_VERSION_MICRO)
36
#define LIBAVFILTER_VERSION     AV_VERSION(LIBAVFILTER_VERSION_MAJOR,   \
37
                                           LIBAVFILTER_VERSION_MINOR,   \
38
                                           LIBAVFILTER_VERSION_MICRO)
39
#define LIBAVFILTER_BUILD       LIBAVFILTER_VERSION_INT
40 a7d46657 Víctor Paesa
41 a9c81431 Vitor Sessak
#include <stddef.h>
42 a5cbb2f4 Vitor Sessak
43 540f1c7b Stefano Sabatini
/**
44 49bd8e4b Måns Rullgård
 * Return the LIBAVFILTER_VERSION_INT constant.
45 540f1c7b Stefano Sabatini
 */
46
unsigned avfilter_version(void);
47
48 c1736936 Diego Biurrun
/**
49 49bd8e4b Måns Rullgård
 * Return the libavfilter build-time configuration.
50 c1736936 Diego Biurrun
 */
51 41600690 Stefano Sabatini
const char *avfilter_configuration(void);
52 c1736936 Diego Biurrun
53
/**
54 49bd8e4b Måns Rullgård
 * Return the libavfilter license.
55 c1736936 Diego Biurrun
 */
56 41600690 Stefano Sabatini
const char *avfilter_license(void);
57 c1736936 Diego Biurrun
58
59 a5cbb2f4 Vitor Sessak
typedef struct AVFilterContext AVFilterContext;
60
typedef struct AVFilterLink    AVFilterLink;
61
typedef struct AVFilterPad     AVFilterPad;
62
63
/**
64 32d7bcd4 Stefano Sabatini
 * A reference-counted buffer data type used by the filter system. Filters
65 a5cbb2f4 Vitor Sessak
 * should not store pointers to this structure directly, but instead use the
66 ecc8dada S.N. Hemanth Meenakshisundaram
 * AVFilterBufferRef structure below.
67 a5cbb2f4 Vitor Sessak
 */
68 f607cc18 Stefano Sabatini
typedef struct AVFilterBuffer {
69 56b5e9d5 S.N. Hemanth Meenakshisundaram
    uint8_t *data[8];           ///< buffer data for each plane/channel
70
    int linesize[8];            ///< number of bytes per line
71 a5cbb2f4 Vitor Sessak
72 32d7bcd4 Stefano Sabatini
    unsigned refcount;          ///< number of references to this buffer
73 13ff8fd0 Vitor Sessak
74
    /** private data to be used by a custom free function */
75 a5cbb2f4 Vitor Sessak
    void *priv;
76 13ff8fd0 Vitor Sessak
    /**
77 32d7bcd4 Stefano Sabatini
     * A pointer to the function to deallocate this buffer if the default
78 38efe768 Stefano Sabatini
     * function is not sufficient. This could, for example, add the memory
79 13ff8fd0 Vitor Sessak
     * back into a memory pool to be reused later without the overhead of
80
     * reallocating it from scratch.
81
     */
82 32d7bcd4 Stefano Sabatini
    void (*free)(struct AVFilterBuffer *buf);
83 36dc00de Michael Niedermayer
84
    int format;                 ///< media format
85
    int w, h;                   ///< width and height of the allocated buffer
86 f0d77b20 S.N. Hemanth Meenakshisundaram
} AVFilterBuffer;
87 a5cbb2f4 Vitor Sessak
88 ff5f1be0 S.N. Hemanth Meenakshisundaram
#define AV_PERM_READ     0x01   ///< can read from the buffer
89
#define AV_PERM_WRITE    0x02   ///< can write to the buffer
90
#define AV_PERM_PRESERVE 0x04   ///< nobody else can overwrite the buffer
91
#define AV_PERM_REUSE    0x08   ///< can output the buffer multiple times, with the same contents each time
92
#define AV_PERM_REUSE2   0x10   ///< can output the buffer multiple times, modified each time
93 0ccabeea Michael Niedermayer
#define AV_PERM_NEG_LINESIZES 0x20  ///< the buffer requested can have negative linesizes
94 ff5f1be0 S.N. Hemanth Meenakshisundaram
95 a5cbb2f4 Vitor Sessak
/**
96 ad2c9501 S.N. Hemanth Meenakshisundaram
 * Audio specific properties in a reference to an AVFilterBuffer. Since
97
 * AVFilterBufferRef is common to different media formats, audio specific
98
 * per reference properties must be separated out.
99
 */
100
typedef struct AVFilterBufferRefAudioProps {
101
    int64_t channel_layout;     ///< channel layout of audio buffer
102 a242ac36 Stefano Sabatini
    int nb_samples;             ///< number of audio samples
103 ad2c9501 S.N. Hemanth Meenakshisundaram
    int size;                   ///< audio buffer size
104
    uint32_t sample_rate;       ///< audio buffer sample rate
105
    int planar;                 ///< audio buffer - planar or packed
106
} AVFilterBufferRefAudioProps;
107
108
/**
109 cc80caff S.N. Hemanth Meenakshisundaram
 * Video specific properties in a reference to an AVFilterBuffer. Since
110
 * AVFilterBufferRef is common to different media formats, video specific
111
 * per reference properties must be separated out.
112
 */
113 f607cc18 Stefano Sabatini
typedef struct AVFilterBufferRefVideoProps {
114 cc80caff S.N. Hemanth Meenakshisundaram
    int w;                      ///< image width
115
    int h;                      ///< image height
116
    AVRational pixel_aspect;    ///< pixel aspect ratio
117
    int interlaced;             ///< is frame interlaced
118
    int top_field_first;        ///< field order
119
} AVFilterBufferRefVideoProps;
120
121
/**
122 f0d77b20 S.N. Hemanth Meenakshisundaram
 * A reference to an AVFilterBuffer. Since filters can manipulate the origin of
123 7fce481a S.N. Hemanth Meenakshisundaram
 * a buffer to, for example, crop image without any memcpy, the buffer origin
124 38efe768 Stefano Sabatini
 * and dimensions are per-reference properties. Linesize is also useful for
125 bbf42679 Vitor Sessak
 * image flipping, frame to field filters, etc, and so is also per-reference.
126 a5cbb2f4 Vitor Sessak
 *
127 1a18860a Vitor Sessak
 * TODO: add anything necessary for frame reordering
128 a5cbb2f4 Vitor Sessak
 */
129 f607cc18 Stefano Sabatini
typedef struct AVFilterBufferRef {
130 7fce481a S.N. Hemanth Meenakshisundaram
    AVFilterBuffer *buf;        ///< the buffer that this is a reference to
131 ad2c9501 S.N. Hemanth Meenakshisundaram
    uint8_t *data[8];           ///< picture/audio data for each plane
132 c1db7bff S.N. Hemanth Meenakshisundaram
    int linesize[8];            ///< number of bytes per line
133 d54e0948 S.N. Hemanth Meenakshisundaram
    int format;                 ///< media format
134 a5cbb2f4 Vitor Sessak
135 867ae7aa Stefano Sabatini
    /**
136
     * presentation timestamp. The time unit may change during
137
     * filtering, as it is specified in the link and the filter code
138
     * may need to rescale the PTS accordingly.
139
     */
140
    int64_t pts;
141 5bb5c1dc Stefano Sabatini
    int64_t pos;                ///< byte position in stream, -1 if unknown
142 1a18860a Vitor Sessak
143 ff5f1be0 S.N. Hemanth Meenakshisundaram
    int perms;                  ///< permissions, see the AV_PERM_* flags
144 efdc74ef Michael Niedermayer
145 cc80caff S.N. Hemanth Meenakshisundaram
    enum AVMediaType type;      ///< media type of buffer data
146
    AVFilterBufferRefVideoProps *video; ///< video buffer specific properties
147 ad2c9501 S.N. Hemanth Meenakshisundaram
    AVFilterBufferRefAudioProps *audio; ///< audio buffer specific properties
148 ecc8dada S.N. Hemanth Meenakshisundaram
} AVFilterBufferRef;
149 a5cbb2f4 Vitor Sessak
150
/**
151 ad2c9501 S.N. Hemanth Meenakshisundaram
 * Copy properties of src to dst, without copying the actual data
152 4d508e4d Stefano Sabatini
 */
153 7fce481a S.N. Hemanth Meenakshisundaram
static inline void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
154 4d508e4d Stefano Sabatini
{
155 cc80caff S.N. Hemanth Meenakshisundaram
    // copy common properties
156 4d508e4d Stefano Sabatini
    dst->pts             = src->pts;
157
    dst->pos             = src->pos;
158 cc80caff S.N. Hemanth Meenakshisundaram
159
    switch (src->type) {
160
    case AVMEDIA_TYPE_VIDEO: *dst->video = *src->video; break;
161 ad2c9501 S.N. Hemanth Meenakshisundaram
    case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break;
162 cc80caff S.N. Hemanth Meenakshisundaram
    }
163 4d508e4d Stefano Sabatini
}
164
165
/**
166 7fce481a S.N. Hemanth Meenakshisundaram
 * Add a new reference to a buffer.
167 3fa3e4f4 Stefano Sabatini
 *
168 7fce481a S.N. Hemanth Meenakshisundaram
 * @param ref   an existing reference to the buffer
169 664f6595 Vitor Sessak
 * @param pmask a bitmask containing the allowable permissions in the new
170 13ff8fd0 Vitor Sessak
 *              reference
171 7fce481a S.N. Hemanth Meenakshisundaram
 * @return      a new reference to the buffer with the same properties as the
172 13ff8fd0 Vitor Sessak
 *              old, excluding any permissions denied by pmask
173 a5cbb2f4 Vitor Sessak
 */
174 7fce481a S.N. Hemanth Meenakshisundaram
AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask);
175 a5cbb2f4 Vitor Sessak
176
/**
177 7fce481a S.N. Hemanth Meenakshisundaram
 * Remove a reference to a buffer. If this is the last reference to the
178
 * buffer, the buffer itself is also automatically freed.
179 3fa3e4f4 Stefano Sabatini
 *
180 6baf4afa Stefano Sabatini
 * @param ref reference to the buffer, may be NULL
181 a5cbb2f4 Vitor Sessak
 */
182 7fce481a S.N. Hemanth Meenakshisundaram
void avfilter_unref_buffer(AVFilterBufferRef *ref);
183 a5cbb2f4 Vitor Sessak
184 13ff8fd0 Vitor Sessak
/**
185 35f3fdf4 Vitor Sessak
 * A list of supported formats for one end of a filter link. This is used
186
 * during the format negotiation process to try to pick the best format to
187
 * use to minimize the number of necessary conversions. Each filter gives a
188
 * list of the formats supported by each input and output pad. The list
189
 * given for each pad need not be distinct - they may be references to the
190
 * same list of formats, as is often the case when a filter supports multiple
191 42f72a3a Stefano Sabatini
 * formats, but will always output the same format as it is given in input.
192 35f3fdf4 Vitor Sessak
 *
193
 * In this way, a list of possible input formats and a list of possible
194
 * output formats are associated with each link. When a set of formats is
195
 * negotiated over a link, the input and output lists are merged to form a
196
 * new list containing only the common elements of each list. In the case
197
 * that there were no common elements, a format conversion is necessary.
198
 * Otherwise, the lists are merged, and all other links which reference
199
 * either of the format lists involved in the merge are also affected.
200
 *
201
 * For example, consider the filter chain:
202
 * filter (a) --> (b) filter (b) --> (c) filter
203
 *
204
 * where the letters in parenthesis indicate a list of formats supported on
205
 * the input or output of the link. Suppose the lists are as follows:
206
 * (a) = {A, B}
207
 * (b) = {A, B, C}
208
 * (c) = {B, C}
209
 *
210
 * First, the first link's lists are merged, yielding:
211
 * filter (a) --> (a) filter (a) --> (c) filter
212
 *
213
 * Notice that format list (b) now refers to the same list as filter list (a).
214
 * Next, the lists for the second link are merged, yielding:
215
 * filter (a) --> (a) filter (a) --> (a) filter
216
 *
217
 * where (a) = {B}.
218
 *
219
 * Unfortunately, when the format lists at the two ends of a link are merged,
220
 * we must ensure that all links which reference either pre-merge format list
221
 * get updated as well. Therefore, we have the format list structure store a
222
 * pointer to each of the pointers to itself.
223
 */
224 f607cc18 Stefano Sabatini
typedef struct AVFilterFormats {
225 35f3fdf4 Vitor Sessak
    unsigned format_count;      ///< number of formats
226 bdab614b S.N. Hemanth Meenakshisundaram
    int *formats;               ///< list of media formats
227 35f3fdf4 Vitor Sessak
228
    unsigned refcount;          ///< number of references to this list
229 f607cc18 Stefano Sabatini
    struct AVFilterFormats ***refs; ///< references to this list
230
}  AVFilterFormats;;
231 35f3fdf4 Vitor Sessak
232
/**
233 49bd8e4b Måns Rullgård
 * Create a list of supported formats. This is intended for use in
234 f6a1fa85 Stefano Sabatini
 * AVFilter->query_formats().
235 3fa3e4f4 Stefano Sabatini
 *
236 bdab614b S.N. Hemanth Meenakshisundaram
 * @param fmts list of media formats, terminated by -1
237 f6a1fa85 Stefano Sabatini
 * @return the format list, with no existing references
238
 */
239 bdab614b S.N. Hemanth Meenakshisundaram
AVFilterFormats *avfilter_make_format_list(const int *fmts);
240 f6a1fa85 Stefano Sabatini
241
/**
242 bdab614b S.N. Hemanth Meenakshisundaram
 * Add fmt to the list of media formats contained in *avff.
243 c1d662fd Stefano Sabatini
 * If *avff is NULL the function allocates the filter formats struct
244
 * and puts its pointer in *avff.
245 4fd1f187 Stefano Sabatini
 *
246
 * @return a non negative value in case of success, or a negative
247
 * value corresponding to an AVERROR code in case of error
248
 */
249 bdab614b S.N. Hemanth Meenakshisundaram
int avfilter_add_format(AVFilterFormats **avff, int fmt);
250 4fd1f187 Stefano Sabatini
251
/**
252 bdab614b S.N. Hemanth Meenakshisundaram
 * Return a list of all formats supported by FFmpeg for the given media type.
253 35f3fdf4 Vitor Sessak
 */
254 bdab614b S.N. Hemanth Meenakshisundaram
AVFilterFormats *avfilter_all_formats(enum AVMediaType type);
255 35f3fdf4 Vitor Sessak
256
/**
257 49bd8e4b Måns Rullgård
 * Return a format list which contains the intersection of the formats of
258 39981f53 Stefano Sabatini
 * a and b. Also, all the references of a, all the references of b, and
259
 * a and b themselves will be deallocated.
260 35f3fdf4 Vitor Sessak
 *
261
 * If a and b do not share any common formats, neither is modified, and NULL
262
 * is returned.
263
 */
264
AVFilterFormats *avfilter_merge_formats(AVFilterFormats *a, AVFilterFormats *b);
265
266 09b63a42 Michael Niedermayer
/**
267 49bd8e4b Måns Rullgård
 * Add *ref as a new reference to formats.
268 09b63a42 Michael Niedermayer
 * That is the pointers will point like in the ascii art below:
269
 *   ________
270 a27c8d5f Michael Niedermayer
 *  |formats |<--------.
271
 *  |  ____  |     ____|___________________
272
 *  | |refs| |    |  __|_
273
 *  | |* * | |    | |  | |  AVFilterLink
274 09b63a42 Michael Niedermayer
 *  | |* *--------->|*ref|
275 a27c8d5f Michael Niedermayer
 *  | |____| |    | |____|
276
 *  |________|    |________________________
277 09b63a42 Michael Niedermayer
 */
278 a27c8d5f Michael Niedermayer
void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref);
279 35f3fdf4 Vitor Sessak
280
/**
281 49bd8e4b Måns Rullgård
 * If *ref is non-NULL, remove *ref as a reference to the format list
282 063e7692 Stefano Sabatini
 * it currently points to, deallocates that list if this was the last
283
 * reference, and sets *ref to NULL.
284 a27c8d5f Michael Niedermayer
 *
285
 *         Before                                 After
286
 *   ________                               ________         NULL
287
 *  |formats |<--------.                   |formats |         ^
288
 *  |  ____  |     ____|________________   |  ____  |     ____|________________
289
 *  | |refs| |    |  __|_                  | |refs| |    |  __|_
290
 *  | |* * | |    | |  | |  AVFilterLink   | |* * | |    | |  | |  AVFilterLink
291
 *  | |* *--------->|*ref|                 | |*   | |    | |*ref|
292
 *  | |____| |    | |____|                 | |____| |    | |____|
293
 *  |________|    |_____________________   |________|    |_____________________
294 35f3fdf4 Vitor Sessak
 */
295
void avfilter_formats_unref(AVFilterFormats **ref);
296
297 b9c2fb34 Michael Niedermayer
/**
298
 *
299
 *         Before                                 After
300
 *   ________                         ________
301 a27c8d5f Michael Niedermayer
 *  |formats |<---------.            |formats |<---------.
302 b9c2fb34 Michael Niedermayer
 *  |  ____  |       ___|___         |  ____  |       ___|___
303
 *  | |refs| |      |   |   |        | |refs| |      |   |   |   NULL
304
 *  | |* *--------->|*oldref|        | |* *--------->|*newref|     ^
305
 *  | |* * | |      |_______|        | |* * | |      |_______|  ___|___
306
 *  | |____| |                       | |____| |                |   |   |
307
 *  |________|                       |________|                |*oldref|
308
 *                                                             |_______|
309
 */
310 eb30e86c Michael Niedermayer
void avfilter_formats_changeref(AVFilterFormats **oldref,
311
                                AVFilterFormats **newref);
312
313 35f3fdf4 Vitor Sessak
/**
314 664f6595 Vitor Sessak
 * A filter pad used for either input or output.
315 13ff8fd0 Vitor Sessak
 */
316 f607cc18 Stefano Sabatini
struct AVFilterPad {
317 a5cbb2f4 Vitor Sessak
    /**
318 38efe768 Stefano Sabatini
     * Pad name. The name is unique among inputs and among outputs, but an
319
     * input may have the same name as an output. This may be NULL if this
320 13ff8fd0 Vitor Sessak
     * pad has no need to ever be referenced by name.
321 a5cbb2f4 Vitor Sessak
     */
322 2844dd39 Vitor Sessak
    const char *name;
323 a5cbb2f4 Vitor Sessak
324
    /**
325 38efe768 Stefano Sabatini
     * AVFilterPad type. Only video supported now, hopefully someone will
326 a5cbb2f4 Vitor Sessak
     * add audio in the future.
327
     */
328 72415b2a Stefano Sabatini
    enum AVMediaType type;
329 a5cbb2f4 Vitor Sessak
330
    /**
331 38efe768 Stefano Sabatini
     * Minimum required permissions on incoming buffers. Any buffer with
332 60bf6ce3 Vitor Sessak
     * insufficient permissions will be automatically copied by the filter
333
     * system to a new buffer which provides the needed access permissions.
334
     *
335
     * Input pads only.
336
     */
337
    int min_perms;
338
339
    /**
340 38efe768 Stefano Sabatini
     * Permissions which are not accepted on incoming buffers. Any buffer
341 9ce95f27 Stefano Sabatini
     * which has any of these permissions set will be automatically copied
342
     * by the filter system to a new buffer which does not have those
343 38efe768 Stefano Sabatini
     * permissions. This can be used to easily disallow buffers with
344 9ce95f27 Stefano Sabatini
     * AV_PERM_REUSE.
345 60bf6ce3 Vitor Sessak
     *
346
     * Input pads only.
347
     */
348
    int rej_perms;
349
350
    /**
351 38efe768 Stefano Sabatini
     * Callback called before passing the first slice of a new frame. If
352 a5cbb2f4 Vitor Sessak
     * NULL, the filter layer will default to storing a reference to the
353
     * picture inside the link structure.
354 13ff8fd0 Vitor Sessak
     *
355
     * Input video pads only.
356 a5cbb2f4 Vitor Sessak
     */
357 ecc8dada S.N. Hemanth Meenakshisundaram
    void (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
358 a5cbb2f4 Vitor Sessak
359
    /**
360 ad2c9501 S.N. Hemanth Meenakshisundaram
     * Callback function to get a video buffer. If NULL, the filter system will
361 da23d424 Stefano Sabatini
     * use avfilter_default_get_video_buffer().
362 13ff8fd0 Vitor Sessak
     *
363
     * Input video pads only.
364 a5cbb2f4 Vitor Sessak
     */
365 ecc8dada S.N. Hemanth Meenakshisundaram
    AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
366 a5cbb2f4 Vitor Sessak
367
    /**
368 ad2c9501 S.N. Hemanth Meenakshisundaram
     * Callback function to get an audio buffer. If NULL, the filter system will
369
     * use avfilter_default_get_audio_buffer().
370
     *
371
     * Input audio pads only.
372
     */
373
    AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
374 5d6e4c16 Stefano Sabatini
                                           enum AVSampleFormat sample_fmt, int size,
375 ad2c9501 S.N. Hemanth Meenakshisundaram
                                           int64_t channel_layout, int planar);
376
377
    /**
378 38efe768 Stefano Sabatini
     * Callback called after the slices of a frame are completely sent. If
379 a5cbb2f4 Vitor Sessak
     * NULL, the filter layer will default to releasing the reference stored
380
     * in the link structure during start_frame().
381 13ff8fd0 Vitor Sessak
     *
382
     * Input video pads only.
383 a5cbb2f4 Vitor Sessak
     */
384
    void (*end_frame)(AVFilterLink *link);
385
386
    /**
387 38efe768 Stefano Sabatini
     * Slice drawing callback. This is where a filter receives video data
388 13ff8fd0 Vitor Sessak
     * and should do its processing.
389
     *
390
     * Input video pads only.
391 a5cbb2f4 Vitor Sessak
     */
392 a13a5437 Stefano Sabatini
    void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
393 a5cbb2f4 Vitor Sessak
394
    /**
395 ad2c9501 S.N. Hemanth Meenakshisundaram
     * Samples filtering callback. This is where a filter receives audio data
396
     * and should do its processing.
397
     *
398
     * Input audio pads only.
399
     */
400
    void (*filter_samples)(AVFilterLink *link, AVFilterBufferRef *samplesref);
401
402
    /**
403 38efe768 Stefano Sabatini
     * Frame poll callback. This returns the number of immediately available
404 177477f5 Michael Niedermayer
     * samples. It should return a positive value if the next request_frame()
405 d224d73a Vitor Sessak
     * is guaranteed to return one frame (with no delay).
406
     *
407
     * Defaults to just calling the source poll_frame() method.
408
     *
409
     * Output video pads only.
410
     */
411
    int (*poll_frame)(AVFilterLink *link);
412
413
    /**
414 38efe768 Stefano Sabatini
     * Frame request callback. A call to this should result in at least one
415
     * frame being output over the given link. This should return zero on
416 13ff8fd0 Vitor Sessak
     * success, and another value on error.
417
     *
418
     * Output video pads only.
419 a5cbb2f4 Vitor Sessak
     */
420 63f64e6f Vitor Sessak
    int (*request_frame)(AVFilterLink *link);
421 a5cbb2f4 Vitor Sessak
422
    /**
423 13ff8fd0 Vitor Sessak
     * Link configuration callback.
424
     *
425
     * For output pads, this should set the link properties such as
426 38efe768 Stefano Sabatini
     * width/height. This should NOT set the format property - that is
427 13ff8fd0 Vitor Sessak
     * negotiated between filters by the filter system using the
428
     * query_formats() callback before this function is called.
429 d3e57c15 Vitor Sessak
     *
430
     * For input pads, this should check the properties of the link, and update
431
     * the filter's internal state as necessary.
432 13ff8fd0 Vitor Sessak
     *
433
     * For both input and output filters, this should return zero on success,
434
     * and another value on error.
435 a5cbb2f4 Vitor Sessak
     */
436 d3e57c15 Vitor Sessak
    int (*config_props)(AVFilterLink *link);
437 a5cbb2f4 Vitor Sessak
};
438
439 2b187df9 Stefano Sabatini
/** default handler for start_frame() for video inputs */
440 ecc8dada S.N. Hemanth Meenakshisundaram
void avfilter_default_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
441 a4fb0ada Stefano Sabatini
442 b9609848 Stefano Sabatini
/** default handler for draw_slice() for video inputs */
443 a13a5437 Stefano Sabatini
void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
444 a4fb0ada Stefano Sabatini
445 2b187df9 Stefano Sabatini
/** default handler for end_frame() for video inputs */
446 a5cbb2f4 Vitor Sessak
void avfilter_default_end_frame(AVFilterLink *link);
447 a4fb0ada Stefano Sabatini
448 ad2c9501 S.N. Hemanth Meenakshisundaram
/** default handler for filter_samples() for audio inputs */
449
void avfilter_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
450
451
/** default handler for config_props() for audio/video outputs */
452 901e6b39 Vitor Sessak
int avfilter_default_config_output_link(AVFilterLink *link);
453 a4fb0ada Stefano Sabatini
454 ad2c9501 S.N. Hemanth Meenakshisundaram
/** default handler for config_props() for audio/video inputs */
455 85322466 Vitor Sessak
int avfilter_default_config_input_link (AVFilterLink *link);
456 a4fb0ada Stefano Sabatini
457 2b187df9 Stefano Sabatini
/** default handler for get_video_buffer() for video inputs */
458 ecc8dada S.N. Hemanth Meenakshisundaram
AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
459 a4fb0ada Stefano Sabatini
                                                     int perms, int w, int h);
460 ad2c9501 S.N. Hemanth Meenakshisundaram
461
/** default handler for get_audio_buffer() for audio inputs */
462
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
463 5d6e4c16 Stefano Sabatini
                                                     enum AVSampleFormat sample_fmt, int size,
464 ad2c9501 S.N. Hemanth Meenakshisundaram
                                                     int64_t channel_layout, int planar);
465
466 35f3fdf4 Vitor Sessak
/**
467
 * A helper for query_formats() which sets all links to the same list of
468
 * formats. If there are no links hooked to this filter, the list of formats is
469
 * freed.
470
 */
471
void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats);
472 a4fb0ada Stefano Sabatini
473 35f3fdf4 Vitor Sessak
/** Default handler for query_formats() */
474
int avfilter_default_query_formats(AVFilterContext *ctx);
475 a5cbb2f4 Vitor Sessak
476 91d1c741 Bobby Bingham
/** start_frame() handler for filters which simply pass video along */
477 ecc8dada S.N. Hemanth Meenakshisundaram
void avfilter_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
478 91d1c741 Bobby Bingham
479
/** draw_slice() handler for filters which simply pass video along */
480
void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
481
482
/** end_frame() handler for filters which simply pass video along */
483
void avfilter_null_end_frame(AVFilterLink *link);
484
485 ad2c9501 S.N. Hemanth Meenakshisundaram
/** filter_samples() handler for filters which simply pass audio along */
486
void avfilter_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
487
488 91d1c741 Bobby Bingham
/** get_video_buffer() handler for filters which simply pass video along */
489 ecc8dada S.N. Hemanth Meenakshisundaram
AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
490 91d1c741 Bobby Bingham
                                                  int perms, int w, int h);
491
492 ad2c9501 S.N. Hemanth Meenakshisundaram
/** get_audio_buffer() handler for filters which simply pass audio along */
493
AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
494 5d6e4c16 Stefano Sabatini
                                                  enum AVSampleFormat sample_fmt, int size,
495 ad2c9501 S.N. Hemanth Meenakshisundaram
                                                  int64_t channel_layout, int planar);
496
497 13ff8fd0 Vitor Sessak
/**
498 38efe768 Stefano Sabatini
 * Filter definition. This defines the pads a filter contains, and all the
499 13ff8fd0 Vitor Sessak
 * callback functions used to interact with the filter.
500
 */
501 f607cc18 Stefano Sabatini
typedef struct AVFilter {
502 2844dd39 Vitor Sessak
    const char *name;         ///< filter name
503 a5cbb2f4 Vitor Sessak
504 13ff8fd0 Vitor Sessak
    int priv_size;      ///< size of private data to allocate for the filter
505 a5cbb2f4 Vitor Sessak
506 4d96a914 Vitor Sessak
    /**
507 38efe768 Stefano Sabatini
     * Filter initialization function. Args contains the user-supplied
508
     * parameters. FIXME: maybe an AVOption-based system would be better?
509 6e365c57 Vitor Sessak
     * opaque is data provided by the code requesting creation of the filter,
510
     * and is used to pass data to the filter.
511 4d96a914 Vitor Sessak
     */
512 95bcf498 Vitor Sessak
    int (*init)(AVFilterContext *ctx, const char *args, void *opaque);
513 13ff8fd0 Vitor Sessak
514
    /**
515 38efe768 Stefano Sabatini
     * Filter uninitialization function. Should deallocate any memory held
516 7fce481a S.N. Hemanth Meenakshisundaram
     * by the filter, release any buffer references, etc. This does not need
517 13ff8fd0 Vitor Sessak
     * to deallocate the AVFilterContext->priv memory itself.
518
     */
519 a5cbb2f4 Vitor Sessak
    void (*uninit)(AVFilterContext *ctx);
520
521 35f3fdf4 Vitor Sessak
    /**
522 c4d2e41c Stefano Sabatini
     * Queries formats supported by the filter and its pads, and sets the
523 35f3fdf4 Vitor Sessak
     * in_formats for links connected to its output pads, and out_formats
524
     * for links connected to its input pads.
525
     *
526 fe592585 Stefano Sabatini
     * @return zero on success, a negative value corresponding to an
527
     * AVERROR code otherwise
528 35f3fdf4 Vitor Sessak
     */
529
    int (*query_formats)(AVFilterContext *);
530
531 13ff8fd0 Vitor Sessak
    const AVFilterPad *inputs;  ///< NULL terminated list of inputs. NULL if none
532
    const AVFilterPad *outputs; ///< NULL terminated list of outputs. NULL if none
533 cccd292a Stefano Sabatini
534
    /**
535
     * A description for the filter. You should use the
536
     * NULL_IF_CONFIG_SMALL() macro to define it.
537
     */
538
    const char *description;
539 a5cbb2f4 Vitor Sessak
} AVFilter;
540
541 13ff8fd0 Vitor Sessak
/** An instance of a filter */
542 f607cc18 Stefano Sabatini
struct AVFilterContext {
543 d42a814e Panagiotis Issaris
    const AVClass *av_class;              ///< needed for av_log()
544 a5cbb2f4 Vitor Sessak
545 664f6595 Vitor Sessak
    AVFilter *filter;               ///< the AVFilter of which this is an instance
546 a5cbb2f4 Vitor Sessak
547 13ff8fd0 Vitor Sessak
    char *name;                     ///< name of this filter instance
548 dcea2482 Vitor Sessak
549 13ff8fd0 Vitor Sessak
    unsigned input_count;           ///< number of input pads
550
    AVFilterPad   *input_pads;      ///< array of input pads
551
    AVFilterLink **inputs;          ///< array of pointers to input links
552 25f8e601 Vitor Sessak
553 13ff8fd0 Vitor Sessak
    unsigned output_count;          ///< number of output pads
554
    AVFilterPad   *output_pads;     ///< array of output pads
555
    AVFilterLink **outputs;         ///< array of pointers to output links
556 a5cbb2f4 Vitor Sessak
557 13ff8fd0 Vitor Sessak
    void *priv;                     ///< private data for use by the filter
558 a5cbb2f4 Vitor Sessak
};
559
560 13ff8fd0 Vitor Sessak
/**
561 38efe768 Stefano Sabatini
 * A link between two filters. This contains pointers to the source and
562 f4433de9 Diego Biurrun
 * destination filters between which this link exists, and the indexes of
563 38efe768 Stefano Sabatini
 * the pads involved. In addition, this link also contains the parameters
564 13ff8fd0 Vitor Sessak
 * which have been negotiated and agreed upon between the filter, such as
565 2b187df9 Stefano Sabatini
 * image dimensions, format, etc.
566 13ff8fd0 Vitor Sessak
 */
567 f607cc18 Stefano Sabatini
struct AVFilterLink {
568 13ff8fd0 Vitor Sessak
    AVFilterContext *src;       ///< source filter
569 acc0490f Stefano Sabatini
    AVFilterPad *srcpad;        ///< output pad on the source filter
570 a5cbb2f4 Vitor Sessak
571 13ff8fd0 Vitor Sessak
    AVFilterContext *dst;       ///< dest filter
572 acc0490f Stefano Sabatini
    AVFilterPad *dstpad;        ///< input pad on the dest filter
573 a5cbb2f4 Vitor Sessak
574 24c4eff6 Vitor Sessak
    /** stage of the initialization of the link properties (dimensions, etc) */
575
    enum {
576
        AVLINK_UNINIT = 0,      ///< not started
577
        AVLINK_STARTINIT,       ///< started, but incomplete
578
        AVLINK_INIT             ///< complete
579
    } init_state;
580
581 bdab614b S.N. Hemanth Meenakshisundaram
    enum AVMediaType type;      ///< filter media type
582
583 ad2c9501 S.N. Hemanth Meenakshisundaram
    /* These two parameters apply only to video */
584 13ff8fd0 Vitor Sessak
    int w;                      ///< agreed upon image width
585
    int h;                      ///< agreed upon image height
586 ad2c9501 S.N. Hemanth Meenakshisundaram
    /* These two parameters apply only to audio */
587 63e8d976 Stefano Sabatini
    int64_t channel_layout;     ///< channel layout of current buffer (see libavcore/audioconvert.h)
588 ad2c9501 S.N. Hemanth Meenakshisundaram
    int64_t sample_rate;        ///< samples per second
589
590 bdab614b S.N. Hemanth Meenakshisundaram
    int format;                 ///< agreed upon media format
591 a5cbb2f4 Vitor Sessak
592 60bf6ce3 Vitor Sessak
    /**
593 35f3fdf4 Vitor Sessak
     * Lists of formats supported by the input and output filters respectively.
594
     * These lists are used for negotiating the format to actually be used,
595
     * which will be loaded into the format member, above, when chosen.
596
     */
597
    AVFilterFormats *in_formats;
598
    AVFilterFormats *out_formats;
599
600
    /**
601 7fce481a S.N. Hemanth Meenakshisundaram
     * The buffer reference currently being sent across the link by the source
602 38efe768 Stefano Sabatini
     * filter. This is used internally by the filter system to allow
603 7fce481a S.N. Hemanth Meenakshisundaram
     * automatic copying of buffers which do not have sufficient permissions
604 38efe768 Stefano Sabatini
     * for the destination. This should not be accessed directly by the
605 60bf6ce3 Vitor Sessak
     * filters.
606
     */
607 5d4890d7 S.N. Hemanth Meenakshisundaram
    AVFilterBufferRef *src_buf;
608 60bf6ce3 Vitor Sessak
609 5d4890d7 S.N. Hemanth Meenakshisundaram
    AVFilterBufferRef *cur_buf;
610
    AVFilterBufferRef *out_buf;
611 867ae7aa Stefano Sabatini
612
    /**
613
     * Define the time base used by the PTS of the frames/samples
614
     * which will pass through this link.
615
     * During the configuration stage, each filter is supposed to
616
     * change only the output timebase, while the timebase of the
617
     * input link is assumed to be an unchangeable property.
618
     */
619
    AVRational time_base;
620 a5cbb2f4 Vitor Sessak
};
621
622 13ff8fd0 Vitor Sessak
/**
623 49bd8e4b Måns Rullgård
 * Link two filters together.
624 3fa3e4f4 Stefano Sabatini
 *
625 664f6595 Vitor Sessak
 * @param src    the source filter
626
 * @param srcpad index of the output pad on the source filter
627
 * @param dst    the destination filter
628
 * @param dstpad index of the input pad on the destination filter
629
 * @return       zero on success
630 13ff8fd0 Vitor Sessak
 */
631 a5cbb2f4 Vitor Sessak
int avfilter_link(AVFilterContext *src, unsigned srcpad,
632
                  AVFilterContext *dst, unsigned dstpad);
633
634 13ff8fd0 Vitor Sessak
/**
635 bdab614b S.N. Hemanth Meenakshisundaram
 * Negotiate the media format, dimensions, etc of all inputs to a filter.
636 3fa3e4f4 Stefano Sabatini
 *
637 664f6595 Vitor Sessak
 * @param filter the filter to negotiate the properties for its inputs
638
 * @return       zero on successful negotiation
639 13ff8fd0 Vitor Sessak
 */
640 24c4eff6 Vitor Sessak
int avfilter_config_links(AVFilterContext *filter);
641 85322466 Vitor Sessak
642 13ff8fd0 Vitor Sessak
/**
643 49bd8e4b Måns Rullgård
 * Request a picture buffer with a specific set of permissions.
644 3fa3e4f4 Stefano Sabatini
 *
645 7fce481a S.N. Hemanth Meenakshisundaram
 * @param link  the output link to the filter from which the buffer will
646 13ff8fd0 Vitor Sessak
 *              be requested
647 664f6595 Vitor Sessak
 * @param perms the required access permissions
648 0eb4ff9e Stefano Sabatini
 * @param w     the minimum width of the buffer to allocate
649
 * @param h     the minimum height of the buffer to allocate
650 7fce481a S.N. Hemanth Meenakshisundaram
 * @return      A reference to the buffer. This must be unreferenced with
651
 *              avfilter_unref_buffer when you are finished with it.
652 13ff8fd0 Vitor Sessak
 */
653 ecc8dada S.N. Hemanth Meenakshisundaram
AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms,
654 0eb4ff9e Stefano Sabatini
                                          int w, int h);
655 13ff8fd0 Vitor Sessak
656
/**
657 d38c340f Stefano Sabatini
 * Create a buffer reference wrapped around an already allocated image
658
 * buffer.
659
 *
660
 * @param data pointers to the planes of the image to reference
661
 * @param linesize linesizes for the planes of the image to reference
662
 * @param perms the required access permissions
663
 * @param w the width of the image specified by the data and linesize arrays
664
 * @param h the height of the image specified by the data and linesize arrays
665
 * @param format the pixel format of the image specified by the data and linesize arrays
666
 */
667
AVFilterBufferRef *
668
avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
669
                                          int w, int h, enum PixelFormat format);
670
671
/**
672 ad2c9501 S.N. Hemanth Meenakshisundaram
 * Request an audio samples buffer with a specific set of permissions.
673
 *
674
 * @param link           the output link to the filter from which the buffer will
675
 *                       be requested
676
 * @param perms          the required access permissions
677
 * @param sample_fmt     the format of each sample in the buffer to allocate
678
 * @param size           the buffer size in bytes
679
 * @param channel_layout the number and type of channels per sample in the buffer to allocate
680
 * @param planar         audio data layout - planar or packed
681
 * @return               A reference to the samples. This must be unreferenced with
682 33377121 Stefano Sabatini
 *                       avfilter_unref_buffer when you are finished with it.
683 ad2c9501 S.N. Hemanth Meenakshisundaram
 */
684
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
685 5d6e4c16 Stefano Sabatini
                                             enum AVSampleFormat sample_fmt, int size,
686 ad2c9501 S.N. Hemanth Meenakshisundaram
                                             int64_t channel_layout, int planar);
687
688
/**
689 49bd8e4b Måns Rullgård
 * Request an input frame from the filter at the other end of the link.
690 3fa3e4f4 Stefano Sabatini
 *
691 664f6595 Vitor Sessak
 * @param link the input link
692
 * @return     zero on success
693 13ff8fd0 Vitor Sessak
 */
694 0155b1a1 Vitor Sessak
int avfilter_request_frame(AVFilterLink *link);
695 13ff8fd0 Vitor Sessak
696
/**
697 49bd8e4b Måns Rullgård
 * Poll a frame from the filter chain.
698 3fa3e4f4 Stefano Sabatini
 *
699 b04c740a Vitor Sessak
 * @param  link the input link
700 055068d0 Stefano Sabatini
 * @return the number of immediately available frames, a negative
701
 * number in case of error
702 b04c740a Vitor Sessak
 */
703
int avfilter_poll_frame(AVFilterLink *link);
704
705
/**
706 49bd8e4b Måns Rullgård
 * Notifie the next filter of the start of a frame.
707 3fa3e4f4 Stefano Sabatini
 *
708 664f6595 Vitor Sessak
 * @param link   the output link the frame will be sent over
709 38efe768 Stefano Sabatini
 * @param picref A reference to the frame about to be sent. The data for this
710 13ff8fd0 Vitor Sessak
 *               frame need only be valid once draw_slice() is called for that
711 38efe768 Stefano Sabatini
 *               portion. The receiving filter will free this reference when
712 13ff8fd0 Vitor Sessak
 *               it no longer needs it.
713
 */
714 ecc8dada S.N. Hemanth Meenakshisundaram
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref);
715 13ff8fd0 Vitor Sessak
716
/**
717 49bd8e4b Måns Rullgård
 * Notifie the next filter that the current frame has finished.
718 3fa3e4f4 Stefano Sabatini
 *
719 664f6595 Vitor Sessak
 * @param link the output link the frame was sent over
720 13ff8fd0 Vitor Sessak
 */
721 a5cbb2f4 Vitor Sessak
void avfilter_end_frame(AVFilterLink *link);
722 13ff8fd0 Vitor Sessak
723
/**
724 49bd8e4b Måns Rullgård
 * Send a slice to the next filter.
725 bd283738 Stefano Sabatini
 *
726
 * Slices have to be provided in sequential order, either in
727
 * top-bottom or bottom-top order. If slices are provided in
728
 * non-sequential order the behavior of the function is undefined.
729
 *
730 664f6595 Vitor Sessak
 * @param link the output link over which the frame is being sent
731
 * @param y    offset in pixels from the top of the image for this slice
732
 * @param h    height of this slice in pixels
733 a13a5437 Stefano Sabatini
 * @param slice_dir the assumed direction for sending slices,
734
 *             from the top slice to the bottom slice if the value is 1,
735
 *             from the bottom slice to the top slice if the value is -1,
736
 *             for other values the behavior of the function is undefined.
737 13ff8fd0 Vitor Sessak
 */
738 a13a5437 Stefano Sabatini
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
739 a5cbb2f4 Vitor Sessak
740 ad2c9501 S.N. Hemanth Meenakshisundaram
/**
741
 * Send a buffer of audio samples to the next filter.
742
 *
743
 * @param link       the output link over which the audio samples are being sent
744
 * @param samplesref a reference to the buffer of audio samples being sent. The
745
 *                   receiving filter will free this reference when it no longer
746
 *                   needs it or pass it on to the next filter.
747
 */
748
void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
749
750 49bd8e4b Måns Rullgård
/** Initialize the filter system. Register all builtin filters. */
751 11de6cac Vitor Sessak
void avfilter_register_all(void);
752 e4152452 Vitor Sessak
753 49bd8e4b Måns Rullgård
/** Uninitialize the filter system. Unregister all filters. */
754 a5cbb2f4 Vitor Sessak
void avfilter_uninit(void);
755 13ff8fd0 Vitor Sessak
756
/**
757 49bd8e4b Måns Rullgård
 * Register a filter. This is only needed if you plan to use
758 fc815c56 Vitor Sessak
 * avfilter_get_by_name later to lookup the AVFilter structure by name. A
759
 * filter can still by instantiated with avfilter_open even if it is not
760
 * registered.
761 3fa3e4f4 Stefano Sabatini
 *
762 664f6595 Vitor Sessak
 * @param filter the filter to register
763 86a60fa1 Stefano Sabatini
 * @return 0 if the registration was succesfull, a negative value
764
 * otherwise
765 13ff8fd0 Vitor Sessak
 */
766 86a60fa1 Stefano Sabatini
int avfilter_register(AVFilter *filter);
767 13ff8fd0 Vitor Sessak
768
/**
769 49bd8e4b Måns Rullgård
 * Get a filter definition matching the given name.
770 3fa3e4f4 Stefano Sabatini
 *
771 664f6595 Vitor Sessak
 * @param name the filter name to find
772
 * @return     the filter definition, if any matching one is registered.
773 13ff8fd0 Vitor Sessak
 *             NULL if none found.
774
 */
775 2844dd39 Vitor Sessak
AVFilter *avfilter_get_by_name(const char *name);
776 a5cbb2f4 Vitor Sessak
777 13ff8fd0 Vitor Sessak
/**
778 1433c4ab Stefano Sabatini
 * If filter is NULL, returns a pointer to the first registered filter pointer,
779
 * if filter is non-NULL, returns the next pointer after filter.
780
 * If the returned pointer points to NULL, the last registered filter
781
 * was already reached.
782
 */
783
AVFilter **av_filter_next(AVFilter **filter);
784
785
/**
786 49bd8e4b Måns Rullgård
 * Create a filter instance.
787 84c03869 Stefano Sabatini
 *
788
 * @param filter_ctx put here a pointer to the created filter context
789
 * on success, NULL on failure
790 664f6595 Vitor Sessak
 * @param filter    the filter to create an instance of
791 38efe768 Stefano Sabatini
 * @param inst_name Name to give to the new instance. Can be NULL for none.
792 84c03869 Stefano Sabatini
 * @return >= 0 in case of success, a negative error code otherwise
793 13ff8fd0 Vitor Sessak
 */
794 84c03869 Stefano Sabatini
int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
795 13ff8fd0 Vitor Sessak
796
/**
797 49bd8e4b Måns Rullgård
 * Initialize a filter.
798 3fa3e4f4 Stefano Sabatini
 *
799 664f6595 Vitor Sessak
 * @param filter the filter to initialize
800 13ff8fd0 Vitor Sessak
 * @param args   A string of parameters to use when initializing the filter.
801
 *               The format and meaning of this string varies by filter.
802 38efe768 Stefano Sabatini
 * @param opaque Any extra non-string data needed by the filter. The meaning
803 13ff8fd0 Vitor Sessak
 *               of this parameter varies by filter.
804 664f6595 Vitor Sessak
 * @return       zero on success
805 13ff8fd0 Vitor Sessak
 */
806 6e365c57 Vitor Sessak
int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
807 13ff8fd0 Vitor Sessak
808
/**
809 24de0edb Stefano Sabatini
 * Free a filter context.
810 3fa3e4f4 Stefano Sabatini
 *
811 24de0edb Stefano Sabatini
 * @param filter the filter to free
812 13ff8fd0 Vitor Sessak
 */
813 24de0edb Stefano Sabatini
void avfilter_free(AVFilterContext *filter);
814 a5cbb2f4 Vitor Sessak
815 13ff8fd0 Vitor Sessak
/**
816 49bd8e4b Måns Rullgård
 * Insert a filter in the middle of an existing link.
817 3fa3e4f4 Stefano Sabatini
 *
818 664f6595 Vitor Sessak
 * @param link the link into which the filter should be inserted
819
 * @param filt the filter to be inserted
820 486adc55 Stefano Sabatini
 * @param filt_srcpad_idx the input pad on the filter to connect
821
 * @param filt_dstpad_idx the output pad on the filter to connect
822 664f6595 Vitor Sessak
 * @return     zero on success
823 13ff8fd0 Vitor Sessak
 */
824 35f3fdf4 Vitor Sessak
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
825 486adc55 Stefano Sabatini
                           unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
826 d3e57c15 Vitor Sessak
827 a9c81431 Vitor Sessak
/**
828 49bd8e4b Måns Rullgård
 * Insert a new pad.
829 3fa3e4f4 Stefano Sabatini
 *
830 38efe768 Stefano Sabatini
 * @param idx Insertion point. Pad is inserted at the end if this point
831 a9c81431 Vitor Sessak
 *            is beyond the end of the list of pads.
832
 * @param count Pointer to the number of pads in the list
833
 * @param padidx_off Offset within an AVFilterLink structure to the element
834
 *                   to increment when inserting a new pad causes link
835
 *                   numbering to change
836
 * @param pads Pointer to the pointer to the beginning of the list of pads
837
 * @param links Pointer to the pointer to the beginning of the list of links
838
 * @param newpad The new pad to add. A copy is made when adding.
839
 */
840
void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
841
                         AVFilterPad **pads, AVFilterLink ***links,
842
                         AVFilterPad *newpad);
843
844 49bd8e4b Måns Rullgård
/** Insert a new input pad for the filter. */
845 a9c81431 Vitor Sessak
static inline void avfilter_insert_inpad(AVFilterContext *f, unsigned index,
846
                                         AVFilterPad *p)
847
{
848
    avfilter_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
849
                        &f->input_pads, &f->inputs, p);
850
}
851
852 49bd8e4b Måns Rullgård
/** Insert a new output pad for the filter. */
853 a9c81431 Vitor Sessak
static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
854
                                          AVFilterPad *p)
855
{
856
    avfilter_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
857
                        &f->output_pads, &f->outputs, p);
858
}
859
860 98790382 Stefano Sabatini
#endif  /* AVFILTER_AVFILTER_H */