diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-05-14 10:55:59 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-05-14 10:55:59 +0000 |
commit | 17fb5fd34e96ce472019d4f2b8d798bbd885a24b (patch) | |
tree | 2ff6cb1985d58cbd551d79c5b9347b29f3788bdf /libavcodec/common.c | |
parent | 924311cd9828695b42cf639c4ea5f258c1a04efd (diff) | |
download | ffmpeg-17fb5fd34e96ce472019d4f2b8d798bbd885a24b.tar.gz |
libmpeg2 style bitstream reader fixes
Originally committed as revision 1875 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/common.c')
-rw-r--r-- | libavcodec/common.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/libavcodec/common.c b/libavcodec/common.c index 4f70e6f924..26165b9018 100644 --- a/libavcodec/common.c +++ b/libavcodec/common.c @@ -140,7 +140,7 @@ void init_get_bits(GetBitContext *s, #ifdef ALT_BITSTREAM_READER s->index=0; #elif defined LIBMPEG2_BITSTREAM_READER -#ifdef LIBMPEG2_BITSTREAM_HACK +#ifdef LIBMPEG2_BITSTREAM_READER_HACK if ((int)buffer&1) { /* word alignment */ s->cache = (*buffer++)<<24; @@ -170,6 +170,30 @@ void init_get_bits(GetBitContext *s, #endif } +/** + * reads 0-32 bits. + */ +unsigned int get_bits_long(GetBitContext *s, int n){ + if(n<=17) return get_bits(s, n); + else{ + int ret= get_bits(s, 16) << (n-16); + return ret | get_bits(s, n-16); + } +} + +/** + * shows 0-32 bits. + */ +unsigned int show_bits_long(GetBitContext *s, int n){ + if(n<=17) return show_bits(s, n); + else{ + GetBitContext gb= *s; + int ret= get_bits_long(s, n); + *s= gb; + return ret; + } +} + void align_get_bits(GetBitContext *s) { int n= (-get_bits_count(s)) & 7; |