Go to the source code of this file.
Typedefs | |
| typedef ff_expr_s | AVEvalExpr |
Functions | |
| double | ff_eval (char *s, double *const_value, const char **const_name, double(**func1)(void *, double), const char **func1_name, double(**func2)(void *, double, double), char **func2_name, void *opaque) |
| double | ff_eval2 (const char *s, double *const_value, const char **const_name, double(**func1)(void *, double), const char **func1_name, double(**func2)(void *, double, double), char **func2_name, void *opaque, const char **error) |
| AVEvalExpr * | ff_parse (const char *s, const char **const_name, double(**func1)(void *, double), const char **func1_name, double(**func2)(void *, double, double), char **func2_name, const char **error) |
| double | ff_parse_eval (AVEvalExpr *e, double *const_value, void *opaque) |
| void | ff_eval_free (AVEvalExpr *e) |
Definition in file eval.h.
| typedef struct ff_expr_s AVEvalExpr |
| double ff_eval | ( | char * | s, | |
| double * | const_value, | |||
| const char ** | const_name, | |||
| double(**)(void *, double) | func1, | |||
| const char ** | func1_name, | |||
| double(**)(void *, double, double) | func2, | |||
| char ** | func2_name, | |||
| void * | opaque | |||
| ) |
| double ff_eval2 | ( | const char * | s, | |
| double * | const_value, | |||
| const char ** | const_name, | |||
| double(**)(void *, double) | func1, | |||
| const char ** | func1_name, | |||
| double(**)(void *, double, double) | func2, | |||
| char ** | func2_name, | |||
| void * | opaque, | |||
| const char ** | error | |||
| ) |
Parses and evaluates an expression. Note, this is significantly slower than ff_parse_eval()
| s | expression as a zero terminated string for example "1+2^3+5*5+sin(2/3)" | |
| func1 | NULL terminated array of function pointers for functions which take 1 argument | |
| func2 | NULL terminated array of function pointers for functions which take 2 arguments | |
| const_name | NULL terminated array of zero terminated strings of constant identifers for example {"PI", "E", 0} | |
| func1_name | NULL terminated array of zero terminated strings of func1 identifers | |
| func2_name | NULL terminated array of zero terminated strings of func2 identifers | |
| error | pointer to a char* which is set to an error message if something goes wrong | |
| const_value | a zero terminated array of values for the identifers from const_name | |
| opaque | a pointer which will be passed to all functions from func1 and func2 |
Definition at line 415 of file eval.c.
References ff_eval_free(), ff_parse(), ff_parse_eval(), and NAN.
Referenced by av_set_string2().
00418 { 00419 AVEvalExpr * e = ff_parse(s, const_name, func1, func1_name, func2, func2_name, error); 00420 double d; 00421 if (!e) return NAN; 00422 d = ff_parse_eval(e, const_value, opaque); 00423 ff_eval_free(e); 00424 return d; 00425 }
| void ff_eval_free | ( | AVEvalExpr * | e | ) |
Definition at line 187 of file eval.c.
References av_freep(), ff_eval_free(), and ff_expr_s::param.
Referenced by ff_eval2(), ff_eval_free(), ff_parse(), ff_rate_control_uninit(), and Release().
00187 { 00188 if (!e) return; 00189 ff_eval_free(e->param[0]); 00190 ff_eval_free(e->param[1]); 00191 av_freep(&e); 00192 }
| AVEvalExpr* ff_parse | ( | const char * | s, | |
| const char ** | const_name, | |||
| double(**)(void *, double) | func1, | |||
| const char ** | func1_name, | |||
| double(**)(void *, double, double) | func2, | |||
| char ** | func2_name, | |||
| const char ** | error | |||
| ) |
Parses a expression.
| s | expression as a zero terminated string for example "1+2^3+5*5+sin(2/3)" | |
| func1 | NULL terminated array of function pointers for functions which take 1 argument | |
| func2 | NULL terminated array of function pointers for functions which take 2 arguments | |
| const_name | NULL terminated array of zero terminated strings of constant identifers for example {"PI", "E", 0} | |
| func1_name | NULL terminated array of zero terminated strings of func1 identifers | |
| func2_name | NULL terminated array of zero terminated strings of func2 identifers | |
| error | pointer to a char* which is set to an error message if something goes wrong |
Definition at line 378 of file eval.c.
References Parser::const_name, Parser::error, ff_eval_free(), Parser::func1, Parser::func1_name, Parser::func2, Parser::func2_name, NULL, parse_expr(), Parser::s, Parser::stack_index, and verify_expr().
Referenced by Configure(), ff_eval2(), and ff_rate_control_init().
00381 { 00382 Parser p; 00383 AVEvalExpr * e; 00384 char w[strlen(s) + 1], * wp = w; 00385 00386 while (*s) 00387 if (!isspace(*s++)) *wp++ = s[-1]; 00388 *wp++ = 0; 00389 00390 p.stack_index=100; 00391 p.s= w; 00392 p.const_name = const_name; 00393 p.func1 = func1; 00394 p.func1_name = func1_name; 00395 p.func2 = func2; 00396 p.func2_name = func2_name; 00397 p.error= error; 00398 00399 e = parse_expr(&p); 00400 if (!verify_expr(e)) { 00401 ff_eval_free(e); 00402 return NULL; 00403 } 00404 return e; 00405 }
| double ff_parse_eval | ( | AVEvalExpr * | e, | |
| double * | const_value, | |||
| void * | opaque | |||
| ) |
Evaluates a previously parsed expression.
| const_value | a zero terminated array of values for the identifers from ff_parse const_name | |
| opaque | a pointer which will be passed to all functions from func1 and func2 |
Definition at line 407 of file eval.c.
References Parser::const_value, eval_expr(), and Parser::opaque.
Referenced by ff_eval2(), get_qscale(), and Process().
00407 { 00408 Parser p; 00409 00410 p.const_value= const_value; 00411 p.opaque = opaque; 00412 return eval_expr(&p, e); 00413 }
1.5.1