summaryrefslogtreecommitdiffstats
path: root/mp3lib
diff options
context:
space:
mode:
Diffstat (limited to 'mp3lib')
-rw-r--r--mp3lib/sr1.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/mp3lib/sr1.c b/mp3lib/sr1.c
index 7a124ee9b9..86b28748a1 100644
--- a/mp3lib/sr1.c
+++ b/mp3lib/sr1.c
@@ -123,7 +123,15 @@ LOCAL unsigned int getbits_fast(short number_of_bits)
// if(MP3_frames>=7741) printf("getbits_fast: bits=%d bitsleft=%d wordptr=%x\n",number_of_bits,bitsleft,wordpointer);
if((bitsleft-=number_of_bits)<0) return 0;
if(!number_of_bits) return 0;
+#if ARCH_X86
rval = bswap_16(*((unsigned short *)wordpointer));
+#else
+ /*
+ * we may not be able to address unaligned 16-bit data on non-x86 cpus.
+ * Fall back to some portable code.
+ */
+ rval = wordpointer[0] << 8 | wordpointer[1];
+#endif
rval <<= bitindex;
rval &= 0xffff;
bitindex += number_of_bits;
@@ -158,7 +166,19 @@ LOCAL void set_pointer(long backstep)
LOCAL int stream_head_read(unsigned char *hbuf,unsigned long *newhead){
if(mp3_read(hbuf,4) != 4) return FALSE;
+#if ARCH_X86
*newhead = bswap_32(*((unsigned long *)hbuf));
+#else
+ /*
+ * we may not be able to address unaligned 32-bit data on non-x86 cpus.
+ * Fall back to some portable code.
+ */
+ *newhead =
+ hbuf[0] << 24 |
+ hbuf[1] << 16 |
+ hbuf[2] << 8 |
+ hbuf[3];
+#endif
return TRUE;
}