From d468ff0fdfdd3ff8f54adea3dd1ef4b94cb8538d Mon Sep 17 00:00:00 2001 From: Jeff Downs Date: Fri, 12 Jun 2009 02:13:12 +0000 Subject: [PATCH] Fix cast of byte buffer to uint32 that was disregarding alignment requirements. Now calculates crc byte at a time until aligned, then continues with uint32 optimized calculation. This fixes crashes during mlp decoding on sparc (at least, maybe others). Originally committed as revision 19160 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavutil/crc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavutil/crc.c b/libavutil/crc.c index ed065d8d50..6fa14fcc58 100644 --- a/libavutil/crc.c +++ b/libavutil/crc.c @@ -115,7 +115,10 @@ uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t le const uint8_t *end= buffer+length; #if !CONFIG_SMALL - if(!ctx[256]) + if(!ctx[256]) { + while(((intptr_t) buffer & 3) && buffer < end) + crc = ctx[((uint8_t)crc) ^ *buffer++] ^ (crc >> 8); + while(buffer>16)&0xFF)] ^ctx[0*256 + ((crc>>24) )]; } + } #endif while(buffer> 8);