ref: 9efcb7cd2bfb0aa0dc8e8399986c7bb55329578a
parent: 7e5718e75af5bc49156923f627dae26af50700fc
author: menno <menno>
date: Fri Nov 8 08:00:35 EST 2002
Small changes for WinCE
--- a/libfaad/bits.c
+++ b/libfaad/bits.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: bits.c,v 1.14 2002/11/01 11:19:35 menno Exp $
+** $Id: bits.c,v 1.15 2002/11/08 13:00:34 menno Exp $
**/
#include "common.h"
@@ -31,13 +31,13 @@
ld->buffer_size = buffer_size;
- tmp = *(uint32_t*)buffer;
+ tmp = getdword((uint32_t*)buffer);
#ifndef ARCH_IS_BIG_ENDIAN
BSWAP(tmp);
#endif
ld->bufa = tmp;
- tmp = *((uint32_t*)buffer + 1);
+ tmp = getdword((uint32_t*)buffer + 1);
#ifndef ARCH_IS_BIG_ENDIAN
BSWAP(tmp);
#endif
@@ -104,13 +104,13 @@
ld->start = (uint32_t*)buffer + index - 2;
- tmp = *((uint32_t*)buffer + index);
+ tmp = getdword((uint32_t*)buffer + index);
#ifndef ARCH_IS_BIG_ENDIAN
BSWAP(tmp);
#endif
ld->bufa = tmp;
- tmp = *((uint32_t*)buffer + index - 1);
+ tmp = getdword((uint32_t*)buffer + index - 1);
#ifndef ARCH_IS_BIG_ENDIAN
BSWAP(tmp);
#endif
--- a/libfaad/bits.h
+++ b/libfaad/bits.h
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: bits.h,v 1.12 2002/11/07 18:24:53 menno Exp $
+** $Id: bits.h,v 1.13 2002/11/08 13:00:35 menno Exp $
**/
#ifndef __BITS_H__
@@ -71,6 +71,22 @@
uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits
DEBUGDEC);
+/* circumvent memory alignment errors on ARM */
+static INLINE uint32_t getdword(void *mem)
+{
+#ifdef ARM
+ uint32_t tmp;
+ ((uint8_t*)&tmp)[0] = ((uint8_t*)mem)[0];
+ ((uint8_t*)&tmp)[1] = ((uint8_t*)mem)[1];
+ ((uint8_t*)&tmp)[2] = ((uint8_t*)mem)[2];
+ ((uint8_t*)&tmp)[3] = ((uint8_t*)mem)[3];
+
+ return tmp;
+#else
+ return *(uint32_t*)mem;
+#endif
+}
+
static INLINE uint32_t faad_showbits(bitfile *ld, uint32_t bits)
{
if (bits <= ld->bits_left)
@@ -91,7 +107,7 @@
uint32_t tmp;
ld->bufa = ld->bufb;
- tmp = *(uint32_t*)ld->tail;
+ tmp = getdword(ld->tail);
#ifndef ARCH_IS_BIG_ENDIAN
BSWAP(tmp);
#endif
@@ -163,7 +179,7 @@
uint32_t tmp;
ld->bufa = ld->bufb;
- tmp = *(uint32_t*)ld->start;
+ tmp = getdword(ld->start);
#ifndef ARCH_IS_BIG_ENDIAN
BSWAP(tmp);
#endif