22 #ifndef AVFILTER_AVFILTER_H
23 #define AVFILTER_AVFILTER_H
36 #include "libavutil/attributes.h"
37 #include "libavutil/avutil.h"
38 #include "libavutil/frame.h"
39 #include "libavutil/log.h"
40 #include "libavutil/samplefmt.h"
41 #include "libavutil/pixfmt.h"
42 #include "libavutil/rational.h"
43 #include "libavcodec/avcodec.h"
47 #include "libavfilter/version.h"
70 #if FF_API_AVFILTERBUFFER
76 typedef struct AVFilterBuffer {
104 void (*free)(
struct AVFilterBuffer *buf);
111 #define AV_PERM_READ 0x01
112 #define AV_PERM_WRITE 0x02
113 #define AV_PERM_PRESERVE 0x04
114 #define AV_PERM_REUSE 0x08
115 #define AV_PERM_REUSE2 0x10
116 #define AV_PERM_NEG_LINESIZES 0x20
123 typedef struct AVFilterBufferRefAudioProps {
124 uint64_t channel_layout;
128 } AVFilterBufferRefAudioProps;
135 typedef struct AVFilterBufferRefVideoProps {
143 } AVFilterBufferRefVideoProps;
153 typedef struct AVFilterBufferRef {
173 AVFilterBufferRefVideoProps *video;
174 AVFilterBufferRefAudioProps *audio;
232 #if FF_API_AVFILTERPAD_PUBLIC
277 int (*start_frame)(
AVFilterLink *link, AVFilterBufferRef *picref);
404 #define AVFILTER_FLAG_DYNAMIC_INPUTS (1 << 0)
410 #define AVFILTER_FLAG_DYNAMIC_OUTPUTS (1 << 1)
415 #define AVFILTER_FLAG_SLICE_THREADS (1 << 2)
558 #define AVFILTER_THREAD_SLICE (1 << 0)
708 #if FF_API_AVFILTERBUFFER
742 uint64_t channel_layout);
748 #if FF_API_OLD_FILTER_REGISTER
773 #if !FF_API_NOCONST_GET_NAME
785 #if FF_API_OLD_FILTER_REGISTER
797 #if FF_API_AVFILTER_OPEN
813 #if FF_API_AVFILTER_INIT_FILTER
880 unsigned filt_srcpad_idx,
unsigned filt_dstpad_idx);
882 #if FF_API_AVFILTERBUFFER
938 void *arg,
int *ret,
int nb_jobs);
944 unsigned filter_count;
947 #if !FF_API_FOO_COUNT
1036 #if FF_API_AVFILTER_OPEN
1064 const char *
name,
const char *args,
void *opaque,
This structure describes decoded (raw) audio or video data.
int thread_type
Type of multithreading allowed for filters in this graph.
char * scale_sws_opts
sws options to use for the auto-inserted scale filters
void avfilter_free(AVFilterContext *filter)
Free a filter context.
const char * name
Filter name.
void * priv
private data for use by the filter
static const AVFilterPad outputs[]
AVFilterFormats * in_samplerates
Lists of channel layouts and sample rates used for automatic negotiation.
int(* init)(AVFilterContext *ctx)
Filter initialization function.
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
int h
agreed upon image height
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
int request_samples
Audio only, the destination filter sets this to a non-zero value to request that buffers with the giv...
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
char * resample_lavr_opts
libavresample options to use for the auto-inserted resample filters
AVFilterContext * filter_ctx
filter context associated to this input/output
const AVFilter * avfilter_next(const AVFilter *prev)
Iterate over all registered filters.
int(* query_formats)(AVFilterContext *)
Query formats supported by the filter on its inputs and outputs.
static const AVRational pixel_aspect[17]
const char * description
A description of the filter.
int thread_type
Type of multithreading being allowed/used.
enum AVFilterLink::@3 init_state
stage of the initialization of the link properties (dimensions, etc)
void avfilter_unref_buffer(AVFilterBufferRef *ref)
AVFilterContext * avfilter_graph_alloc_filter(AVFilterGraph *graph, const AVFilter *filter, const char *name)
Create a new filter instance in a filter graph.
static void draw_slice(HYuvContext *s, AVFrame *frame, int y)
int priv_size
size of private data to allocate for the filter
int avfilter_link(AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad)
Link two filters together.
struct AVFilterChannelLayouts * in_channel_layouts
const AVFilterPad * inputs
List of inputs, terminated by a zeroed element.
const AVFilter * avfilter_get_by_name(const char *name)
Get a filter definition matching the given name.
int( avfilter_execute_func)(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
A function executing multiple jobs, possibly in parallel.
static int poll_frame(AVFilterLink *link)
const AVFilterPad * outputs
List of outputs, terminated by a zeroed element.
int flags
A combination of AVFILTER_FLAG_*.
void avfilter_register_all(void)
Initialize the filter system.
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx)
Create and add a filter instance into an existing graph.
int nb_threads
Maximum number of threads used by filters in this graph.
int avfilter_config_links(AVFilterContext *filter)
Negotiate the media format, dimensions, etc of all inputs to a filter.
void(* uninit)(AVFilterContext *ctx)
Filter uninitialization function.
int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, AVFilterInOut **inputs, AVFilterInOut **outputs)
Add a graph described by a string to a graph.
const OptionDef options[]
#define attribute_deprecated
A link between two filters.
int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque)
int sample_rate
samples per second
unsigned nb_outputs
number of output pads
unsigned avfilter_version(void)
Return the LIBAVFILTER_VERSION_INT constant.
int(* init_dict)(AVFilterContext *ctx, AVDictionary **options)
Should be set instead of init by the filters that want to pass a dictionary of AVOptions to nested co...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
AVFilterContext * src
source filter
AVFilterPad * dstpad
input pad on the dest filter
AVPixelFormat
Pixel format.
void avfilter_uninit(void)
int w
agreed upon image width
static int config_props(AVFilterLink *link)
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
char * name
name of this filter instance
unsigned nb_inputs
number of input pads
const AVFilter * filter
the AVFilter of which this is an instance
int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name)
struct AVFilter * next
Used by the filter registration system.
const AVClass * av_class
needed for av_log()
AVFilterGraph * avfilter_graph_alloc(void)
Allocate a filter graph.
char * name
unique name for this input/output in the list
AVFilter ** av_filter_next(AVFilter **filter)
int format
agreed upon media format
int( avfilter_action_func)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
A function pointer passed to the AVFilterGraph::execute callback to be executed multiple times...
void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
int avfilter_init_str(AVFilterContext *ctx, const char *args)
Initialize a filter with the supplied parameters.
AVFilterFormats * out_samplerates
A linked-list of the inputs/outputs of the filter chain.
AVFilterLink ** outputs
array of pointers to output links
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.
AVFilterInOut * avfilter_inout_alloc(void)
Allocate a single AVFilterInOut entry.
const AVClass * avfilter_get_class(void)
AVSampleFormat
Audio Sample Formats.
AVFilterPad * input_pads
array of input pads
AVFilterFormats * out_formats
static void(WINAPI *cond_broadcast)(pthread_cond_t *cond)
int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, AVFilterInOut *inputs, AVFilterInOut *outputs, void *log_ctx)
Add a graph described by a string to a graph.
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
int pad_idx
index of the filt_ctx pad to use for linking
AVFilterLink ** inputs
array of pointers to input links
rational number numerator/denominator
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
const char * avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx)
Get the name of an AVFilterPad.
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
enum AVMediaType type
filter media type
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)
int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
Initialize a filter with the supplied dictionary of options.
void * opaque
Opaque user data.
const char * avfilter_license(void)
Return the libavfilter license.
int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
AVFilterBufferRef * avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms, int w, int h, enum AVPixelFormat format)
static int request_frame(AVFilterLink *outlink)
struct AVFilterGraph * graph
filtergraph this filter belongs to
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
struct AVFilterPad AVFilterPad
AVFilterContext ** filters
struct AVFilterInOut * next
next input/input in the list, NULL if this is the last
AVFilterPad * srcpad
output pad on the source filter
int avfilter_register(AVFilter *filter)
Register a filter.
const AVClass * priv_class
A class for the private data, used to declare filter private AVOptions.
const char * avfilter_configuration(void)
Return the libavfilter build-time configuration.
AVFilterPad * output_pads
array of output pads
int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
avfilter_execute_func * execute
This callback may be set by the caller immediately after allocating the graph and before adding any f...
int avfilter_pad_count(const AVFilterPad *pads)
Get the number of elements in a NULL-terminated array of AVFilterPads (e.g.
struct AVFilterChannelLayouts * out_channel_layouts
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
AVFilterFormats * in_formats
Lists of formats supported by the input and output filters respectively.
int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
AVFilterContext * avfilter_graph_get_filter(AVFilterGraph *graph, char *name)
Get a filter instance with name name from graph.
void avfilter_unref_bufferp(AVFilterBufferRef **ref)