comparison mlp.c @ 9857:964d08f7b46f libavcodec

Fix unaligned accesses by doing bytewise access until aligned, then continuing in 32-bit quantities. Fixes crash observed on sparc during FATE mlp test. Patch by Ramiro.
author heydowns
date Mon, 15 Jun 2009 14:38:30 +0000
parents 18737839ed27
children 41bd795ae40b
comparison
equal deleted inserted replaced
9856:ff2358195bc7 9857:964d08f7b46f
94 uint8_t ff_mlp_calculate_parity(const uint8_t *buf, unsigned int buf_size) 94 uint8_t ff_mlp_calculate_parity(const uint8_t *buf, unsigned int buf_size)
95 { 95 {
96 uint32_t scratch = 0; 96 uint32_t scratch = 0;
97 const uint8_t *buf_end = buf + buf_size; 97 const uint8_t *buf_end = buf + buf_size;
98 98
99 for (; ((intptr_t) buf & 3) && buf < buf_end; buf++)
100 scratch ^= *buf;
99 for (; buf < buf_end - 3; buf += 4) 101 for (; buf < buf_end - 3; buf += 4)
100 scratch ^= *((const uint32_t*)buf); 102 scratch ^= *((const uint32_t*)buf);
101 103
102 scratch = xor_32_to_8(scratch); 104 scratch = xor_32_to_8(scratch);
103 105