opt.c File Reference

AVOptions. More...

#include "avutil.h"
#include "avstring.h"
#include "common.h"
#include "opt.h"
#include "eval.h"
#include "dict.h"
#include "log.h"
#include "parseutils.h"
#include "pixdesc.h"
#include "mathematics.h"
#include "samplefmt.h"
#include <float.h>
Include dependency graph for opt.c:

Go to the source code of this file.

Macros

#define DEFAULT_NUMVAL(opt)
 
#define OPT_EVAL_NUMBER(name, opttype, vartype)
 
#define WHITESPACES   " \n\t"
 

Functions

const AVOptionav_find_opt (void *v, const char *name, const char *unit, int mask, int flags)
 Look for an option in obj. More...
 
const AVOptionav_next_option (void *obj, const AVOption *last)
 
const AVOptionav_opt_next (void *obj, const AVOption *last)
 Iterate over all AVOptions belonging to obj. More...
 
static int read_number (const AVOption *o, void *dst, double *num, int *den, int64_t *intnum)
 
static int write_number (void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum)
 
static int hexchar2int (char c)
 
static int set_string_binary (void *obj, const AVOption *o, const char *val, uint8_t **dst)
 
static int set_string (void *obj, const AVOption *o, const char *val, uint8_t **dst)
 
static int set_string_number (void *obj, void *target_obj, const AVOption *o, const char *val, void *dst)
 
int av_set_string3 (void *obj, const char *name, const char *val, int alloc, const AVOption **o_out)
 Set the field of obj with the given name to value. More...
 
int av_opt_set (void *obj, const char *name, const char *val, int search_flags)
 
static int set_number (void *obj, const char *name, double num, int den, int64_t intnum, int search_flags)
 
const AVOptionav_set_double (void *obj, const char *name, double n)
 
const AVOptionav_set_q (void *obj, const char *name, AVRational n)
 
const AVOptionav_set_int (void *obj, const char *name, int64_t n)
 
int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags)
 
int av_opt_set_double (void *obj, const char *name, double val, int search_flags)
 
int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags)
 
int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int len, int search_flags)
 
int av_opt_set_image_size (void *obj, const char *name, int w, int h, int search_flags)
 
int av_opt_set_video_rate (void *obj, const char *name, AVRational val, int search_flags)
 
static int set_format (void *obj, const char *name, int fmt, int search_flags, enum AVOptionType type, const char *desc, int nb_fmts)
 
int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags)
 
int av_opt_set_sample_fmt (void *obj, const char *name, enum AVSampleFormat fmt, int search_flags)
 
const char * av_get_string (void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len)
 
int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val)
 
static int get_number (void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum, int search_flags)
 
double av_get_double (void *obj, const char *name, const AVOption **o_out)
 
AVRational av_get_q (void *obj, const char *name, const AVOption **o_out)
 
int64_t av_get_int (void *obj, const char *name, const AVOption **o_out)
 
int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val)
 
int av_opt_get_double (void *obj, const char *name, int search_flags, double *out_val)
 
int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val)
 
int av_opt_get_image_size (void *obj, const char *name, int search_flags, int *w_out, int *h_out)
 
int av_opt_get_video_rate (void *obj, const char *name, int search_flags, AVRational *out_val)
 
static int get_format (void *obj, const char *name, int search_flags, int *out_fmt, enum AVOptionType type, const char *desc)
 
int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt)
 
int av_opt_get_sample_fmt (void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt)
 
int av_opt_flag_is_set (void *obj, const char *field_name, const char *flag_name)
 Check whether a particular flag is set in a flags field. More...
 
static void log_value (void *av_log_obj, int level, double d)
 
static void opt_list (void *obj, void *av_log_obj, const char *unit, int req_flags, int rej_flags)
 
int av_opt_show2 (void *obj, void *av_log_obj, int req_flags, int rej_flags)
 Show the obj options. More...
 
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)
 
static int parse_key_value_pair (void *ctx, const char **buf, const char *key_val_sep, const char *pairs_sep)
 Store the value in the field in ctx that is named like key. More...
 
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. More...
 
static int is_key_char (char c)
 
static int get_key (const char **ropts, const char *delim, char **rkey)
 Read a key from a string. 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...
 
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. More...
 
void av_opt_free (void *obj)
 Free all string and binary options in obj. More...
 
int av_opt_set_dict (void *obj, AVDictionary **options)
 Set all the options from a given dictionary on an object. 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...
 
voidav_opt_child_next (void *obj, void *prev)
 Iterate over AVOptions-enabled children of obj. More...
 
const AVClassav_opt_child_class_next (const AVClass *parent, const AVClass *prev)
 Iterate over potential AVOptions-enabled children of parent. More...
 
voidav_opt_ptr (const AVClass *class, void *obj, const char *name)
 Gets a pointer to the requested field in a struct. More...
 
int av_opt_query_ranges (AVOptionRanges **ranges_arg, void *obj, const char *key, int flags)
 Get a list of allowed ranges for the given option. More...
 
int av_opt_query_ranges_default (AVOptionRanges **ranges_arg, void *obj, const char *key, int flags)
 Get a default list of allowed ranges for the given option. More...
 
void av_opt_freep_ranges (AVOptionRanges **rangesp)
 Free an AVOptionRanges struct and set it to NULL. More...
 

Variables

static const double const_values []
 
static const char *const const_names []
 

Detailed Description

AVOptions.

Author
Michael Niedermayer micha.nosp@m.elni.nosp@m.@gmx..nosp@m.at

Definition in file opt.c.

Macro Definition Documentation

#define DEFAULT_NUMVAL (   opt)
Value:
((opt->type == AV_OPT_TYPE_INT64 || \
opt->type == AV_OPT_TYPE_CONST || \
opt->type == AV_OPT_TYPE_FLAGS || \
opt->type == AV_OPT_TYPE_INT) ? \
opt->default_val.i64 : opt->default_val.dbl)

Definition at line 176 of file opt.c.

Referenced by set_string_number().

#define OPT_EVAL_NUMBER (   name,
  opttype,
  vartype 
)
Value:
int av_opt_eval_ ## name(void *obj, const AVOption *o, const char *val, vartype *name ## _out)\
{\
if (!o || o->type != opttype)\
return AVERROR(EINVAL);\
return set_string_number(obj, obj, o, val, name ## _out);\
}
const char * name
Definition: avisynth_c.h:675
AVOption.
Definition: opt.h:251
initialize output if(nPeaks >3)%at least 3 peaks in spectrum for trying to find f0 nf0peaks
static int set_string_number(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst)
Definition: opt.c:182
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Buffer references ownership and permissions
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame This method is called when a frame is wanted on an output For an it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return it should return

Definition at line 340 of file opt.c.

#define WHITESPACES   " \n\t"

Definition at line 1082 of file opt.c.

Referenced by get_key().

Function Documentation

static int get_format ( void obj,
const char *  name,
int  search_flags,
int *  out_fmt,
enum AVOptionType  type,
const char *  desc 
)
static

Definition at line 761 of file opt.c.

Referenced by av_opt_get_pixel_fmt(), and av_opt_get_sample_fmt().

static int get_key ( const char **  ropts,
const char *  delim,
char **  rkey 
)
static

Read a key from a string.

The key consists of is_key_char characters and must be terminated by a character from the delim string; spaces are ignored.

Returns
0 for success (even with ellipsis), <0 for failure

Definition at line 1099 of file opt.c.

Referenced by av_opt_get_key_value().

static int get_number ( void obj,
const char *  name,
const AVOption **  o_out,
double *  num,
int *  den,
int64_t *  intnum,
int  search_flags 
)
static
static int hexchar2int ( char  c)
static

Definition at line 133 of file opt.c.

Referenced by set_string_binary().

static int is_key_char ( char  c)
static

Definition at line 1084 of file opt.c.

Referenced by get_key().

static void log_value ( void av_log_obj,
int  level,
double  d 
)
static

Definition at line 802 of file opt.c.

Referenced by opt_list().

static void opt_list ( void obj,
void av_log_obj,
const char *  unit,
int  req_flags,
int  rej_flags 
)
static

Definition at line 821 of file opt.c.

Referenced by av_opt_show2().

static int parse_key_value_pair ( void ctx,
const char **  buf,
const char *  key_val_sep,
const char *  pairs_sep 
)
static

Store the value in the field in ctx that is named like key.

ctx must be an AVClass context, storing is done using AVOptions.

Parameters
bufthe string to parse, buf will be updated to point at the separator just after the parsed key/value pair
key_val_sepa 0-terminated list of characters used to separate key from value
pairs_sepa 0-terminated list of characters used to separate two pairs from each other
Returns
0 if the key/value pair has been successfully parsed and set, or a negative value corresponding to an AVERROR code in case of error: AVERROR(EINVAL) if the key/value pair cannot be parsed, the error code issued by av_opt_set() if the key/value pair cannot be set

Definition at line 1028 of file opt.c.

Referenced by av_set_options_string().

static int read_number ( const AVOption o,
void dst,
double *  num,
int *  den,
int64_t *  intnum 
)
static

Definition at line 73 of file opt.c.

Referenced by get_number(), and set_string_number().

static int set_format ( void obj,
const char *  name,
int  fmt,
int  search_flags,
enum AVOptionType  type,
const char *  desc,
int  nb_fmts 
)
static

Definition at line 478 of file opt.c.

Referenced by av_opt_set_pixel_fmt(), av_opt_set_sample_fmt(), and dshow_cycle_pins().

static int set_number ( void obj,
const char *  name,
double  num,
int  den,
int64_t  intnum,
int  search_flags 
)
static
static int set_string ( void obj,
const AVOption o,
const char *  val,
uint8_t **  dst 
)
static

Definition at line 169 of file opt.c.

Referenced by av_opt_set().

static int set_string_binary ( void obj,
const AVOption o,
const char *  val,
uint8_t **  dst 
)
static

Definition at line 140 of file opt.c.

Referenced by av_opt_set().

static int set_string_number ( void obj,
void target_obj,
const AVOption o,
const char *  val,
void dst 
)
static

Definition at line 182 of file opt.c.

Referenced by av_opt_set().

static int write_number ( void obj,
const AVOption o,
void dst,
double  num,
int  den,
int64_t  intnum 
)
static

Definition at line 92 of file opt.c.

Referenced by set_number(), and set_string_number().

Variable Documentation

const char* const const_names[]
static
Initial value:
= {
"PI",
"E",
"QP2LAMBDA",
0
}

Definition at line 126 of file opt.c.

Referenced by config(), ff_rate_control_init(), and set_string_number().

const double const_values[]
static
Initial value:
= {
M_E,
0
}
#define M_E
Definition: ratecontrol.c:37
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
Definition: avutil.h:169
#define M_PI
Definition: mathematics.h:46

Definition at line 119 of file opt.c.

Referenced by config(), get_qscale(), and set_string_number().