summaryrefslogtreecommitdiff
path: root/ac3dec/bitstream.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2001-08-09 11:41:39 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2001-08-09 11:41:39 +0200
commitc50dc5e888627bd1644f46585a44dc118c865127 (patch)
tree1dc5a28da106e3404863fc0234891142a5c29b2f /ac3dec/bitstream.c
parent85a027791063dfd7e94ccef45ea9e755df63d29a (diff)
downloadvdr-c50dc5e888627bd1644f46585a44dc118c865127.tar.gz
vdr-c50dc5e888627bd1644f46585a44dc118c865127.tar.bz2
Improvements from Matjaz Thaler
Diffstat (limited to 'ac3dec/bitstream.c')
-rw-r--r--ac3dec/bitstream.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/ac3dec/bitstream.c b/ac3dec/bitstream.c
index 296d5ee3..f48d2408 100644
--- a/ac3dec/bitstream.c
+++ b/ac3dec/bitstream.c
@@ -23,54 +23,57 @@
#include <stdlib.h>
#include <stdio.h>
+#include <inttypes.h>
+
+#include <bswap.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "ac3.h"
#include "ac3_internal.h"
#include "bitstream.h"
-uint_8 *buffer_start = 0;
-uint_32 bits_left = 0;
-uint_32 current_word;
+uint32_t bits_left = 0;
+uint64_t current_word;
+uint64_t *buffer_start = 0;
+
+
+static inline uint64_t getdword (void)
+{
+ return be2me_64 (*buffer_start++);
+}
+
-static inline void
-bitstream_fill_current()
+static inline void bitstream_fill_current (void)
{
- current_word = *((uint_32*)buffer_start)++;
- current_word = swab32(current_word);
+ //current_word = bswap_64 (*buffer_start++);
+ current_word = getdword ();
}
-//
-// The fast paths for _get is in the
-// bitstream.h header file so it can be inlined.
-//
-// The "bottom half" of this routine is suffixed _bh
-//
-// -ah
-//
-
-uint_32
-bitstream_get_bh(uint_32 num_bits)
+
+uint32_t bitstream_get_bh (uint32_t num_bits)
{
- uint_32 result;
+ uint32_t result;
num_bits -= bits_left;
- result = (current_word << (32 - bits_left)) >> (32 - bits_left);
+ result = (current_word << (64 - bits_left)) >> (64 - bits_left);
bitstream_fill_current();
if(num_bits != 0)
- result = (result << num_bits) | (current_word >> (32 - num_bits));
+ result = (result << num_bits) | (current_word >> (64 - num_bits));
- bits_left = 32 - num_bits;
+ bits_left = 64 - num_bits;
return result;
}
-void
-bitstream_init(uint_8 *start)
+
+void bitstream_init (uint8_t *start)
{
//initialize the start of the buffer
- buffer_start = start;
+ buffer_start = (uint64_t *) start;
bits_left = 0;
}