FFmpeg
Data Structures | Macros | Enumerations | Functions
internal.h File Reference
#include "libavutil/internal.h"
#include "avfilter.h"

Go to the source code of this file.

Data Structures

struct  AVFilterPad
 A filter pad used for either input or output. More...
 
struct  FFFilterContext
 

Macros

#define AVFILTERPAD_FLAG_NEEDS_WRITABLE   (1 << 0)
 The filter expects writable frames from its input link, duplicating data buffers if needed. More...
 
#define AVFILTERPAD_FLAG_FREE_NAME   (1 << 1)
 The pad's name is allocated and should be freed generically. More...
 
#define FILTER_QUERY_FUNC(func)
 
#define FILTER_PIXFMTS_ARRAY(array)
 
#define FILTER_SAMPLEFMTS_ARRAY(array)
 
#define FILTER_PIXFMTS(...)   FILTER_PIXFMTS_ARRAY(((const enum AVPixelFormat []) { __VA_ARGS__, AV_PIX_FMT_NONE }))
 
#define FILTER_SAMPLEFMTS(...)   FILTER_SAMPLEFMTS_ARRAY(((const enum AVSampleFormat[]) { __VA_ARGS__, AV_SAMPLE_FMT_NONE }))
 
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
 
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
 
#define FILTER_INOUTPADS(inout, array)
 
#define FILTER_INPUTS(array)   FILTER_INOUTPADS(inputs, (array))
 
#define FILTER_OUTPUTS(array)   FILTER_INOUTPADS(outputs, (array))
 
#define D2TS(d)   (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
 
#define TS2D(ts)   ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
 
#define TS2T(ts, tb)   ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))
 
#define FF_TPRINTF_START(ctx, func)   ff_tlog(NULL, "%-16s: ", #func)
 
#define ff_tlog_link(ctx, link, end)   do { } while(0)
 
#define AVFILTER_DEFINE_CLASS_EXT(name, desc, options)
 
#define AVFILTER_DEFINE_CLASS(fname)   AVFILTER_DEFINE_CLASS_EXT(fname, #fname, fname##_options)
 
#define FF_INLINK_IDX(link)   ((int)((link)->dstpad - (link)->dst->input_pads))
 Find the index of a link. More...
 
#define FF_OUTLINK_IDX(link)   ((int)((link)->srcpad - (link)->src->output_pads))
 
#define FF_FILTER_FLAG_HWFRAME_AWARE   (1 << 0)
 The filter is aware of hardware frames, and any hardware frame context should not be automatically propagated through it. More...
 

Enumerations

enum  FilterFormatsState {
  FF_FILTER_FORMATS_PASSTHROUGH = 0, FF_FILTER_FORMATS_QUERY_FUNC, FF_FILTER_FORMATS_PIXFMT_LIST, FF_FILTER_FORMATS_SAMPLEFMTS_LIST,
  FF_FILTER_FORMATS_SINGLE_PIXFMT, FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
}
 

Functions

static FFFilterContextfffilterctx (AVFilterContext *ctx)
 
static av_always_inline int ff_filter_execute (AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
 
int ff_fmt_is_in (int fmt, const int *fmts)
 Tell if an integer is contained in the provided -1-terminated list of integers. More...
 
int ff_fmt_is_regular_yuv (enum AVPixelFormat fmt)
 Returns true if a pixel format is "regular YUV", which includes all pixel formats that are affected by YUV colorspace negotiation. More...
 
av_warn_unused_result int ff_parse_pixel_format (enum AVPixelFormat *ret, const char *arg, void *log_ctx)
 Parse a pixel format. More...
 
av_warn_unused_result int ff_parse_sample_rate (int *ret, const char *arg, void *log_ctx)
 Parse a sample rate. More...
 
av_warn_unused_result int ff_parse_channel_layout (AVChannelLayout *ret, int *nret, const char *arg, void *log_ctx)
 Parse a channel layout or a corresponding integer representation. 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...
 
int ff_filter_config_links (AVFilterContext *filter)
 Negotiate the media format, dimensions, etc of all inputs to a filter. More...
 
int ff_append_inpad (AVFilterContext *f, AVFilterPad *p)
 Append a new input/output pad to the filter's list of such pads. More...
 
int ff_append_outpad (AVFilterContext *f, AVFilterPad *p)
 
int ff_append_inpad_free_name (AVFilterContext *f, AVFilterPad *p)
 
int ff_append_outpad_free_name (AVFilterContext *f, AVFilterPad *p)
 
int ff_request_frame (AVFilterLink *link)
 Request an input frame from the filter at the other end of the link. More...
 
int ff_filter_frame (AVFilterLink *link, AVFrame *frame)
 Send a frame of data to the next filter. More...
 
int ff_filter_graph_run_once (AVFilterGraph *graph)
 Run one round of processing on a filter graph. More...
 
int ff_filter_get_nb_threads (AVFilterContext *ctx) av_pure
 Get number of threads for current filter instance. More...
 
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. More...
 
int ff_filter_init_hw_frames (AVFilterContext *avctx, AVFilterLink *link, int default_pool_size)
 Perform any additional setup required for hardware frames. More...
 

Detailed Description

internal API functions

Definition in file internal.h.

Macro Definition Documentation

◆ AVFILTERPAD_FLAG_NEEDS_WRITABLE

#define AVFILTERPAD_FLAG_NEEDS_WRITABLE   (1 << 0)

The filter expects writable frames from its input link, duplicating data buffers if needed.

input pads only.

Definition at line 52 of file internal.h.

◆ AVFILTERPAD_FLAG_FREE_NAME

#define AVFILTERPAD_FLAG_FREE_NAME   (1 << 1)

The pad's name is allocated and should be freed generically.

Definition at line 57 of file internal.h.

◆ FILTER_QUERY_FUNC

#define FILTER_QUERY_FUNC (   func)
Value:
.formats.query_func = func, \

Definition at line 159 of file internal.h.

◆ FILTER_PIXFMTS_ARRAY

#define FILTER_PIXFMTS_ARRAY (   array)
Value:
.formats.pixels_list = array, \

Definition at line 162 of file internal.h.

◆ FILTER_SAMPLEFMTS_ARRAY

#define FILTER_SAMPLEFMTS_ARRAY (   array)
Value:
.formats.samples_list = array, \

Definition at line 165 of file internal.h.

◆ FILTER_PIXFMTS

#define FILTER_PIXFMTS (   ...)    FILTER_PIXFMTS_ARRAY(((const enum AVPixelFormat []) { __VA_ARGS__, AV_PIX_FMT_NONE }))

Definition at line 168 of file internal.h.

◆ FILTER_SAMPLEFMTS

#define FILTER_SAMPLEFMTS (   ...)    FILTER_SAMPLEFMTS_ARRAY(((const enum AVSampleFormat[]) { __VA_ARGS__, AV_SAMPLE_FMT_NONE }))

Definition at line 170 of file internal.h.

◆ FILTER_SINGLE_PIXFMT

#define FILTER_SINGLE_PIXFMT (   pix_fmt_)
Value:
.formats.pix_fmt = pix_fmt_, \

Definition at line 172 of file internal.h.

◆ FILTER_SINGLE_SAMPLEFMT

#define FILTER_SINGLE_SAMPLEFMT (   sample_fmt_)
Value:
.formats.sample_fmt = sample_fmt_, \

Definition at line 175 of file internal.h.

◆ FILTER_INOUTPADS

#define FILTER_INOUTPADS (   inout,
  array 
)
Value:
.inout = array, \
.nb_ ## inout = FF_ARRAY_ELEMS(array)

Definition at line 179 of file internal.h.

◆ FILTER_INPUTS

#define FILTER_INPUTS (   array)    FILTER_INOUTPADS(inputs, (array))

Definition at line 182 of file internal.h.

◆ FILTER_OUTPUTS

#define FILTER_OUTPUTS (   array)    FILTER_INOUTPADS(outputs, (array))

Definition at line 183 of file internal.h.

◆ D2TS

#define D2TS (   d)    (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))

Definition at line 257 of file internal.h.

◆ TS2D

#define TS2D (   ts)    ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))

Definition at line 258 of file internal.h.

◆ TS2T

#define TS2T (   ts,
  tb 
)    ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb))

Definition at line 259 of file internal.h.

◆ FF_TPRINTF_START

#define FF_TPRINTF_START (   ctx,
  func 
)    ff_tlog(NULL, "%-16s: ", #func)

Definition at line 263 of file internal.h.

◆ ff_tlog_link

#define ff_tlog_link (   ctx,
  link,
  end 
)    do { } while(0)

Definition at line 268 of file internal.h.

◆ AVFILTER_DEFINE_CLASS_EXT

#define AVFILTER_DEFINE_CLASS_EXT (   name,
  desc,
  options 
)
Value:
static const AVClass name##_class = { \
.class_name = desc, \
.item_name = av_default_item_name, \
.option = options, \
.version = LIBAVUTIL_VERSION_INT, \
.category = AV_CLASS_CATEGORY_FILTER, \
}

Definition at line 315 of file internal.h.

◆ AVFILTER_DEFINE_CLASS

#define AVFILTER_DEFINE_CLASS (   fname)    AVFILTER_DEFINE_CLASS_EXT(fname, #fname, fname##_options)

Definition at line 323 of file internal.h.

◆ FF_INLINK_IDX

#define FF_INLINK_IDX (   link)    ((int)((link)->dstpad - (link)->dst->input_pads))

Find the index of a link.

I.e. find i such that link == ctx->(in|out)puts[i]

Definition at line 331 of file internal.h.

◆ FF_OUTLINK_IDX

#define FF_OUTLINK_IDX (   link)    ((int)((link)->srcpad - (link)->src->output_pads))

Definition at line 332 of file internal.h.

◆ FF_FILTER_FLAG_HWFRAME_AWARE

#define FF_FILTER_FLAG_HWFRAME_AWARE   (1 << 0)

The filter is aware of hardware frames, and any hardware frame context should not be automatically propagated through it.

Definition at line 351 of file internal.h.

Enumeration Type Documentation

◆ FilterFormatsState

Enumerator
FF_FILTER_FORMATS_PASSTHROUGH 

The default value meaning that this filter supports all formats and (for audio) sample rates and channel layouts/counts as long as these properties agree for all inputs and outputs.

This state is only allowed in case all inputs and outputs actually have the same type. The union is unused in this state.

This value must always be zero (for default static initialization).

FF_FILTER_FORMATS_QUERY_FUNC 

formats.query active.

FF_FILTER_FORMATS_PIXFMT_LIST 

formats.pixels_list active.

FF_FILTER_FORMATS_SAMPLEFMTS_LIST 

formats.samples_list active.

FF_FILTER_FORMATS_SINGLE_PIXFMT 

formats.pix_fmt active

FF_FILTER_FORMATS_SINGLE_SAMPLEFMT 

formats.sample_fmt active.

Definition at line 140 of file internal.h.

Function Documentation

◆ fffilterctx()

static FFFilterContext* fffilterctx ( AVFilterContext ctx)
inlinestatic

◆ ff_filter_execute()

static av_always_inline int ff_filter_execute ( AVFilterContext ctx,
avfilter_action_func func,
void *  arg,
int ret,
int  nb_jobs 
)
static

◆ ff_fmt_is_in()

int ff_fmt_is_in ( int  fmt,
const int fmts 
)

Tell if an integer is contained in the provided -1-terminated list of integers.

This is useful for determining (for instance) if an AVPixelFormat is in an array of supported formats.

Parameters
fmtprovided format
fmts-1-terminated list of formats
Returns
1 if present, 0 if absent

Definition at line 407 of file formats.c.

Referenced by config_input(), config_input_main(), config_input_overlay(), config_out_props(), config_props(), filter_frame(), and init().

◆ ff_fmt_is_regular_yuv()

int ff_fmt_is_regular_yuv ( enum AVPixelFormat  fmt)

Returns true if a pixel format is "regular YUV", which includes all pixel formats that are affected by YUV colorspace negotiation.

Definition at line 605 of file avfiltergraph.c.

Referenced by pick_format(), and query_formats().

◆ ff_parse_pixel_format()

av_warn_unused_result int ff_parse_pixel_format ( enum AVPixelFormat ret,
const char *  arg,
void *  log_ctx 
)

Parse a pixel format.

Parameters
retpixel format pointer to where the value should be written
argstring to parse
log_ctxlog context
Returns
>= 0 in case of success, a negative AVERROR code on error

Definition at line 940 of file formats.c.

Referenced by init().

◆ ff_parse_sample_rate()

av_warn_unused_result int ff_parse_sample_rate ( int ret,
const char *  arg,
void *  log_ctx 
)

Parse a sample rate.

Parameters
retunsigned integer pointer to where the value should be written
argstring to parse
log_ctxlog context
Returns
>= 0 in case of success, a negative AVERROR code on error

Definition at line 955 of file formats.c.

Referenced by init().

◆ ff_parse_channel_layout()

av_warn_unused_result int ff_parse_channel_layout ( AVChannelLayout ret,
int nret,
const char *  arg,
void *  log_ctx 
)

Parse a channel layout or a corresponding integer representation.

Parameters
ret64bit integer pointer to where the value should be written.
nretinteger pointer to the number of channels; if not NULL, then unknown channel layouts are accepted
argstring to parse
log_ctxlog context
Returns
>= 0 in case of success, a negative AVERROR code on error

Definition at line 967 of file formats.c.

Referenced by init(), and main().

◆ ff_avfilter_link_set_in_status()

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 258 of file avfilter.c.

Referenced by av_buffersrc_close(), ff_outlink_set_status(), and ff_request_frame_to_filter().

◆ ff_filter_config_links()

int ff_filter_config_links ( AVFilterContext filter)

Negotiate the media format, dimensions, etc of all inputs to a filter.

Parameters
filterthe filter to negotiate the properties for its inputs
Returns
zero on successful negotiation

Definition at line 333 of file avfilter.c.

Referenced by ff_filter_config_links(), graph_config_links(), and process_command().

◆ ff_append_inpad()

int ff_append_inpad ( AVFilterContext f,
AVFilterPad p 
)

Append a new input/output pad to the filter's list of such pads.

The *_free_name versions will set the AVFILTERPAD_FLAG_FREE_NAME flag ensuring that the name will be freed generically (even on insertion error).

Definition at line 127 of file avfilter.c.

Referenced by decimate_init(), ff_append_inpad_free_name(), fieldmatch_init(), and init().

◆ ff_append_outpad()

int ff_append_outpad ( AVFilterContext f,
AVFilterPad p 
)

Definition at line 138 of file avfilter.c.

Referenced by ff_append_outpad_free_name(), and init().

◆ ff_append_inpad_free_name()

int ff_append_inpad_free_name ( AVFilterContext f,
AVFilterPad p 
)

◆ ff_append_outpad_free_name()

int ff_append_outpad_free_name ( AVFilterContext f,
AVFilterPad p 
)

Definition at line 143 of file avfilter.c.

Referenced by init(), movie_common_init(), parse_definition(), and split_init().

◆ ff_request_frame()

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.

Parameters
linkthe input link
Returns
zero on success AVERROR_EOF on end of file AVERROR(EAGAIN) if the previous filter cannot output a frame currently and can neither guarantee that EOF has been reached.

Definition at line 473 of file avfilter.c.

Referenced by avfilter_graph_request_oldest(), deint_vaapi_request_frame(), ff_request_frame_to_filter(), ff_yadif_request_frame(), request_frame(), and request_frame_ref().

◆ ff_filter_frame()

int ff_filter_frame ( AVFilterLink link,
AVFrame frame 
)

Send a frame of data to the next filter.

Parameters
linkthe output link over which the data is being sent
framea 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.
Returns
>= 0 on success, a negative AVERROR on error. The receiving filter is responsible for unreferencing frame in case of error.

Definition at line 1024 of file avfilter.c.

Referenced by activate(), addroi_filter_frame(), apply_filter(), audio_frame(), av_buffersrc_add_frame_flags(), avgblur_opencl_filter_frame(), avgblur_vulkan_filter_frame(), blend_frame(), blend_frame_for_dualinput(), blockdetect_filter_frame(), blur_frame(), blurdetect_filter_frame(), channelmap_filter_frame(), chromaber_vulkan_filter_frame(), compand_delay(), compand_drain(), compand_nodelay(), convolution_opencl_filter_frame(), create_frame(), cuda_bilateral_filter_frame(), cudachromakey_filter_frame(), cudacolorspace_filter_frame(), cudascale_filter_frame(), cudaupload_filter_frame(), ddagrab_request_frame(), decode_packet(), default_filter_frame(), deint_vaapi_filter_frame(), dnn_classify_activate(), dnn_classify_flush_frame(), dnn_detect_activate(), dnn_detect_flush_frame(), do_alphamerge(), do_blend(), do_convolve(), do_corr(), do_identity(), do_morpho(), do_psnr(), do_scale(), do_ssim(), do_ssim360(), do_vmaf(), draw_spatial(), drawbox_vaapi_filter_frame(), end_last_frame(), extract_plane(), ff_qsvvpp_init(), ff_yadif_filter_frame(), filter(), filter_callback(), filter_frame(), filter_frame_ref(), fir_frame(), flip_bayer(), flush_frame(), forward_frame(), gblur_vulkan_filter_frame(), geq_filter_frame(), get_frame(), headphone_frame(), hwdownload_filter_frame(), hwmap_filter_frame(), hwupload_filter_frame(), iccdetect_filter_frame(), iccgen_filter_frame(), load_apply_palette(), misc_vaapi_filter_frame(), neighbor_opencl_filter_frame(), nlmeans_opencl_filter_frame(), nppscale_filter_frame(), nppscale_filter_frame_ref(), nppsharpen_filter_frame(), npptranspose_filter_frame(), oscilloscope_filter_frame(), output_frame(), output_single_frame(), overlay_cuda_blend(), overlay_opencl_blend(), overlay_vaapi_blend(), overlay_vulkan_blend(), pad_vaapi_filter_frame(), pixscope_filter_frame(), plot_freqs(), plot_spectrum_column(), pp_filter_frame(), procamp_vaapi_filter_frame(), process_frame(), program_opencl_run(), push_frame(), push_samples(), remap_opencl_process_frame(), request_frame(), return_frame(), scale_vaapi_filter_frame(), scale_vt_filter_frame(), scale_vulkan_filter_frame(), send_silence(), shuffleplanes_filter_frame(), sierpinski_request_frame(), source_request_frame(), testsrc_vulkan_activate(), tonemap_opencl_filter_frame(), tonemap_vaapi_filter_frame(), transpose_opencl_filter_frame(), transpose_vaapi_filter_frame(), transpose_vt_filter_frame(), try_push_frame(), unsharp_opencl_filter_frame(), varblur_frame(), video_frame(), write_frame(), xfade_activate(), xfade_frame(), and xfade_opencl_activate().

◆ ff_filter_graph_run_once()

int ff_filter_graph_run_once ( AVFilterGraph graph)

Run one round of processing on a filter graph.

Definition at line 1418 of file avfiltergraph.c.

Referenced by avfilter_graph_request_oldest(), get_frame_internal(), and push_frame().

◆ ff_filter_get_nb_threads()

int ff_filter_get_nb_threads ( AVFilterContext ctx)

◆ ff_filter_process_command()

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.

NOTE: 'enable' option is handled separately, and not by this function.

Definition at line 895 of file avfilter.c.

Referenced by command(), libplacebo_process_command(), oscilloscope_process_command(), pixscope_process_command(), and process_command().

◆ ff_filter_init_hw_frames()

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 1624 of file avfilter.c.

Referenced by config_output(), ff_vaapi_vpp_config_output(), scale_vt_config_output(), and transpose_vt_recreate_hw_ctx().

func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:68
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
FF_FILTER_FORMATS_SAMPLEFMTS_LIST
@ FF_FILTER_FORMATS_SAMPLEFMTS_LIST
formats.samples_list active.
Definition: internal.h:154
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
@ FF_FILTER_FORMATS_SINGLE_SAMPLEFMT
formats.sample_fmt active.
Definition: internal.h:156
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV_CLASS_CATEGORY_FILTER
@ AV_CLASS_CATEGORY_FILTER
Definition: log.h:36
options
const OptionDef options[]
array
static int array[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:111
desc
const char * desc
Definition: libsvtav1.c:79
FF_FILTER_FORMATS_PIXFMT_LIST
@ FF_FILTER_FORMATS_PIXFMT_LIST
formats.pixels_list active.
Definition: internal.h:153
FF_FILTER_FORMATS_QUERY_FUNC
@ FF_FILTER_FORMATS_QUERY_FUNC
formats.query active.
Definition: internal.h:152
FF_FILTER_FORMATS_SINGLE_PIXFMT
@ FF_FILTER_FORMATS_SINGLE_PIXFMT
formats.pix_fmt active
Definition: internal.h:155