~ubuntu-branches/ubuntu/utopic/libav/utopic

« back to all changes in this revision

Viewing changes to libavutil/eval.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-12-21 15:32:13 UTC
  • mto: (1.2.18)
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: package-import@ubuntu.com-20121221153213-fudzrugjzivtv0wp
Tags: upstream-9~beta3
ImportĀ upstreamĀ versionĀ 9~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
    d = strtod(numstr, &next);
82
82
    /* if parsing succeeded, check for and interpret postfixes */
83
83
    if (next!=numstr) {
84
 
        if (*next >= 'E' && *next <= 'z') {
 
84
        if (next[0] == 'd' && next[1] == 'B') {
 
85
            /* treat dB as decibels instead of decibytes */
 
86
            d = pow(10, d / 20);
 
87
            next += 2;
 
88
        } else if (*next >= 'E' && *next <= 'z') {
85
89
            int e= si_prefixes[*next - 'E'];
86
90
            if (e) {
87
91
                if (next[1] == 'i') {
339
343
    return parse_primary(e, p);
340
344
}
341
345
 
 
346
static int parse_dB(AVExpr **e, Parser *p, int *sign)
 
347
{
 
348
    /* do not filter out the negative sign when parsing a dB value.
 
349
       for example, -3dB is not the same as -(3dB) */
 
350
    if (*p->s == '-') {
 
351
        char *next;
 
352
        strtod(p->s, &next);
 
353
        if (next != p->s && next[0] == 'd' && next[1] == 'B') {
 
354
            *sign = 0;
 
355
            return parse_primary(e, p);
 
356
        }
 
357
    }
 
358
    return parse_pow(e, p, sign);
 
359
}
 
360
 
342
361
static int parse_factor(AVExpr **e, Parser *p)
343
362
{
344
363
    int sign, sign2, ret;
345
364
    AVExpr *e0, *e1, *e2;
346
 
    if ((ret = parse_pow(&e0, p, &sign)) < 0)
 
365
    if ((ret = parse_dB(&e0, p, &sign)) < 0)
347
366
        return ret;
348
367
    while(p->s[0]=='^'){
349
368
        e1 = e0;
350
369
        p->s++;
351
 
        if ((ret = parse_pow(&e2, p, &sign2)) < 0) {
 
370
        if ((ret = parse_dB(&e2, p, &sign2)) < 0) {
352
371
            av_expr_free(e1);
353
372
            return ret;
354
373
        }
545
564
}
546
565
 
547
566
#ifdef TEST
548
 
#undef printf
549
567
#include <string.h>
550
568
 
551
569
static const double const_values[] = {
630
648
        "not(1)",
631
649
        "not(NAN)",
632
650
        "not(0)",
 
651
        "6.0206dB",
 
652
        "-3.0103dB",
633
653
        NULL
634
654
    };
635
655