On 04/09/2012 14:53, Kostya Shishkov wrote:
First thing looks equally WTFy to me. One can easily replace
     int bit   = (((c->value - c->low) << 1) + 1) / range;

with

     int bit   = (((c->value - c->low) << 1) + 1) >= range;

But further simplifying that way is not obvious.

Starting with
    int bit   = ((c->value - c->low) << 1) + 1 >= range;

Replace range with its expression:
    int bit   = ((c->value - c->low) << 1) + 1 >= c->high - c->low + 1;

Subtract 1 on both sides:
    int bit   =  (c->value - c->low) << 1      >= c->high - c->low;

Add c->low on both sides:
    int bit   =  (c->value - c->low) << 1  + c->low >= c->high;

(Shift to multiplication)
    int bit   =  2 * (c->value - c->low)   + c->low >= c->high;

Expand product:
    int bit   =  2 * c->value - 2 * c->low + c->low >= c->high;

Simplify:
    int bit   =  2 * c->value - c->low >= c->high;
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to