⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libwma.patch

📁 在mplayer播放器增加wma的定点运算补丁
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
+attribute_deprecated void *ff_realloc_static(void *ptr, unsigned int size);+++const uint8_t libwma_sqrt_tab[128]={+        0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5,+        5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,+        8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,+        9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11+};++const uint8_t libwma_log2_tab[256]={+        0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,+        5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,+        6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,+        6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,+        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,+        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,+        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,+        7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7+};+++void libwma_align_put_bits(PutBitContext *s)+{+#ifdef ALT_BITSTREAM_WRITER+    put_bits(s,(  - s->index) & 7,0);+#else+    put_bits(s,s->bit_left & 7,0);+#endif+}++void libwma_put_string(PutBitContext * pbc, char *s, int put_zero)+{+    while(*s){+        put_bits(pbc, 8, *s);+        s++;+    }+    if(put_zero)+        put_bits(pbc, 8, 0);+}++/* VLC decoding */++//#define DEBUG_VLC++#define GET_DATA(v, table, i, wrap, size) \+{\+    const uint8_t *ptr = (const uint8_t *)table + i * wrap;\+    switch(size) {\+    case 1:\+        v = *(const uint8_t *)ptr;\+        break;\+    case 2:\+        v = *(const uint16_t *)ptr;\+        break;\+    default:\+        v = *(const uint32_t *)ptr;\+        break;\+    }\+}+++static int alloc_table(VLC *vlc, int size)+{+    int index;+    index = vlc->table_size;+    vlc->table_size += size;+    if (vlc->table_size > vlc->table_allocated) {+        DEBUGF("Tried to allocate past the end of a Huffman table: %d/%d\n", +            vlc->table_allocated, vlc->table_allocated+(1 << vlc->bits));+        vlc->table_allocated += (1 << vlc->bits);+        if (!vlc->table)+            return -1;+    }+    return index;+}++static int build_table(VLC *vlc, int table_nb_bits,+                       int nb_codes,+                       const void *bits, int bits_wrap, int bits_size,+                       const void *codes, int codes_wrap, int codes_size,+                       uint32_t code_prefix, int n_prefix)+{+    int i, j, k, n, table_size, table_index, nb, n1, index, code_prefix2;+    uint32_t code;+    int flags = 0;+    VLC_TYPE (*table)[2];++    table_size = 1 << table_nb_bits;+    table_index = alloc_table(vlc, table_size);+#ifdef DEBUG_VLC+    printf("new table index=%d size=%d code_prefix=%x n=%d\n",+           table_index, table_size, code_prefix, n_prefix);+#endif+    if (table_index < 0)+        return -1;+    table = &vlc->table[table_index];++    for(i=0;i<table_size;i++) {+        table[i][1] = 0; //bits+        table[i][0] = -1; //codes+    }++    /* first pass: map codes and compute auxillary table sizes */+    for(i=0;i<nb_codes;i++) {+        GET_DATA(n, bits, i, bits_wrap, bits_size);+        GET_DATA(code, codes, i, codes_wrap, codes_size);+        /* we accept tables with holes */+        if (n <= 0)+            continue;+#if defined(DEBUG_VLC) && 0+        printf("i=%d n=%d code=0x%x\n", i, n, code);+#endif+        /* if code matches the prefix, it is in the table */+        n -= n_prefix;+        if(flags & INIT_VLC_LE)+            code_prefix2= code & (n_prefix>=32 ? 0xffffffff : (uint32_t)(1 << n_prefix)-1);+        else+            code_prefix2= code >> n;+        if (n > 0 && (int)code_prefix2 == (int)code_prefix) {+            if (n <= table_nb_bits) {+                /* no need to add another table */+                j = (code << (table_nb_bits - n)) & (table_size - 1);+                nb = 1 << (table_nb_bits - n);+                for(k=0;k<nb;k++) {+                    if(flags & INIT_VLC_LE)+                        j = (code >> n_prefix) + (k<<n);+#ifdef DEBUG_VLC+                    av_log(NULL, 0, "%4x: code=%d n=%d\n",+                           j, i, n);+#endif+                    if (table[j][1] /*bits*/ != 0) {+                        return -1;+                    }+                    table[j][1] = n; //bits+                    table[j][0] = i; //code+                    j++;+                }+            } else {+                n -= table_nb_bits;+                j = (code >> ((flags & INIT_VLC_LE) ? n_prefix : n)) & ((1 << table_nb_bits) - 1);+#ifdef DEBUG_VLC+                av_log(NULL, 0,"%4x: n=%d (subtable)\n",+                       j, n);+#endif+                /* compute table size */+                n1 = -table[j][1]; //bits+                if (n > n1)+                    n1 = n;+                table[j][1] = -n1; //bits+            }+        }+    }++    /* second pass : fill auxillary tables recursively */+    for(i=0;i<table_size;i++) {+        n = table[i][1]; //bits+        if (n < 0) {+            n = -n;+            if (n > table_nb_bits) {+                n = table_nb_bits;+                table[i][1] = -n; //bits+            }+            index = build_table(vlc, n, nb_codes,+                                bits, bits_wrap, bits_size,+                                codes, codes_wrap, codes_size,+                                (flags & INIT_VLC_LE) ? (code_prefix | (i << n_prefix)) : ((code_prefix << table_nb_bits) | i),+                                n_prefix + table_nb_bits);+            if (index < 0)+                return -1;+            /* note: realloc has been done, so reload tables */+            table = &vlc->table[table_index];+            table[i][0] = index; //code+        }+    }+    return table_index;+}+++/* Build VLC decoding tables suitable for use with get_vlc().++   'nb_bits' set thee decoding table size (2^nb_bits) entries. The+   bigger it is, the faster is the decoding. But it should not be too+   big to save memory and L1 cache. '9' is a good compromise.++   'nb_codes' : number of vlcs codes++   'bits' : table which gives the size (in bits) of each vlc code.++   'codes' : table which gives the bit pattern of of each vlc code.++   'xxx_wrap' : give the number of bytes between each entry of the+   'bits' or 'codes' tables.++   'xxx_size' : gives the number of bytes of each entry of the 'bits'+   or 'codes' tables.++   'wrap' and 'size' allows to use any memory configuration and types+   (byte/word/long) to store the 'bits' and 'codes' tables.++   'use_static' should be set to 1 for tables, which should be freed+   with av_free_static(), 0 if free_vlc() will be used.+*/+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)+{++    vlc->bits = nb_bits;+     vlc->table_size = 0;++#ifdef DEBUG_VLC+    printf("build table nb_codes=%d\n", nb_codes);+#endif++    if (build_table(vlc, nb_bits, nb_codes,+                    bits, bits_wrap, bits_size,+                    codes, codes_wrap, codes_size,+                    0, 0) < 0) {+        //av_free(vlc->table);+        return -1;+    }+    /* return flags to block gcc warning while allowing us to keep+     * consistent with ffmpeg's function parameters+     */+    return flags;+}++diff -uNr MPlayer-1.0rc2.orig/libwma/bitstream.h MPlayer-1.0rc2/libwma/bitstream.h--- MPlayer-1.0rc2.orig/libwma/bitstream.h	1969-12-31 18:00:00.000000000 -0600+++ MPlayer-1.0rc2/libwma/bitstream.h	2008-04-27 18:46:54.000000000 -0500@@ -0,0 +1,991 @@+/*+ * copyright (c) 2004 Michael Niedermayer <michaelni@gmx.at>+ *+ * 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 bitstream.h+ * bitstream api header.+ */++#ifndef BITSTREAM_H+#define BITSTREAM_H++#define av_always_inline inline+#define attribute_deprecated++#include <inttypes.h>+#include "ffmpeg_config.h"+#include <stdlib.h>++#include "bswap.h"++extern const uint8_t libwma_log2_tab[256];+++/*misc utility functions added to make it compile */+static inline int libwma_log2(unsigned int v)+{+    int n;++    n = 0;+    if (v & 0xffff0000) {+        v >>= 16;+        n += 16;+    }+    if (v & 0xff00) {+        v >>= 8;+        n += 8;+    }+    n += libwma_log2_tab[v];++    return n;+}+++//#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++extern const uint8_t ff_reverse[256];++#if defined(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 output */++/* buf and buf_end must be present and used by every alternative writer. */+typedef struct PutBitContext {+#ifdef ALT_BITSTREAM_WRITER+    uint8_t *buf, *buf_end;+    int index;+#else+    uint32_t bit_buf;+    int bit_left;+    uint8_t *buf, *buf_ptr, *buf_end;+#endif+} PutBitContext;++static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)+{+    if(buffer_size < 0) {+        buffer_size = 0;+        buffer = NULL;+    }++    s->buf = buffer;+    s->buf_end = s->buf + buffer_size;+#ifdef ALT_BITSTREAM_WRITER+    s->index=0;+    ((uint32_t*)(s->buf))[0]=0;+//    memset(buffer, 0, buffer_size);+#else+    s->buf_ptr = s->buf;+    s->bit_left=32;+    s->bit_buf=0;+#endif+}++/* return the number of bits output */+static inline int put_bits_count(PutBitContext *s)+{+#ifdef ALT_BITSTREAM_WRITER+    return s->index;+#else+    return (s->buf_ptr - s->buf) * 8 + 32 - s->bit_left;+#endif+}++/* pad the end of the output stream with zeros */+static inline void flush_put_bits(PutBitContext *s)+{+#ifdef ALT_BITSTREAM_WRITER+    libwma_align_put_bits(s);+#else+    s->bit_buf<<= s->bit_left;+    while (s->bit_left < 32) {+        /* XXX: should test end of buffer */+        *s->buf_ptr++=s->bit_buf >> 24;+        s->bit_buf<<=8;+        s->bit_left+=8;+    }+    s->bit_left=32;+    s->bit_buf=0;+#endif+}++void libwma_align_put_bits(PutBitContext *s);+void libwma_put_string(PutBitContext * pbc, char *s, int put_zero);++/* 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;++#if defined(ARCH_SPARC) || defined(ARCH_ARMV4L) || defined(ARCH_MIPS) || defined(ARCH_BFIN)+#define UNALIGNED_STORES_ARE_BAD+#endif++/* used to avoid missaligned exceptions on some archs (alpha, ...) */+#if defined(ARCH_X86) || defined(CPU_COLDFIRE)+#    define unaligned16(a) (*(const uint16_t*)(a))+#    define unaligned32(a) (*(const uint32_t*)(a))+#    define unaligned64(a) (*(const uint64_t*)(a))+#else+#    ifdef __GNUC__+#    define unaligned(x)                                \+static inline uint##x##_t unaligned##x(const void *v) { \+    struct Unaligned {                                  \+        uint##x##_t i;                                  \+    } __attribute__((packed));                          \+                                                        \+    return ((const struct Unaligned *) v)->i;           \

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -