40 if (!last &&
class->option &&
class->option[0].name)
42 if (last && last[1].
name)
51 *intnum = *(
unsigned int *)dst;
54 *intnum = *(
int *)dst;
57 *intnum = *(int64_t *)dst;
63 *num = *(
double *)dst;
76 (o->
max * den < num * intnum || o->
min * den > num * intnum)) {
78 num * intnum / den, o->
name);
85 *(
int *)dst =
llrint(num / den) * intnum;
88 *(int64_t *)dst =
llrint(num / den) * intnum;
91 *(
float *)dst = num * intnum / den;
94 *(
double *)dst = num * intnum / den;
124 if (c >=
'0' && c <=
'9')
126 if (c >=
'a' && c <=
'f')
128 if (c >=
'A' && c <=
'F')
135 int *lendst = (
int *)(dst + 1);
137 int len = strlen(val);
152 if (a < 0 || b < 0) {
156 *ptr++ = (a << 4) | b;
168 return *dst ? 0 :
AVERROR(ENOMEM);
171 #define DEFAULT_NUMVAL(opt) ((opt->type == AV_OPT_TYPE_INT64 || \ 172 opt->type == AV_OPT_TYPE_CONST || \ 173 opt->type == AV_OPT_TYPE_FLAGS || \ 174 opt->type == AV_OPT_TYPE_INT) \ 175 ? opt->default_val.i64 \ 176 : opt->default_val.dbl) 180 int ret = 0, notfirst = 0;
189 if (*val ==
'+' || *val ==
'-') {
196 for (; i <
sizeof(buf) - 1 && val[i] && val[i] !=
'+' && val[i] !=
'-'; i++)
204 else if (!strcmp(buf,
"default"))
206 else if (!strcmp(buf,
"max"))
208 else if (!strcmp(buf,
"min"))
210 else if (!strcmp(buf,
"none"))
212 else if (!strcmp(buf,
"all"))
215 int res =
av_expr_parse_and_eval(&d, buf,
const_names,
const_values,
NULL,
NULL,
NULL,
NULL,
NULL, 0, obj);
225 d = intnum | (int64_t)d;
227 d = intnum & ~(int64_t)d;
231 d = notfirst * num * intnum / den + d;
233 d = notfirst * num * intnum / den - d;
249 void *dst, *target_obj;
251 if (!o || !target_obj)
275 #define OPT_EVAL_NUMBER(name, opttype, vartype) \ 276 int av_opt_eval_ ## name(void *obj, const AVOption *o, \ 277 const char *val, vartype *name ## _out) \ 279 if (!o || o->type != opttype || o->flags & AV_OPT_FLAG_READONLY) \ 280 return AVERROR(EINVAL); \ 281 return set_string_number(obj, obj, o, val, name ## _out); \ 291 static
int set_number(
void *obj, const
char *
name,
double num,
int den, int64_t intnum,
294 void *dst, *target_obj;
297 if (!o || !target_obj)
309 return set_number(obj, name, 1, 1, val, search_flags);
314 return set_number(obj, name, val, 1, 1, search_flags);
330 if (!o || !target_obj)
341 lendst = (
int *)(dst + 1);
346 memcpy(ptr, val, len);
358 if (!o || !target_obj)
372 void *dst, *target_obj;
377 if (!o || !target_obj)
385 ret = snprintf(buf,
sizeof(buf),
"0x%08X", *(
int *)dst);
388 ret = snprintf(buf,
sizeof(buf),
"%d", *(
int *)dst);
391 ret = snprintf(buf,
sizeof(buf),
"%" PRId64, *(int64_t *)dst);
394 ret = snprintf(buf,
sizeof(buf),
"%f", *(
float *)dst);
397 ret = snprintf(buf,
sizeof(buf),
"%f", *(
double *)dst);
400 ret = snprintf(buf,
sizeof(buf),
"%d/%d", ((
AVRational *)dst)->num,
408 return *out_val ? 0 :
AVERROR(ENOMEM);
411 if ((uint64_t)len * 2 + 1 > INT_MAX)
413 if (!(*out_val =
av_malloc(len * 2 + 1)))
416 for (i = 0; i <
len; i++)
417 snprintf(*out_val + i * 2, 3,
"%02X", bin[i]);
423 if (ret >=
sizeof(buf))
426 return *out_val ? 0 :
AVERROR(ENOMEM);
429 static int get_number(
void *obj,
const char *
name,
double *num,
int *den, int64_t *intnum,
432 void *dst, *target_obj;
434 if (!o || !target_obj)
453 if ((ret =
get_number(obj, name, &num, &den, &intnum, search_flags)) < 0)
455 *out_val = num * intnum / den;
465 if ((ret =
get_number(obj, name, &num, &den, &intnum, search_flags)) < 0)
467 *out_val = num * intnum / den;
477 if ((ret =
get_number(obj, name, &num, &den, &intnum, search_flags)) < 0)
480 if (num == 1.0 && (
int)intnum == intnum)
483 *out_val =
av_d2q(num * intnum / den, 1 << 24);
493 if (!o || !target_obj)
517 static void opt_list(
void *obj,
void *av_log_obj,
const char *unit,
518 int req_flags,
int rej_flags)
523 if (!(opt->
flags & req_flags) || (opt->
flags & rej_flags))
583 opt_list(obj, av_log_obj, opt->
unit, req_flags, rej_flags);
587 int av_opt_show2(
void *obj,
void *av_log_obj,
int req_flags,
int rej_flags)
662 const char *key_val_sep,
const char *pairs_sep)
671 if (*key && strspn(*buf, key_val_sep)) {
679 av_log(ctx,
AV_LOG_ERROR,
"Missing key or no key/value separator found after key '%s'\n", key);
696 const char *key_val_sep,
const char *pairs_sep)
757 int opt_flags,
int search_flags)
763 int opt_flags,
int search_flags,
void **target_obj)
780 if (o =
av_opt_find2(child, name, unit, opt_flags, search_flags, target_obj))
786 if (!strcmp(o->
name, name) && (o->
flags & opt_flags) == opt_flags &&
788 (unit && o->
unit && !strcmp(o->
unit, unit)))) {
823 return sizeof(int64_t);
825 return sizeof(double);
827 return sizeof(float);
833 return sizeof(
uint8_t *) +
sizeof(
int);
848 if (!c || c != *(
AVClass **)dst)
859 if (*field_src8 && !*field_dst8)
862 int len = *(
int *)(field_src8 + 1);
863 if (*field_dst8 != *field_src8)
871 memcpy(*field_dst8, *field_src8, len);
875 *(
int *)(field_dst8 + 1) =
len;
883 memcpy(field_dst, field_src, size);
int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int av_opt_set_q(void *obj, const char *name, AVRational val, int search_flags)
#define AV_OPT_FLAG_EXPORT
The option is intended for exporting values to the caller.
#define AV_OPT_FLAG_SUBTITLE_PARAM
void * av_opt_child_next(void *obj, void *prev)
Iterate over AVOptions-enabled children of obj.
const AVClass * av_opt_child_class_next(const AVClass *parent, const AVClass *prev)
Iterate over potential AVOptions-enabled children of parent.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
static int opt_size(enum AVOptionType type)
#define AV_OPT_FLAG_AUDIO_PARAM
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.
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int search_flags)
int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_val)
static void opt_list(void *obj, void *av_log_obj, const char *unit, int req_flags, int rej_flags)
int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int av_opt_copy(void *dst, const void *src)
Copy options from src object into dest object.
const char * help
short English help text
static int read_number(const AVOption *o, const void *dst, double *num, int *den, int64_t *intnum)
const struct AVOption * option
a pointer to the first option specified in the class if any or NULL
int av_opt_set_double(void *obj, const char *name, double val, int search_flags)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static const double const_values[]
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
const OptionDef options[]
void *(* child_next)(void *obj, void *prev)
Return next AVOptions-enabled child or NULL.
static int hexchar2int(char c)
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
double max
maximum valid value for the option
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
const AVOption * av_opt_next(const void *obj, const AVOption *last)
Iterate over all AVOptions belonging to obj.
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
static const char *const const_names[]
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.
static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **dst)
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
const char * unit
The logical unit to which the option belongs.
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.
double min
minimum valid value for the option
static int set_string_number(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst)
static int set_string_binary(void *obj, const AVOption *o, const char *val, uint8_t **dst)
const struct AVClass *(* child_class_next)(const struct AVClass *prev)
Return an AVClass corresponding to the next potential AVOptions-enabled child.
offset must point to a pointer immediately followed by an int for the length
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
#define AV_LOG_INFO
Standard information.
int offset
The offset relative to the context structure where the option value is stored.
int av_opt_set_dict(void *obj, AVDictionary **options)
char * av_strdup(const char *s)
Duplicate the string s.
static int set_number(void *obj, const char *name, double num, int den, int64_t intnum, int search_flags)
int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
Show the obj options.
#define AV_OPT_FLAG_VIDEO_PARAM
#define OPT_EVAL_NUMBER(name, opttype, vartype)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Describe the class of an AVClass context structure.
rational number numerator/denominator
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
union AVOption::@170 default_val
the default value for scalar options
void av_opt_free(void *obj)
Free all allocated objects in obj.
common internal and external API header
#define DEFAULT_NUMVAL(opt)
int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val)
#define AV_OPT_SEARCH_FAKE_OBJ
The obj passed to av_opt_find() is fake – only a double pointer to AVClass instead of a required poi...
static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum)
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
#define AVERROR_OPTION_NOT_FOUND
Option not found.
#define AV_OPT_FLAG_READONLY
The option may not be set through the AVOptions API, only read.
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
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.
#define AV_DICT_IGNORE_SUFFIX
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.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
simple arithmetic expression evaluator
static int get_number(void *obj, const char *name, double *num, int *den, int64_t *intnum, int search_flags)