Go to the documentation of this file.
21 #ifndef AVFILTER_FILTERS_H
22 #define AVFILTER_FILTERS_H
33 #define FFERROR_NOT_READY FFERRTAG('N','R','D','Y')
57 #define AVFILTERPAD_FLAG_NEEDS_WRITABLE (1 << 0)
62 #define AVFILTERPAD_FLAG_FREE_NAME (1 << 1)
206 #define FF_FILTER_FLAG_HWFRAME_AWARE (1 << 0)
213 #define FF_INLINK_IDX(link) ((int)((link)->dstpad - (link)->dst->input_pads))
214 #define FF_OUTLINK_IDX(link) ((int)((link)->srcpad - (link)->src->output_pads))
236 #define FILTER_QUERY_FUNC(func) \
237 .formats.query_func = func, \
238 .formats_state = FF_FILTER_FORMATS_QUERY_FUNC
239 #define FILTER_QUERY_FUNC2(func) \
240 .formats.query_func2 = func, \
241 .formats_state = FF_FILTER_FORMATS_QUERY_FUNC2
242 #define FILTER_PIXFMTS_ARRAY(array) \
243 .formats.pixels_list = array, \
244 .formats_state = FF_FILTER_FORMATS_PIXFMT_LIST
245 #define FILTER_SAMPLEFMTS_ARRAY(array) \
246 .formats.samples_list = array, \
247 .formats_state = FF_FILTER_FORMATS_SAMPLEFMTS_LIST
248 #define FILTER_PIXFMTS(...) \
249 FILTER_PIXFMTS_ARRAY(((const enum AVPixelFormat []) { __VA_ARGS__, AV_PIX_FMT_NONE }))
250 #define FILTER_SAMPLEFMTS(...) \
251 FILTER_SAMPLEFMTS_ARRAY(((const enum AVSampleFormat[]) { __VA_ARGS__, AV_SAMPLE_FMT_NONE }))
252 #define FILTER_SINGLE_PIXFMT(pix_fmt_) \
253 .formats.pix_fmt = pix_fmt_, \
254 .formats_state = FF_FILTER_FORMATS_SINGLE_PIXFMT
255 #define FILTER_SINGLE_SAMPLEFMT(sample_fmt_) \
256 .formats.sample_fmt = sample_fmt_, \
257 .formats_state = FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
259 #define FILTER_INOUTPADS(inout, array) \
261 .nb_ ## inout = FF_ARRAY_ELEMS(array)
262 #define FILTER_INPUTS(array) FILTER_INOUTPADS(inputs, (array))
263 #define FILTER_OUTPUTS(array) FILTER_INOUTPADS(outputs, (array))
468 #define AVFILTER_DEFINE_CLASS_EXT(name, desc, options) \
469 static const AVClass name##_class = { \
470 .class_name = desc, \
471 .item_name = av_default_item_name, \
473 .version = LIBAVUTIL_VERSION_INT, \
474 .category = AV_CLASS_CATEGORY_FILTER, \
476 #define AVFILTER_DEFINE_CLASS(fname) \
477 AVFILTER_DEFINE_CLASS_EXT(fname, #fname, fname##_options)
479 #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
480 #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
481 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
637 #define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink) do { \
638 int ret = ff_outlink_get_status(outlink); \
640 ff_inlink_set_status(inlink, ret); \
650 #define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter) do { \
651 int ret = ff_outlink_get_status(outlink); \
654 for (i = 0; i < filter->nb_inputs; i++) \
655 ff_inlink_set_status(filter->inputs[i], ret); \
664 #define FF_FILTER_FORWARD_STATUS(inlink, outlink) do { \
667 if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { \
668 ff_outlink_set_status(outlink, status, pts); \
677 #define FF_FILTER_FORWARD_STATUS_ALL(inlink, filter) do { \
680 if (ff_inlink_acknowledge_status(inlink, &status, &pts)) { \
682 for (i = 0; i < filter->nb_outputs; i++) \
683 ff_outlink_set_status(filter->outputs[i], status, pts); \
692 #define FF_FILTER_FORWARD_WANTED(outlink, inlink) do { \
693 if (ff_outlink_frame_wanted(outlink)) { \
694 ff_inlink_request_frame(inlink); \
721 int default_pool_size);
730 const char *
arg,
char *res,
int res_len,
int flags);
807 void *
arg,
int *
ret,
int nb_jobs);
int(* func)(AVBPrint *dst, const char *in, const char *arg)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
AVPixelFormat
Pixel format.
int ff_inlink_make_frame_writable(AVFilterLink *link, AVFrame **rframe)
Make sure a frame is writable.
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
@ FF_FILTER_FORMATS_QUERY_FUNC
formats.query active.
int ff_inlink_check_available_samples(AVFilterLink *link, unsigned min)
Test if enough samples are available on the link.
int(* process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags)
Make the filter instance process a command.
int ff_inoutlink_check_flow(AVFilterLink *inlink, AVFilterLink *outlink)
Check for flow control between input and output.
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,...
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
void(* uninit)(AVFilterContext *ctx)
Filter uninitialization function.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
int64_t current_pts
Current timestamp of the link, as defined by the most recent frame(s), in link time_base units.
int64_t sample_count_in
Number of past samples sent through the link.
This structure describes decoded (raw) audio or video data.
int max_samples
Maximum number of samples to filter at once.
int(* query_func2)(const AVFilterContext *, struct AVFilterFormatsConfig **cfg_in, struct AVFilterFormatsConfig **cfg_out)
Same as query_func(), except this function writes the results into provided arrays.
int priv_size
size of private data to allocate for the filter
@ FF_FILTER_FORMATS_SINGLE_PIXFMT
formats.pix_fmt active
void(* filter)(uint8_t *src, int stride, int qscale)
int(* init)(AVFilterContext *ctx)
Filter initialization function.
A link between two filters.
int64_t current_pts_us
Current timestamp of the link, as defined by the most recent frame(s), in AV_TIME_BASE units.
enum AVSampleFormat sample_fmt
Equivalent to { sample_fmt, AV_SAMPLE_FMT_NONE } as samples_list.
static const FFFilter * fffilter(const AVFilter *f)
Link properties exposed to filter code, but not external callers.
uint8_t formats_state
This field determines the state of the formats union.
AVFrame * ff_inlink_peek_frame(AVFilterLink *link, size_t idx)
Access a frame in the link fifo without consuming it.
A filter pad used for either input or output.
int ff_append_outpad(AVFilterContext *f, AVFilterPad *p)
int(* request_frame)(AVFilterLink *link)
Frame request callback.
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
enum AVSampleFormat * samples_list
Analogous to pixels, but delimited by AV_SAMPLE_FMT_NONE and restricted to filters that only have AVM...
void ff_avfilter_link_set_in_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
int ff_fmt_is_in(int fmt, const int *fmts)
Tell if an integer is contained in the provided -1-terminated list of integers.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
int(* preinit)(AVFilterContext *ctx)
Filter pre-initialization function.
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
union FFFilter::@322 formats
The state of the following union is determined by formats_state.
int(* activate)(AVFilterContext *ctx)
Filter activation function.
Rational number (pair of numerator and denominator).
int(* filter_frame)(AVFilterLink *link, AVFrame *frame)
Filtering callback.
int ff_inlink_queued_samples(AVFilterLink *link)
static FilterLink * ff_filter_link(AVFilterLink *link)
@ FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
formats.sample_fmt active.
int(* config_props)(AVFilterLink *link)
Link configuration callback.
uint8_t nb_outputs
The number of entries in the list of outputs.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
@ FF_FILTER_FORMATS_PASSTHROUGH
The default value meaning that this filter supports all formats and (for audio) sample rates and chan...
enum AVPixelFormat pix_fmt
Equivalent to { pix_fmt, AV_PIX_FMT_NONE } as pixels_list.
int ff_filter_init_hw_frames(AVFilterContext *avctx, AVFilterLink *link, int default_pool_size)
Perform any additional setup required for hardware frames.
uint8_t nb_inputs
The number of entries in the list of inputs.
AVSampleFormat
Audio sample formats.
int flags
A combination of AVFILTERPAD_FLAG_* flags.
const char * name
Pad name.
int(* query_func)(AVFilterContext *)
Query formats supported by the filter on its inputs and outputs.
enum AVMediaType type
AVFilterPad type.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int flags_internal
Additional flags for avfilter internal use only.
@ FF_FILTER_FORMATS_QUERY_FUNC2
formats.query_func2 active.
int ff_append_inpad_free_name(AVFilterContext *f, AVFilterPad *p)
int ff_inlink_check_available_frame(AVFilterLink *link)
Test if a frame is available on the link.
size_t ff_inlink_queued_frames(AVFilterLink *link)
Get the number of frames available on the link.
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
void ff_inlink_set_status(AVFilterLink *link, int status)
Set the status on an input link.
struct AVFilterGraph * graph
Graph the filter belongs to.
AVFilter p
The public AVFilter.
A reference to a data buffer.
int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
@ FF_FILTER_FORMATS_SAMPLEFMTS_LIST
formats.samples_list active.
#define flags(name, subs,...)
enum AVPixelFormat * pixels_list
A pointer to an array of admissible pixel formats delimited by AV_PIX_FMT_NONE.
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
AVRational frame_rate
Frame rate of the stream on the link, or 1/0 if unknown or variable.
int min_samples
Minimum number of samples to filter at once.
int ff_filter_get_nb_threads(AVFilterContext *ctx) av_pure
Get number of threads for current filter instance.
int ff_append_outpad_free_name(AVFilterContext *f, AVFilterPad *p)
union AVFilterPad::@321 get_buffer
Callback functions to get a video/audio buffers.
int64_t frame_count_in
Number of past frames sent through the link.
int ff_append_inpad(AVFilterContext *f, AVFilterPad *p)
Append a new input/output pad to the filter's list of such pads.
@ FF_FILTER_FORMATS_PIXFMT_LIST
formats.pixels_list active.