FFmpeg
Macros | Functions
filters.h File Reference
#include "avfilter.h"
#include "internal.h"

Go to the source code of this file.

Macros

#define FFERROR_NOT_READY   FFERRTAG('N','R','D','Y')
 Filters implementation helper functions. More...
 
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
 Forward the status on an output link to an input link. More...
 
#define FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, filter)
 Forward the status on an output link to all input links. More...
 
#define FF_FILTER_FORWARD_STATUS(inlink, outlink)
 Acknowledge the status on an input link and forward it to an output link. More...
 
#define FF_FILTER_FORWARD_STATUS_ALL(inlink, filter)
 Acknowledge the status on an input link and forward it to an output link. More...
 
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
 Forward the frame_wanted_out flag from an output link to an input link. More...
 

Functions

void ff_filter_set_ready (AVFilterContext *filter, unsigned priority)
 Mark a filter ready and schedule it for activation. More...
 
int ff_inlink_process_commands (AVFilterLink *link, const AVFrame *frame)
 Process the commands queued in the link up to the time of the frame. More...
 
int ff_inlink_evaluate_timeline_at_frame (AVFilterLink *link, const AVFrame *frame)
 Evaluate the timeline expression of the link for the time and properties of the frame. More...
 
size_t ff_inlink_queued_frames (AVFilterLink *link)
 Get the number of frames available on the link. More...
 
int ff_inlink_check_available_frame (AVFilterLink *link)
 Test if a frame is available on the link. More...
 
int ff_inlink_queued_samples (AVFilterLink *link)
 
int ff_inlink_check_available_samples (AVFilterLink *link, unsigned min)
 Test if enough samples are available on the link. More...
 
int ff_inlink_consume_frame (AVFilterLink *link, AVFrame **rframe)
 Take a frame from the link's FIFO and update the link's stats. More...
 
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. More...
 
AVFrameff_inlink_peek_frame (AVFilterLink *link, size_t idx)
 Access a frame in the link fifo without consuming it. More...
 
int ff_inlink_make_frame_writable (AVFilterLink *link, AVFrame **rframe)
 Make sure a frame is writable. More...
 
int ff_inlink_acknowledge_status (AVFilterLink *link, int *rstatus, int64_t *rpts)
 Test and acknowledge the change of status on the link. More...
 
void ff_inlink_request_frame (AVFilterLink *link)
 Mark that a frame is wanted on the link. More...
 
void ff_inlink_set_status (AVFilterLink *link, int status)
 Set the status on an input link. More...
 
static int ff_outlink_frame_wanted (AVFilterLink *link)
 Test if a frame is wanted on an output link. More...
 
int ff_outlink_get_status (AVFilterLink *link)
 Get the status on an output link. More...
 
static void ff_outlink_set_status (AVFilterLink *link, int status, int64_t pts)
 Set the status field of a link from the source filter. More...
 

Macro Definition Documentation

#define FFERROR_NOT_READY   FFERRTAG('N','R','D','Y')

Filters implementation helper functions.

Special return code when activate() did not do anything.

Definition at line 34 of file filters.h.

#define FF_FILTER_FORWARD_STATUS_BACK (   outlink,
  inlink 
)
Value:
do { \
if (ret) { \
return 0; \
} \
} while (0)
if(ret)
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
Definition: avfilter.c:1630
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
int
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 it should return
void ff_inlink_set_status(AVFilterLink *link, int status)
Set the status on an input link.
Definition: avfilter.c:1615

Forward the status on an output link to an input link.

If the status is set, it will discard all queued frames and this macro will return immediately.

Definition at line 199 of file filters.h.

Referenced by activate(), check_size(), init(), plot_spectrum_column(), and spatial_activate().

#define FF_FILTER_FORWARD_STATUS_BACK_ALL (   outlink,
  filter 
)
Value:
do { \
if (ret) { \
unsigned i; \
for (i = 0; i < filter->nb_inputs; i++) \
ff_inlink_set_status(filter->inputs[i], ret); \
return 0; \
} \
} while (0)
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
if(ret)
int ff_outlink_get_status(AVFilterLink *link)
Get the status on an output link.
Definition: avfilter.c:1630
int
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 it should return
for(j=16;j >0;--j)
void ff_inlink_set_status(AVFilterLink *link, int status)
Set the status on an input link.
Definition: avfilter.c:1615

Forward the status on an output link to all input links.

If the status is set, it will discard all queued frames and this macro will return immediately.

Definition at line 212 of file filters.h.

Referenced by activate(), compressor(), config_output(), and gate().

#define FF_FILTER_FORWARD_STATUS (   inlink,
  outlink 
)
Value:
do { \
int64_t pts; \
ff_outlink_set_status(outlink, status, pts); \
return 0; \
} \
} while (0)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:189
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition: avfilter.c:1436
if(ret)
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
static int64_t pts
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
int
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 it should return

Acknowledge the status on an input link and forward it to an output link.

If the status is set, this macro will return immediately.

Definition at line 226 of file filters.h.

#define FF_FILTER_FORWARD_STATUS_ALL (   inlink,
  filter 
)
Value:
do { \
int64_t pts; \
unsigned i; \
for (i = 0; i < filter->nb_outputs; i++) \
ff_outlink_set_status(filter->outputs[i], status, pts); \
return 0; \
} \
} while (0)
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:189
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition: avfilter.c:1436
if(ret)
they must not be accessed directly The fifo field contains the frames that are queued in the input for processing by the filter The status_in and status_out fields contains the queued status(EOF or error) of the link
static int64_t pts
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
int
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 it should return
for(j=16;j >0;--j)

Acknowledge the status on an input link and forward it to an output link.

If the status is set, this macro will return immediately.

Definition at line 239 of file filters.h.

#define FF_FILTER_FORWARD_WANTED (   outlink,
  inlink 
)
Value:
do { \
return 0; \
} \
} while (0)
static int ff_outlink_frame_wanted(AVFilterLink *link)
Test if a frame is wanted on an output link.
Definition: filters.h:172
if(ret)
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
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1607
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 it should return

Forward the frame_wanted_out flag from an output link to an input link.

If the flag is set, this macro will return immediately.

Definition at line 254 of file filters.h.

Function Documentation

void ff_filter_set_ready ( AVFilterContext filter,
unsigned  priority 
)

Mark a filter ready and schedule it for activation.

This is automatically done when something happens to the filter (queued frame, status change, request on output). Filters implementing the activate callback can call it directly to perform one more round of processing later. It is also useful for filters reacting to external or asynchronous events.

Definition at line 193 of file avfilter.c.

Referenced by activate(), ff_avfilter_link_set_in_status(), ff_avfilter_link_set_out_status(), ff_filter_frame(), ff_filter_frame_to_filter(), ff_inlink_request_frame(), ff_request_frame(), forward_status_change(), plot_spectrum_column(), and spatial_activate().

int ff_inlink_process_commands ( AVFilterLink link,
const AVFrame frame 
)

Process the commands queued in the link up to the time of the frame.

Commands will trigger the process_command() callback.

Returns
>= 0 or AVERROR code.

Definition at line 1574 of file avfilter.c.

Referenced by consume_update(), and ff_filter_frame_framed().

int ff_inlink_evaluate_timeline_at_frame ( AVFilterLink link,
const AVFrame frame 
)

Evaluate the timeline expression of the link for the time and properties of the frame.

Returns
>0 if enabled, 0 if disabled
Note
It does not update link->dst->is_disabled.

Definition at line 1589 of file avfilter.c.

Referenced by consume_update(), and ff_filter_frame_framed().

size_t ff_inlink_queued_frames ( AVFilterLink link)

Get the number of frames available on the link.

Returns
the number of frames available in the link fifo.

Definition at line 1451 of file avfilter.c.

Referenced by activate(), create_frame(), and filter_have_queued().

int ff_inlink_check_available_frame ( AVFilterLink link)

Test if a frame is available on the link.

Returns
>0 if a frame is available

Definition at line 1456 of file avfilter.c.

Referenced by activate(), and ff_inlink_consume_frame().

int ff_inlink_queued_samples ( AVFilterLink link)

Definition at line 1461 of file avfilter.c.

Referenced by activate(), check_ir(), config_output(), and convert_coeffs().

int ff_inlink_check_available_samples ( AVFilterLink link,
unsigned  min 
)

Test if enough samples are available on the link.

Returns
>0 if enough samples are available
Note
on EOF and error, min becomes 1

Definition at line 1466 of file avfilter.c.

Referenced by activate(), and ff_inlink_consume_samples().

int ff_inlink_consume_frame ( AVFilterLink link,
AVFrame **  rframe 
)

Take a frame from the link's FIFO and update the link's stats.

If ff_inlink_check_available_frame() was previously called, the preferred way of expressing it is "av_assert1(ret);" immediately after ff_inlink_consume_frame(). Negative error codes must still be checked.

Note
May trigger process_command() and/or update is_disabled.
Returns
>0 if a frame is available, 0 and set rframe to NULL if no frame available, or AVERROR code

Definition at line 1481 of file avfilter.c.

Referenced by activate(), check_size(), compressor(), config_output(), consume_from_fifos(), ff_filter_frame_to_filter(), gate(), get_frame_internal(), plot_spectrum_column(), read_frame(), and spatial_activate().

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.

If ff_inlink_check_available_samples() was previously called, the preferred way of expressing it is "av_assert1(ret);" immediately after ff_inlink_consume_samples(). Negative error codes must still be checked.

Note
May trigger process_command() and/or update is_disabled.
Returns
>0 if a frame is available, 0 and set rframe to NULL if no frame available, or AVERROR code

Definition at line 1500 of file avfilter.c.

Referenced by activate(), config_output(), convert_coeffs(), ff_filter_frame_to_filter(), ff_inlink_consume_frame(), get_frame_internal(), init(), and try_push_frame().

AVFrame* ff_inlink_peek_frame ( AVFilterLink link,
size_t  idx 
)

Access a frame in the link fifo without consuming it.

The first frame is numbered 0; the designated frame must exist.

Returns
the frame at idx position in the link fifo.

Definition at line 1520 of file avfilter.c.

Referenced by activate().

int ff_inlink_make_frame_writable ( AVFilterLink link,
AVFrame **  rframe 
)

Make sure a frame is writable.

This is similar to av_frame_make_writable() except it uses the link's buffer allocation callback, and therefore allows direct rendering.

Definition at line 1525 of file avfilter.c.

Referenced by ff_filter_frame_framed(), and ff_framesync_dualinput_get_writable().

int ff_inlink_acknowledge_status ( AVFilterLink link,
int rstatus,
int64_t *  rpts 
)

Test and acknowledge the change of status on the link.

Status means EOF or an error condition; a change from the normal (0) status to a non-zero status can be queued in a filter's input link, it becomes relevant after the frames queued in the link's FIFO are processed. This function tests if frames are still queued and if a queued status change has not yet been processed. In that case it performs basic treatment (updating the link's timestamp) and returns a positive value to let the filter do its own treatments (flushing...).

Filters implementing the activate callback should call this function when they think it might succeed (usually after checking unsuccessfully for a queued frame). Filters implementing the filter_frame and request_frame callbacks do not need to call that since the same treatment happens in ff_filter_frame().

Parameters
[out]rstatusnew or current status
[out]rptscurrent timestamp of the link in link time base
Returns
>0 if status changed, <0 if status already acked, 0 otherwise

Definition at line 1436 of file avfilter.c.

Referenced by activate(), check_size(), config_output(), consume_from_fifos(), and get_frame_internal().

void ff_inlink_request_frame ( AVFilterLink link)

Mark that a frame is wanted on the link.

Unlike ff_filter_frame(), it must not be called when the link has a non-zero status, and thus does not acknowledge it. Also it cannot fail.

Definition at line 1607 of file avfilter.c.

Referenced by activate(), compressor(), config_output(), consume_from_fifos(), gate(), get_frame_internal(), if(), plot_spectrum_column(), request_samples(), and spatial_activate().

void ff_inlink_set_status ( AVFilterLink link,
int  status 
)

Set the status on an input link.

Also discard all frames in the link's FIFO.

Definition at line 1615 of file avfilter.c.

Referenced by activate(), and if().

static int ff_outlink_frame_wanted ( AVFilterLink link)
inlinestatic

Test if a frame is wanted on an output link.

Definition at line 172 of file filters.h.

int ff_outlink_get_status ( AVFilterLink link)

Get the status on an output link.

Definition at line 1630 of file avfilter.c.

Referenced by activate(), config_output(), ff_outlink_frame_wanted(), filter_frame(), init(), and plot_spectrum_column().

static void ff_outlink_set_status ( AVFilterLink link,
int  status,
int64_t  pts 
)
inlinestatic

Set the status field of a link from the source filter.

The pts should reflect the timestamp of the status change, in link time base and relative to the frames timeline. In particular, for AVERROR_EOF, it should reflect the end time of the last frame.

Definition at line 189 of file filters.h.

Referenced by activate(), check_size(), config_output(), framesync_eof(), output_frame(), and plot_spectrum_column().