FFmpeg
Data Structures | Macros | Functions
internal.h File Reference
#include "libavutil/internal.h"
#include "avfilter.h"
#include "formats.h"
#include "framepool.h"
#include "framequeue.h"
#include "thread.h"
#include "version.h"
#include "video.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/internal.h"

Go to the source code of this file.

Data Structures

struct  AVFilterCommand
 
struct  AVFilterPad
 A filter pad used for either input or output. More...
 
struct  AVFilterGraphInternal
 
struct  AVFilterInternal
 

Macros

#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 AVFILTER_DEFINE_CLASS(fname)
 
#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...
 

Functions

void ff_avfilter_graph_update_heap (AVFilterGraph *graph, AVFilterLink *link)
 Update the position of a link in the age heap. More...
 
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...
 
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 (int64_t *ret, int *nret, const char *arg, void *log_ctx)
 Parse a channel layout or a corresponding integer representation. More...
 
void ff_update_link_current_pts (AVFilterLink *link, int64_t pts)
 
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 ff_command_queue_pop (AVFilterContext *filter)
 
char * ff_get_ref_perms_string (char *buf, size_t buf_size, int perms)
 
void ff_tlog_ref (void *ctx, AVFrame *ref, int end)
 
void ff_tlog_link (void *ctx, AVFilterLink *link, int end)
 
int ff_insert_pad (unsigned idx, unsigned *count, size_t padidx_off, AVFilterPad **pads, AVFilterLink ***links, AVFilterPad *newpad)
 Insert a new pad. More...
 
static int ff_insert_inpad (AVFilterContext *f, unsigned index, AVFilterPad *p)
 Insert a new input pad for the filter. More...
 
static int ff_insert_outpad (AVFilterContext *f, unsigned index, AVFilterPad *p)
 Insert a new output pad for the filter. More...
 
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...
 
AVFilterContextff_filter_alloc (const AVFilter *filter, const char *inst_name)
 Allocate a new filter context and return it. More...
 
int ff_filter_activate (AVFilterContext *filter)
 
void ff_filter_graph_remove_filter (AVFilterGraph *graph, AVFilterContext *filter)
 Remove a filter from a graph;. More...
 
int ff_filter_graph_run_once (AVFilterGraph *graph)
 Run one round of processing on a filter graph. More...
 
static int ff_norm_qscale (int qscale, int type)
 Normalize the qscale factor FIXME the H264 qscale is a log based scale, mpeg1/2 is not, the code below cannot be optimal. More...
 
int ff_filter_get_nb_threads (AVFilterContext *ctx)
 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

◆ D2TS

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

Definition at line 207 of file internal.h.

◆ TS2D

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

Definition at line 208 of file internal.h.

◆ TS2T

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

Definition at line 209 of file internal.h.

◆ FF_TPRINTF_START

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

Definition at line 213 of file internal.h.

◆ AVFILTER_DEFINE_CLASS

#define AVFILTER_DEFINE_CLASS (   fname)
Value:
static const AVClass fname##_class = { \
.class_name = #fname, \
.item_name = av_default_item_name, \
.option = fname##_options, \
.version = LIBAVUTIL_VERSION_INT, \
.category = AV_CLASS_CATEGORY_FILTER, \
}

Definition at line 288 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 302 of file internal.h.

◆ FF_OUTLINK_IDX

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

Definition at line 303 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 339 of file internal.h.

Function Documentation

◆ ff_avfilter_graph_update_heap()

void ff_avfilter_graph_update_heap ( AVFilterGraph graph,
AVFilterLink link 
)

Update the position of a link in the age heap.

Definition at line 1340 of file avfiltergraph.c.

Referenced by ff_update_link_current_pts().

◆ 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 257 of file formats.c.

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

◆ 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 617 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 632 of file formats.c.

Referenced by init().

◆ ff_parse_channel_layout()

av_warn_unused_result int ff_parse_channel_layout ( int64_t *  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 644 of file formats.c.

Referenced by init(), and main().

◆ ff_update_link_current_pts()

void ff_update_link_current_pts ( AVFilterLink link,
int64_t  pts 
)

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

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

◆ ff_avfilter_link_set_out_status()

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().

◆ ff_command_queue_pop()

void ff_command_queue_pop ( AVFilterContext filter)

Definition at line 94 of file avfilter.c.

Referenced by avfilter_free(), and ff_inlink_process_commands().

◆ ff_get_ref_perms_string()

char* ff_get_ref_perms_string ( char *  buf,
size_t  buf_size,
int  perms 
)

◆ ff_tlog_ref()

void ff_tlog_ref ( void *  ctx,
AVFrame ref,
int  end 
)

Definition at line 49 of file avfilter.c.

Referenced by ff_filter_frame().

◆ ff_tlog_link()

void ff_tlog_link ( void *  ctx,
AVFilterLink link,
int  end 
)

◆ ff_insert_pad()

int ff_insert_pad ( unsigned  idx,
unsigned *  count,
size_t  padidx_off,
AVFilterPad **  pads,
AVFilterLink ***  links,
AVFilterPad newpad 
)

Insert a new pad.

Parameters
idxInsertion point. Pad is inserted at the end if this point is beyond the end of the list of pads.
countPointer to the number of pads in the list
padidx_offOffset within an AVFilterLink structure to the element to increment when inserting a new pad causes link numbering to change
padsPointer to the pointer to the beginning of the list of pads
linksPointer to the pointer to the beginning of the list of links
newpadThe new pad to add. A copy is made when adding.
Returns
>= 0 in case of success, a negative AVERROR code on error

Definition at line 103 of file avfilter.c.

Referenced by ff_insert_inpad(), and ff_insert_outpad().

◆ ff_insert_inpad()

static int ff_insert_inpad ( AVFilterContext f,
unsigned  index,
AVFilterPad p 
)
inlinestatic

Insert a new input pad for the filter.

Definition at line 240 of file internal.h.

Referenced by decimate_init(), fieldmatch_init(), init(), join_init(), parse_definition(), and program_opencl_init().

◆ ff_insert_outpad()

static int ff_insert_outpad ( AVFilterContext f,
unsigned  index,
AVFilterPad p 
)
inlinestatic

Insert a new output pad for the filter.

Definition at line 248 of file internal.h.

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

Referenced by avfilter_graph_request_oldest(), ff_request_frame_to_filter(), ff_yadif_request_frame(), qsvdeint_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 1096 of file avfilter.c.

Referenced by activate(), activate_async(), addroi_filter_frame(), apply_filter(), av_buffersrc_add_frame_flags(), avgblur_opencl_filter_frame(), avgblur_vulkan_filter_frame(), blend_frame_for_dualinput(), channelmap_filter_frame(), chromaber_vulkan_filter_frame(), compand_delay(), compand_drain(), compand_nodelay(), convolution_opencl_filter_frame(), create_frame(), cudascale_filter_frame(), cudaupload_filter_frame(), default_filter_frame(), deint_vaapi_filter_frame(), do_alphamerge(), do_blend(), do_convolve(), do_identity(), do_psnr(), do_ssim(), do_vmaf(), draw_spatial(), end_last_frame(), ff_qsvvpp_create(), ff_yadif_filter_frame(), filter(), filter_callback(), filter_frame(), filter_frame16(), filter_frame8(), filter_frame_ref(), fir_frame(), flip_bayer(), flush(), flush_frame(), geq_filter_frame(), get_frame(), headphone_frame(), hwdownload_filter_frame(), hwmap_filter_frame(), hwupload_filter_frame(), load_apply_palette(), misc_vaapi_filter_frame(), movie_push_frame(), neighbor_opencl_filter_frame(), nlmeans_opencl_filter_frame(), nppscale_filter_frame(), npptranspose_filter_frame(), oscilloscope_filter_frame(), output_frame(), output_single_frame(), overlay_cuda_blend(), overlay_opencl_blend(), overlay_vulkan_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_frame(), scale_vaapi_filter_frame(), scale_vulkan_filter_frame(), send_silence(), shuffleplanes_filter_frame(), sierpinski_request_frame(), source_request_frame(), tonemap_opencl_filter_frame(), tonemap_vaapi_filter_frame(), transpose_opencl_filter_frame(), transpose_vaapi_filter_frame(), try_push_frame(), unsharp_opencl_filter_frame(), write_frame(), xfade_activate(), xfade_frame(), and xfade_opencl_activate().

◆ ff_filter_alloc()

AVFilterContext* ff_filter_alloc ( const AVFilter filter,
const char *  inst_name 
)

Allocate a new filter context and return it.

Parameters
filterwhat filter to create an instance of
inst_namename to give to the new filter context
Returns
newly created filter context or NULL on failure

Definition at line 663 of file avfilter.c.

Referenced by avfilter_graph_alloc_filter().

◆ ff_filter_activate()

int ff_filter_activate ( AVFilterContext filter)

Definition at line 1434 of file avfilter.c.

Referenced by ff_filter_graph_run_once().

◆ ff_filter_graph_remove_filter()

void ff_filter_graph_remove_filter ( AVFilterGraph graph,
AVFilterContext filter 
)

Remove a filter from a graph;.

Definition at line 102 of file avfiltergraph.c.

Referenced by avfilter_free().

◆ 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 1391 of file avfiltergraph.c.

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

◆ ff_norm_qscale()

static int ff_norm_qscale ( int  qscale,
int  type 
)
inlinestatic

Normalize the qscale factor FIXME the H264 qscale is a log based scale, mpeg1/2 is not, the code below cannot be optimal.

Definition at line 351 of file internal.h.

Referenced by filter(), and filter_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 882 of file avfilter.c.

Referenced by 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 1653 of file avfilter.c.

Referenced by config_output(), ff_vaapi_vpp_config_output(), and init_out_pool().

LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
AV_CLASS_CATEGORY_FILTER
@ AV_CLASS_CATEGORY_FILTER
Definition: log.h:37
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72