[FFmpeg-devel] [PATCH] WMA Voice decoder
Uoti Urpala
uoti.urpala
Fri Jan 22 19:30:44 CET 2010
On Fri, 2010-01-22 at 13:23 -0500, Ronald S. Bultje wrote:
> On Fri, Jan 22, 2010 at 1:20 PM, Uoti Urpala <uoti.urpala at pp1.inet.fi> wrote:
> > On Fri, 2010-01-22 at 10:48 -0500, Ronald S. Bultje wrote:
> >> >> >> + int z = (uint16_t) (x * 49995 / y);
> >
> > BTW I forgot to mention earlier than since x is signed int, x * 49995
> > can overflow here (undefined behavior).
>
> If it matters, it's an unsigned multiply (is there an "unsigned" MULu16?).
The multiply instruction will be the same in either case. But the
undefined behavior means that it's for example valid for the compiler to
assume that x < 42954 always. And even if the compiler does nothing like
that and generates straightforward code, it will matter for the
following _division_ whether results with the highest bit set are
interpreted as signed or unsigned.
(signed)(-1)/46 = 0
(unsigned)(-1)/46 = 93368854
More information about the ffmpeg-devel
mailing list