aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/common.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2003-05-14 10:55:59 +0000
committerMichael Niedermayer <michaelni@gmx.at>2003-05-14 10:55:59 +0000
commit17fb5fd34e96ce472019d4f2b8d798bbd885a24b (patch)
tree2ff6cb1985d58cbd551d79c5b9347b29f3788bdf /libavcodec/common.c
parent924311cd9828695b42cf639c4ea5f258c1a04efd (diff)
downloadffmpeg-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.c26
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;