[XviD-devel] Re: Don't do " signed /= unsigned "

Marco Al xvid-devel@xvid.org
Sun, 19 Jan 2003 05:55:37 +0100


Felix von Leitner wrote:

> Wenn hier eh nur durch 1 oder 2 geteilt wird, dann doch lieber
>
>   dx >>= quarterpel

That floors the value, we have to truncate into the direction of zero instead.

Thats why I arrived, after a couple of detours, at the rather convoluted

(dx >> qpel) + (dx & qpel & (dx >> (sizeoff(dx) * 8 - 1)))

Which adds 1 if dx's LSB is set and dx is negative (ie. whenever floor would
give the wrong result).

Marco