#include "avcodec.h"
#include "eval.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
Go to the source code of this file.
Data Structures | |
struct | Parser |
struct | ff_expr_s |
Defines | |
#define | NAN 0.0/0.0 |
#define | VARS 10 |
Functions | |
static double | av_strtod (const char *name, char **tail) |
strtod() function extended with 'k', 'M', 'G', 'ki', 'Mi', 'Gi' and 'B' postfixes. | |
static int | strmatch (const char *s, const char *prefix) |
static double | eval_expr (Parser *p, AVEvalExpr *e) |
static AVEvalExpr * | parse_expr (Parser *p) |
void | ff_eval_free (AVEvalExpr *e) |
static AVEvalExpr * | parse_primary (Parser *p) |
static AVEvalExpr * | new_eval_expr (int type, int value, AVEvalExpr *p0, AVEvalExpr *p1) |
static AVEvalExpr * | parse_pow (Parser *p, int *sign) |
static AVEvalExpr * | parse_factor (Parser *p) |
static AVEvalExpr * | parse_term (Parser *p) |
static AVEvalExpr * | parse_subexpr (Parser *p) |
static int | verify_expr (AVEvalExpr *e) |
AVEvalExpr * | ff_parse (const char *s, const char *const *const_name, double(**func1)(void *, double), const char **func1_name, double(**func2)(void *, double, double), const char **func2_name, const char **error) |
Parses a expression. | |
double | ff_parse_eval (AVEvalExpr *e, const double *const_value, void *opaque) |
Evaluates a previously parsed expression. | |
double | ff_eval2 (const char *s, const double *const_value, const char *const *const_name, double(**func1)(void *, double), const char **func1_name, double(**func2)(void *, double, double), const char **func2_name, void *opaque, const char **error) |
Parses and evaluates an expression. | |
Variables | |
static const int8_t | si_prefixes ['z'- 'E'+1] |
see http://joe.hotchkiss.com/programming/eval/eval.html
Definition in file eval.c.
#define NAN 0.0/0.0 |
#define VARS 10 |
static double av_strtod | ( | const char * | name, | |
char ** | tail | |||
) | [static] |
strtod() function extended with 'k', 'M', 'G', 'ki', 'Mi', 'Gi' and 'B' postfixes.
This allows using f.e. kB, MiB, G and B as a postfix. This function assumes that the unit of numbers is bits not bytes.
Definition at line 89 of file eval.c.
Referenced by parse_primary().
static double eval_expr | ( | Parser * | p, | |
AVEvalExpr * | e | |||
) | [static] |
double ff_eval2 | ( | const char * | s, | |
const double * | const_value, | |||
const char *const * | const_name, | |||
double(**)(void *, double) | func1, | |||
const char ** | func1_name, | |||
double(**)(void *, double, double) | func2, | |||
const 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.
Referenced by av_set_string3().
void ff_eval_free | ( | AVEvalExpr * | e | ) |
Definition at line 187 of file eval.c.
Referenced by ff_eval2(), ff_eval_free(), ff_parse(), ff_rate_control_uninit(), parse_primary(), and Release().
AVEvalExpr* ff_parse | ( | const char * | s, | |
const char *const * | const_name, | |||
double(**)(void *, double) | func1, | |||
const char ** | func1_name, | |||
double(**)(void *, double, double) | func2, | |||
const 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.
Referenced by Configure(), ff_eval2(), and ff_rate_control_init().
double ff_parse_eval | ( | AVEvalExpr * | e, | |
const 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.
Referenced by ff_eval2(), get_qscale(), and Process().
static AVEvalExpr* new_eval_expr | ( | int | type, | |
int | value, | |||
AVEvalExpr * | p0, | |||
AVEvalExpr * | p1 | |||
) | [static] |
Definition at line 300 of file eval.c.
Referenced by parse_expr(), parse_factor(), parse_subexpr(), and parse_term().
static AVEvalExpr * parse_expr | ( | Parser * | p | ) | [static] |
static AVEvalExpr* parse_factor | ( | Parser * | p | ) | [static] |
static AVEvalExpr* parse_pow | ( | Parser * | p, | |
int * | sign | |||
) | [static] |
static AVEvalExpr* parse_primary | ( | Parser * | p | ) | [static] |
static AVEvalExpr* parse_subexpr | ( | Parser * | p | ) | [static] |
static AVEvalExpr* parse_term | ( | Parser * | p | ) | [static] |
static int strmatch | ( | const char * | s, | |
const char * | prefix | |||
) | [static] |
static int verify_expr | ( | AVEvalExpr * | e | ) | [static] |
const int8_t si_prefixes['z'- 'E'+1] [static] |
Initial value:
{ ['y'-'E']= -24, ['z'-'E']= -21, ['a'-'E']= -18, ['f'-'E']= -15, ['p'-'E']= -12, ['n'-'E']= - 9, ['u'-'E']= - 6, ['m'-'E']= - 3, ['c'-'E']= - 2, ['d'-'E']= - 1, ['h'-'E']= 2, ['k'-'E']= 3, ['K'-'E']= 3, ['M'-'E']= 6, ['G'-'E']= 9, ['T'-'E']= 12, ['P'-'E']= 15, ['E'-'E']= 18, ['Z'-'E']= 21, ['Y'-'E']= 24, }
Definition at line 62 of file eval.c.
Referenced by av_strtod().