From 5de2cbc82c0760a043e2b9d81c470729f2ef6328 Mon Sep 17 00:00:00 2001 From: michael Date: Sat, 26 Aug 2006 10:26:14 +0000 Subject: [PATCH] move align_get_bits() to .h to avoid conflicts between different bitstream readers in different codecs add a skip_bits_long() which can skip by any amount in any direction (several codecs contain half working hacks to do that) git-svn-id: file:///var/local/repositories/ffmpeg/trunk@6093 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b --- libavcodec/bitstream.c | 6 ------ libavcodec/bitstream.h | 28 +++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 49c6ece1b0..7eee0229a8 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -73,12 +73,6 @@ unsigned int show_bits_long(GetBitContext *s, int n){ } } -void align_get_bits(GetBitContext *s) -{ - int n= (-get_bits_count(s)) & 7; - if(n) skip_bits(s, n); -} - int check_marker(GetBitContext *s, const char *msg) { int bit= get_bits1(s); diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h index 13a563bb90..4c789e4a6a 100644 --- a/libavcodec/bitstream.h +++ b/libavcodec/bitstream.h @@ -444,6 +444,11 @@ static inline int unaligned32_le(const void *v) static inline int get_bits_count(GetBitContext *s){ return s->index; } + +static inline void skip_bits_long(GetBitContext *s, int n){ + s->index + n; +} + #elif defined LIBMPEG2_BITSTREAM_READER //libmpeg2 like reader @@ -572,6 +577,22 @@ static inline int get_bits_count(GetBitContext *s){ return ((uint8_t*)s->buffer_ptr - s->buffer)*8 - 32 + s->bit_count; } +static inline void skip_bits_long(GetBitContext *s, int n){ + OPEN_READER(re, s) + re_bit_count += n; + re_buffer_ptr += s->bit_count>>5; + re_bit_count &= 31; + if(re_bit_count<=0){ + re_bit_count += 32; + re_buffer_ptr--; + } + re_cache0= + re_cache1= 0; + UPDATE_CACHE(re, s) + re_cache1= 0; + CLOSE_READER(re, s) +} + #endif /** @@ -720,8 +741,13 @@ static inline void init_get_bits(GetBitContext *s, #endif } +static void align_get_bits(GetBitContext *s) +{ + int n= (-get_bits_count(s)) & 7; + if(n) skip_bits(s, n); +} + int check_marker(GetBitContext *s, const char *msg); -void align_get_bits(GetBitContext *s); int init_vlc(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, -- 2.11.4.GIT