[FFmpeg-devel] [PATCH] optimized H.261 probe function

Michael Niedermayer michaelni
Sun Feb 14 19:37:13 CET 2010


On Sun, Feb 14, 2010 at 05:32:06PM +0100, Reimar D?ffinger wrote:
> Hello,
> this function seems awfully slow.
> While better optimization would be welcome, here is the "quick and dirty"
> method.
> Typical results are at least 5 times faster, e.g.:
> /dev/urandom:
> old:
> 53267160 dezicycles in probe, 1 runs, 0 skips
> new:
> 9200160 dezicycles in probe, 1 runs, 0 skips
> 
> 
> /dev/zero:
> old:
> 44670360 dezicycles in probe, 1 runs, 0 skips
> new:
> 6818880 dezicycles in probe, 1 runs, 0 skips
> 
> 
> AVI file:
> old:
> 45313800 dezicycles in probe, 1 runs, 0 skips
> new:
> 7632360 dezicycles in probe, 1 runs, 0 skips
> 
> It's tested but not exactly well-tested, I only know it still works for the
> samples on mphq.
> 
> Index: libavformat/raw.c
> ===================================================================
> --- libavformat/raw.c	(revision 21819)
> +++ libavformat/raw.c	(working copy)
> @@ -497,6 +497,10 @@
>      init_get_bits(&gb, p->buf, p->buf_size*8);
>  
>      for(i=0; i<p->buf_size*8; i++){
> +        if ((code & 0x01ff0000) || !(code & 0xff00)) {
> +            code = (code<<8) + get_bits(&gb, 8);
> +            i += 7;
> +        } else
>          code = (code<<1) + get_bits1(&gb);
>          if ((code & 0xffff0000) == 0x10000) {
>              int gn= (code>>12)&0xf;

ok

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100214/33119c8c/attachment.pgp>



More information about the ffmpeg-devel mailing list