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;
55 
61 typedef struct AVFilterBuffer {
62  uint8_t *data[8];
63  int linesize[8];
64 
65  unsigned refcount;
66 
68  void *priv;
75  void (*free)(struct AVFilterBuffer *buf);
76 
77  int format;
78  int w, h;
80 
81 #define AV_PERM_READ 0x01
82 #define AV_PERM_WRITE 0x02
83 #define AV_PERM_PRESERVE 0x04
84 #define AV_PERM_REUSE 0x08
85 #define AV_PERM_REUSE2 0x10
86 #define AV_PERM_NEG_LINESIZES 0x20
87 
88 
94  uint64_t channel_layout;
95  int nb_samples;
96  int size;
97  uint32_t sample_rate;
98  int planar;
100 
107  int w;
108  int h;
113  int key_frame;
115 
124 typedef struct AVFilterBufferRef {
126  uint8_t *data[8];
127  int linesize[8];
128  int format;
129 
135  int64_t pts;
136  int64_t pos;
137 
138  int perms;
139 
144 
149 {
150  // copy common properties
151  dst->pts = src->pts;
152  dst->pos = src->pos;
153 
154  switch (src->type) {
155  case AVMEDIA_TYPE_VIDEO: *dst->video = *src->video; break;
156  case AVMEDIA_TYPE_AUDIO: *dst->audio = *src->audio; break;
157  default: break;
158  }
159 }
160 
171 
179 
220 typedef struct AVFilterFormats {
221  unsigned format_count;
222  int *formats;
223 
224  unsigned refcount;
225  struct AVFilterFormats ***refs;
227 
236 
245 int avfilter_add_format(AVFilterFormats **avff, int fmt);
246 
251 
261 
275 
292 
307  AVFilterFormats **newref);
308 
312 struct AVFilterPad {
318  const char *name;
319 
325 
334 
345 
354 
361  AVFilterBufferRef *(*get_video_buffer)(AVFilterLink *link, int perms, int w, int h);
362 
369  AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
370  enum AVSampleFormat sample_fmt, int size,
371  uint64_t channel_layout, int planar);
372 
381 
388  void (*draw_slice)(AVFilterLink *link, int y, int height, int slice_dir);
389 
397 
407  int (*poll_frame)(AVFilterLink *link);
408 
417 
432  int (*config_props)(AVFilterLink *link);
433 };
434 
437 
439 void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
440 
443 
446 
449 
452 
455  int perms, int w, int h);
456 
459  enum AVSampleFormat sample_fmt, int size,
460  uint64_t channel_layout, int planar);
461 
468 
471 
474 
476 void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
477 
480 
483 
486  int perms, int w, int h);
487 
490  enum AVSampleFormat sample_fmt, int size,
491  uint64_t channel_layout, int planar);
492 
497 typedef struct AVFilter {
498  const char *name;
499 
500  int priv_size;
501 
508  int (*init)(AVFilterContext *ctx, const char *args, void *opaque);
509 
516 
526 
529 
534  const char *description;
535 } AVFilter;
536 
539  const AVClass *av_class;
540 
542 
543  char *name;
544 
545  unsigned input_count;
548 
549  unsigned output_count;
552 
553  void *priv;
554 };
555 
563 struct AVFilterLink {
566 
569 
571  enum {
575  } init_state;
576 
578 
579  /* These parameters apply only to video */
580  int w;
581  int h;
583  /* These two parameters apply only to audio */
584  uint64_t channel_layout;
585  int64_t sample_rate;
586 
587  int format;
588 
596 
605 
608 
617 };
618 
628 int avfilter_link(AVFilterContext *src, unsigned srcpad,
629  AVFilterContext *dst, unsigned dstpad);
630 
638 
651  int w, int h);
652 
665 avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms,
666  int w, int h, enum PixelFormat format);
667 
682  enum AVSampleFormat sample_fmt, int size,
683  uint64_t channel_layout, int planar);
684 
692 
701 
712 
718 void avfilter_end_frame(AVFilterLink *link);
719 
735 void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir);
736 
746 
748 void avfilter_register_all(void);
749 
751 void avfilter_uninit(void);
752 
764 
772 AVFilter *avfilter_get_by_name(const char *name);
773 
781 
791 int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name);
792 
803 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
804 
811 
822  unsigned filt_srcpad_idx, unsigned filt_dstpad_idx);
823 
837 void avfilter_insert_pad(unsigned idx, unsigned *count, size_t padidx_off,
838  AVFilterPad **pads, AVFilterLink ***links,
839  AVFilterPad *newpad);
840 
842 static inline void avfilter_insert_inpad(AVFilterContext *f, unsigned index,
843  AVFilterPad *p)
844 {
845  avfilter_insert_pad(index, &f->input_count, offsetof(AVFilterLink, dstpad),
846  &f->input_pads, &f->inputs, p);
847 }
848 
850 static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
851  AVFilterPad *p)
852 {
853  avfilter_insert_pad(index, &f->output_count, offsetof(AVFilterLink, srcpad),
854  &f->output_pads, &f->outputs, p);
855 }
856 
864 
865 #endif /* AVFILTER_AVFILTER_H */