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

Reimar Döffinger Reimar.Doeffinger
Sun Feb 14 17:32:06 CET 2010


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;




More information about the ffmpeg-devel mailing list