comparison eval.c @ 1057:bb5de8a59da8 libavcodec

* static,const,compiler warning cleanup
author kabi
date Mon, 10 Feb 2003 09:35:32 +0000
parents 79c43f519d02
children 1e39f273ecd6
comparison
equal deleted inserted replaced
1056:eb403f8158eb 1057:bb5de8a59da8
20 */ 20 */
21 21
22 /* 22 /*
23 * see http://joe.hotchkiss.com/programming/eval/eval.html 23 * see http://joe.hotchkiss.com/programming/eval/eval.html
24 */ 24 */
25
26 #include "avcodec.h"
27 #include "mpegvideo.h"
25 28
26 #include <stdio.h> 29 #include <stdio.h>
27 #include <stdlib.h> 30 #include <stdlib.h>
28 #include <string.h> 31 #include <string.h>
29 #include <math.h> 32 #include <math.h>
41 typedef struct Parser{ 44 typedef struct Parser{
42 double stack[STACK_SIZE]; 45 double stack[STACK_SIZE];
43 int stack_index; 46 int stack_index;
44 char *s; 47 char *s;
45 double *const_value; 48 double *const_value;
46 char **const_name; // NULL terminated 49 const char **const_name; // NULL terminated
47 double (**func1)(void *, double a); // NULL terminated 50 double (**func1)(void *, double a); // NULL terminated
48 char **func1_name; // NULL terminated 51 const char **func1_name; // NULL terminated
49 double (**func2)(void *, double a, double b); // NULL terminated 52 double (**func2)(void *, double a, double b); // NULL terminated
50 char **func2_name; // NULL terminated 53 char **func2_name; // NULL terminated
51 void *opaque; 54 void *opaque;
52 } Parser; 55 } Parser;
53 56
69 } 72 }
70 //printf("pop\n"); fflush(stdout); 73 //printf("pop\n"); fflush(stdout);
71 return p->stack[ --p->stack_index ]; 74 return p->stack[ --p->stack_index ];
72 } 75 }
73 76
74 static int strmatch(char *s, char *prefix){ 77 static int strmatch(const char *s, const char *prefix){
75 int i; 78 int i;
76 for(i=0; prefix[i]; i++){ 79 for(i=0; prefix[i]; i++){
77 if(prefix[i] != s[i]) return 0; 80 if(prefix[i] != s[i]) return 0;
78 } 81 }
79 return 1; 82 return 1;
124 else if( strmatch(next, "tan" ) ) d= tan(d); 127 else if( strmatch(next, "tan" ) ) d= tan(d);
125 else if( strmatch(next, "exp" ) ) d= exp(d); 128 else if( strmatch(next, "exp" ) ) d= exp(d);
126 else if( strmatch(next, "log" ) ) d= log(d); 129 else if( strmatch(next, "log" ) ) d= log(d);
127 else if( strmatch(next, "squish") ) d= 1/(1+exp(4*d)); 130 else if( strmatch(next, "squish") ) d= 1/(1+exp(4*d));
128 else if( strmatch(next, "gauss" ) ) d= exp(-d*d/2)/sqrt(2*M_PI); 131 else if( strmatch(next, "gauss" ) ) d= exp(-d*d/2)/sqrt(2*M_PI);
129 else if( strmatch(next, "abs" ) ) d= abs(d); 132 else if( strmatch(next, "abs" ) ) d= fabs(d);
130 else if( strmatch(next, "max" ) ) d= d > d2 ? d : d2; 133 else if( strmatch(next, "max" ) ) d= d > d2 ? d : d2;
131 else if( strmatch(next, "min" ) ) d= d < d2 ? d : d2; 134 else if( strmatch(next, "min" ) ) d= d < d2 ? d : d2;
132 else if( strmatch(next, "gt" ) ) d= d > d2 ? 1.0 : 0.0; 135 else if( strmatch(next, "gt" ) ) d= d > d2 ? 1.0 : 0.0;
133 else if( strmatch(next, "lt" ) ) d= d > d2 ? 0.0 : 1.0; 136 else if( strmatch(next, "lt" ) ) d= d > d2 ? 0.0 : 1.0;
134 else if( strmatch(next, "eq" ) ) d= d == d2 ? 1.0 : 0.0; 137 else if( strmatch(next, "eq" ) ) d= d == d2 ? 1.0 : 0.0;
226 if(sign) d= -d; 229 if(sign) d= -d;
227 push(p, d + pop(p)); 230 push(p, d + pop(p));
228 } 231 }
229 } 232 }
230 233
231 double ff_eval(char *s, double *const_value, char **const_name, 234 double ff_eval(char *s, double *const_value, const char **const_name,
232 double (**func1)(void *, double), char **func1_name, 235 double (**func1)(void *, double), const char **func1_name,
233 double (**func2)(void *, double, double), char **func2_name, 236 double (**func2)(void *, double, double), char **func2_name,
234 void *opaque){ 237 void *opaque){
235 Parser p; 238 Parser p;
236 239
237 p.stack_index=0; 240 p.stack_index=0;