FFmpeg
|
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/buffer.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/eval.h"
#include "libavutil/hwcontext.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/rational.h"
#include "libavutil/samplefmt.h"
#include "libavutil/thread.h"
#include "framequeue.h"
#include "audio.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "internal.h"
#include "libavutil/ffversion.h"
Go to the source code of this file.
Macros | |
#define | FF_INTERNAL_FIELDS 1 |
#define | LICENSE_PREFIX "libavfilter license: " |
#define | OFFSET(x) offsetof(AVFilterContext, x) |
#define | FLAGS AV_OPT_FLAG_FILTERING_PARAM |
Enumerations | |
enum | { VAR_T, VAR_N, VAR_POS, VAR_W, VAR_H, VAR_VARS_NB } |
Functions | |
void | ff_tlog_ref (void *ctx, AVFrame *ref, int end) |
unsigned | avfilter_version (void) |
Return the LIBAVFILTER_VERSION_INT constant. More... | |
const char * | avfilter_configuration (void) |
Return the libavfilter build-time configuration. More... | |
const char * | avfilter_license (void) |
Return the libavfilter license. More... | |
void | ff_command_queue_pop (AVFilterContext *filter) |
int | ff_insert_pad (unsigned idx, unsigned *count, size_t padidx_off, AVFilterPad **pads, AVFilterLink ***links, AVFilterPad *newpad) |
Insert a new pad. More... | |
int | avfilter_link (AVFilterContext *src, unsigned srcpad, AVFilterContext *dst, unsigned dstpad) |
Link two filters together. More... | |
void | avfilter_link_free (AVFilterLink **link) |
Free the link in *link, and set its pointer to NULL. More... | |
void | ff_filter_set_ready (AVFilterContext *filter, unsigned priority) |
Mark a filter ready and schedule it for activation. More... | |
static void | filter_unblock (AVFilterContext *filter) |
Clear frame_blocked_in on all outputs. More... | |
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. More... | |
void | ff_avfilter_link_set_out_status (AVFilterLink *link, int status, int64_t pts) |
Set the status field of a link from the destination filter. More... | |
void | avfilter_link_set_closed (AVFilterLink *link, int closed) |
Set the closed field of a link. More... | |
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. More... | |
int | avfilter_config_links (AVFilterContext *filter) |
Negotiate the media format, dimensions, etc of all inputs to a filter. More... | |
void | ff_tlog_link (void *ctx, AVFilterLink *link, int end) |
int | ff_request_frame (AVFilterLink *link) |
Request an input frame from the filter at the other end of the link. More... | |
static int64_t | guess_status_pts (AVFilterContext *ctx, int status, AVRational link_time_base) |
static int | ff_request_frame_to_filter (AVFilterLink *link) |
int | ff_poll_frame (AVFilterLink *link) |
Poll a frame from the filter chain. More... | |
static int | set_enable_expr (AVFilterContext *ctx, const char *expr) |
void | ff_update_link_current_pts (AVFilterLink *link, int64_t pts) |
int | avfilter_process_command (AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags) |
Make the filter instance process a command. More... | |
int | avfilter_pad_count (const AVFilterPad *pads) |
Get the number of elements in a NULL-terminated array of AVFilterPads (e.g. More... | |
static const char * | default_filter_name (void *filter_ctx) |
static void * | filter_child_next (void *obj, void *prev) |
static const AVClass * | filter_child_class_next (const AVClass *prev) |
static int | default_execute (AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs) |
AVFilterContext * | ff_filter_alloc (const AVFilter *filter, const char *inst_name) |
Allocate a new filter context and return it. More... | |
static void | free_link (AVFilterLink *link) |
void | avfilter_free (AVFilterContext *filter) |
Free a filter context. More... | |
int | ff_filter_get_nb_threads (AVFilterContext *ctx) |
Get number of threads for current filter instance. More... | |
static int | process_options (AVFilterContext *ctx, AVDictionary **options, const char *args) |
int | avfilter_init_dict (AVFilterContext *ctx, AVDictionary **options) |
Initialize a filter with the supplied dictionary of options. More... | |
int | avfilter_init_str (AVFilterContext *filter, const char *args) |
Initialize a filter with the supplied parameters. More... | |
const char * | avfilter_pad_get_name (const AVFilterPad *pads, int pad_idx) |
Get the name of an AVFilterPad. More... | |
enum AVMediaType | avfilter_pad_get_type (const AVFilterPad *pads, int pad_idx) |
Get the type of an AVFilterPad. More... | |
static int | default_filter_frame (AVFilterLink *link, AVFrame *frame) |
static int | ff_filter_frame_framed (AVFilterLink *link, AVFrame *frame) |
int | ff_filter_frame (AVFilterLink *link, AVFrame *frame) |
Send a frame of data to the next filter. More... | |
static int | samples_ready (AVFilterLink *link, unsigned min) |
static int | take_samples (AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe) |
static int | ff_filter_frame_to_filter (AVFilterLink *link) |
static int | forward_status_change (AVFilterContext *filter, AVFilterLink *in) |
static int | ff_filter_activate_default (AVFilterContext *filter) |
int | ff_filter_activate (AVFilterContext *filter) |
int | ff_inlink_acknowledge_status (AVFilterLink *link, int *rstatus, int64_t *rpts) |
Test and acknowledge the change of status 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_check_available_samples (AVFilterLink *link, unsigned min) |
Test if enough samples are available on the link. More... | |
static void | consume_update (AVFilterLink *link, const AVFrame *frame) |
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... | |
int | ff_inlink_make_frame_writable (AVFilterLink *link, AVFrame **rframe) |
Make sure a frame is writable. 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... | |
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... | |
int | ff_outlink_get_status (AVFilterLink *link) |
Get the status on an output link. More... | |
const AVClass * | avfilter_get_class (void) |
int | ff_filter_init_hw_frames (AVFilterContext *avctx, AVFilterLink *link, int default_pool_size) |
Perform any additional setup required for hardware frames. More... | |
Variables | |
const char | av_filter_ffversion [] = "FFmpeg version " FFMPEG_VERSION |
static const char *const | var_names [] |
static const AVOption | avfilter_options [] |
static const AVClass | avfilter_class |
#define FF_INTERNAL_FIELDS 1 |
Definition at line 37 of file avfilter.c.
#define LICENSE_PREFIX "libavfilter license: " |
Referenced by avfilter_license().
#define OFFSET | ( | x | ) | offsetof(AVFilterContext, x) |
Definition at line 626 of file avfilter.c.
#define FLAGS AV_OPT_FLAG_FILTERING_PARAM |
Definition at line 627 of file avfilter.c.
anonymous enum |
Enumerator | |
---|---|
VAR_T | |
VAR_N | |
VAR_POS | |
VAR_W | |
VAR_H | |
VAR_VARS_NB |
Definition at line 497 of file avfilter.c.
Definition at line 49 of file avfilter.c.
Referenced by ff_filter_frame().
void ff_command_queue_pop | ( | AVFilterContext * | filter | ) |
Definition at line 94 of file avfilter.c.
Referenced by avfilter_free(), and ff_inlink_process_commands().
int ff_insert_pad | ( | unsigned | idx, |
unsigned * | count, | ||
size_t | padidx_off, | ||
AVFilterPad ** | pads, | ||
AVFilterLink *** | links, | ||
AVFilterPad * | newpad | ||
) |
Insert a new pad.
idx | Insertion point. Pad is inserted at the end if this point is beyond the end of the list of pads. |
count | Pointer to the number of pads in the list |
padidx_off | Offset within an AVFilterLink structure to the element to increment when inserting a new pad causes link numbering to change |
pads | Pointer to the pointer to the beginning of the list of pads |
links | Pointer to the pointer to the beginning of the list of links |
newpad | The new pad to add. A copy is made when adding. |
Definition at line 103 of file avfilter.c.
Referenced by ff_insert_inpad(), and ff_insert_outpad().
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(), and forward_status_change().
|
static |
Clear frame_blocked_in on all outputs.
This is necessary whenever something changes on input.
Definition at line 202 of file avfilter.c.
Referenced by ff_avfilter_link_set_in_status(), ff_avfilter_link_set_out_status(), ff_filter_frame(), and ff_filter_frame_to_filter().
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.
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 211 of file avfilter.c.
Referenced by av_buffersrc_close(), ff_outlink_set_status(), and ff_request_frame_to_filter().
void ff_avfilter_link_set_out_status | ( | AVFilterLink * | link, |
int | status, | ||
int64_t | pts | ||
) |
Set the status field of a link from the destination filter.
The pts should probably be left unset (AV_NOPTS_VALUE).
Definition at line 224 of file avfilter.c.
Referenced by avfilter_link_set_closed(), ff_filter_frame_to_filter(), ff_inlink_set_status(), ff_request_frame(), and forward_status_change().
void ff_tlog_link | ( | void * | ctx, |
AVFilterLink * | link, | ||
int | end | ||
) |
Definition at line 383 of file avfilter.c.
Referenced by ff_filter_frame(), ff_get_video_buffer(), ff_request_frame(), and ff_request_frame_to_filter().
int ff_request_frame | ( | AVFilterLink * | link | ) |
Request an input frame from the filter at the other end of the link.
This function must not be used by filters using the activate callback, use ff_link_set_frame_wanted() instead.
The input filter may pass the request on to its inputs, fulfill the request from an internal buffer or any other means specific to its function.
When the end of a stream is reached AVERROR_EOF is returned and no further frames are returned after that.
When a filter is unable to output a frame for example due to its sources being unable to do so or because it depends on external means pushing data into it then AVERROR(EAGAIN) is returned. It is important that a AVERROR(EAGAIN) return is returned all the way to the caller (generally eventually a user application) as this step may (but does not have to be) necessary to provide the input with the next frame.
If a request is successful then some progress has been made towards providing a frame on the link (through ff_filter_frame()). A filter that needs several frames to produce one is allowed to return success if one more frame has been processed but no output has been produced yet. A filter is also allowed to simply forward a success return value.
link | the input link |
Definition at line 407 of file avfilter.c.
Referenced by avfilter_graph_request_oldest(), ff_request_frame_to_filter(), qsvdeint_request_frame(), request_frame(), request_frame_ref(), request_inlink(), and return_audio_frame().
|
static |
Definition at line 432 of file avfilter.c.
Referenced by ff_request_frame_to_filter().
|
static |
Definition at line 450 of file avfilter.c.
Referenced by ff_filter_activate_default(), and forward_status_change().
int ff_poll_frame | ( | AVFilterLink * | link | ) |
Poll a frame from the filter chain.
link | the input link |
Definition at line 470 of file avfilter.c.
Referenced by ff_poll_frame().
|
static |
Definition at line 506 of file avfilter.c.
Referenced by avfilter_process_command(), and process_options().
void ff_update_link_current_pts | ( | AVFilterLink * | link, |
int64_t | pts | ||
) |
Definition at line 546 of file avfilter.c.
Referenced by consume_update(), ff_avfilter_link_set_out_status(), and ff_inlink_acknowledge_status().
|
static |
Definition at line 590 of file avfilter.c.
Definition at line 596 of file avfilter.c.
Definition at line 604 of file avfilter.c.
|
static |
Definition at line 650 of file avfilter.c.
Referenced by ff_filter_alloc().
AVFilterContext* ff_filter_alloc | ( | const AVFilter * | filter, |
const char * | inst_name | ||
) |
Allocate a new filter context and return it.
filter | what filter to create an instance of |
inst_name | name to give to the new filter context |
Definition at line 663 of file avfilter.c.
Referenced by avfilter_graph_alloc_filter().
|
static |
Definition at line 739 of file avfilter.c.
Referenced by avfilter_free().
int ff_filter_get_nb_threads | ( | AVFilterContext * | ctx | ) |
Get number of threads for current filter instance.
This number is always same or less than graph->nb_threads.
Definition at line 802 of file avfilter.c.
Referenced by apply_lut(), averageiir2d(), blend_frame(), blend_frames(), config_input(), config_props(), do_convolve(), filter(), filter_frame(), filter_frame16(), filter_frame8(), gaussianiir2d(), geq_filter_frame(), and nlmeans_plane().
|
static |
Definition at line 809 of file avfilter.c.
Referenced by avfilter_init_str().
|
static |
Definition at line 1044 of file avfilter.c.
Referenced by ff_filter_frame_framed().
|
static |
Definition at line 1049 of file avfilter.c.
Referenced by ff_filter_frame_to_filter().
int ff_filter_frame | ( | AVFilterLink * | link, |
AVFrame * | frame | ||
) |
Send a frame of data to the next filter.
link | the output link over which the data is being sent |
frame | a reference to the buffer of data being sent. The receiving filter will free this reference when it no longer needs it or pass it on to the next filter. |
Definition at line 1080 of file avfilter.c.
Referenced by activate(), apply_filter(), avgblur_opencl_filter_frame(), blend_frame_for_dualinput(), channelmap_filter_frame(), compand_delay(), compand_nodelay(), convolution_opencl_filter_frame(), cudascale_filter_frame(), cudaupload_filter_frame(), default_filter_frame(), deint_vaapi_filter_frame(), do_blend(), do_convolve(), do_psnr(), do_ssim(), do_vmaf(), end_last_frame(), ff_qsvvpp_create(), filter(), filter_callback(), filter_frame(), filter_frame16(), filter_frame8(), filter_frame_ref(), flush(), geq_filter_frame(), hwdownload_filter_frame(), hwmap_filter_frame(), hwupload_filter_frame(), load_apply_palette(), misc_vaapi_filter_frame(), movie_push_frame(), nppscale_filter_frame(), oscilloscope_filter_frame(), output_frame(), output_single_frame(), overlay_opencl_blend(), pixscope_filter_frame(), plot_freqs(), plot_spectrum_column(), pp_filter_frame(), procamp_vaapi_filter_frame(), process_frame(), program_opencl_run(), push_frame(), push_samples(), qsvscale_filter_frame(), request_frame(), return_audio_frame(), return_frame(), scale_vaapi_filter_frame(), send_silence(), shuffleplanes_filter_frame(), try_push_frame(), unsharp_opencl_filter_frame(), and write_frame().
|
static |
Definition at line 1131 of file avfilter.c.
Referenced by ff_filter_activate_default(), and take_samples().
|
static |
Definition at line 1138 of file avfilter.c.
Referenced by ff_inlink_consume_samples().
|
static |
Definition at line 1198 of file avfilter.c.
Referenced by ff_filter_activate_default().
|
static |
Definition at line 1230 of file avfilter.c.
Referenced by ff_filter_activate_default().
|
static |
Definition at line 1262 of file avfilter.c.
Referenced by ff_filter_activate().
int ff_filter_activate | ( | AVFilterContext * | filter | ) |
Definition at line 1421 of file avfilter.c.
Referenced by ff_filter_graph_run_once().
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().
[out] | rstatus | new or current status |
[out] | rpts | current timestamp of the link in link time base |
Definition at line 1436 of file avfilter.c.
Referenced by activate(), consume_from_fifos(), and get_frame_internal().
int ff_inlink_check_available_frame | ( | AVFilterLink * | link | ) |
Test if a frame is available on the link.
Definition at line 1451 of file avfilter.c.
Referenced by activate(), and ff_inlink_consume_frame().
int ff_inlink_check_available_samples | ( | AVFilterLink * | link, |
unsigned | min | ||
) |
Test if enough samples are available on the link.
Definition at line 1456 of file avfilter.c.
Referenced by activate(), and ff_inlink_consume_samples().
|
static |
Definition at line 1463 of file avfilter.c.
Referenced by ff_inlink_consume_frame(), 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.
Definition at line 1471 of file avfilter.c.
Referenced by activate(), consume_from_fifos(), ff_filter_frame_to_filter(), get_frame_internal(), and read_frame().
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.
Definition at line 1490 of file avfilter.c.
Referenced by activate(), ff_filter_frame_to_filter(), ff_inlink_consume_frame(), and get_frame_internal().
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 1510 of file avfilter.c.
Referenced by ff_filter_frame_framed(), and ff_framesync_dualinput_get_writable().
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.
Definition at line 1559 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.
Definition at line 1574 of file avfilter.c.
Referenced by consume_update(), and ff_filter_frame_framed().
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 1592 of file avfilter.c.
Referenced by activate(), consume_from_fifos(), get_frame_internal(), and request_samples().
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 1600 of file avfilter.c.
int ff_outlink_get_status | ( | AVFilterLink * | link | ) |
Get the status on an output link.
Definition at line 1615 of file avfilter.c.
int ff_filter_init_hw_frames | ( | AVFilterContext * | avctx, |
AVFilterLink * | link, | ||
int | default_pool_size | ||
) |
Perform any additional setup required for hardware frames.
link->hw_frames_ctx must be set before calling this function. Inside link->hw_frames_ctx, the fields format, sw_format, width and height must be set. If dynamically allocated pools are not supported, then initial_pool_size must also be set, to the minimum hardware frame pool size necessary for the filter to work (taking into account any frames which need to stored for use in operations as appropriate). If default_pool_size is nonzero, then it will be used as the pool size if no other modification takes place (this can be used to preserve compatibility).
Definition at line 1625 of file avfilter.c.
Referenced by ff_vaapi_vpp_config_output(), and init_out_pool().
const char av_filter_ffversion[] = "FFmpeg version " FFMPEG_VERSION |
Definition at line 47 of file avfilter.c.
|
static |
Definition at line 488 of file avfilter.c.
Referenced by set_enable_expr().
|
static |
Definition at line 628 of file avfilter.c.
|
static |
Definition at line 640 of file avfilter.c.
Referenced by avfilter_get_class(), and ff_filter_alloc().