Revision edd259f9 libavcodec/eval.c

View differences:

libavcodec/eval.c
369 369
    }
370 370
}
371 371

  
372
AVExpr *ff_parse_expr(const char *s, const char * const *const_name,
373
               double (* const *func1)(void *, double), const char * const *func1_name,
374
               double (* const *func2)(void *, double, double), const char * const *func2_name,
372
AVExpr *ff_parse_expr(const char *s,
373
                      const char * const *const_name,
374
                      const char * const *func1_name, double (* const *func1)(void *, double),
375
                      const char * const *func2_name, double (* const *func2)(void *, double, double),
375 376
               const char **error){
376 377
    Parser p;
377 378
    AVExpr *e = NULL;
......
412 413
    return eval_expr(&p, e);
413 414
}
414 415

  
415
double ff_parse_and_eval_expr(const char *s, const double *const_value, const char * const *const_name,
416
               double (* const *func1)(void *, double), const char * const *func1_name,
417
               double (* const *func2)(void *, double, double), const char * const *func2_name,
416
double ff_parse_and_eval_expr(const char *s,
417
                              const char * const *const_name, const double *const_value,
418
                              const char * const *func1_name, double (* const *func1)(void *, double),
419
                              const char * const *func2_name, double (* const *func2)(void *, double, double),
418 420
               void *opaque, const char **error){
419
    AVExpr * e = ff_parse_expr(s, const_name, func1, func1_name, func2, func2_name, error);
421
    AVExpr *e = ff_parse_expr(s, const_name, func1_name, func1, func2_name, func2, error);
420 422
    double d;
421 423
    if (!e) return NAN;
422 424
    d = ff_eval_expr(e, const_value, opaque);
......
438 440
};
439 441
int main(void){
440 442
    int i;
441
    printf("%f == 12.7\n", ff_parse_and_eval_expr("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL, NULL));
442
    printf("%f == 0.931322575\n", ff_parse_and_eval_expr("80G/80Gi", const_values, const_names, NULL, NULL, NULL, NULL, NULL, NULL));
443
    printf("%f == 12.7\n", ff_parse_and_eval_expr("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_names, const_values, NULL, NULL, NULL, NULL, NULL, NULL));
444
    printf("%f == 0.931322575\n", ff_parse_and_eval_expr("80G/80Gi", const_names, const_values, NULL, NULL, NULL, NULL, NULL, NULL));
443 445

  
444 446
    for(i=0; i<1050; i++){
445 447
        START_TIMER
446
            ff_parse_and_eval_expr("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL, NULL);
448
            ff_parse_and_eval_expr("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_names, const_values, NULL, NULL, NULL, NULL, NULL, NULL);
447 449
        STOP_TIMER("ff_parse_and_eval_expr")
448 450
    }
449 451
    return 0;

Also available in: Unified diff