[FFmpeg-devel] [PATCH] Demuxer for Leitch/Harris' VR native stream format (LXF)

Tomas Härdin tomas.hardin
Tue Sep 14 16:46:41 CEST 2010


On Tue, 2010-09-14 at 14:03 +0200, Michael Niedermayer wrote:
> On Tue, Sep 14, 2010 at 01:36:53PM +0200, Tomas H?rdin wrote:
> > On Tue, 2010-09-14 at 08:06 +0100, M?ns Rullg?rd wrote:
> > > Tomas H?rdin <tomas.hardin at codemill.se> writes:
> > > 
> > > > Updated the patch per M?ns suggestions (unrolled, static table). I kept
> > > > it as simple as possible for now, assuming the compiler will ignore
> > > > shifts by zero. I didn't perform any detailed speedup analysis, but it's
> > > > around 50% faster.
> > > >
> > > > /Tomas
> > > >
> > > > diff --git a/libavutil/avutil.h b/libavutil/avutil.h
> > > > index c51a682..0b0b4ce 100644
> > > > --- a/libavutil/avutil.h
> > > > +++ b/libavutil/avutil.h
> > > > @@ -40,7 +40,7 @@
> > > >  #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
> > > >  
> > > >  #define LIBAVUTIL_VERSION_MAJOR 50
> > > > -#define LIBAVUTIL_VERSION_MINOR 26
> > > > +#define LIBAVUTIL_VERSION_MINOR 27
> > > >  #define LIBAVUTIL_VERSION_MICRO  0
> > > >  
> > > >  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
> > > > diff --git a/libavutil/common.h b/libavutil/common.h
> > > > index d054f87..00c70ed 100644
> > > > --- a/libavutil/common.h
> > > > +++ b/libavutil/common.h
> > > > @@ -192,6 +192,26 @@ static inline av_const int av_ceil_log2_c(int x)
> > > >      return av_log2((x - 1) << 1);
> > > >  }
> > > >  
> > > > +/**
> > > > + * Count number of bits set to one in x
> > > > + * @param x value to count bits of
> > > > + * @return the number of bits set to one in x
> > > > + */
> > > > +static inline av_const int av_popcount_c(uint32_t x)
> > > > +{
> > > > +    static const uint8_t tab[16] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};
> > > > +#define AV_POPCOUNT_ITER(s) tab[(x >> s) & 0xF]
> > > > +
> > > > +    return AV_POPCOUNT_ITER(0 ) +
> > > > +           AV_POPCOUNT_ITER(4 ) +
> > > > +           AV_POPCOUNT_ITER(8 ) +
> > > > +           AV_POPCOUNT_ITER(12) +
> > > > +           AV_POPCOUNT_ITER(16) +
> > > > +           AV_POPCOUNT_ITER(20) +
> > > > +           AV_POPCOUNT_ITER(24) +
> > > > +           AV_POPCOUNT_ITER(28);
> > > > +}
> > > 
> > > Sorry to be annoying, but the loop looked better, and gcc seems to do
> > > the right thing after all.  Anyway, the bit twisting hack is probably
> > > better still.
> > 
> > I've attached two patches: one that uses the bit hack and one that just
> > makes the table static while keeping the loop. The bit hack and the
> > unrolled table lookup versions seem to be about the same. At least close
> > enough that my simple testing method is insufficient to tell them apart.
> > Someone who knows more x86 asm than me would probably be able to figure
> > out which is faster.
> 
> we can change the implementation as often as we like if we find a faster
> also the code size should be considered as some things are code cache
> limited not to mention that the lut needs a tiny bit data cache
> 
> 
> > 
> > Also, since Michael suggested the name av_popcount rather than
> > ff_popcount I assume he wanted the function public. Since intmath.h
> > doesn't get installed it either has to be installed or av_popcount must
> > reside in an installed header (like common.h) or it should be renamed to
> > ff_popcount. Please clarify.
> 
> it should be public and av_popcount()
> 
> > 
> > /Tomas
> > 
> 
> >  avutil.h |    2 +-
> >  common.h |   17 +++++++++++++++++
> >  2 files changed, 18 insertions(+), 1 deletion(-)
> > 2dbf72d5d56922f95cfdee62f881dc59172ef823  popcount3.patch
> 
> ok

Applied.

/Tomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100914/39d8d591/attachment.pgp>



More information about the ffmpeg-devel mailing list