📄 libwma.patch
字号:
+ * @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+ }+}++/**+ * 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+ * 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);+}++int libwma_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,+ int flags);+#define INIT_VLC_USE_STATIC 1+#define INIT_VLC_LE 2+void free_vlc(VLC *vlc);++/**+ *+ * 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__)+#define DEBUGF(p, ...) printf(p, __VA_ARGS__)++#else //TRACE+#define tprintf(p, ...) {}+#define DEBUGF(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;+}++#endif /* BITSTREAM_H */diff -uNr MPlayer-1.0rc2.orig/libwma/bswap.h MPlayer-1.0rc2/libwma/bswap.h--- MPlayer-1.0rc2.orig/libwma/bswap.h 1969-12-31 18:00:00.000000000 -0600+++ MPlayer-1.0rc2/libwma/bswap.h 2008-04-27 15:16:23.000000000 -0500@@ -0,0 +1,129 @@+/**+ * @file bswap.h+ * byte swap.+ */++#ifndef __BSWAP_H__+#define __BSWAP_H__++#ifdef HAVE_BYTESWAP_H+#include <byteswap.h>+#else++#if defined(ARCH_X86)+static inline unsigned short ByteSwap16(unsigned short x)+{+ __asm("xchgb %b0,%h0" :+ "=q" (x) :+ "0" (x));+ return x;+}+#define bswap_16(x) ByteSwap16(x)++static inline unsigned int ByteSwap32(unsigned int x)+{+#if __CPU__ > 386+ __asm("bswap %0":+ "=r" (x) :+#else+ __asm("xchgb %b0,%h0\n"+ " rorl $16,%0\n"+ " xchgb %b0,%h0":+ "=q" (x) :+#endif+ "0" (x));+ return x;+}+#define bswap_32(x) ByteSwap32(x)++static inline unsigned long long int ByteSwap64(unsigned long long int x)+{+ register union { __extension__ uint64_t __ll;+ uint32_t __l[2]; } __x;+ asm("xchgl %0,%1":+ "=r"(__x.__l[0]),"=r"(__x.__l[1]):+ "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));+ return __x.__ll;+}+#define bswap_64(x) ByteSwap64(x)++#elif defined(ARCH_SH4)++static inline uint16_t ByteSwap16(uint16_t x) {+ __asm__("swap.b %0,%0":"=r"(x):"0"(x));+ return x;+}++static inline uint32_t ByteSwap32(uint32_t x) {+ __asm__(+ "swap.b %0,%0\n"+ "swap.w %0,%0\n"+ "swap.b %0,%0\n"+ :"=r"(x):"0"(x));+ return x;+}++#define bswap_16(x) ByteSwap16(x)+#define bswap_32(x) ByteSwap32(x)++static inline uint64_t ByteSwap64(uint64_t x)+{+ union { + uint64_t ll;+ struct {+ uint32_t l,h;+ } l;+ } r;+ r.l.l = bswap_32 (x);+ r.l.h = bswap_32 (x>>32);+ return r.ll;+}+#define bswap_64(x) ByteSwap64(x)++#else++#define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8)+++// code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc.+#define bswap_32(x) \+ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \+ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))++static inline uint64_t ByteSwap64(uint64_t x)+{+ union { + uint64_t ll;+ uint32_t l[2]; + } w, r;+ w.ll = x;+ r.l[0] = bswap_32 (w.l[1]);+ r.l[1] = bswap_32 (w.l[0]);+ return r.ll;+}+#define bswap_64(x) ByteSwap64(x)++#endif /* !ARCH_X86 */++#endif /* !HAVE_BYTESWAP_H */++// be2me ... BigEndian to MachineEndian+// le2me ... LittleEndian to MachineEndian++#ifdef WORDS_BIGENDIAN+#define be2me_16(x) (x)+#define be2me_32(x) (x)+#define be2me_64(x) (x)+#define le2me_16(x) bswap_16(x)+#define le2me_32(x) bswap_32(x)+#define le2me_64(x) bswap_64(x)+#else+#define be2me_16(x) bswap_16(x)+#define be2me_32(x) bswap_32(x)+#define be2me_64(x) bswap_64(x)+#define le2me_16(x) (x)+#define le2me_32(x) (x)+#define le2me_64(x) (x)+#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -