"Ronald S. Bultje" <[email protected]> writes: > Hi, > > 2011/4/7 Benjamin Larsson <[email protected]>: >> +static inline int32_t mul32(int32_t a, int32_t b) >> +{ >> + /* on >=i686, gcc compiles this into a single "imull" instruction */ >> + int64_t r = (int64_t)a * b; >> + /* round the result before truncating - improves accuracy */ >> + return (r + 0x80000000) >> 32; >> +} > > I believe this is what the MUL64() macro is for, then it works on > non-x86 archs also, but that doesn't round...
ARM has a rounding version of that instruction FWIW. -- Måns Rullgård [email protected] _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
