[FFmpeg-devel] [PATCH 1/3] adler32: avoid "too big" check in the inner loop

Michael Niedermayer michaelni at gmx.at
Fri Feb 3 22:20:18 CET 2012


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavutil/adler32.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavutil/adler32.c b/libavutil/adler32.c
index f4f56ea..9ea639f 100644
--- a/libavutil/adler32.c
+++ b/libavutil/adler32.c
@@ -37,17 +37,23 @@ unsigned long av_adler32_update(unsigned long adler, const uint8_t * buf,
     unsigned long s2 = adler >> 16;
 
     while (len > 0) {
+        unsigned len2=(len-1) & ~15;
+        if (len2 > 2048) len2 = 2048;
+        if (len2) {
+            len -= len2;
+
 #if CONFIG_SMALL
-        while (len > 4  && s2 < (1U << 31)) {
+        while (len2 >= 4) {
             DO4(buf);
-            len -= 4;
+            len2 -= 4;
         }
 #else
-        while (len > 16 && s2 < (1U << 31)) {
+        while (len2 >= 16) {
             DO16(buf);
-            len -= 16;
+            len2 -= 16;
         }
 #endif
+        }
         DO1(buf); len--;
         s1 %= BASE;
         s2 %= BASE;
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list