[FFmpeg-devel] [PATCH 2/5] fate: avoid framemd5, use framecrc its faster

Giorgio Vazzana mywing81 at gmail.com
Fri May 17 15:15:59 CEST 2013


Hi,

about a year ago I studied ffmpeg's implementation of md5, and I
noticed it was a slow compared to GNU md5sum. So I managed to make it
almost as fast as the GNU implementation, but I never sent a patch
because I wanted to work on it some more... of course I never did that
because of lack of free time. Anyway, I found my old patch, since it's
relatively simple I thought I'd send it in, hoping you will find it
useful, maybe as a temporary solution until someone else comes up with
something faster.

Quick benchmark:
# create test file and compile test program
$ dd if=/dev/zero of=data bs=1M count=500
$ gcc -Wall avutil_md5_test.c -O2 -o avutil_md5_test -L ./libavutil/ -lavutil


# without the patch:
$ for i in $(seq 1 3); do time ./avutil_md5_test < data; done
d8b61b2c0025919d5321461045c8226f

real    0m2.906s
user    0m2.680s
sys    0m0.180s
d8b61b2c0025919d5321461045c8226f

real    0m2.936s
user    0m2.560s
sys    0m0.330s
d8b61b2c0025919d5321461045c8226f

real    0m2.903s
user    0m2.690s
sys    0m0.170s


# with the patch:
$ for i in $(seq 1 3); do time ./avutil_md5_test < data; done
d8b61b2c0025919d5321461045c8226f

real    0m1.896s
user    0m1.580s
sys    0m0.280s
d8b61b2c0025919d5321461045c8226f

real    0m1.895s
user    0m1.650s
sys    0m0.210s
d8b61b2c0025919d5321461045c8226f

real    0m1.891s
user    0m1.650s
sys    0m0.200s


# for comparison:
$ for i in $(seq 1 3); do time md5sum < data; done
d8b61b2c0025919d5321461045c8226f  -

real    0m1.842s
user    0m1.510s
sys    0m0.280s
d8b61b2c0025919d5321461045c8226f  -

real    0m1.803s
user    0m1.530s
sys    0m0.250s
d8b61b2c0025919d5321461045c8226f  -

real    0m1.821s
user    0m1.620s
sys    0m0.160s

Giorgio Vazzana
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avutil_md5_test.c
Type: text/x-csrc
Size: 672 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130517/bff35d84/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-md5-speed-optimizations.patch
Type: application/octet-stream
Size: 3812 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130517/bff35d84/attachment.obj>


More information about the ffmpeg-devel mailing list