changeset 294:97f5321b12ad libavutil

make count count bytes not bits (this is simpler and leads to a very slightly smaller object file)
author michael
date Mon, 12 Mar 2007 21:29:39 +0000
parents f75e55461c54
children e96e6ae1c3fa
files sha1.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/sha1.c	Mon Mar 12 21:23:33 2007 +0000
+++ b/sha1.c	Mon Mar 12 21:29:39 2007 +0000
@@ -73,8 +73,8 @@
 void av_sha1_update(AVSHA1* context, uint8_t* data, unsigned int len){
     unsigned int i, j;
 
-    j = (context->count >> 3) & 63;
-    context->count += len << 3;
+    j = context->count & 63;
+    context->count += len;
     if ((j + len) > 63) {
         memcpy(&context->buffer[j], data, (i = 64-j));
         transform(context->state, context->buffer);
@@ -88,10 +88,10 @@
 
 void av_sha1_final(AVSHA1* context, uint8_t digest[20]){
     int i;
-    uint64_t finalcount= be2me_64(context->count);
+    uint64_t finalcount= be2me_64(context->count<<3);
 
     av_sha1_update(context, "\200", 1);
-    while ((context->count & 504) != 448) {
+    while ((context->count & 63) != 56) {
         av_sha1_update(context, "\0", 1);
     }
     av_sha1_update(context, &finalcount, 8);  /* Should cause a transform() */