Loading...
Searching...
No Matches
Setting and modifying option values
libavutil » Data Structures » AVOptions

## Topics

| Option setting functions
| Those functions set the field of obj with the given name to value.

## Functions

int | av_set_options_string (void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
| Parse the key/value pairs list in opts.
int | av_opt_set_from_string (void *ctx, const char *opts, const char *const *shorthand, const char *key_val_sep, const char *pairs_sep)
| Parse the key-value pairs list in opts.
int | av_opt_set_dict (void *obj, struct AVDictionary **options)
| Set all the options from a given dictionary on an object.
int | av_opt_set_dict2 (void *obj, struct AVDictionary **options, int search_flags)
| Set all the options from a given dictionary on an object.
int | av_opt_copy (void *dest, const void *src)
| Copy options from src object into dest object.

## Detailed Description

## Function Documentation

## av_set_options_string()

int av_set_options_string | ( | void * | ctx,
|  | const char * | opts,
|  | const char * | key_val_sep,
|  | const char * | pairs_sep )

Parse the key/value pairs list in opts.

For each key/value pair found, stores the value in the field in ctx that is named like the key. ctx must be an AVClass context, storing is done using AVOptions.

Parameters

  opts | options string to parse, may be NULL
  key_val_sep | a 0-terminated list of characters used to separate key from value
  pairs_sep | a 0-terminated list of characters used to separate two pairs from each other

Returns
  the number of successfully set key/value pairs, or a negative value corresponding to an AVERROR code in case of error: AVERROR(EINVAL) if opts cannot be parsed, the error code issued by av_opt_set() if a key/value pair cannot be set

## av_opt_set_from_string()

int av_opt_set_from_string | ( | void * | ctx,
|  | const char * | opts,
|  | const char *const * | shorthand,
|  | const char * | key_val_sep,
|  | const char * | pairs_sep )

Parse the key-value pairs list in opts.

For each key=value pair found, set the value of the corresponding option in ctx.

Parameters

  ctx | the AVClass object to set options on
  opts | the options string, key-value pairs separated by a delimiter
  shorthand | a NULL-terminated array of options names for shorthand notation: if the first field in opts has no key part, the key is taken from the first element of shorthand; then again for the second, etc., until either opts is finished, shorthand is finished or a named option is found; after that, all options must be named
  key_val_sep | a 0-terminated list of characters used to separate key from value, for example '='
  pairs_sep | a 0-terminated list of characters used to separate two pairs from each other, for example ':' or ','

Returns
  the number of successfully set key=value pairs, or a negative value corresponding to an AVERROR code in case of error: AVERROR(EINVAL) if opts cannot be parsed, the error code issued by av_set_string3() if a key/value pair cannot be set

Options names must use only the following characters: a-z A-Z 0-9 - . / _ Separators must use characters distinct from option names and from each other.

## av_opt_set_dict()

int av_opt_set_dict | ( | void * | obj,
|  | struct AVDictionary ** | options )

Set all the options from a given dictionary on an object.

Parameters

  obj | a struct whose first element is a pointer to AVClass
  options | options to process. This dictionary will be freed and replaced by a new one containing all options not found in obj. Of course this new dictionary needs to be freed by caller with av_dict_free().

Returns
  0 on success, a negative AVERROR if some option was found in obj, but could not be set.

See also
  av_dict_copy()

Examples
  qsv_transcode.c.

Referenced by dynamic_set_parameter().

## av_opt_set_dict2()

int av_opt_set_dict2 | ( | void * | obj,
|  | struct AVDictionary ** | options,
|  | int | search_flags )

Set all the options from a given dictionary on an object.

Parameters

  obj | a struct whose first element is a pointer to AVClass
  options | options to process. This dictionary will be freed and replaced by a new one containing all options not found in obj. Of course this new dictionary needs to be freed by caller with av_dict_free().
  search_flags | A combination of AV_OPT_SEARCH_*.

Returns
  0 on success, a negative AVERROR if some option was found in obj, but could not be set.

See also
  av_dict_copy()

## av_opt_copy()

int av_opt_copy | ( | void * | dest,
|  | const void * | src )

Copy options from src object into dest object.

The underlying AVClass of both src and dest must coincide. The guarantee below does not apply if this is not fulfilled.

Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object. Original memory allocated for such options is freed unless both src and dest options points to the same memory.

Even on error it is guaranteed that allocated options from src and dest no longer alias each other afterwards; in particular calling av_opt_free() on both src and dest is safe afterwards if dest has been memdup'ed from src.

Parameters

  dest | Object to copy from
  src | Object to copy into

Returns
  0 on success, negative on error