From 17fb5fd34e96ce472019d4f2b8d798bbd885a24b Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 14 May 2003 10:55:59 +0000 Subject: libmpeg2 style bitstream reader fixes Originally committed as revision 1875 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/common.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'libavcodec/common.c') 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; -- cgit v1.2.3