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

Tomas Härdin tomas.hardin
Tue Sep 14 13:36:53 CEST 2010


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.

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.

/Tomas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: popcount3.patch
Type: text/x-patch
Size: 1442 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100914/947c9820/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: popcount4.patch
Type: text/x-patch
Size: 1448 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100914/947c9820/attachment-0001.bin>
-------------- 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/947c9820/attachment.pgp>



More information about the ffmpeg-devel mailing list