Revision 5ae4251c libavutil/eval.c

View differences:

libavutil/eval.c
121 121
        e_squish, e_gauss, e_ld, e_isnan,
122 122
        e_mod, e_max, e_min, e_eq, e_gt, e_gte,
123 123
        e_pow, e_mul, e_div, e_add,
124
        e_last, e_st, e_while,
124
        e_last, e_st, e_while, e_floor, e_ceil, e_trunc,
125 125
    } type;
126 126
    double value; // is sign in other types
127 127
    union {
......
145 145
        case e_gauss: { double d = eval_expr(p, e->param[0]); return exp(-d*d/2)/sqrt(2*M_PI); }
146 146
        case e_ld:     return e->value * p->var[av_clip(eval_expr(p, e->param[0]), 0, VARS-1)];
147 147
        case e_isnan:  return e->value * !!isnan(eval_expr(p, e->param[0]));
148
        case e_floor:  return e->value * floor(eval_expr(p, e->param[0]));
149
        case e_ceil :  return e->value * ceil (eval_expr(p, e->param[0]));
150
        case e_trunc:  return e->value * trunc(eval_expr(p, e->param[0]));
148 151
        case e_while: {
149 152
            double d = NAN;
150 153
            while (eval_expr(p, e->param[0]))
......
276 279
    else if (strmatch(next, "isnan" )) d->type = e_isnan;
277 280
    else if (strmatch(next, "st"    )) d->type = e_st;
278 281
    else if (strmatch(next, "while" )) d->type = e_while;
282
    else if (strmatch(next, "floor" )) d->type = e_floor;
283
    else if (strmatch(next, "ceil"  )) d->type = e_ceil;
284
    else if (strmatch(next, "trunc" )) d->type = e_trunc;
279 285
    else {
280 286
        for (i=0; p->func1_names && p->func1_names[i]; i++) {
281 287
            if (strmatch(next, p->func1_names[i])) {
......
439 445
        case e_squish:
440 446
        case e_ld:
441 447
        case e_gauss:
442
        case e_isnan: return verify_expr(e->param[0]);
448
        case e_isnan:
449
        case e_floor:
450
        case e_ceil:
451
        case e_trunc:
452
            return verify_expr(e->param[0]);
443 453
        default: return verify_expr(e->param[0]) && verify_expr(e->param[1]);
444 454
    }
445 455
}
......
611 621
        "st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))",
612 622
        "isnan(1)",
613 623
        "isnan(NAN)",
624
        "floor(NAN)",
625
        "floor(123.123)",
626
        "floor(-123.123)",
627
        "trunc(123.123)",
628
        "trunc(-123.123)",
629
        "ceil(123.123)",
630
        "ceil(-123.123)",
614 631
        NULL
615 632
    };
616 633

  

Also available in: Unified diff