X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fbitstream.h;h=bbb7fcda09ce5c48923f10e127b1247282f12d0c;hb=0de9926f62584db587a2a29fc00f6af8e7a34dc1;hp=7325449aa178bb7943a876bfd33d4b861ddac39f;hpb=6e4703cac7e3b9c0bca77d46bf1f4df60f2424ea;p=ffmpeg diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h index 7325449aa17..bbb7fcda09c 100644 --- a/libavcodec/bitstream.h +++ b/libavcodec/bitstream.h @@ -1,3 +1,21 @@ +/* + * copyright (c) 2004 Michael Niedermayer + * + * This library 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 of the License, or (at your option) any later version. + * + * This library 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 this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + /** * @file bitstream.h * bitstream api header. @@ -6,12 +24,22 @@ #ifndef BITSTREAM_H #define BITSTREAM_H +#include "log.h" + +#if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER) +#define ALT_BITSTREAM_READER +#endif + //#define ALT_BITSTREAM_WRITER //#define ALIGNED_BITSTREAM_WRITER #if !defined(LIBMPEG2_BITSTREAM_READER) && !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER) +# ifdef ARCH_ARMV4L +# define A32_BITSTREAM_READER +# else #define ALT_BITSTREAM_READER //#define LIBMPEG2_BITSTREAM_READER //#define A32_BITSTREAM_READER +# endif #endif #define LIBMPEG2_BITSTREAM_READER_HACK //add BERO @@ -553,7 +581,7 @@ static inline void skip_bits_long(GetBitContext *s, int n){ "shldl %2, %1, %0 \n\t"\ "shll %2, %1 \n\t"\ : "+r" (name##_cache0), "+r" (name##_cache1)\ - : "Ic" ((uint8_t)num)\ + : "Ic" ((uint8_t)(num))\ ); #else # define SKIP_CACHE(name, gb, num)\ @@ -642,8 +670,6 @@ static inline unsigned int get_bits(GetBitContext *s, int n){ return tmp; } -unsigned int get_bits_long(GetBitContext *s, int n); - /** * shows 0-17 bits. * Note, the alt bitstream reader can read up to 25 bits, but the libmpeg2 reader can't @@ -657,8 +683,6 @@ static inline unsigned int show_bits(GetBitContext *s, int n){ return tmp; } -unsigned int show_bits_long(GetBitContext *s, int n); - 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) @@ -695,6 +719,44 @@ 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 + } +} + +/** + * 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; + int ret= get_bits_long(s, n); + *s= gb; + return ret; + } +} + +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 @@ -726,13 +788,12 @@ static inline void init_get_bits(GetBitContext *s, #endif } -static void align_get_bits(GetBitContext *s) +static inline 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 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, @@ -828,7 +889,6 @@ static always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], //#define TRACE #ifdef TRACE -#include "avcodec.h" static inline void print_bin(int bits, int n){ int i;