FFmpeg
Macros | Enumerations | Functions
AVOption (un)initialization and inspection.

Macros

#define AV_OPT_SEARCH_CHILDREN   (1 << 0)
 Search in possible children of the given object first. More...
 
#define AV_OPT_SEARCH_FAKE_OBJ   (1 << 1)
 The obj passed to av_opt_find() is fake – only a double pointer to AVClass instead of a required pointer to a struct containing AVClass. More...
 
#define AV_OPT_ALLOW_NULL   (1 << 2)
 In av_opt_get, return NULL if the option has a pointer type and is set to NULL, rather than returning an empty string. More...
 
#define AV_OPT_MULTI_COMPONENT_RANGE   (1 << 12)
 Allows av_opt_query_ranges and av_opt_query_ranges_default to return more than one component for certain option types. More...
 

Enumerations

enum  { AV_OPT_FLAG_IMPLICIT_KEY = 1 }
 

Functions

void av_opt_set_defaults (void *s)
 Set the values of all AVOption fields to their default values. More...
 
void av_opt_set_defaults2 (void *s, int mask, int flags)
 Set the values of all AVOption fields to their default values. More...
 
void av_opt_free (void *obj)
 Free all allocated objects in obj. More...
 
const AVOptionav_opt_next (const void *obj, const AVOption *prev)
 Iterate over all AVOptions belonging to obj. More...
 
void * av_opt_child_next (void *obj, void *prev)
 Iterate over AVOptions-enabled children of obj. More...
 
const AVClassav_opt_child_class_iterate (const AVClass *parent, void **iter)
 Iterate over potential AVOptions-enabled children of parent. More...
 
const AVOptionav_opt_find (void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
 Look for an option in an object. More...
 
const AVOptionav_opt_find2 (void *obj, const char *name, const char *unit, int opt_flags, int search_flags, void **target_obj)
 Look for an option in an object. More...
 
int av_opt_show2 (void *obj, void *av_log_obj, int req_flags, int rej_flags)
 Show the obj options. More...
 
int av_opt_get_key_value (const char **ropts, const char *key_val_sep, const char *pairs_sep, unsigned flags, char **rkey, char **rval)
 Extract a key-value pair from the beginning of a string. More...
 

Detailed Description

Macro Definition Documentation

◆ AV_OPT_SEARCH_CHILDREN

#define AV_OPT_SEARCH_CHILDREN   (1 << 0)

Search in possible children of the given object first.

Examples
avio_http_serve_files.c, decode_filter_audio.c, decode_filter_video.c, filter_audio.c, and transcode.c.

Definition at line 522 of file opt.h.

◆ AV_OPT_SEARCH_FAKE_OBJ

#define AV_OPT_SEARCH_FAKE_OBJ   (1 << 1)

The obj passed to av_opt_find() is fake – only a double pointer to AVClass instead of a required pointer to a struct containing AVClass.

This is useful for searching for options without needing to allocate the corresponding object.

Definition at line 530 of file opt.h.

◆ AV_OPT_ALLOW_NULL

#define AV_OPT_ALLOW_NULL   (1 << 2)

In av_opt_get, return NULL if the option has a pointer type and is set to NULL, rather than returning an empty string.

Definition at line 536 of file opt.h.

◆ AV_OPT_MULTI_COMPONENT_RANGE

#define AV_OPT_MULTI_COMPONENT_RANGE   (1 << 12)

Allows av_opt_query_ranges and av_opt_query_ranges_default to return more than one component for certain option types.

See also
AVOptionRanges for details.

Definition at line 543 of file opt.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
AV_OPT_FLAG_IMPLICIT_KEY 

Accept to parse a value without a key; the key will then be returned as NULL.

Definition at line 629 of file opt.h.

Function Documentation

◆ av_opt_set_defaults()

void av_opt_set_defaults ( void *  s)

◆ av_opt_set_defaults2()

void av_opt_set_defaults2 ( void *  s,
int  mask,
int  flags 
)

Set the values of all AVOption fields to their default values.

Only these AVOption fields for which (opt->flags & mask) == flags will have their default applied to s.

Parameters
san AVOption-enabled struct (its first member must be a pointer to AVClass)
maskcombination of AV_OPT_FLAG_*
flagscombination of AV_OPT_FLAG_*

Definition at line 1643 of file opt.c.

Referenced by av_opt_set_defaults(), and init_context_defaults().

◆ av_opt_free()

void av_opt_free ( void *  obj)

◆ av_opt_next()

const AVOption* av_opt_next ( const void *  obj,
const AVOption prev 
)

Iterate over all AVOptions belonging to obj.

Parameters
objan AVOptions-enabled struct or a double pointer to an AVClass describing it.
prevresult of the previous call to av_opt_next() on this object or NULL
Returns
next AVOption or NULL

Definition at line 48 of file opt.c.

Referenced by av_opt_copy(), av_opt_find2(), av_opt_free(), av_opt_serialize(), av_opt_set_defaults2(), bsf_list_append_internal(), ff_filter_opt_parse(), get_opt_const_name(), get_opt_flags_string(), main(), opt_list(), print_option(), print_private_data(), set_string_number(), and show_opts().

◆ av_opt_child_next()

void* av_opt_child_next ( void *  obj,
void *  prev 
)

Iterate over AVOptions-enabled children of obj.

Parameters
prevresult of a previous call to this function or NULL
Returns
next AVOptions-enabled child or NULL

Definition at line 2001 of file opt.c.

Referenced by av_opt_find2().

◆ av_opt_child_class_iterate()

const AVClass* av_opt_child_class_iterate ( const AVClass parent,
void **  iter 
)

Iterate over potential AVOptions-enabled children of parent.

Parameters
itera pointer where iteration state is stored.
Returns
AVClass corresponding to next potential child or NULL

Definition at line 2009 of file opt.c.

Referenced by av_opt_find2(), and show_help_children().

◆ av_opt_find()

const AVOption* av_opt_find ( void *  obj,
const char *  name,
const char *  unit,
int  opt_flags,
int  search_flags 
)

Look for an option in an object.

Consider only options which have all the specified flags set.

Parameters
[in]objA pointer to a struct whose first element is a pointer to an AVClass. Alternatively a double pointer to an AVClass, if AV_OPT_SEARCH_FAKE_OBJ search flag is set.
[in]nameThe name of the option to look for.
[in]unitWhen searching for named constants, name of the unit it belongs to.
opt_flagsFind only options with all the specified flags set (AV_OPT_FLAG).
search_flagsA combination of AV_OPT_SEARCH_*.
Returns
A pointer to the option found, or NULL if no option was found.
Note
Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable directly with av_opt_set(). Use special calls which take an options AVDictionary (e.g. avformat_open_input()) to set options found with this flag.

Definition at line 1950 of file opt.c.

Referenced by av_opt_flag_is_set(), av_opt_query_ranges_default(), check_opt_bitexact(), filter_codec_opts(), filter_opt_apply(), ifile_open(), ofilter_bind_ost(), opt_find(), set_string_number(), and validate_enc_avopt().

◆ av_opt_find2()

const AVOption* av_opt_find2 ( void *  obj,
const char *  name,
const char *  unit,
int  opt_flags,
int  search_flags,
void **  target_obj 
)

Look for an option in an object.

Consider only options which have all the specified flags set.

Parameters
[in]objA pointer to a struct whose first element is a pointer to an AVClass. Alternatively a double pointer to an AVClass, if AV_OPT_SEARCH_FAKE_OBJ search flag is set.
[in]nameThe name of the option to look for.
[in]unitWhen searching for named constants, name of the unit it belongs to.
opt_flagsFind only options with all the specified flags set (AV_OPT_FLAG).
search_flagsA combination of AV_OPT_SEARCH_*.
[out]target_objif non-NULL, an object to which the option belongs will be written here. It may be different from obj if AV_OPT_SEARCH_CHILDREN is present in search_flags. This parameter is ignored if search_flags contain AV_OPT_SEARCH_FAKE_OBJ.
Returns
A pointer to the option found, or NULL if no option was found.

Definition at line 1956 of file opt.c.

Referenced by av_opt_find(), av_opt_find2(), av_opt_get(), av_opt_get_chlayout(), av_opt_get_dict_val(), av_opt_get_image_size(), av_opt_is_set_to_default_by_name(), av_opt_ptr(), av_opt_set(), av_opt_set_bin(), av_opt_set_chlayout(), av_opt_set_dict_val(), av_opt_set_image_size(), av_opt_set_video_rate(), ff_filter_process_command(), get_format(), get_number(), set_format(), and set_number().

◆ av_opt_show2()

int av_opt_show2 ( void *  obj,
void *  av_log_obj,
int  req_flags,
int  rej_flags 
)

Show the obj options.

Parameters
req_flagsrequested flags for the options to show. Show only the options for which it is opt->flags & req_flags.
rej_flagsrejected flags for the options to show. Show only the options for which it is !(opt->flags & req_flags).
av_log_objlog context to use for showing the options

Definition at line 1626 of file opt.c.

Referenced by main(), and show_help_children().

◆ av_opt_get_key_value()

int av_opt_get_key_value ( const char **  ropts,
const char *  key_val_sep,
const char *  pairs_sep,
unsigned  flags,
char **  rkey,
char **  rval 
)

Extract a key-value pair from the beginning of a string.

Parameters
roptspointer to the options string, will be updated to point to the rest of the string (one of the pairs_sep or the final NUL)
key_val_sepa 0-terminated list of characters used to separate key from value, for example '='
pairs_sepa 0-terminated list of characters used to separate two pairs from each other, for example ':' or ','
flagsflags; see the AV_OPT_FLAG_* values below
rkeyparsed key; must be freed using av_free()
rvalparsed value; must be freed using av_free()
Returns
>=0 for success, or a negative value corresponding to an AVERROR code in case of error; in particular: AVERROR(EINVAL) if no key is present

Definition at line 1834 of file opt.c.

Referenced by av_opt_set_from_string(), ff_filter_opt_parse(), ff_tee_parse_slave_options(), init_report(), and parse_channel_list().