[FFmpeg-devel] [PATCH] WMA Voice decoder
Ronald S. Bultje
rsbultje
Fri Jan 22 19:35:27 CET 2010
Hi,
On Fri, Jan 22, 2010 at 1:30 PM, Uoti Urpala <uoti.urpala at pp1.inet.fi> wrote:
> 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
Right, so I meant that the division is unsigned also.
Or in fact, if you want to be totally correct, the division is signed,
but 64-bit with the input number zero-extended (unsigned).
Ronald
More information about the ffmpeg-devel
mailing list