From 9106a698e726c041128a05db0a011caae755d10b Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 13 Apr 2009 16:20:26 +0000 Subject: Rename bitstream.h to get_bits.h. Originally committed as revision 18494 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/4xm.c | 2 +- libavcodec/aac.c | 2 +- libavcodec/aac_parser.c | 2 +- libavcodec/aac_parser.h | 2 +- libavcodec/aacenc.c | 2 +- libavcodec/ac3.c | 2 +- libavcodec/ac3_parser.c | 2 +- libavcodec/ac3_parser.h | 2 +- libavcodec/ac3dec.h | 2 +- libavcodec/ac3enc.c | 2 +- libavcodec/adpcm.c | 2 +- libavcodec/alac.c | 2 +- libavcodec/alacenc.c | 2 +- libavcodec/apedec.c | 2 +- libavcodec/asv1.c | 2 +- libavcodec/atrac3.c | 2 +- libavcodec/avs.c | 2 +- libavcodec/bitstream.c | 2 +- libavcodec/bitstream.h | 705 --------------------------------------------- libavcodec/cabac.c | 2 +- libavcodec/cavs.c | 2 +- libavcodec/cavsdec.c | 2 +- libavcodec/cljr.c | 2 +- libavcodec/cook.c | 2 +- libavcodec/dca.c | 2 +- libavcodec/dnxhddec.c | 2 +- libavcodec/dv.c | 2 +- libavcodec/dvbsub_parser.c | 2 +- libavcodec/dvbsubdec.c | 2 +- libavcodec/dvdsubdec.c | 2 +- libavcodec/eatgq.c | 2 +- libavcodec/eatgv.c | 2 +- libavcodec/eatqi.c | 2 +- libavcodec/escape124.c | 2 +- libavcodec/faxcompr.c | 2 +- libavcodec/ffv1.c | 2 +- libavcodec/flacdec.c | 2 +- libavcodec/flacenc.c | 2 +- libavcodec/flashsv.c | 2 +- libavcodec/fraps.c | 2 +- libavcodec/g726.c | 2 +- libavcodec/g729dec.c | 2 +- libavcodec/get_bits.h | 705 +++++++++++++++++++++++++++++++++++++++++++++ libavcodec/golomb.h | 2 +- libavcodec/h264enc.c | 2 +- libavcodec/huffman.c | 2 +- libavcodec/huffman.h | 2 +- libavcodec/huffyuv.c | 2 +- libavcodec/imc.c | 2 +- libavcodec/indeo2.c | 2 +- libavcodec/intrax8.c | 2 +- libavcodec/intrax8.h | 2 +- libavcodec/jpeglsdec.c | 2 +- libavcodec/jpeglsenc.c | 2 +- libavcodec/lcldec.c | 2 +- libavcodec/loco.c | 2 +- libavcodec/lzw.h | 2 +- libavcodec/mimic.c | 2 +- libavcodec/mjpegdec.h | 2 +- libavcodec/mlp_parser.c | 2 +- libavcodec/mlp_parser.h | 2 +- libavcodec/mlpdec.c | 2 +- libavcodec/motionpixels.c | 2 +- libavcodec/mpc.c | 2 +- libavcodec/mpc.h | 2 +- libavcodec/mpc7.c | 2 +- libavcodec/mpc8.c | 2 +- libavcodec/mpeg4audio.c | 2 +- libavcodec/mpegaudio.h | 2 +- libavcodec/mpegaudiodec.c | 2 +- libavcodec/mpegvideo.h | 2 +- libavcodec/msmpeg4data.h | 2 +- libavcodec/nellymoser.c | 2 +- libavcodec/nellymoserdec.c | 2 +- libavcodec/pcm.c | 2 +- libavcodec/pcx.c | 2 +- libavcodec/pixdesc.h | 2 +- libavcodec/qcelpdec.c | 2 +- libavcodec/qdm2.c | 2 +- libavcodec/ra144.c | 2 +- libavcodec/ra288.c | 2 +- libavcodec/rl.h | 2 +- libavcodec/rtjpeg.c | 2 +- libavcodec/shorten.c | 2 +- libavcodec/smacker.c | 2 +- libavcodec/sonic.c | 2 +- libavcodec/tiertexseqv.c | 2 +- libavcodec/truemotion2.c | 2 +- libavcodec/tta.c | 2 +- libavcodec/unary.h | 2 +- libavcodec/vc1data.h | 2 +- libavcodec/vorbis.c | 2 +- libavcodec/vorbis_dec.c | 2 +- libavcodec/vp3.c | 2 +- libavcodec/vp5.c | 2 +- libavcodec/vp56.h | 2 +- libavcodec/vp6.c | 2 +- libavcodec/wavpack.c | 2 +- libavcodec/wma.h | 2 +- libavcodec/wnv1.c | 2 +- libavcodec/xsubdec.c | 2 +- 101 files changed, 804 insertions(+), 804 deletions(-) delete mode 100644 libavcodec/bitstream.h create mode 100644 libavcodec/get_bits.h (limited to 'libavcodec') diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c index 8f6ec3a00e..7aae23a678 100644 --- a/libavcodec/4xm.c +++ b/libavcodec/4xm.c @@ -27,7 +27,7 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" #include "bytestream.h" //#undef NDEBUG diff --git a/libavcodec/aac.c b/libavcodec/aac.c index 7ba3d946fc..b950ec9b56 100644 --- a/libavcodec/aac.c +++ b/libavcodec/aac.c @@ -78,7 +78,7 @@ #include "avcodec.h" #include "internal.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "lpc.h" diff --git a/libavcodec/aac_parser.c b/libavcodec/aac_parser.c index 09f074b8b5..70d733a9a1 100644 --- a/libavcodec/aac_parser.c +++ b/libavcodec/aac_parser.c @@ -23,7 +23,7 @@ #include "parser.h" #include "aac_ac3_parser.h" #include "aac_parser.h" -#include "bitstream.h" +#include "get_bits.h" #include "mpeg4audio.h" #define AAC_HEADER_SIZE 7 diff --git a/libavcodec/aac_parser.h b/libavcodec/aac_parser.h index efc46785cd..bae1a895fa 100644 --- a/libavcodec/aac_parser.h +++ b/libavcodec/aac_parser.h @@ -25,7 +25,7 @@ #include #include "aac_ac3_parser.h" -#include "bitstream.h" +#include "get_bits.h" typedef struct { uint32_t sample_rate; diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index fb7b6b18ca..cdc8ba0405 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -32,7 +32,7 @@ ***********************************/ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "mpeg4audio.h" diff --git a/libavcodec/ac3.c b/libavcodec/ac3.c index 244fdf33c5..84862c69e9 100644 --- a/libavcodec/ac3.c +++ b/libavcodec/ac3.c @@ -26,7 +26,7 @@ #include "avcodec.h" #include "ac3.h" -#include "bitstream.h" +#include "get_bits.h" static uint8_t band_start_tab[51]; static uint8_t bin_to_band_tab[253]; diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c index baa18fd755..35d8a17fb1 100644 --- a/libavcodec/ac3_parser.c +++ b/libavcodec/ac3_parser.c @@ -23,7 +23,7 @@ #include "parser.h" #include "ac3_parser.h" #include "aac_ac3_parser.h" -#include "bitstream.h" +#include "get_bits.h" #define AC3_HEADER_SIZE 7 diff --git a/libavcodec/ac3_parser.h b/libavcodec/ac3_parser.h index 0d235df022..766c68b2bc 100644 --- a/libavcodec/ac3_parser.h +++ b/libavcodec/ac3_parser.h @@ -24,7 +24,7 @@ #define AVCODEC_AC3_PARSER_H #include "ac3.h" -#include "bitstream.h" +#include "get_bits.h" /** * Parses AC-3 frame header. diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h index 4e513d2710..29eb04182e 100644 --- a/libavcodec/ac3dec.h +++ b/libavcodec/ac3dec.h @@ -30,7 +30,7 @@ #include "libavutil/internal.h" #include "libavutil/lfg.h" #include "ac3.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" /* override ac3.h to include coupling channel */ diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 190bc38c1a..c00d9d63ba 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -27,7 +27,7 @@ //#define DEBUG_BITALLOC #include "libavutil/crc.h" #include "avcodec.h" -#include "bitstream.h" // for ff_reverse +#include "get_bits.h" // for ff_reverse #include "put_bits.h" #include "ac3.h" diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 59c7cabcd9..a72ee20dab 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" #include "bytestream.h" diff --git a/libavcodec/alac.c b/libavcodec/alac.c index b9715eef85..5c48a4b28f 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -53,7 +53,7 @@ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "bytestream.h" #include "unary.h" #include "mathops.h" diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index fe1f56ac31..f8a18b9556 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -20,7 +20,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" #include "dsputil.h" #include "lpc.h" diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 0305d7b4ec..9b8d707135 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -23,7 +23,7 @@ #define ALT_BITSTREAM_READER_LE #include "avcodec.h" #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" #include "bytestream.h" /** diff --git a/libavcodec/asv1.c b/libavcodec/asv1.c index 0bbf3e63f0..10fbac24bc 100644 --- a/libavcodec/asv1.c +++ b/libavcodec/asv1.c @@ -25,7 +25,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" #include "dsputil.h" #include "mpeg12data.h" diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index 811dc4fe0c..49a818e3a7 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -37,7 +37,7 @@ #include #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "bytestream.h" diff --git a/libavcodec/avs.c b/libavcodec/avs.c index c00ff5eaf5..a53a068c15 100644 --- a/libavcodec/avs.c +++ b/libavcodec/avs.c @@ -20,7 +20,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" typedef struct { diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 39dbe0411e..267fc818ec 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -28,7 +28,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" const uint8_t ff_log2_run[32]={ diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h deleted file mode 100644 index e6ce62cfe3..0000000000 --- a/libavcodec/bitstream.h +++ /dev/null @@ -1,705 +0,0 @@ -/* - * copyright (c) 2004 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file libavcodec/bitstream.h - * bitstream api header. - */ - -#ifndef AVCODEC_BITSTREAM_H -#define AVCODEC_BITSTREAM_H - -#include -#include -#include -#include "libavutil/bswap.h" -#include "libavutil/common.h" -#include "libavutil/intreadwrite.h" -#include "libavutil/log.h" -#include "mathops.h" - -#if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER) -# define ALT_BITSTREAM_READER -#endif - -#if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER) -# if ARCH_ARM -# define A32_BITSTREAM_READER -# else -# define ALT_BITSTREAM_READER -//#define LIBMPEG2_BITSTREAM_READER -//#define A32_BITSTREAM_READER -# endif -#endif - -extern const uint8_t ff_reverse[256]; - -#if ARCH_X86 -// avoid +32 for shift optimization (gcc should do that ...) -static inline int32_t NEG_SSR32( int32_t a, int8_t s){ - __asm__ ("sarl %1, %0\n\t" - : "+r" (a) - : "ic" ((uint8_t)(-s)) - ); - return a; -} -static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ - __asm__ ("shrl %1, %0\n\t" - : "+r" (a) - : "ic" ((uint8_t)(-s)) - ); - return a; -} -#else -# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) -# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) -#endif - -/* bit input */ -/* buffer, buffer_end and size_in_bits must be present and used by every reader */ -typedef struct GetBitContext { - const uint8_t *buffer, *buffer_end; -#ifdef ALT_BITSTREAM_READER - int index; -#elif defined LIBMPEG2_BITSTREAM_READER - uint8_t *buffer_ptr; - uint32_t cache; - int bit_count; -#elif defined A32_BITSTREAM_READER - uint32_t *buffer_ptr; - uint32_t cache0; - uint32_t cache1; - int bit_count; -#endif - int size_in_bits; -} GetBitContext; - -#define VLC_TYPE int16_t - -typedef struct VLC { - int bits; - VLC_TYPE (*table)[2]; ///< code, bits - int table_size, table_allocated; -} VLC; - -typedef struct RL_VLC_ELEM { - int16_t level; - int8_t len; - uint8_t run; -} RL_VLC_ELEM; - -/* Bitstream reader API docs: -name - arbitrary name which is used as prefix for the internal variables - -gb - getbitcontext - -OPEN_READER(name, gb) - loads gb into local variables - -CLOSE_READER(name, gb) - stores local vars in gb - -UPDATE_CACHE(name, gb) - refills the internal cache from the bitstream - after this call at least MIN_CACHE_BITS will be available, - -GET_CACHE(name, gb) - will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit) - -SHOW_UBITS(name, gb, num) - will return the next num bits - -SHOW_SBITS(name, gb, num) - will return the next num bits and do sign extension - -SKIP_BITS(name, gb, num) - will skip over the next num bits - note, this is equivalent to SKIP_CACHE; SKIP_COUNTER - -SKIP_CACHE(name, gb, num) - will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER) - -SKIP_COUNTER(name, gb, num) - will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS) - -LAST_SKIP_CACHE(name, gb, num) - will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing - -LAST_SKIP_BITS(name, gb, num) - is equivalent to SKIP_LAST_CACHE; SKIP_COUNTER - -for examples see get_bits, show_bits, skip_bits, get_vlc -*/ - -#ifdef ALT_BITSTREAM_READER -# define MIN_CACHE_BITS 25 - -# define OPEN_READER(name, gb)\ - int name##_index= (gb)->index;\ - int name##_cache= 0;\ - -# define CLOSE_READER(name, gb)\ - (gb)->index= name##_index;\ - -# ifdef ALT_BITSTREAM_READER_LE -# define UPDATE_CACHE(name, gb)\ - name##_cache= AV_RL32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\ - -# define SKIP_CACHE(name, gb, num)\ - name##_cache >>= (num); -# else -# define UPDATE_CACHE(name, gb)\ - name##_cache= AV_RB32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\ - -# define SKIP_CACHE(name, gb, num)\ - name##_cache <<= (num); -# endif - -// FIXME name? -# define SKIP_COUNTER(name, gb, num)\ - name##_index += (num);\ - -# define SKIP_BITS(name, gb, num)\ - {\ - SKIP_CACHE(name, gb, num)\ - SKIP_COUNTER(name, gb, num)\ - }\ - -# define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num) -# define LAST_SKIP_CACHE(name, gb, num) ; - -# ifdef ALT_BITSTREAM_READER_LE -# define SHOW_UBITS(name, gb, num)\ - ((name##_cache) & (NEG_USR32(0xffffffff,num))) - -# define SHOW_SBITS(name, gb, num)\ - NEG_SSR32((name##_cache)<<(32-(num)), num) -# else -# define SHOW_UBITS(name, gb, num)\ - NEG_USR32(name##_cache, num) - -# define SHOW_SBITS(name, gb, num)\ - NEG_SSR32(name##_cache, num) -# endif - -# define GET_CACHE(name, gb)\ - ((uint32_t)name##_cache) - -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 - -# define MIN_CACHE_BITS 17 - -# define OPEN_READER(name, gb)\ - int name##_bit_count=(gb)->bit_count;\ - int name##_cache= (gb)->cache;\ - uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\ - -# define CLOSE_READER(name, gb)\ - (gb)->bit_count= name##_bit_count;\ - (gb)->cache= name##_cache;\ - (gb)->buffer_ptr= name##_buffer_ptr;\ - -# define UPDATE_CACHE(name, gb)\ - if(name##_bit_count >= 0){\ - name##_cache+= AV_RB16(name##_buffer_ptr) << name##_bit_count; \ - name##_buffer_ptr+=2;\ - name##_bit_count-= 16;\ - }\ - -# define SKIP_CACHE(name, gb, num)\ - name##_cache <<= (num);\ - -# define SKIP_COUNTER(name, gb, num)\ - name##_bit_count += (num);\ - -# define SKIP_BITS(name, gb, num)\ - {\ - SKIP_CACHE(name, gb, num)\ - SKIP_COUNTER(name, gb, num)\ - }\ - -# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num) -# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num) - -# define SHOW_UBITS(name, gb, num)\ - NEG_USR32(name##_cache, num) - -# define SHOW_SBITS(name, gb, num)\ - NEG_SSR32(name##_cache, num) - -# define GET_CACHE(name, gb)\ - ((uint32_t)name##_cache) - -static inline int get_bits_count(GetBitContext *s){ - return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count; -} - -static inline void skip_bits_long(GetBitContext *s, int n){ - OPEN_READER(re, s) - re_bit_count += n; - re_buffer_ptr += 2*(re_bit_count>>4); - re_bit_count &= 15; - re_cache = ((re_buffer_ptr[-2]<<8) + re_buffer_ptr[-1]) << (16+re_bit_count); - UPDATE_CACHE(re, s) - CLOSE_READER(re, s) -} - -#elif defined A32_BITSTREAM_READER - -# define MIN_CACHE_BITS 32 - -# define OPEN_READER(name, gb)\ - int name##_bit_count=(gb)->bit_count;\ - uint32_t name##_cache0= (gb)->cache0;\ - uint32_t name##_cache1= (gb)->cache1;\ - uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\ - -# define CLOSE_READER(name, gb)\ - (gb)->bit_count= name##_bit_count;\ - (gb)->cache0= name##_cache0;\ - (gb)->cache1= name##_cache1;\ - (gb)->buffer_ptr= name##_buffer_ptr;\ - -# define UPDATE_CACHE(name, gb)\ - if(name##_bit_count > 0){\ - const uint32_t next= be2me_32( *name##_buffer_ptr );\ - name##_cache0 |= NEG_USR32(next,name##_bit_count);\ - name##_cache1 |= next<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 += re_bit_count>>5; - re_bit_count &= 31; - re_cache0 = be2me_32( re_buffer_ptr[-1] ) << re_bit_count; - re_cache1 = 0; - UPDATE_CACHE(re, s) - CLOSE_READER(re, s) -} - -#endif - -/** - * read mpeg1 dc style vlc (sign bit + mantisse with no MSB). - * if MSB not set it is negative - * @param n length in bits - * @author BERO - */ -static inline int get_xbits(GetBitContext *s, int n){ - register int sign; - register int32_t cache; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - cache = GET_CACHE(re,s); - sign=(~cache)>>31; - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) - return (NEG_USR32(sign ^ cache, n) ^ sign) - sign; -} - -static inline int get_sbits(GetBitContext *s, int n){ - register int tmp; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - tmp= SHOW_SBITS(re, s, n); - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) - return tmp; -} - -/** - * reads 1-17 bits. - * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't - */ -static inline unsigned int get_bits(GetBitContext *s, int n){ - register int tmp; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - tmp= SHOW_UBITS(re, s, n); - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) - return tmp; -} - -/** - * shows 1-17 bits. - * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't - */ -static inline unsigned int show_bits(GetBitContext *s, int n){ - register int tmp; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - tmp= SHOW_UBITS(re, s, n); -// CLOSE_READER(re, s) - return tmp; -} - -static inline void skip_bits(GetBitContext *s, int n){ - //Note gcc seems to optimize this to s->index+=n for the ALT_READER :)) - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) -} - -static inline unsigned int get_bits1(GetBitContext *s){ -#ifdef ALT_BITSTREAM_READER - int index= s->index; - uint8_t result= s->buffer[ index>>3 ]; -#ifdef ALT_BITSTREAM_READER_LE - result>>= (index&0x07); - result&= 1; -#else - result<<= (index&0x07); - result>>= 8 - 1; -#endif - index++; - s->index= index; - - return result; -#else - return get_bits(s, 1); -#endif -} - -static inline unsigned int show_bits1(GetBitContext *s){ - return show_bits(s, 1); -} - -static inline void skip_bits1(GetBitContext *s){ - skip_bits(s, 1); -} - -/** - * reads 0-32 bits. - */ -static inline unsigned int get_bits_long(GetBitContext *s, int n){ - if(n<=17) return get_bits(s, n); - else{ -#ifdef ALT_BITSTREAM_READER_LE - int ret= get_bits(s, 16); - return ret | (get_bits(s, n-16) << 16); -#else - int ret= get_bits(s, 16) << (n-16); - return ret | get_bits(s, n-16); -#endif - } -} - -/** - * reads 0-32 bits as a signed integer. - */ -static inline int get_sbits_long(GetBitContext *s, int n) { - return sign_extend(get_bits_long(s, n), n); -} - -/** - * shows 0-32 bits. - */ -static inline unsigned int show_bits_long(GetBitContext *s, int n){ - if(n<=17) return show_bits(s, n); - else{ - GetBitContext gb= *s; - return get_bits_long(&gb, n); - } -} - -static inline int check_marker(GetBitContext *s, const char *msg) -{ - int bit= get_bits1(s); - if(!bit) - av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg); - - return bit; -} - -/** - * init GetBitContext. - * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits - * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end - * @param bit_size the size of the buffer in bits - */ -static inline void init_get_bits(GetBitContext *s, - const uint8_t *buffer, int bit_size) -{ - int buffer_size= (bit_size+7)>>3; - if(buffer_size < 0 || bit_size < 0) { - buffer_size = bit_size = 0; - buffer = NULL; - } - - s->buffer= buffer; - s->size_in_bits= bit_size; - s->buffer_end= buffer + buffer_size; -#ifdef ALT_BITSTREAM_READER - s->index=0; -#elif defined LIBMPEG2_BITSTREAM_READER - s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1)); - s->bit_count = 16 + 8*((intptr_t)buffer&1); - skip_bits_long(s, 0); -#elif defined A32_BITSTREAM_READER - s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3)); - s->bit_count = 32 + 8*((intptr_t)buffer&3); - skip_bits_long(s, 0); -#endif -} - -static inline void align_get_bits(GetBitContext *s) -{ - int n= (-get_bits_count(s)) & 7; - if(n) skip_bits(s, n); -} - -#define init_vlc(vlc, nb_bits, nb_codes,\ - bits, bits_wrap, bits_size,\ - codes, codes_wrap, codes_size,\ - flags)\ - init_vlc_sparse(vlc, nb_bits, nb_codes,\ - bits, bits_wrap, bits_size,\ - codes, codes_wrap, codes_size,\ - NULL, 0, 0, flags) - -int init_vlc_sparse(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, - const void *symbols, int symbols_wrap, int symbols_size, - int flags); -#define INIT_VLC_USE_STATIC 1 ///< VERY strongly deprecated and forbidden -#define INIT_VLC_LE 2 -#define INIT_VLC_USE_NEW_STATIC 4 -void free_vlc(VLC *vlc); - -#define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size)\ -{\ - static VLC_TYPE table[static_size][2];\ - (vlc)->table= table;\ - (vlc)->table_allocated= static_size;\ - init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC);\ -} - - -/** - * - * if the vlc code is invalid and max_depth=1 than no bits will be removed - * if the vlc code is invalid and max_depth>1 than the number of bits removed - * is undefined - */ -#define GET_VLC(code, name, gb, table, bits, max_depth)\ -{\ - int n, index, nb_bits;\ -\ - index= SHOW_UBITS(name, gb, bits);\ - code = table[index][0];\ - n = table[index][1];\ -\ - if(max_depth > 1 && n < 0){\ - LAST_SKIP_BITS(name, gb, bits)\ - UPDATE_CACHE(name, gb)\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + code;\ - code = table[index][0];\ - n = table[index][1];\ - if(max_depth > 2 && n < 0){\ - LAST_SKIP_BITS(name, gb, nb_bits)\ - UPDATE_CACHE(name, gb)\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + code;\ - code = table[index][0];\ - n = table[index][1];\ - }\ - }\ - SKIP_BITS(name, gb, n)\ -} - -#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\ -{\ - int n, index, nb_bits;\ -\ - index= SHOW_UBITS(name, gb, bits);\ - level = table[index].level;\ - n = table[index].len;\ -\ - if(max_depth > 1 && n < 0){\ - SKIP_BITS(name, gb, bits)\ - if(need_update){\ - UPDATE_CACHE(name, gb)\ - }\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + level;\ - level = table[index].level;\ - n = table[index].len;\ - }\ - run= table[index].run;\ - SKIP_BITS(name, gb, n)\ -} - - -/** - * parses a vlc code, faster then get_vlc() - * @param bits is the number of bits which will be read at once, must be - * identical to nb_bits in init_vlc() - * @param max_depth is the number of times bits bits must be read to completely - * read the longest vlc code - * = (max_vlc_length + bits - 1) / bits - */ -static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], - int bits, int max_depth) -{ - int code; - - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - - GET_VLC(code, re, s, table, bits, max_depth) - - CLOSE_READER(re, s) - return code; -} - -//#define TRACE - -#ifdef TRACE -static inline void print_bin(int bits, int n){ - int i; - - for(i=n-1; i>=0; i--){ - av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1); - } - for(i=n; i<24; i++) - av_log(NULL, AV_LOG_DEBUG, " "); -} - -static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ - int r= get_bits(s, n); - - print_bin(r, n); - av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line); - return r; -} -static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){ - int show= show_bits(s, 24); - int pos= get_bits_count(s); - int r= get_vlc2(s, table, bits, max_depth); - int len= get_bits_count(s) - pos; - int bits2= show>>(24-len); - - print_bin(bits2, len); - - av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line); - return r; -} -static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ - int show= show_bits(s, n); - int r= get_xbits(s, n); - - print_bin(show, n); - av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line); - return r; -} - -#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__) -#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__) - -#define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__) - -#else //TRACE -#define tprintf(p, ...) {} -#endif - -static inline int decode012(GetBitContext *gb){ - int n; - n = get_bits1(gb); - if (n == 0) - return 0; - else - return get_bits1(gb) + 1; -} - -static inline int decode210(GetBitContext *gb){ - if (get_bits1(gb)) - return 0; - else - return 2 - get_bits1(gb); -} - -#endif /* AVCODEC_BITSTREAM_H */ diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c index ffcd889c2e..9a3bdafb8f 100644 --- a/libavcodec/cabac.c +++ b/libavcodec/cabac.c @@ -27,7 +27,7 @@ #include #include "libavutil/common.h" -#include "bitstream.h" +#include "get_bits.h" #include "cabac.h" static const uint8_t lps_range[64][4]= { diff --git a/libavcodec/cavs.c b/libavcodec/cavs.c index f7338c6878..a201fe26c2 100644 --- a/libavcodec/cavs.c +++ b/libavcodec/cavs.c @@ -26,7 +26,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "golomb.h" #include "mathops.h" #include "cavs.h" diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c index c04cc39982..31e9ff39c6 100644 --- a/libavcodec/cavsdec.c +++ b/libavcodec/cavsdec.c @@ -26,7 +26,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "golomb.h" #include "cavs.h" diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c index 9157b00137..2164bf20f4 100644 --- a/libavcodec/cljr.c +++ b/libavcodec/cljr.c @@ -26,7 +26,7 @@ #include "avcodec.h" #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" /* Disable the encoder. */ #undef CONFIG_CLJR_ENCODER diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 9dd13bfef8..b8f74551eb 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -49,7 +49,7 @@ #include "libavutil/lfg.h" #include "libavutil/random_seed.h" #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "bytestream.h" diff --git a/libavcodec/dca.c b/libavcodec/dca.c index 86b9c8f6ab..64fe38e2ae 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -32,7 +32,7 @@ #include "avcodec.h" #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" #include "dcadata.h" #include "dcahuff.h" diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c index 2d3762b396..ed349d2b64 100644 --- a/libavcodec/dnxhddec.c +++ b/libavcodec/dnxhddec.c @@ -23,7 +23,7 @@ //#define DEBUG #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dnxhddata.h" #include "dsputil.h" diff --git a/libavcodec/dv.c b/libavcodec/dv.c index c11e33a31b..a43e6e43b6 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -40,7 +40,7 @@ #define ALT_BITSTREAM_READER #include "avcodec.h" #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" #include "simple_idct.h" #include "dvdata.h" diff --git a/libavcodec/dvbsub_parser.c b/libavcodec/dvbsub_parser.c index 96381df10e..11ade86627 100644 --- a/libavcodec/dvbsub_parser.c +++ b/libavcodec/dvbsub_parser.c @@ -20,7 +20,7 @@ */ #include "avcodec.h" #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" //#define DEBUG //#define DEBUG_PACKET_CONTENTS diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index e2e8d5f913..a0d0eb976d 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -20,7 +20,7 @@ */ #include "avcodec.h" #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" #include "colorspace.h" //#define DEBUG diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index ba1738089d..8abf700688 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "colorspace.h" #include "dsputil.h" diff --git a/libavcodec/eatgq.c b/libavcodec/eatgq.c index 05f03e7b05..bc1a072ecd 100644 --- a/libavcodec/eatgq.c +++ b/libavcodec/eatgq.c @@ -30,7 +30,7 @@ #include "avcodec.h" #define ALT_BITSTREAM_READER_LE -#include "bitstream.h" +#include "get_bits.h" #include "bytestream.h" #include "dsputil.h" #include "aandcttab.h" diff --git a/libavcodec/eatgv.c b/libavcodec/eatgv.c index 93a722ff25..f2fa2fa982 100644 --- a/libavcodec/eatgv.c +++ b/libavcodec/eatgv.c @@ -30,7 +30,7 @@ #include "avcodec.h" #define ALT_BITSTREAM_READER_LE -#include "bitstream.h" +#include "get_bits.h" #include "libavutil/lzo.h" #define EA_PREAMBLE_SIZE 8 diff --git a/libavcodec/eatqi.c b/libavcodec/eatqi.c index 2a62402345..55b4726ff0 100644 --- a/libavcodec/eatqi.c +++ b/libavcodec/eatqi.c @@ -29,7 +29,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "aandcttab.h" #include "mpeg12.h" diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c index 7f22b84c67..80b1484b75 100644 --- a/libavcodec/escape124.c +++ b/libavcodec/escape124.c @@ -22,7 +22,7 @@ #include "avcodec.h" #define ALT_BITSTREAM_READER_LE -#include "bitstream.h" +#include "get_bits.h" typedef union MacroBlock { uint16_t pixels[4]; diff --git a/libavcodec/faxcompr.c b/libavcodec/faxcompr.c index 8d5e857de7..9a9d1f5528 100644 --- a/libavcodec/faxcompr.c +++ b/libavcodec/faxcompr.c @@ -25,7 +25,7 @@ * @author Konstantin Shishkov */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" #include "faxcompr.h" diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 281a400a3e..c6767493af 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -26,7 +26,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" #include "dsputil.h" #include "rangecoder.h" diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index e6b52c7d1b..2d46ccda66 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -38,7 +38,7 @@ #include "libavutil/crc.h" #include "avcodec.h" #include "internal.h" -#include "bitstream.h" +#include "get_bits.h" #include "bytestream.h" #include "golomb.h" #include "flac.h" diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index b517cfa720..849650b43c 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -23,7 +23,7 @@ #include "libavutil/lls.h" #include "libavutil/md5.h" #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "golomb.h" #include "lpc.h" diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 91c04996eb..20c85e3ac0 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -51,7 +51,7 @@ #include #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index 6fac1680a7..e5f8f49b28 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -32,7 +32,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "huffman.h" #include "bytestream.h" #include "dsputil.h" diff --git a/libavcodec/g726.c b/libavcodec/g726.c index 383d08af63..3004041b08 100644 --- a/libavcodec/g726.c +++ b/libavcodec/g726.c @@ -23,7 +23,7 @@ */ #include #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" /** diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c index 5a0bd16df0..78444c1c09 100644 --- a/libavcodec/g729dec.c +++ b/libavcodec/g729dec.c @@ -28,7 +28,7 @@ #include "avcodec.h" #include "libavutil/avutil.h" -#include "bitstream.h" +#include "get_bits.h" #include "g729.h" #include "lsp.h" diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h new file mode 100644 index 0000000000..877f909a74 --- /dev/null +++ b/libavcodec/get_bits.h @@ -0,0 +1,705 @@ +/* + * copyright (c) 2004 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/get_bits.h + * bitstream reader API header. + */ + +#ifndef AVCODEC_GET_BITS_H +#define AVCODEC_GET_BITS_H + +#include +#include +#include +#include "libavutil/bswap.h" +#include "libavutil/common.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/log.h" +#include "mathops.h" + +#if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER) +# define ALT_BITSTREAM_READER +#endif + +#if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER) +# if ARCH_ARM +# define A32_BITSTREAM_READER +# else +# define ALT_BITSTREAM_READER +//#define LIBMPEG2_BITSTREAM_READER +//#define A32_BITSTREAM_READER +# endif +#endif + +extern const uint8_t ff_reverse[256]; + +#if ARCH_X86 +// avoid +32 for shift optimization (gcc should do that ...) +static inline int32_t NEG_SSR32( int32_t a, int8_t s){ + __asm__ ("sarl %1, %0\n\t" + : "+r" (a) + : "ic" ((uint8_t)(-s)) + ); + return a; +} +static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ + __asm__ ("shrl %1, %0\n\t" + : "+r" (a) + : "ic" ((uint8_t)(-s)) + ); + return a; +} +#else +# define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) +# define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) +#endif + +/* bit input */ +/* buffer, buffer_end and size_in_bits must be present and used by every reader */ +typedef struct GetBitContext { + const uint8_t *buffer, *buffer_end; +#ifdef ALT_BITSTREAM_READER + int index; +#elif defined LIBMPEG2_BITSTREAM_READER + uint8_t *buffer_ptr; + uint32_t cache; + int bit_count; +#elif defined A32_BITSTREAM_READER + uint32_t *buffer_ptr; + uint32_t cache0; + uint32_t cache1; + int bit_count; +#endif + int size_in_bits; +} GetBitContext; + +#define VLC_TYPE int16_t + +typedef struct VLC { + int bits; + VLC_TYPE (*table)[2]; ///< code, bits + int table_size, table_allocated; +} VLC; + +typedef struct RL_VLC_ELEM { + int16_t level; + int8_t len; + uint8_t run; +} RL_VLC_ELEM; + +/* Bitstream reader API docs: +name + arbitrary name which is used as prefix for the internal variables + +gb + getbitcontext + +OPEN_READER(name, gb) + loads gb into local variables + +CLOSE_READER(name, gb) + stores local vars in gb + +UPDATE_CACHE(name, gb) + refills the internal cache from the bitstream + after this call at least MIN_CACHE_BITS will be available, + +GET_CACHE(name, gb) + will output the contents of the internal cache, next bit is MSB of 32 or 64 bit (FIXME 64bit) + +SHOW_UBITS(name, gb, num) + will return the next num bits + +SHOW_SBITS(name, gb, num) + will return the next num bits and do sign extension + +SKIP_BITS(name, gb, num) + will skip over the next num bits + note, this is equivalent to SKIP_CACHE; SKIP_COUNTER + +SKIP_CACHE(name, gb, num) + will remove the next num bits from the cache (note SKIP_COUNTER MUST be called before UPDATE_CACHE / CLOSE_READER) + +SKIP_COUNTER(name, gb, num) + will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS) + +LAST_SKIP_CACHE(name, gb, num) + will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing + +LAST_SKIP_BITS(name, gb, num) + is equivalent to SKIP_LAST_CACHE; SKIP_COUNTER + +for examples see get_bits, show_bits, skip_bits, get_vlc +*/ + +#ifdef ALT_BITSTREAM_READER +# define MIN_CACHE_BITS 25 + +# define OPEN_READER(name, gb)\ + int name##_index= (gb)->index;\ + int name##_cache= 0;\ + +# define CLOSE_READER(name, gb)\ + (gb)->index= name##_index;\ + +# ifdef ALT_BITSTREAM_READER_LE +# define UPDATE_CACHE(name, gb)\ + name##_cache= AV_RL32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) >> (name##_index&0x07);\ + +# define SKIP_CACHE(name, gb, num)\ + name##_cache >>= (num); +# else +# define UPDATE_CACHE(name, gb)\ + name##_cache= AV_RB32( ((const uint8_t *)(gb)->buffer)+(name##_index>>3) ) << (name##_index&0x07);\ + +# define SKIP_CACHE(name, gb, num)\ + name##_cache <<= (num); +# endif + +// FIXME name? +# define SKIP_COUNTER(name, gb, num)\ + name##_index += (num);\ + +# define SKIP_BITS(name, gb, num)\ + {\ + SKIP_CACHE(name, gb, num)\ + SKIP_COUNTER(name, gb, num)\ + }\ + +# define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num) +# define LAST_SKIP_CACHE(name, gb, num) ; + +# ifdef ALT_BITSTREAM_READER_LE +# define SHOW_UBITS(name, gb, num)\ + ((name##_cache) & (NEG_USR32(0xffffffff,num))) + +# define SHOW_SBITS(name, gb, num)\ + NEG_SSR32((name##_cache)<<(32-(num)), num) +# else +# define SHOW_UBITS(name, gb, num)\ + NEG_USR32(name##_cache, num) + +# define SHOW_SBITS(name, gb, num)\ + NEG_SSR32(name##_cache, num) +# endif + +# define GET_CACHE(name, gb)\ + ((uint32_t)name##_cache) + +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 + +# define MIN_CACHE_BITS 17 + +# define OPEN_READER(name, gb)\ + int name##_bit_count=(gb)->bit_count;\ + int name##_cache= (gb)->cache;\ + uint8_t * name##_buffer_ptr=(gb)->buffer_ptr;\ + +# define CLOSE_READER(name, gb)\ + (gb)->bit_count= name##_bit_count;\ + (gb)->cache= name##_cache;\ + (gb)->buffer_ptr= name##_buffer_ptr;\ + +# define UPDATE_CACHE(name, gb)\ + if(name##_bit_count >= 0){\ + name##_cache+= AV_RB16(name##_buffer_ptr) << name##_bit_count; \ + name##_buffer_ptr+=2;\ + name##_bit_count-= 16;\ + }\ + +# define SKIP_CACHE(name, gb, num)\ + name##_cache <<= (num);\ + +# define SKIP_COUNTER(name, gb, num)\ + name##_bit_count += (num);\ + +# define SKIP_BITS(name, gb, num)\ + {\ + SKIP_CACHE(name, gb, num)\ + SKIP_COUNTER(name, gb, num)\ + }\ + +# define LAST_SKIP_BITS(name, gb, num) SKIP_BITS(name, gb, num) +# define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num) + +# define SHOW_UBITS(name, gb, num)\ + NEG_USR32(name##_cache, num) + +# define SHOW_SBITS(name, gb, num)\ + NEG_SSR32(name##_cache, num) + +# define GET_CACHE(name, gb)\ + ((uint32_t)name##_cache) + +static inline int get_bits_count(GetBitContext *s){ + return (s->buffer_ptr - s->buffer)*8 - 16 + s->bit_count; +} + +static inline void skip_bits_long(GetBitContext *s, int n){ + OPEN_READER(re, s) + re_bit_count += n; + re_buffer_ptr += 2*(re_bit_count>>4); + re_bit_count &= 15; + re_cache = ((re_buffer_ptr[-2]<<8) + re_buffer_ptr[-1]) << (16+re_bit_count); + UPDATE_CACHE(re, s) + CLOSE_READER(re, s) +} + +#elif defined A32_BITSTREAM_READER + +# define MIN_CACHE_BITS 32 + +# define OPEN_READER(name, gb)\ + int name##_bit_count=(gb)->bit_count;\ + uint32_t name##_cache0= (gb)->cache0;\ + uint32_t name##_cache1= (gb)->cache1;\ + uint32_t * name##_buffer_ptr=(gb)->buffer_ptr;\ + +# define CLOSE_READER(name, gb)\ + (gb)->bit_count= name##_bit_count;\ + (gb)->cache0= name##_cache0;\ + (gb)->cache1= name##_cache1;\ + (gb)->buffer_ptr= name##_buffer_ptr;\ + +# define UPDATE_CACHE(name, gb)\ + if(name##_bit_count > 0){\ + const uint32_t next= be2me_32( *name##_buffer_ptr );\ + name##_cache0 |= NEG_USR32(next,name##_bit_count);\ + name##_cache1 |= next<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 += re_bit_count>>5; + re_bit_count &= 31; + re_cache0 = be2me_32( re_buffer_ptr[-1] ) << re_bit_count; + re_cache1 = 0; + UPDATE_CACHE(re, s) + CLOSE_READER(re, s) +} + +#endif + +/** + * read mpeg1 dc style vlc (sign bit + mantisse with no MSB). + * if MSB not set it is negative + * @param n length in bits + * @author BERO + */ +static inline int get_xbits(GetBitContext *s, int n){ + register int sign; + register int32_t cache; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + cache = GET_CACHE(re,s); + sign=(~cache)>>31; + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) + return (NEG_USR32(sign ^ cache, n) ^ sign) - sign; +} + +static inline int get_sbits(GetBitContext *s, int n){ + register int tmp; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + tmp= SHOW_SBITS(re, s, n); + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) + return tmp; +} + +/** + * reads 1-17 bits. + * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't + */ +static inline unsigned int get_bits(GetBitContext *s, int n){ + register int tmp; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + tmp= SHOW_UBITS(re, s, n); + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) + return tmp; +} + +/** + * shows 1-17 bits. + * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't + */ +static inline unsigned int show_bits(GetBitContext *s, int n){ + register int tmp; + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + tmp= SHOW_UBITS(re, s, n); +// CLOSE_READER(re, s) + return tmp; +} + +static inline void skip_bits(GetBitContext *s, int n){ + //Note gcc seems to optimize this to s->index+=n for the ALT_READER :)) + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + LAST_SKIP_BITS(re, s, n) + CLOSE_READER(re, s) +} + +static inline unsigned int get_bits1(GetBitContext *s){ +#ifdef ALT_BITSTREAM_READER + int index= s->index; + uint8_t result= s->buffer[ index>>3 ]; +#ifdef ALT_BITSTREAM_READER_LE + result>>= (index&0x07); + result&= 1; +#else + result<<= (index&0x07); + result>>= 8 - 1; +#endif + index++; + s->index= index; + + return result; +#else + return get_bits(s, 1); +#endif +} + +static inline unsigned int show_bits1(GetBitContext *s){ + return show_bits(s, 1); +} + +static inline void skip_bits1(GetBitContext *s){ + skip_bits(s, 1); +} + +/** + * reads 0-32 bits. + */ +static inline unsigned int get_bits_long(GetBitContext *s, int n){ + if(n<=17) return get_bits(s, n); + else{ +#ifdef ALT_BITSTREAM_READER_LE + int ret= get_bits(s, 16); + return ret | (get_bits(s, n-16) << 16); +#else + int ret= get_bits(s, 16) << (n-16); + return ret | get_bits(s, n-16); +#endif + } +} + +/** + * reads 0-32 bits as a signed integer. + */ +static inline int get_sbits_long(GetBitContext *s, int n) { + return sign_extend(get_bits_long(s, n), n); +} + +/** + * shows 0-32 bits. + */ +static inline unsigned int show_bits_long(GetBitContext *s, int n){ + if(n<=17) return show_bits(s, n); + else{ + GetBitContext gb= *s; + return get_bits_long(&gb, n); + } +} + +static inline int check_marker(GetBitContext *s, const char *msg) +{ + int bit= get_bits1(s); + if(!bit) + av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg); + + return bit; +} + +/** + * init GetBitContext. + * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits + * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end + * @param bit_size the size of the buffer in bits + */ +static inline void init_get_bits(GetBitContext *s, + const uint8_t *buffer, int bit_size) +{ + int buffer_size= (bit_size+7)>>3; + if(buffer_size < 0 || bit_size < 0) { + buffer_size = bit_size = 0; + buffer = NULL; + } + + s->buffer= buffer; + s->size_in_bits= bit_size; + s->buffer_end= buffer + buffer_size; +#ifdef ALT_BITSTREAM_READER + s->index=0; +#elif defined LIBMPEG2_BITSTREAM_READER + s->buffer_ptr = (uint8_t*)((intptr_t)buffer&(~1)); + s->bit_count = 16 + 8*((intptr_t)buffer&1); + skip_bits_long(s, 0); +#elif defined A32_BITSTREAM_READER + s->buffer_ptr = (uint32_t*)((intptr_t)buffer&(~3)); + s->bit_count = 32 + 8*((intptr_t)buffer&3); + skip_bits_long(s, 0); +#endif +} + +static inline void align_get_bits(GetBitContext *s) +{ + int n= (-get_bits_count(s)) & 7; + if(n) skip_bits(s, n); +} + +#define init_vlc(vlc, nb_bits, nb_codes,\ + bits, bits_wrap, bits_size,\ + codes, codes_wrap, codes_size,\ + flags)\ + init_vlc_sparse(vlc, nb_bits, nb_codes,\ + bits, bits_wrap, bits_size,\ + codes, codes_wrap, codes_size,\ + NULL, 0, 0, flags) + +int init_vlc_sparse(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, + const void *symbols, int symbols_wrap, int symbols_size, + int flags); +#define INIT_VLC_USE_STATIC 1 ///< VERY strongly deprecated and forbidden +#define INIT_VLC_LE 2 +#define INIT_VLC_USE_NEW_STATIC 4 +void free_vlc(VLC *vlc); + +#define INIT_VLC_STATIC(vlc, bits, a,b,c,d,e,f,g, static_size)\ +{\ + static VLC_TYPE table[static_size][2];\ + (vlc)->table= table;\ + (vlc)->table_allocated= static_size;\ + init_vlc(vlc, bits, a,b,c,d,e,f,g, INIT_VLC_USE_NEW_STATIC);\ +} + + +/** + * + * if the vlc code is invalid and max_depth=1 than no bits will be removed + * if the vlc code is invalid and max_depth>1 than the number of bits removed + * is undefined + */ +#define GET_VLC(code, name, gb, table, bits, max_depth)\ +{\ + int n, index, nb_bits;\ +\ + index= SHOW_UBITS(name, gb, bits);\ + code = table[index][0];\ + n = table[index][1];\ +\ + if(max_depth > 1 && n < 0){\ + LAST_SKIP_BITS(name, gb, bits)\ + UPDATE_CACHE(name, gb)\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + code;\ + code = table[index][0];\ + n = table[index][1];\ + if(max_depth > 2 && n < 0){\ + LAST_SKIP_BITS(name, gb, nb_bits)\ + UPDATE_CACHE(name, gb)\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + code;\ + code = table[index][0];\ + n = table[index][1];\ + }\ + }\ + SKIP_BITS(name, gb, n)\ +} + +#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)\ +{\ + int n, index, nb_bits;\ +\ + index= SHOW_UBITS(name, gb, bits);\ + level = table[index].level;\ + n = table[index].len;\ +\ + if(max_depth > 1 && n < 0){\ + SKIP_BITS(name, gb, bits)\ + if(need_update){\ + UPDATE_CACHE(name, gb)\ + }\ +\ + nb_bits = -n;\ +\ + index= SHOW_UBITS(name, gb, nb_bits) + level;\ + level = table[index].level;\ + n = table[index].len;\ + }\ + run= table[index].run;\ + SKIP_BITS(name, gb, n)\ +} + + +/** + * parses a vlc code, faster then get_vlc() + * @param bits is the number of bits which will be read at once, must be + * identical to nb_bits in init_vlc() + * @param max_depth is the number of times bits bits must be read to completely + * read the longest vlc code + * = (max_vlc_length + bits - 1) / bits + */ +static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], + int bits, int max_depth) +{ + int code; + + OPEN_READER(re, s) + UPDATE_CACHE(re, s) + + GET_VLC(code, re, s, table, bits, max_depth) + + CLOSE_READER(re, s) + return code; +} + +//#define TRACE + +#ifdef TRACE +static inline void print_bin(int bits, int n){ + int i; + + for(i=n-1; i>=0; i--){ + av_log(NULL, AV_LOG_DEBUG, "%d", (bits>>i)&1); + } + for(i=n; i<24; i++) + av_log(NULL, AV_LOG_DEBUG, " "); +} + +static inline int get_bits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ + int r= get_bits(s, n); + + print_bin(r, n); + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d bit @%5d in %s %s:%d\n", r, n, r, get_bits_count(s)-n, file, func, line); + return r; +} +static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2], int bits, int max_depth, char *file, const char *func, int line){ + int show= show_bits(s, 24); + int pos= get_bits_count(s); + int r= get_vlc2(s, table, bits, max_depth); + int len= get_bits_count(s) - pos; + int bits2= show>>(24-len); + + print_bin(bits2, len); + + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d vlc @%5d in %s %s:%d\n", bits2, len, r, pos, file, func, line); + return r; +} +static inline int get_xbits_trace(GetBitContext *s, int n, char *file, const char *func, int line){ + int show= show_bits(s, n); + int r= get_xbits(s, n); + + print_bin(show, n); + av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d xbt @%5d in %s %s:%d\n", show, n, r, get_bits_count(s)-n, file, func, line); + return r; +} + +#define get_bits(s, n) get_bits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_bits1(s) get_bits_trace(s, 1, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_xbits(s, n) get_xbits_trace(s, n, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_vlc(s, vlc) get_vlc_trace(s, (vlc)->table, (vlc)->bits, 3, __FILE__, __PRETTY_FUNCTION__, __LINE__) +#define get_vlc2(s, tab, bits, max) get_vlc_trace(s, tab, bits, max, __FILE__, __PRETTY_FUNCTION__, __LINE__) + +#define tprintf(p, ...) av_log(p, AV_LOG_DEBUG, __VA_ARGS__) + +#else //TRACE +#define tprintf(p, ...) {} +#endif + +static inline int decode012(GetBitContext *gb){ + int n; + n = get_bits1(gb); + if (n == 0) + return 0; + else + return get_bits1(gb) + 1; +} + +static inline int decode210(GetBitContext *gb){ + if (get_bits1(gb)) + return 0; + else + return 2 - get_bits1(gb); +} + +#endif /* AVCODEC_GET_BITS_H */ diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h index be64f2533e..7044042c95 100644 --- a/libavcodec/golomb.h +++ b/libavcodec/golomb.h @@ -31,7 +31,7 @@ #define AVCODEC_GOLOMB_H #include -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" #define INVALID_VLC 0x80000000 diff --git a/libavcodec/h264enc.c b/libavcodec/h264enc.c index 788e0ae858..5693336b55 100644 --- a/libavcodec/h264enc.c +++ b/libavcodec/h264enc.c @@ -20,7 +20,7 @@ #include "libavutil/common.h" -#include "bitstream.h" +#include "get_bits.h" #include "mpegvideo.h" #include "h264data.h" diff --git a/libavcodec/huffman.c b/libavcodec/huffman.c index 286ac677a1..10dd2b09d0 100644 --- a/libavcodec/huffman.c +++ b/libavcodec/huffman.c @@ -21,7 +21,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "huffman.h" /* symbol for Huffman tree node */ diff --git a/libavcodec/huffman.h b/libavcodec/huffman.h index 594013e0bb..d56c7274b0 100644 --- a/libavcodec/huffman.h +++ b/libavcodec/huffman.h @@ -24,7 +24,7 @@ #define AVCODEC_HUFFMAN_H #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" typedef struct { int16_t sym; diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index de1118dd1d..27de662804 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -29,7 +29,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" #include "dsputil.h" diff --git a/libavcodec/imc.c b/libavcodec/imc.c index ff50d4b59b..93093ebd53 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -36,7 +36,7 @@ #define ALT_BITSTREAM_READER #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "imcdata.h" diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index 75b9ee9836..a107574a26 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -25,7 +25,7 @@ */ #define ALT_BITSTREAM_READER_LE #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "indeo2data.h" typedef struct Ir2Context{ diff --git a/libavcodec/intrax8.c b/libavcodec/intrax8.c index 177b60f34e..9971e6479b 100644 --- a/libavcodec/intrax8.c +++ b/libavcodec/intrax8.c @@ -22,7 +22,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "mpegvideo.h" #include "msmpeg4data.h" #include "intrax8huf.h" diff --git a/libavcodec/intrax8.h b/libavcodec/intrax8.h index 5f63e6abf3..8ce4f8d098 100644 --- a/libavcodec/intrax8.h +++ b/libavcodec/intrax8.h @@ -19,7 +19,7 @@ #ifndef AVCODEC_INTRAX8_H #define AVCODEC_INTRAX8_H -#include "bitstream.h" +#include "get_bits.h" #include "mpegvideo.h" typedef struct{ diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index fdf4c4c424..bc80d13d68 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -26,7 +26,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "golomb.h" #include "mathops.h" #include "mjpeg.h" diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index 8bad77a3bf..4224a24633 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -26,7 +26,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "golomb.h" #include "mathops.h" #include "dsputil.h" diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c index 9c0d8d75d6..e4114f88ca 100644 --- a/libavcodec/lcldec.c +++ b/libavcodec/lcldec.c @@ -42,7 +42,7 @@ #include #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "lcl.h" #if CONFIG_ZLIB diff --git a/libavcodec/loco.c b/libavcodec/loco.c index fc7b44075f..4fd64f4bda 100644 --- a/libavcodec/loco.c +++ b/libavcodec/loco.c @@ -25,7 +25,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "golomb.h" #include "mathops.h" diff --git a/libavcodec/lzw.h b/libavcodec/lzw.h index ea64eef17e..601d01fd67 100644 --- a/libavcodec/lzw.h +++ b/libavcodec/lzw.h @@ -30,7 +30,7 @@ #ifndef AVCODEC_LZW_H #define AVCODEC_LZW_H -#include "bitstream.h" +#include "get_bits.h" enum FF_LZW_MODES{ FF_LZW_GIF, diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 42ae53e7e2..a0af430c76 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -24,7 +24,7 @@ #include #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "bytestream.h" #include "dsputil.h" diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h index a0974201d2..5a77759b3c 100644 --- a/libavcodec/mjpegdec.h +++ b/libavcodec/mjpegdec.h @@ -30,7 +30,7 @@ #define AVCODEC_MJPEGDEC_H #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #define MAX_COMPONENTS 4 diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c index 34ee193da2..42295cc352 100644 --- a/libavcodec/mlp_parser.c +++ b/libavcodec/mlp_parser.c @@ -27,7 +27,7 @@ #include #include "libavutil/crc.h" -#include "bitstream.h" +#include "get_bits.h" #include "parser.h" #include "mlp_parser.h" #include "mlp.h" diff --git a/libavcodec/mlp_parser.h b/libavcodec/mlp_parser.h index 634ed0da74..5e8861b94f 100644 --- a/libavcodec/mlp_parser.h +++ b/libavcodec/mlp_parser.h @@ -27,7 +27,7 @@ #ifndef AVCODEC_MLP_PARSER_H #define AVCODEC_MLP_PARSER_H -#include "bitstream.h" +#include "get_bits.h" typedef struct MLPHeaderInfo { diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index ba374c9dfa..e74d146af0 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -28,7 +28,7 @@ #include "avcodec.h" #include "libavutil/intreadwrite.h" -#include "bitstream.h" +#include "get_bits.h" #include "libavutil/crc.h" #include "parser.h" #include "mlp_parser.h" diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index dcdd5d2757..6f9aac47df 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -20,7 +20,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #define MAX_HUFF_CODES 16 diff --git a/libavcodec/mpc.c b/libavcodec/mpc.c index 441adeea57..f8fe4c4bc3 100644 --- a/libavcodec/mpc.c +++ b/libavcodec/mpc.c @@ -26,7 +26,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "mpegaudio.h" diff --git a/libavcodec/mpc.h b/libavcodec/mpc.h index 2720afefaf..738aede6c5 100644 --- a/libavcodec/mpc.h +++ b/libavcodec/mpc.h @@ -30,7 +30,7 @@ #include "libavutil/lfg.h" #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "mpegaudio.h" diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index 8bc05d5375..2c4083fb73 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -27,7 +27,7 @@ #include "libavutil/lfg.h" #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "mpegaudio.h" diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index d72e36f306..5ffd82864d 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -27,7 +27,7 @@ #include "libavutil/lfg.h" #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "mpegaudio.h" diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c index 9c7e02b751..792f41d9e2 100644 --- a/libavcodec/mpeg4audio.c +++ b/libavcodec/mpeg4audio.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "bitstream.h" +#include "get_bits.h" #include "mpeg4audio.h" const int ff_mpeg4audio_sample_rates[16] = { diff --git a/libavcodec/mpegaudio.h b/libavcodec/mpegaudio.h index e55e6d682e..65a2283fba 100644 --- a/libavcodec/mpegaudio.h +++ b/libavcodec/mpegaudio.h @@ -27,7 +27,7 @@ #define AVCODEC_MPEGAUDIO_H #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #define CONFIG_AUDIO_NONSHORT 0 diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index 8c052a4d5d..404c21a7c0 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -25,7 +25,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" /* diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index ab90bef5f2..6240aac639 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -29,7 +29,7 @@ #define AVCODEC_MPEGVIDEO_H #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" #include "ratecontrol.h" #include "parser.h" diff --git a/libavcodec/msmpeg4data.h b/libavcodec/msmpeg4data.h index 7492b0b16f..69d542fe6f 100644 --- a/libavcodec/msmpeg4data.h +++ b/libavcodec/msmpeg4data.h @@ -31,7 +31,7 @@ #define AVCODEC_MSMPEG4DATA_H #include "libavutil/common.h" -#include "bitstream.h" +#include "get_bits.h" #include "rl.h" /* motion vector table */ diff --git a/libavcodec/nellymoser.c b/libavcodec/nellymoser.c index 00c2cfd3a1..08559e68c7 100644 --- a/libavcodec/nellymoser.c +++ b/libavcodec/nellymoser.c @@ -36,7 +36,7 @@ #include "dsputil.h" #define ALT_BITSTREAM_READER_LE -#include "bitstream.h" +#include "get_bits.h" const float ff_nelly_dequantization_table[127] = { 0.0000000000, diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c index 5ea2547a76..cf4a916260 100644 --- a/libavcodec/nellymoserdec.c +++ b/libavcodec/nellymoserdec.c @@ -38,7 +38,7 @@ #include "dsputil.h" #define ALT_BITSTREAM_READER_LE -#include "bitstream.h" +#include "get_bits.h" typedef struct NellyMoserDecodeContext { diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index b30e2fe70b..ca42b53f8d 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -25,7 +25,7 @@ */ #include "avcodec.h" -#include "bitstream.h" // for ff_reverse +#include "get_bits.h" // for ff_reverse #include "bytestream.h" #define MAX_CHANNELS 64 diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c index 23a808d633..dde01bedf4 100644 --- a/libavcodec/pcx.c +++ b/libavcodec/pcx.c @@ -24,7 +24,7 @@ #include "avcodec.h" #include "bytestream.h" -#include "bitstream.h" +#include "get_bits.h" typedef struct PCXContext { AVFrame picture; diff --git a/libavcodec/pixdesc.h b/libavcodec/pixdesc.h index 6ad217acee..11a437803b 100644 --- a/libavcodec/pixdesc.h +++ b/libavcodec/pixdesc.h @@ -22,7 +22,7 @@ #include #include "libavutil/intreadwrite.h" -#include "libavcodec/bitstream.h" +#include "libavcodec/get_bits.h" typedef struct AVComponentDescriptor{ uint16_t plane :2; ///< which of the 4 planes contains the component diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c index 516965c7cf..eff57cfecf 100644 --- a/libavcodec/qcelpdec.c +++ b/libavcodec/qcelpdec.c @@ -31,7 +31,7 @@ #include "avcodec.h" #include "internal.h" -#include "bitstream.h" +#include "get_bits.h" #include "qcelpdata.h" diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 6dafd0aabd..25d0ec11cc 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -36,7 +36,7 @@ #define ALT_BITSTREAM_READER_LE #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "mpegaudio.h" diff --git a/libavcodec/ra144.c b/libavcodec/ra144.c index a4e4943952..81a29086ca 100644 --- a/libavcodec/ra144.c +++ b/libavcodec/ra144.c @@ -23,7 +23,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "ra144.h" #include "celp_filters.h" diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c index 437adb355b..abc7df51bd 100644 --- a/libavcodec/ra288.c +++ b/libavcodec/ra288.c @@ -21,7 +21,7 @@ #include "avcodec.h" #define ALT_BITSTREAM_READER_LE -#include "bitstream.h" +#include "get_bits.h" #include "ra288.h" #include "lpc.h" #include "celp_math.h" diff --git a/libavcodec/rl.h b/libavcodec/rl.h index 6d40a14224..64cbeddfaa 100644 --- a/libavcodec/rl.h +++ b/libavcodec/rl.h @@ -28,7 +28,7 @@ #define AVCODEC_RL_H #include -#include "bitstream.h" +#include "get_bits.h" /* run length table */ #define MAX_RUN 64 diff --git a/libavcodec/rtjpeg.c b/libavcodec/rtjpeg.c index 218c7dd4c2..d9ca035158 100644 --- a/libavcodec/rtjpeg.c +++ b/libavcodec/rtjpeg.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavutil/common.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "rtjpeg.h" diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 8f7149af0a..328aaccd29 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -29,7 +29,7 @@ #define DEBUG #include #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "golomb.h" #define MAX_CHANNELS 8 diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index ac638f8522..fca693add4 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -34,7 +34,7 @@ #include "avcodec.h" #define ALT_BITSTREAM_READER_LE -#include "bitstream.h" +#include "get_bits.h" #include "bytestream.h" #define SMKTREE_BITS 9 diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index 7db8b3c957..00ae835873 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "golomb.h" /** diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c index 0970370713..66055937fe 100644 --- a/libavcodec/tiertexseqv.c +++ b/libavcodec/tiertexseqv.c @@ -26,7 +26,7 @@ #include "avcodec.h" #define ALT_BITSTREAM_READER_LE -#include "bitstream.h" +#include "get_bits.h" typedef struct SeqVideoContext { diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c index b3289162ee..da7a2c28be 100644 --- a/libavcodec/truemotion2.c +++ b/libavcodec/truemotion2.c @@ -25,7 +25,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #define TM2_ESCAPE 0x80000000 diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 3ab31e6629..b26724b528 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -31,7 +31,7 @@ //#define DEBUG #include #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #define FORMAT_INT 1 #define FORMAT_FLOAT 3 diff --git a/libavcodec/unary.h b/libavcodec/unary.h index 5484be4d56..908dc93507 100644 --- a/libavcodec/unary.h +++ b/libavcodec/unary.h @@ -21,7 +21,7 @@ #ifndef AVCODEC_UNARY_H #define AVCODEC_UNARY_H -#include "bitstream.h" +#include "get_bits.h" /** * Get unary code of limited length diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h index a9c06342ff..0f3c47ea1b 100644 --- a/libavcodec/vc1data.h +++ b/libavcodec/vc1data.h @@ -30,7 +30,7 @@ #include #include "libavutil/rational.h" -#include "bitstream.h" +#include "get_bits.h" /** Table for conversion between TTBLK and TTMB */ extern const int ff_vc1_ttblk_to_tt[3][8]; diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c index 45daa3c2a9..2148c23665 100644 --- a/libavcodec/vorbis.c +++ b/libavcodec/vorbis.c @@ -25,7 +25,7 @@ #define ALT_BITSTREAM_READER_LE #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "vorbis.h" diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c index 77dbfa2e93..12a9fed761 100644 --- a/libavcodec/vorbis_dec.c +++ b/libavcodec/vorbis_dec.c @@ -28,7 +28,7 @@ #define ALT_BITSTREAM_READER_LE #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "dsputil.h" #include "vorbis.h" diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 33d6c8f74b..40f802de9f 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -36,7 +36,7 @@ #include "avcodec.h" #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" #include "vp3data.h" #include "xiph.h" diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c index dfa2a1b094..1f8434c731 100644 --- a/libavcodec/vp5.c +++ b/libavcodec/vp5.c @@ -26,7 +26,7 @@ #include "avcodec.h" #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" #include "vp56.h" #include "vp56data.h" diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index 904c57e82c..da01ad73cc 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -26,7 +26,7 @@ #include "vp56data.h" #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" #include "bytestream.h" diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 5071903701..c1ca2273b1 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -29,7 +29,7 @@ #include "avcodec.h" #include "dsputil.h" -#include "bitstream.h" +#include "get_bits.h" #include "huffman.h" #include "vp56.h" diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index 1c1406f8c7..bf68406852 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -20,7 +20,7 @@ */ #define ALT_BITSTREAM_READER_LE #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "unary.h" /** diff --git a/libavcodec/wma.h b/libavcodec/wma.h index 869c54bf9a..213eff6db4 100644 --- a/libavcodec/wma.h +++ b/libavcodec/wma.h @@ -22,7 +22,7 @@ #ifndef AVCODEC_WMA_H #define AVCODEC_WMA_H -#include "bitstream.h" +#include "get_bits.h" #include "put_bits.h" #include "dsputil.h" diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c index e721a983cc..94240aba58 100644 --- a/libavcodec/wnv1.c +++ b/libavcodec/wnv1.c @@ -25,7 +25,7 @@ */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" typedef struct WNV1Context{ diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 942db0cd1b..ccb9bf92e5 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "avcodec.h" -#include "bitstream.h" +#include "get_bits.h" #include "bytestream.h" static av_cold int decode_init(AVCodecContext *avctx) { -- cgit v1.2.3