From dcf6b20403886932bff88ba93fa47c954abc38a6 Mon Sep 17 00:00:00 2001 From: uid56437 Date: Wed, 4 Jul 2001 14:09:52 +0000 Subject: * 32-bit aligned memory access for bitstream access, so a SPARC cpu is happy. * gcc-3.0 fixes for bit_allocate.c: The same variable is used with autoincrement on left/right side of an assigment, which is an undefined operation. CVS patchset: 246 CVS date: 2001/07/04 14:09:52 --- src/libac3/bitstream.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/libac3/bitstream.c') diff --git a/src/libac3/bitstream.c b/src/libac3/bitstream.c index 1f4aff54e..2a06ea747 100644 --- a/src/libac3/bitstream.c +++ b/src/libac3/bitstream.c @@ -22,6 +22,7 @@ */ #include +#include #include #include "ac3.h" @@ -30,32 +31,31 @@ #define BUFFER_SIZE 4096 -static uint8_t *buffer_start; +struct uint32_alignment { + char a; + uint32_t b; +}; +#define UINT32_ALIGNMENT offsetof(struct uint32_alignment, b) + + +static uint32_t *buffer_start; uint32_t bits_left; uint32_t current_word; void bitstream_set_ptr (uint8_t * buf) { - buffer_start = buf; + int align = (long)buf & (UINT32_ALIGNMENT-1); + buffer_start = (uint32_t *) (buf - align); bits_left = 0; + if (align > 0) bitstream_get(align * 8); } static inline void bitstream_fill_current() { -#ifdef __sparc__ -#warning FIXME: cannot access unaligned pointer on sparc - current_word = - (buffer_start[0] << 24) | - (buffer_start[1] << 16) | - (buffer_start[2] << 8) | - buffer_start[3]; - buffer_start += 4; -#else - current_word = *((uint32_t*)buffer_start)++; + current_word = *buffer_start++; current_word = swab32(current_word); -#endif } // -- cgit v1.2.3