[Ffmpeg-devel] [patch] move av_xiphlacing in avutil

Michael Niedermayer michaelni
Fri Nov 25 01:41:38 CET 2005


Hi

On Thu, Nov 24, 2005 at 09:38:46PM +0100, Jindrich Makovicka wrote:
[...]
> >
> >hmm, cant the table and start_crc be modified so that the ctx->le case is 
> >always useable?
> >
> 
> I am not sure, I'll try to look at other implementations.

try the following (warning, hand edited so wont apply)

@@ -34,7 +72,7 @@
 	for (i = 0; i < 256; i++) {
 	    for (c = i << (bits-8), j = 0; j < 8; j++)
 		c = (c & (1<<(bits-1))) ? (c<<1)^poly : (c<<1);
-		     ctx->tab[i] = c & ctx->mask;
+		     ctx->tab[i] = bswap_32(c << (32-bits));
 	}
     }
 
@@ -49,20 +87,21 @@
     if (ctx->bits <= 8) {
 	for (i = 0; i < length; i++)
 	    start_crc = ctx->tab[((uint8_t)start_crc) ^ *buffer++];
-    } else if (ctx->le) {
-	for (i = 0; i < length; i++)
-	    start_crc = ctx->tab[((uint8_t)start_crc) ^ *buffer++] ^ (start_crc >> 8);
     } else {
 	for (i = 0; i < length; i++)
-	    start_crc = ctx->tab[(uint8_t)(start_crc>>(ctx->bits-8)) ^ *buffer++] ^ (start_crc << 8);
-    }
+	    start_crc = ctx->tab[((uint8_t)start_crc) ^ *buffer++] ^ (start_crc >> 8);
-    return(start_crc & ctx->mask);
+    }
+    if(!ctx->le)
+        start_crc= bswap_32(start_crc<<(32-ctx->bits));
+    return start_crc;
 }
 
 void av_crc_init()

[...]

-- 
Michael





More information about the ffmpeg-devel mailing list