avfilter.h
Go to the documentation of this file.
1 /*
2  * filter layer
3  * Copyright (c) 2007 Bobby Bingham
4  *
5  * This file is part of Libav.
6  *
7  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVFILTER_AVFILTER_H
23 #define AVFILTER_AVFILTER_H
24 
25 #include "libavutil/avutil.h"
26 #include "libavutil/log.h"
27 #include "libavutil/samplefmt.h"
28 #include "libavutil/pixfmt.h"
29 #include "libavutil/rational.h"
30 #include "libavcodec/avcodec.h"
31 
32 #include <stddef.h>
33 
34 #include "libavfilter/version.h"
35 
39 unsigned avfilter_version(void);
40 
44 const char *avfilter_configuration(void);
45 
49 const char *avfilter_license(void);
50 
51 
53 typedef struct AVFilterLink AVFilterLink;
54 typedef struct AVFilterPad AVFilterPad;
56 
62 typedef struct AVFilterBuffer {
63  uint8_t *data[8];
64 
80  int linesize[8];
81 
83  void *priv;
90  void (*free)(struct AVFilterBuffer *buf);
91 
92  int format;
93  int w, h;
94  unsigned refcount;
96 
97 #define AV_PERM_READ 0x01
98 #define AV_PERM_WRITE 0x02
99 #define AV_PERM_PRESERVE 0x04
100 #define AV_PERM_REUSE 0x08
101 #define AV_PERM_REUSE2 0x10
102 #define AV_PERM_NEG_LINESIZES 0x20
103 
104 
110  uint64_t channel_layout;
113  int planar;
115 
122  int w;
123  int h;
128  int key_frame;
130 
139 typedef struct AVFilterBufferRef {
141  uint8_t *data[8];
142 
157  int linesize[8];
158 
161 
167  int64_t pts;
168  int64_t pos;
169 
170  int format;
171 
172  int perms;
173 
176 
181 
192 
203 
212 
213 #if FF_API_AVFILTERPAD_PUBLIC
214 
222 struct AVFilterPad {
228  const char *name;
229 
233  enum AVMediaType type;
234 
242  int min_perms;
243 
253  int rej_perms;
254 
258  int (*start_frame)(AVFilterLink *link, AVFilterBufferRef *picref);
259 
266  AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
267 
274  AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
275  int nb_samples);
276 
280  int (*end_frame)(AVFilterLink *link);
281 
285  int (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
286 
297  int (*filter_frame)(AVFilterLink *link, AVFilterBufferRef *frame);
298 
308  int (*poll_frame)(AVFilterLink *link);
309 
317  int (*request_frame)(AVFilterLink *link);
318 
333  int (*config_props)(AVFilterLink *link);
334 
341  int needs_fifo;
342 };
343 #endif
344 
354 const char *avfilter_pad_get_name(AVFilterPad *pads, int pad_idx);
355 
365 enum AVMediaType avfilter_pad_get_type(AVFilterPad *pads, int pad_idx);
366 
371 typedef struct AVFilter {
372  const char *name;
373 
378  const char *description;
379 
382 
383  /*****************************************************************
384  * All fields below this line are not part of the public API. They
385  * may not be used outside of libavfilter and can be changed and
386  * removed at will.
387  * New public fields should be added right above.
388  *****************************************************************
389  */
390 
395  int (*init)(AVFilterContext *ctx, const char *args);
396 
403 
413 
414  int priv_size;
415 } AVFilter;
416 
419  const AVClass *av_class;
420 
422 
423  char *name;
424 
427 #if FF_API_FOO_COUNT
428  unsigned input_count;
429 #endif
430  unsigned nb_inputs;
431 
434 #if FF_API_FOO_COUNT
435  unsigned output_count;
436 #endif
437  unsigned nb_outputs;
438 
439  void *priv;
440 };
441 
449 struct AVFilterLink {
452 
455 
457 
458  /* These parameters apply only to video */
459  int w;
460  int h;
462  /* These two parameters apply only to audio */
463  uint64_t channel_layout;
465 
466  int format;
467 
476 
477  /*****************************************************************
478  * All fields below this line are not part of the public API. They
479  * may not be used outside of libavfilter and can be changed and
480  * removed at will.
481  * New public fields should be added right above.
482  *****************************************************************
483  */
491 
500 
509 
511  enum {
515  } init_state;
516 };
517 
527 int avfilter_link(AVFilterContext *src, unsigned srcpad,
528  AVFilterContext *dst, unsigned dstpad);
529 
537 
550 avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
551  int w, int h, enum AVPixelFormat format);
552 
565  int linesize,
566  int perms,
567  int nb_samples,
569  uint64_t channel_layout);
570 
572 void avfilter_register_all(void);
573 
575 void avfilter_uninit(void);
576 
588 
596 AVFilter *avfilter_get_by_name(const char *name);
597 
605 
615 int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
616 
627 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
628 
635 
646  unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
647 
655 
663 
664 #endif /* AVFILTER_AVFILTER_H */
uint8_t * data[8]
buffer data for each plane/channel
Definition: avfilter.h:63
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: avfilter.h:156
int(* poll_frame)(AVFilterLink *link)
Frame poll callback.
Definition: internal.h:104
enum AVMediaType avfilter_pad_get_type(AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
Definition: avfilter.c:449
int format
media format
Definition: avfilter.h:92
This structure describes decoded (raw) audio or video data.
Definition: avcodec.h:989
int nb_samples
number of audio samples
Definition: avfilter.h:111
AVFilterBufferRefAudioProps * audio
audio buffer specific properties
Definition: avfilter.h:160
AVFilterBufferRefVideoProps * video
video buffer specific properties
Definition: avfilter.h:159
int linesize[8]
number of bytes per line
Definition: avfilter.h:157
int(* init)(AVFilterContext *ctx, const char *args)
Filter initialization function.
Definition: avfilter.h:395
Libavfilter version macros.
void * priv
private data to be used by a custom free function
Definition: avfilter.h:83
enum AVMediaType type
media type of buffer data
Definition: avfilter.h:174
int(* filter_frame)(AVFilterLink *link, AVFilterBufferRef *frame)
Filtering callback.
Definition: internal.h:93
external API header
Audio specific properties in a reference to an AVFilterBuffer.
Definition: avfilter.h:109
A reference-counted buffer data type used by the filter system.
Definition: avfilter.h:62
enum AVMediaType type
AVFilterPad type.
Definition: internal.h:44
struct AVFilterBufferRefVideoProps AVFilterBufferRefVideoProps
Video specific properties in a reference to an AVFilterBuffer.
int(* query_formats)(AVFilterContext *)
Queries formats supported by the filter and its pads, and sets the in_formats for links connected to ...
Definition: avfilter.h:412
int h
width and height of the allocated buffer
Definition: avfilter.h:93
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
Definition: buffer.c:75
const char * name
Pad name.
Definition: internal.h:39
int priv_size
size of private data to allocate for the filter
Definition: avfilter.h:414
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:426
char * name
name of this filter instance
Definition: avfilter.h:423
AVFilterPad * output_pads
array of output pads
Definition: avfilter.h:432
uint8_t
int linesize[8]
number of bytes per line
Definition: avfilter.h:80
int(* request_frame)(AVFilterLink *link)
Frame request callback.
Definition: internal.h:113
int top_field_first
field order
Definition: avfilter.h:126
const char * name
void avfilter_unref_bufferp(AVFilterBufferRef **ref)
Remove a reference to a buffer and set the pointer to NULL.
Definition: buffer.c:88
const char data[16]
Definition: mxf.c:66
const char * avfilter_pad_get_name(AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
Definition: avfilter.c:444
int key_frame
1 -> keyframe, 0-> not
Definition: avfilter.h:128
void(* uninit)(AVFilterContext *ctx)
Filter uninitialization function.
Definition: avfilter.h:402
AVRational pixel_aspect
pixel aspect ratio
Definition: avfilter.h:124
int64_t pts
presentation timestamp.
Definition: avfilter.h:167
A filter pad used for either input or output.
Definition: internal.h:33
AVFilterPad * input_pads
array of input pads
Definition: avfilter.h:425
int h
image height
Definition: avfilter.h:123
void avfilter_register_all(void)
Initialize the filter system.
Definition: allfilters.c:39
AVFilterBuffer * buf
the buffer that this is a reference to
Definition: avfilter.h:140
unsigned nb_outputs
number of output pads
Definition: avfilter.h:437
void * priv
private data for use by the filter
Definition: avfilter.h:439
Video specific properties in a reference to an AVFilterBuffer.
Definition: avfilter.h:121
unsigned avfilter_version(void)
Return the LIBAVFILTER_VERSION_INT constant.
Definition: avfilter.c:37
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
Add a new reference to a buffer.
Definition: buffer.c:35
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
Definition: mpegaudioenc.c:318
void avfilter_free(AVFilterContext *filter)
Free a filter context.
Definition: avfilter.c:391
unsigned nb_inputs
number of input pads
Definition: avfilter.h:430
int avfilter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
Definition: avfilter.c:140
struct AVFilterBufferRef AVFilterBufferRef
A reference to an AVFilterBuffer.
unsigned refcount
number of references to this buffer
Definition: avfilter.h:94
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, unsigned filt_srcpad_idx, unsigned filt_dstpad_idx)
Insert a filter in the middle of an existing link.
Definition: avfilter.c:103
int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
Copy the frame properties of src to dst, without copying the actual image data.
Definition: buffer.c:94
const char * avfilter_configuration(void)
Return the libavfilter build-time configuration.
Definition: avfilter.c:41
const AVFilterPad * inputs
NULL terminated list of inputs. NULL if none.
Definition: avfilter.h:380
void(* free)(struct AVFilterBuffer *buf)
A pointer to the function to deallocate this buffer if the default function is not sufficient...
Definition: avfilter.h:90
A reference to an AVFilterBuffer.
Definition: avfilter.h:139
struct AVFilter AVFilter
Filter definition.
sample_fmt
Definition: avconv_filter.c:63
external API header
int perms
permissions, see the AV_PERM_* flags
Definition: avfilter.h:172
int sample_rate
audio buffer sample rate
Definition: avfilter.h:112
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
out nb_samples
static int start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: dxva2_h264.c:373
void avfilter_uninit(void)
Uninitialize the filter system.
Definition: avfilter.c:299
enum AVPictureType pict_type
picture type of the frame
Definition: avfilter.h:127
Describe the class of an AVClass context structure.
Definition: log.h:33
Filter definition.
Definition: avfilter.h:371
rational number numerator/denominator
Definition: rational.h:43
AVMediaType
Definition: avutil.h:177
const char * name
filter name
Definition: avfilter.h:372
AVPictureType
Definition: avutil.h:244
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: avfilter.h:79
uint64_t channel_layout
channel layout of audio buffer
Definition: avfilter.h:110
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:433
int planar
audio buffer - planar or packed
Definition: avfilter.h:113
int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
Create a filter instance.
Definition: avfilter.c:329
int height
Definition: gxfenc.c:72
int rej_perms
Permissions which are not accepted on incoming buffers.
Definition: internal.h:64
int interlaced
is frame interlaced
Definition: avfilter.h:125
rational numbers
int avfilter_register(AVFilter *filter)
Register a filter.
Definition: avfilter.c:285
void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
Definition: buffer.c:164
AVSampleFormat
Audio Sample Formats.
Definition: samplefmt.h:49
AVFilterBufferRef * avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms, int w, int h, enum AVPixelFormat format)
Create a buffer reference wrapped around an already allocated image buffer.
Definition: video.c:101
AVFilterBufferRef * avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, int linesize, int perms, int nb_samples, enum AVSampleFormat sample_fmt, uint64_t channel_layout)
Create an audio buffer reference wrapped around an already allocated samples buffer.
Definition: audio.c:80
pixel format definitions
const char * description
A description for the filter.
Definition: avfilter.h:378
int64_t pos
byte position in stream, -1 if unknown
Definition: avfilter.h:168
AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:421
const AVClass * av_class
needed for av_log()
Definition: avfilter.h:419
uint8_t * data[8]
picture/audio data for each plane
Definition: avfilter.h:141
int format
media format
Definition: avfilter.h:170
A list of supported formats for one end of a filter link.
Definition: formats.h:64
An instance of a filter.
Definition: avfilter.h:418
struct AVFilterBuffer AVFilterBuffer
A reference-counted buffer data type used by the filter system.
const AVFilterPad * outputs
NULL terminated list of outputs. NULL if none.
Definition: avfilter.h:381
int(* config_props)(AVFilterLink *link)
Link configuration callback.
Definition: internal.h:129
struct AVFilterBufferRefAudioProps AVFilterBufferRefAudioProps
Audio specific properties in a reference to an AVFilterBuffer.
const char * avfilter_license(void)
Return the libavfilter license.
Definition: avfilter.c:46
int needs_fifo
The filter expects a fifo to be inserted on its input link, typically because it has a delay...
Definition: internal.h:137
static void draw_slice(HYuvContext *s, int y)
Definition: huffyuvdec.c:469
int min_perms
Minimum required permissions on incoming buffers.
Definition: internal.h:53
AVPixelFormat
Pixel format.
Definition: pixfmt.h:63
int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque)
Initialize a filter.
Definition: avfilter.c:435
AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
Definition: avfilter.c:274
AVFilter ** av_filter_next(AVFilter **filter)
If filter is NULL, returns a pointer to the first registered filter pointer, if filter is non-NULL...
Definition: avfilter.c:294
int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
Copy the frame properties and data pointers of src to dst, without copying the actual data...
Definition: buffer.c:120
static int end_frame(AVCodecContext *avctx)
Definition: dxva2_h264.c:427
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
Definition: avfilter.c:73