On 2012-11-29 13:46:12 +0000, Måns Rullgård wrote:
> Janne Grunau <[email protected]> writes:
> 
> > On 2012-11-29 00:08:52 +0000, Måns Rullgård wrote:
> >> Janne Grunau <[email protected]> writes:
> >> 
> >> > On 2012-11-28 23:52:27 +0100, Luca Barbato wrote:
> >> >> 
> >> >> Is INVALID_VLC value negative?
> >> >
> >> > no, 0x80000000. But arithmetic conversion saves us.
> >> 
> >> Ouch, that's _really_ bad.  The svq3_get_ue_golomb() return type is
> >> (inexplicably) int, so returning that value entails a conversion with
> >> implementation-defined behaviour.  Most compilers leave the bits intact
> >> in such conversions, but I'd rather not depend on it.  Also, such code
> >> is nothing short of obfuscated even if it does work reliably.
> >
> > 6.3.1.3 reads to me as if signed int to unsigned int conversion is well
> > defined:
> 
> Yes, but we're dealing with unsigned to signed here.  The integer
> constant 0x80000000 has type unsigned int (if int is 32-bit).  Returning
> this from svq3_get_ue_golomb() as a signed int invokes an
> implementation-defined conversion.

svq3_get_ue_golomb() doesn't return INVALID_VLC explicitly. The only it
can return something negative is due to signed arithmetic on the int ret
in the else branch.

svq3_get_se_golomb() on the other hand does and should be fixed.

Janne
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to