Mercurial > mplayer.hg
diff libfaad2/bits.c @ 10989:3185f64f6350
synced with current cvs
author | alex |
---|---|
date | Fri, 03 Oct 2003 22:23:26 +0000 |
parents | e989150f8216 |
children | 4a370c80fe5c |
line wrap: on
line diff
--- a/libfaad2/bits.c Fri Oct 03 18:13:45 2003 +0000 +++ b/libfaad2/bits.c Fri Oct 03 22:23:26 2003 +0000 @@ -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 @@ { 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 @@ 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 @@ 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) {