summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmad/huffman.c
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/libmad/huffman.c') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/huffman.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/core/multimedia/opieplayer/libmad/huffman.c b/core/multimedia/opieplayer/libmad/huffman.c
index 8ec9499..5ea6547 100644
--- a/core/multimedia/opieplayer/libmad/huffman.c
+++ b/core/multimedia/opieplayer/libmad/huffman.c
@@ -1,14 +1,14 @@
1/* 1/*
2 * mad - MPEG audio decoder 2 * libmad - MPEG audio decoder library
3 * Copyright (C) 2000-2001 Robert Leslie 3 * Copyright (C) 2000-2001 Robert Leslie
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
@@ -25,26 +25,32 @@
25 25
26# include "libmad_global.h" 26# include "libmad_global.h"
27 27
28# include "huffman.h" 28# include "huffman.h"
29 29
30/* 30/*
31 * These are the Huffman code words for Layer III. 31 * These are the Huffman code words for Layer III.
32 * The data for these tables are derived from Table B.7 of ISO/IEC 11172-3. 32 * The data for these tables are derived from Table B.7 of ISO/IEC 11172-3.
33 * 33 *
34 * These tables support decoding up to 4 Huffman code bits at a time. 34 * These tables support decoding up to 4 Huffman code bits at a time.
35 */ 35 */
36 36
37 # define V(v, w, x, y, hlen){ { 1, hlen, v, w, x, y } } 37# if defined(__GNUC__)
38 # define PTR(offs, bits){ ptr: { 0, bits, offs } } 38 # define PTR(offs, bits){ ptr: { 0, bits, offs } }
39 # define V(v, w, x, y, hlen){ value: { 1, hlen, v, w, x, y } }
40# else
41 # define PTR(offs, bits){ { 0, bits, offs } }
42 # define V(v, w, x, y, hlen){ { 1, hlen, (v << 0) | (w << 1) | \
43 (x << 2) | (y << 3) } }
44# endif
39 45
40static 46static
41union huffquad const hufftabA[] = { 47union huffquad const hufftabA[] = {
42 /* 0000 */ PTR(16, 2), 48 /* 0000 */ PTR(16, 2),
43 /* 0001 */ PTR(20, 2), 49 /* 0001 */ PTR(20, 2),
44 /* 0010 */ PTR(24, 1), 50 /* 0010 */ PTR(24, 1),
45 /* 0011 */ PTR(26, 1), 51 /* 0011 */ PTR(26, 1),
46 /* 0100 */ V(0, 0, 1, 0, 4), 52 /* 0100 */ V(0, 0, 1, 0, 4),
47 /* 0101 */ V(0, 0, 0, 1, 4), 53 /* 0101 */ V(0, 0, 0, 1, 4),
48 /* 0110 */ V(0, 1, 0, 0, 4), 54 /* 0110 */ V(0, 1, 0, 0, 4),
49 /* 0111 */ V(1, 0, 0, 0, 4), 55 /* 0111 */ V(1, 0, 0, 0, 4),
50 /* 1000 */ V(0, 0, 0, 0, 1), 56 /* 1000 */ V(0, 0, 0, 0, 1),
@@ -91,26 +97,31 @@ union huffquad const hufftabB[] = {
91 /* 1001 */ V(0, 1, 1, 0, 4), 97 /* 1001 */ V(0, 1, 1, 0, 4),
92 /* 1010 */ V(0, 1, 0, 1, 4), 98 /* 1010 */ V(0, 1, 0, 1, 4),
93 /* 1011 */ V(0, 1, 0, 0, 4), 99 /* 1011 */ V(0, 1, 0, 0, 4),
94 /* 1100 */ V(0, 0, 1, 1, 4), 100 /* 1100 */ V(0, 0, 1, 1, 4),
95 /* 1101 */ V(0, 0, 1, 0, 4), 101 /* 1101 */ V(0, 0, 1, 0, 4),
96 /* 1110 */ V(0, 0, 0, 1, 4), 102 /* 1110 */ V(0, 0, 0, 1, 4),
97 /* 1111 */ V(0, 0, 0, 0, 4) 103 /* 1111 */ V(0, 0, 0, 0, 4)
98}; 104};
99 105
100# undef V 106# undef V
101# undef PTR 107# undef PTR
102 108
103 # define V(x, y, hlen) { { 1, hlen, x, y } } 109# if defined(__GNUC__)
104 # define PTR(offs, bits){ ptr: { 0, bits, offs } } 110 # define PTR(offs, bits){ ptr: { 0, bits, offs } }
111 # define V(x, y, hlen) { value: { 1, hlen, x, y } }
112# else
113 # define PTR(offs, bits){ { 0, bits, offs } }
114 # define V(x, y, hlen) { { 1, hlen, (x << 0) | (y << 4) } }
115# endif
105 116
106static 117static
107union huffpair const hufftab0[] = { 118union huffpair const hufftab0[] = {
108 /* */ V(0, 0, 0) 119 /* */ V(0, 0, 0)
109}; 120};
110 121
111static 122static
112union huffpair const hufftab1[] = { 123union huffpair const hufftab1[] = {
113 /* 000 */ V(1, 1, 3), 124 /* 000 */ V(1, 1, 3),
114 /* 001 */ V(0, 1, 3), 125 /* 001 */ V(0, 1, 3),
115 /* 010 */ V(1, 0, 2), 126 /* 010 */ V(1, 0, 2),
116 /* 011 */ V(1, 0, 2), 127 /* 011 */ V(1, 0, 2),