[Ffmpeg-devel] H.264 encoder
Panagiotis Issaris
takis.issaris
Wed Oct 4 19:11:18 CEST 2006
On wo, 2006-10-04 at 19:11 +0200, Christian Iversen wrote:
> On Wednesday 04 October 2006 19:00, Morten Nilsen wrote:
> > Christian Iversen wrote:
> > >>>> + if (val > 0)
> > >>>> + val--;
> > >>>> + else // < 0
> > >>>> + val++;
> > >>>
> > >>> val -= (val>>31)|1;
> > >
> > > Is it because I appearantly don't understand C, or is that a pretty odd
> > > expression?
> > >
> > > You take the sign bit, and "or" it with 1, leaving ... 1, in all cases.
> > >
> > > Is this expression equiv. to val--; ?
> >
> > -xxx >> 31 = -1
> > xxx >> 31 = 0
> >
> > -1 | 1 = -1
> > 0 | 1 = 1
> >
> > so, we get;
> > negative: val -= -1;
> > positive: val -= 1;
> >
> > Quite elegant, I just love bit magic. :)
>
> Absolutely, it all makes sense now :)
>
> So, it there some way to force logical SHR in C?
Casting to unsigned first :)
With friendly regards,
Takis
More information about the ffmpeg-devel
mailing list