summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruid56437 <none@none>2001-07-04 14:09:52 +0000
committeruid56437 <none@none>2001-07-04 14:09:52 +0000
commitdcf6b20403886932bff88ba93fa47c954abc38a6 (patch)
tree56d3773485e25a8089017c4b281158caba959da6
parent0342d76c613911b282e14a1188326075d1d43bca (diff)
downloadxine-lib-dcf6b20403886932bff88ba93fa47c954abc38a6.tar.gz
xine-lib-dcf6b20403886932bff88ba93fa47c954abc38a6.tar.bz2
* 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
-rw-r--r--src/libac3/bit_allocate.c15
-rw-r--r--src/libac3/bitstream.c26
-rw-r--r--src/libac3/bitstream.h5
3 files changed, 23 insertions, 23 deletions
diff --git a/src/libac3/bit_allocate.c b/src/libac3/bit_allocate.c
index 74c5ec902..17f35b159 100644
--- a/src/libac3/bit_allocate.c
+++ b/src/libac3/bit_allocate.c
@@ -165,7 +165,8 @@ void bit_allocate(int fscod, audblk_t * audblk, ac3_ba_t * ba,
psd = 128 * exp[i];
mask = psd + fgain + lowcomp;
COMPUTE_MASK ();
- bap[i++] = (baptab+156)[mask + 4 * exp[i]];
+ bap[i] = (baptab+156)[mask + 4 * exp[i]];
+ i++;
} while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1])));
fastleak = psd + fgain;
slowleak = psd + sgain;
@@ -182,7 +183,8 @@ void bit_allocate(int fscod, audblk_t * audblk, ac3_ba_t * ba,
mask = ((fastleak + lowcomp < slowleak) ?
fastleak + lowcomp : slowleak);
COMPUTE_MASK ();
- bap[i++] = (baptab+156)[mask + 4 * exp[i]];
+ bap[i] = (baptab+156)[mask + 4 * exp[i]];
+ i++;
}
if (end == 7) // lfe channel
@@ -198,7 +200,8 @@ void bit_allocate(int fscod, audblk_t * audblk, ac3_ba_t * ba,
mask = ((fastleak + lowcomp < slowleak) ?
fastleak + lowcomp : slowleak);
COMPUTE_MASK ();
- bap[i++] = (baptab+156)[mask + 4 * exp[i]];
+ bap[i] = (baptab+156)[mask + 4 * exp[i]];
+ i++;
} while (i < 20);
while (lowcomp > 128) { // two iterations maximum
@@ -208,7 +211,8 @@ void bit_allocate(int fscod, audblk_t * audblk, ac3_ba_t * ba,
mask = ((fastleak + lowcomp < slowleak) ?
fastleak + lowcomp : slowleak);
COMPUTE_MASK ();
- bap[i++] = (baptab+156)[mask + 4 * exp[i]];
+ bap[i] = (baptab+156)[mask + 4 * exp[i]];
+ i++;
}
j = i;
}
@@ -245,7 +249,8 @@ void bit_allocate(int fscod, audblk_t * audblk, ac3_ba_t * ba,
do {
// max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp
// min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5
- bap[j++] = (baptab+156)[mask + 4 * exp[j]];
+ bap[j] = (baptab+156)[mask + 4 * exp[j]];
+ j++;
} while (j < endband);
} while (j < end);
}
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 <stdlib.h>
+#include <stddef.h>
#include <stdio.h>
#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
}
//
diff --git a/src/libac3/bitstream.h b/src/libac3/bitstream.h
index b5d896184..84f3287c8 100644
--- a/src/libac3/bitstream.h
+++ b/src/libac3/bitstream.h
@@ -21,11 +21,6 @@
*
*/
-#warning FIXME: need WORDS_BIGENDIAN autoconf test
-#ifdef __sparc__
-#define WORDS_BIGENDIAN 1
-#endif
-
//My new and improved vego-matic endian swapping routine
//(stolen from the kernel)
#ifdef WORDS_BIGENDIAN