Skip to content
Snippets Groups Projects
Commit d468ff0f authored by Jeff Downs's avatar Jeff Downs
Browse files

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
parent be43ae66
No related branches found
No related tags found
No related merge requests found
...@@ -115,7 +115,10 @@ uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t le ...@@ -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; const uint8_t *end= buffer+length;
#if !CONFIG_SMALL #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<end-3){ while(buffer<end-3){
crc ^= le2me_32(*(const uint32_t*)buffer); buffer+=4; crc ^= le2me_32(*(const uint32_t*)buffer); buffer+=4;
crc = ctx[3*256 + ( crc &0xFF)] crc = ctx[3*256 + ( crc &0xFF)]
...@@ -123,6 +126,7 @@ uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t le ...@@ -123,6 +126,7 @@ uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t le
^ctx[1*256 + ((crc>>16)&0xFF)] ^ctx[1*256 + ((crc>>16)&0xFF)]
^ctx[0*256 + ((crc>>24) )]; ^ctx[0*256 + ((crc>>24) )];
} }
}
#endif #endif
while(buffer<end) while(buffer<end)
crc = ctx[((uint8_t)crc) ^ *buffer++] ^ (crc >> 8); crc = ctx[((uint8_t)crc) ^ *buffer++] ^ (crc >> 8);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment