[Ffmpeg-devel] clip_uint8
    Michael Niedermayer 
    michaelni
       
    Fri Apr 28 19:50:28 CEST 2006
    
    
  
Hi
On Fri, Apr 28, 2006 at 12:45:59PM -0400, Rich Felker wrote:
> On Fri, Apr 28, 2006 at 05:58:56PM +0200, Panagiotis Issaris wrote:
> > -static inline int clip_uint8(int a)
> > +static inline uint8_t clip_uint8(int a)
> >  {
> >      if (a&(~255)) return (-a)>>31;
> >      else          return a;
> 
> This code is slow btw. 
"slow" is relative, unless you suggest something faster id say its not slow
> I'm sure it can be done without conditionals.
everything can, this doesnt mean it should, only if the conditional is not
predictable should t be avoided, and a overflow check is likely going to be
false in 99.9% of the cases so there should be practically 0 branch
misspredictions
then again if you can do this faster i surely wont complain
[...]
-- 
Michael
In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is
    
    
More information about the ffmpeg-devel
mailing list