summaryrefslogtreecommitdiffstats
path: root/libfaad2/bits.c
diff options
context:
space:
mode:
authoralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-10-03 22:23:26 +0000
committeralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-10-03 22:23:26 +0000
commite24087509a752d8f4dcc679b304fc1745ff768b0 (patch)
tree60bbaca1e13f268df83d5d88c1daa49debacc541 /libfaad2/bits.c
parent22c9bcf82417c33258c74104704f196f6672f696 (diff)
downloadmpv-e24087509a752d8f4dcc679b304fc1745ff768b0.tar.bz2
mpv-e24087509a752d8f4dcc679b304fc1745ff768b0.tar.xz
synced with current cvs
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10990 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libfaad2/bits.c')
-rw-r--r--libfaad2/bits.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/libfaad2/bits.c b/libfaad2/bits.c
index 00f9ad0090..1d8c91bed3 100644
--- a/libfaad2/bits.c
+++ b/libfaad2/bits.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: bits.c,v 1.22 2003/07/29 08:20:12 menno Exp $
+** $Id: bits.c,v 1.1 2003/08/30 22:30:21 arpi Exp $
**/
#include "common.h"
@@ -37,6 +37,18 @@ void faad_initbits(bitfile *ld, void *_buffer, uint32_t buffer_size)
{
uint32_t tmp;
+ if (ld == NULL)
+ return;
+
+ memset(ld, 0, sizeof(bitfile));
+
+ if (buffer_size == 0 || _buffer == NULL)
+ {
+ ld->error = 1;
+ ld->no_more_reading = 1;
+ return;
+ }
+
ld->buffer = malloc((buffer_size+12)*sizeof(uint8_t));
memset(ld->buffer, 0, (buffer_size+12)*sizeof(uint8_t));
memcpy(ld->buffer, _buffer, buffer_size*sizeof(uint8_t));
@@ -71,10 +83,9 @@ void faad_endbits(bitfile *ld)
if (ld->buffer) free(ld->buffer);
}
-
uint32_t faad_get_processed_bits(bitfile *ld)
{
- return 8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left);
+ return (uint32_t)(8 * (4*(ld->tail - ld->start) - 4) - (ld->bits_left));
}
uint8_t faad_byte_align(bitfile *ld)
@@ -89,6 +100,25 @@ uint8_t faad_byte_align(bitfile *ld)
return 0;
}
+void faad_flushbits_ex(bitfile *ld, uint32_t bits)
+{
+ uint32_t tmp;
+
+ ld->bufa = ld->bufb;
+ tmp = getdword(ld->tail);
+ ld->tail++;
+#ifndef ARCH_IS_BIG_ENDIAN
+ BSWAP(tmp);
+#endif
+ ld->bufb = tmp;
+ ld->bits_left += (32 - bits);
+ ld->bytes_used += 4;
+ if (ld->bytes_used == ld->buffer_size)
+ ld->no_more_reading = 1;
+ if (ld->bytes_used > ld->buffer_size)
+ ld->error = 1;
+}
+
/* rewind to beginning */
void faad_rewindbits(bitfile *ld)
{