[FFmpeg-devel] [PATCH] ff_shift (left shift with allowed negative offset) implementation

Vladimir Voroshilov voroshil
Sat May 10 15:42:09 CEST 2008


2008/5/10, Michael Niedermayer <michaelni at gmx.at>:
> On Sat, May 10, 2008 at 01:48:28PM +0700, Vladimir Voroshilov wrote:
> > Hi, All
> >
> > Code in attached patch is used in several places of G.729 code.
> > Michael asked me to make implement it as separate routine.
> > So here is it.
> > Is patch (routine/file name)  ok ?
> [...]
> > diff --git a/libavcodec/acelp_math.c b/libavcodec/acelp_math.c
> > index 6c8a017..b992c11 100644
> > --- a/libavcodec/acelp_math.c
> > +++ b/libavcodec/acelp_math.c
> > @@ -195,3 +195,11 @@ int ff_log2(uint32_t value)
> >
> >      return (power_int << 15) + value;
> >  }
> > +
> > +int ff_shift(int value, int offset)
>
> static inline would be better

ok.

> and the name is not good, it should give some hint that offset is meant
> leftward and that value is signed.

the given name is the best a can invent for it.
Please anybody suggest better.

> > +{
> > +    if(offset < 0)
> > +        return value >> -offset;
> > +    else
> > +        return value << offset;
>
> if(offset < 0)  return value >> -offset;
> else            return value <<  offset;
>
> looks nicer IMHO

ok


-- 
Regards,
Vladimir Voroshilov     mailto:voroshil at gmail.com
JID: voroshil at gmail.com, voroshil at jabber.ru
ICQ: 95587719




More information about the ffmpeg-devel mailing list