diff options
author | Giorgio Vazzana <mywing81@gmail.com> | 2013-05-20 21:43:07 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-05-20 22:07:48 +0200 |
commit | a67304d05f11b2377bf157a356d7ebb00f3e06dd (patch) | |
tree | 6d37afb5ea8ff530372a0e53c6d45896a2c8acff /libavutil/md5.c | |
parent | 2211c76287e073a9e176fde7dbb9a63ceb2af8d1 (diff) | |
download | ffmpeg-a67304d05f11b2377bf157a356d7ebb00f3e06dd.tar.gz |
avutil/md5: move loop inside inner function
AMD Athlon(tm) II X3 450 Processor
size: 1048576 runs: 1024 time: 5.660 +- 0.023
size: 1048576 runs: 1024 time: 5.661 +- 0.030
size: 1048576 runs: 1024 time: 5.656 +- 0.022
size: 1048576 runs: 1024 time: 5.647 +- 0.026
size: 1048576 runs: 1024 time: 5.428 +- 0.037
size: 1048576 runs: 1024 time: 5.426 +- 0.034
size: 1048576 runs: 1024 time: 5.426 +- 0.034
size: 1048576 runs: 1024 time: 5.428 +- 0.038
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/md5.c')
-rw-r--r-- | libavutil/md5.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/libavutil/md5.c b/libavutil/md5.c index e3c4981217..21a6e57098 100644 --- a/libavutil/md5.c +++ b/libavutil/md5.c @@ -92,14 +92,19 @@ static const uint32_t T[64] = { // T[i]= fabs(sin(i+1)<<32) a = b + (a << t | a >> (32 - t)); \ } while (0) -static void body(uint32_t ABCD[4], uint32_t X[16]) +static void body(uint32_t ABCD[4], uint32_t *src, int nblocks) { int i av_unused; - uint32_t t; - uint32_t a = ABCD[3]; - uint32_t b = ABCD[2]; - uint32_t c = ABCD[1]; - uint32_t d = ABCD[0]; + int n; + uint32_t a, b, c, d, t, *X; + + for (n = 0; n < nblocks; n++) { + a = ABCD[3]; + b = ABCD[2]; + c = ABCD[1]; + d = ABCD[0]; + + X = src + n * 16; #if HAVE_BIGENDIAN for (i = 0; i < 16; i++) @@ -127,6 +132,7 @@ static void body(uint32_t ABCD[4], uint32_t X[16]) ABCD[1] += c; ABCD[2] += b; ABCD[3] += a; + } } void av_md5_init(AVMD5 *ctx) @@ -154,21 +160,20 @@ void av_md5_update(AVMD5 *ctx, const uint8_t *src, int len) len -= cnt; if (j + cnt < 64) return; - body(ctx->ABCD, (uint32_t *)ctx->block); + body(ctx->ABCD, (uint32_t *)ctx->block, 1); } end = src + (len & ~63); if (HAVE_BIGENDIAN || (!HAVE_FAST_UNALIGNED && ((intptr_t)src & 3))) { while (src < end) { memcpy(ctx->block, src, 64); - body(ctx->ABCD, (uint32_t *) ctx->block); + body(ctx->ABCD, (uint32_t *) ctx->block, 1); src += 64; } } else { - while (src < end) { - body(ctx->ABCD, (uint32_t *)src); - src += 64; - } + int nblocks = len / 64; + body(ctx->ABCD, (uint32_t *)src, nblocks); + src = end; } len &= 63; if (len > 0) |