[FFmpeg-cvslog] r12165 - trunk/libavcodec/dsputil.c

Rich Felker dalias
Thu Feb 21 23:21:41 CET 2008


On Thu, Feb 21, 2008 at 09:20:00PM +0000, M?ns Rullg?rd wrote:
> Uoti Urpala <uoti.urpala at pp1.inet.fi> writes:
> 
> > On Thu, 2008-02-21 at 20:28 +0200, Uoti Urpala wrote:
> >> On Thu, 2008-02-21 at 08:54 +0100, lorenm wrote:
> >> > +static const unsigned long pb_7f = 0x7f7f7f7f7f7f7f7fUL;
> >> > +static const unsigned long pb_80 = 0x8080808080808080UL;
> >> 
> >> I think these should have a comment about truncation on 32-bit platforms
> >> being intentional. And the code will fail on a 128-bit platform :)
> >
> > I forgot to add that these could be written in a way that is independent
> > of sizeof(long) and doesn't cause compiler warnings about truncation on
> > platforms with shorter longs:
> > static const unsigned long pb_7f = -1UL/255 * 0x7f;
> 
> This assumes two's complement signed numbers.  Using ~0UL avoids this
> assumption.

Yes, a completely reasonable assumption. There are plenty of things
that will go to hell without twos complement and absolutely no
motivations for other integer representations except for historical
systems from the 1960s whose creators failed algebra. =)

Rich




More information about the ffmpeg-cvslog mailing list