69 .log_level_offset_offset = offsetof(
Parser, log_offset),
70 .parent_log_context_offset = offsetof(
Parser, log_ctx),
78 [
'y'-
'E']= { 8.271806125530276749e-25, 1e-24, -24 },
79 [
'z'-
'E']= { 8.4703294725430034e-22, 1e-21, -21 },
80 [
'a'-
'E']= { 8.6736173798840355e-19, 1e-18, -18 },
81 [
'f'-
'E']= { 8.8817841970012523e-16, 1e-15, -15 },
82 [
'p'-
'E']= { 9.0949470177292824e-13, 1e-12, -12 },
83 [
'n'-
'E']= { 9.3132257461547852e-10, 1e-9, -9 },
84 [
'u'-
'E']= { 9.5367431640625e-7, 1e-6, -6 },
85 [
'm'-
'E']= { 9.765625e-4, 1e-3, -3 },
86 [
'c'-
'E']= { 9.8431332023036951e-3, 1e-2, -2 },
87 [
'd'-
'E']= { 9.921256574801246e-2, 1e-1, -1 },
88 [
'h'-
'E']= { 1.0159366732596479e2, 1e2, 2 },
89 [
'k'-
'E']= { 1.024e3, 1e3, 3 },
90 [
'K'-
'E']= { 1.024e3, 1e3, 3 },
91 [
'M'-
'E']= { 1.048576e6, 1e6, 6 },
92 [
'G'-
'E']= { 1.073741824e9, 1e9, 9 },
93 [
'T'-
'E']= { 1.099511627776e12, 1e12, 12 },
94 [
'P'-
'E']= { 1.125899906842624e15, 1e15, 15 },
95 [
'E'-
'E']= { 1.152921504606847e18, 1e18, 18 },
96 [
'Z'-
'E']= { 1.1805916207174113e21, 1e21, 21 },
97 [
'Y'-
'E']= { 1.2089258196146292e24, 1e24, 24 },
114 if(numstr[0]==
'0' && (numstr[1]|0x20)==
'x') {
115 d = strtoul(numstr, &next, 16);
117 d =
strtod(numstr, &next);
120 if (next[0] ==
'd' && next[1] ==
'B') {
124 }
else if (*next >=
'E' && *next <=
'z') {
127 if (next[1] ==
'i') {
149#define IS_IDENTIFIER_CHAR(c) ((c) - '0' <= 9U || (c) - 'a' <= 25U || (c) - 'A' <= 25U || (c) == '_')
236 return e->
value * (v0 + (v1 - v0) *
f);
245#define COMPUTE_NEXT_RANDOM() \
246 int idx = av_clip(eval_expr(p, e->param[0]), 0, VARS-1); \
247 FFSFC64 *s = p->prng_state + idx; \
251 r = isnan(p->var[idx]) ? 0 : p->var[idx]; \
252 ff_sfc64_init(s, r, r, r, 12); \
254 r = ff_sfc64_get(s); \
259 return r * (1.0/UINT64_MAX);
274 double t = 1, d = 0, v;
278 double var0 = p->var[
id];
279 for(
i=0;
i<1000;
i++) {
293 double low = -1,
high = -1, v, low_v = -DBL_MAX, high_v = DBL_MAX;
294 double var0 = p->var[0];
296 for(
i=-1;
i<1024;
i++) {
300 p->var[0] = x_max*pow(0.9,
i-255);
301 if (
i&1) p->var[0] *= -1;
302 if (
i&2) p->var[0] += low;
303 else p->var[0] +=
high;
306 if (v<=0 && v>low_v) {
310 if (v>=0 && v<high_v) {
314 if (low>=0 &&
high>=0){
315 for (j=0; j<1000; j++) {
316 p->var[0] = (low+
high)*0.5;
317 if (low == p->var[0] ||
high == p->var[0])
320 if (v<=0) low = p->var[0];
321 if (v>=0)
high= p->var[0];
331 return -low_v<high_v ? low :
high;
339 case e_max:
return e->
value * (d > d2 ? d : d2);
340 case e_min:
return e->
value * (d < d2 ? d : d2);
341 case e_eq:
return e->
value * (d == d2 ? 1.0 : 0.0);
342 case e_gt:
return e->
value * (d > d2 ? 1.0 : 0.0);
343 case e_gte:
return e->
value * (d >= d2 ? 1.0 : 0.0);
344 case e_lt:
return e->
value * (d < d2 ? 1.0 : 0.0);
345 case e_lte:
return e->
value * (d <= d2 ? 1.0 : 0.0);
353 p->prng_state[
index].counter = 0;
385 char *next = p->s, *s0 = p->s;
402 for (
i=0; p->const_names && p->const_names[
i];
i++) {
404 p->s+= strlen(p->const_names[
i]);
421 p->s= strchr(p->s,
'(');
433 if (p->s[0] !=
')') {
454 if (p->s[0] !=
')') {
461 for (
int i = 0;
i<3;
i++)
522 for (
i=0; p->func1_names && p->func1_names[
i];
i++) {
532 for (
i=0; p->func2_names && p->func2_names[
i];
i++) {
569 *sign= (*p->s ==
'+') - (*p->s ==
'-');
581 if (next != p->s && next[0] ==
'd' && next[1] ==
'B') {
591 int sign, sign2, ret;
593 if ((ret =
parse_dB(&e0, p, &sign)) < 0)
598 if ((ret =
parse_dB(&e2, p, &sign2)) < 0) {
610 if (e0) e0->
value *= (sign|1);
622 while (p->s[0]==
'*' || p->s[0]==
'/') {
646 while (*p->s ==
'+' || *p->s ==
'-') {
668 if (p->stack_index <= 0)
674 while (*p->s ==
';') {
738 const char *
const *
func2_names,
double (*
const *funcs2)(
void *,
double,
double),
739 int log_offset,
void *log_ctx)
763 p.log_offset = log_offset;
769 av_log(&p,
AV_LOG_ERROR,
"Invalid chars '%s' at the end of expression '%s'\n", p.s, s0);
786 if (!
r->var || !
r->prng_state) {
802 if (!e || !counter || !
size)
833 .prng_state =
r->prng_state,
842 const char *
const *
func2_names,
double (*
const *funcs2)(
void *,
double,
double),
843 void *opaque,
int log_offset,
void *log_ctx)
static const char *const func2_names[]
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static const struct @105000147377261105311001355164026305374075040210 si_prefixes[]
Convenience header that includes libavutil's core.
#define i(width, name, range_min, range_max)
common internal and external API header
static __device__ float ceil(float a)
static __device__ float fabs(float a)
static __device__ float floor(float a)
static __device__ float trunc(float a)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
static int strmatch(const char *s, const char *prefix)
static AVExpr * make_eval_expr(int type, int value, AVExpr *p0, AVExpr *p1)
int av_expr_count_vars(AVExpr *e, unsigned *counter, int size)
Track the presence of variables and their number of occurrences in a parsed expression.
static int parse_pow(AVExpr **e, Parser *p, int *sign)
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
static int parse_primary(AVExpr **e, Parser *p)
static int parse_term(AVExpr **e, Parser *p)
static int parse_dB(AVExpr **e, Parser *p, int *sign)
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
#define IS_IDENTIFIER_CHAR(c)
static double etime(double v)
static int parse_subexpr(AVExpr **e, Parser *p)
static int parse_expr(AVExpr **e, Parser *p)
static const struct @033145243110221005363036244076252070150076110330 constants[]
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.
static double eval_expr(Parser *p, AVExpr *e)
static int parse_factor(AVExpr **e, Parser *p)
static int verify_expr(AVExpr *e)
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
static const AVClass eval_class
static int expr_count(AVExpr *e, unsigned *counter, int size, int type)
int av_expr_count_func(AVExpr *e, unsigned *counter, int size, int arg)
Track the presence of user provided functions and their number of occurrences in a parsed expression.
#define COMPUTE_NEXT_RANDOM()
simple arithmetic expression evaluator
internal math functions header
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
#define LIBAVUTIL_VERSION_INT
Macro definitions for various function/variable attributes.
const uint8_t ff_reverse[256]
static av_const double hypot(double x, double y)
static av_always_inline av_const double round(double x)
#define FFDIFFSIGN(x, y)
Comparator.
Memory handling functions.
simple Pseudo Random Number Generator
#define FF_ARRAY_ELEMS(a)
double strtod(const char *, char **)
Describe the class of an AVClass context structure.
double(* func1)(void *, double)
double(* func2)(void *, double, double)
const char *const * func2_names
const double * const_values
const char *const * func1_names
double(*const funcs2)(void *, double a, double b)
double(*const funcs1)(void *, double a)
const char *const * const_names
static const double const_values[]
static const char *const const_names[]
int64_t av_gettime(void)
Get the current time in microseconds.
static double(*const funcs1[])(void *, double)
static void eval_expr(AVFilterContext *ctx)
static const char *const func1_names[]