[Ffmpeg-devel] [PATCH] qcelp codec supporrt

Rich Felker dalias
Thu Dec 14 02:46:07 CET 2006


On Wed, Dec 13, 2006 at 11:18:02PM +0000, M?ns Rullg?rd wrote:
> >> > +            *p++ = (pkt.data[i] >> 8) & 0xff;
> >> > +            *p++ = pkt.data[i] & 0xff;
> >> 
> >> the & 0xff isnt needed
> >
> > I appended it because I thought signed to unsigned conversion
> > between two values of the different storage size is not
> > defined in the C spefication.
> 
> Conversion to unsigned is well-defined.  Conversion to signed is only
> defined when the value is within the range of the target type.  This
> is mostly because the C standard doesn't specify how negative numbers
> are represented.  Apparently there were some machines in the distant
> past that used one's complement to represent negative numbers.

Because their creators failed MATH 101... For all practical purposes,
all arithmetic is twos complement and signed truncation is well-defined.

Rich





More information about the ffmpeg-devel mailing list