[SCM] libav/experimental: simplify, null pointer, selftest
siretart at users.alioth.debian.org
siretart at users.alioth.debian.org
Sun Jun 30 15:42:43 UTC 2013
The following commit has been merged in the experimental branch:
commit b349fde101d5f5296e70fef6992afcbcfc4ba2c0
Author: Michael Niedermayer <michaelni at gmx.at>
Date: Sat Jan 15 19:05:26 2005 +0000
simplify, null pointer, selftest
Originally committed as revision 3840 to svn://svn.ffmpeg.org/ffmpeg/trunk
diff --git a/libavcodec/eval.c b/libavcodec/eval.c
index aead600..257d969 100644
--- a/libavcodec/eval.c
+++ b/libavcodec/eval.c
@@ -99,7 +99,7 @@ static void evalPrimary(Parser *p){
}
/* named constants */
- for(i=0; p->const_name[i]; i++){
+ for(i=0; p->const_name && p->const_name[i]; i++){
if(strmatch(p->s, p->const_name[i])){
push(p, p->const_value[i]);
p->s+= strlen(p->const_name[i]);
@@ -147,29 +147,25 @@ static void evalPrimary(Parser *p){
// else if( strmatch(next, "l1" ) ) d= 1 + d2*(d - 1);
// else if( strmatch(next, "sq01" ) ) d= (d >= 0.0 && d <=1.0) ? 1.0 : 0.0;
else{
- int error=1;
for(i=0; p->func1_name && p->func1_name[i]; i++){
if(strmatch(next, p->func1_name[i])){
d= p->func1[i](p->opaque, d);
- error=0;
- break;
+ goto push_ret;
}
}
for(i=0; p->func2_name && p->func2_name[i]; i++){
if(strmatch(next, p->func2_name[i])){
d= p->func2[i](p->opaque, d, d2);
- error=0;
- break;
+ goto push_ret;
}
}
- if(error){
- av_log(NULL, AV_LOG_ERROR, "Parser: unknown function in \"%s\"\n", next);
- return;
- }
+ av_log(NULL, AV_LOG_ERROR, "Parser: unknown function in \"%s\"\n", next);
+ return;
}
-
+
+push_ret:
push(p, d);
}
@@ -183,7 +179,7 @@ static void evalPow(Parser *p){
}
if(p->s[0]=='('){
- p->s++;;
+ p->s++;
evalExpression(p);
if(p->s[0]!=')')
@@ -255,3 +251,20 @@ double ff_eval(char *s, double *const_value, const char **const_name,
evalExpression(&p);
return pop(&p);
}
+
+#ifdef TEST
+#undef printf
+static double const_values[]={
+ M_PI,
+ M_E,
+ 0
+};
+static const char *const_names[]={
+ "PI",
+ "E",
+ 0
+};
+main(){
+ printf("%f == 12.7\n", ff_eval("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL));
+}
+#endif
--
Libav/FFmpeg packaging
More information about the pkg-multimedia-commits
mailing list