FFmpeg
mpc8huff.h
Go to the documentation of this file.
1 /*
2  * Musepack SV8 decoder
3  * Copyright (c) 2007 Konstantin Shishkov
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVCODEC_MPC8HUFF_H
23 #define AVCODEC_MPC8HUFF_H
24 
25 #include <stdint.h>
26 
27 #define MPC8_MAX_VLC_SIZE 256
28 
29 #define MPC8_BANDS_SIZE 33
30 #define MPC8_BANDS_BITS 9
31 
33  13, 19, 10, 11, 12, 14, 15, 16, 17, 18, 20, 21, 22, 9, 23, 24, 25, 8, 26,
34  27, 7, 28, 5, 6, 29, 4, 3, 30, 2, 31, 1, 32, 0
35 };
36 static const uint8_t mpc8_bands_len_counts[16] = {
37  1, 1, 1, 0, 2, 2, 1, 3, 2, 3, 4, 11, 2, 0, 0, 0
38 };
39 
40 static const uint8_t mpc8_scfi_syms[] = {
41  /* SCFI[0] VLC symbols - 4 entries */
42  0, 1, 3, 2,
43  /* SCFI[1] VLC symbols - 16 entries */
44  1, 4, 0, 2, 3, 8, 12, 5, 6, 7, 9, 13, 11, 14, 10, 15
45 };
46 
47 static const uint8_t mpc8_scfi_len_counts[2][16] = {
48  { 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
49  { 0, 2, 2, 0, 5, 5, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
50 };
51 
52 #define MPC8_DSCF0_BITS 9
53 #define MPC8_DSCF1_BITS 9
54 
55 static const uint8_t mpc8_dscf_syms[] = {
56  /* DSCF[0] VLC symbols - 64 entries */
57  58, 59, 60, 61, 62, 63, 55, 56, 57, 0, 1, 2, 53, 54, 3, 4, 5, 50, 51,
58  52, 6, 7, 8, 9, 10, 31, 47, 48, 49, 11, 12, 13, 14, 44, 45, 46, 15, 16,
59  17, 18, 41, 42, 43, 19, 20, 21, 22, 40, 23, 24, 38, 39, 25, 28, 37, 26, 27,
60  29, 30, 32, 36, 33, 34, 35,
61  /* DSCF[1] VLC symbols - 65 entries */
62  0, 59, 60, 61, 62, 63, 1, 2, 56, 57, 58, 3, 4, 5, 53, 54, 55, 6, 7,
63  8, 9, 49, 50, 51, 52, 64, 10, 11, 12, 13, 46, 47, 48, 14, 15, 16, 17, 43,
64  44, 45, 18, 19, 20, 41, 42, 21, 22, 39, 40, 23, 24, 38, 25, 37, 26, 35, 36,
65  27, 28, 34, 29, 30, 31, 32, 33,
66 };
67 
68 static const uint8_t mpc8_dscf_len_counts[2][16] = {
69  { 0, 0, 3, 6, 3, 4, 5, 7, 7, 9, 6, 5, 3, 6, 0, 0 },
70  { 0, 0, 5, 3, 3, 2, 3, 4, 5, 7, 7, 9, 6, 5, 6, 0 },
71 };
72 
73 #define MPC8_RES_BITS 9
74 
75 static const uint8_t mpc8_res_syms[] = {
76  /* RES[0] VLC symbols - 17 entries */
77  13, 14, 12, 11, 10, 9, 8, 7, 6, 15, 5, 4, 3, 2, 16, 1, 0,
78  /* RES[1] VLC symbols - 17 entries */
79  8, 9, 10, 11, 7, 12, 6, 13, 5, 4, 14, 3, 15, 2, 0, 1, 16,
80 };
81 
82 static const uint8_t mpc8_res_len_counts[2][16] = {
83  { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2 },
84  { 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 4, 0, 0 },
85 };
86 
87 #define MPC8_Q1_BITS 9
88 
89 static const uint8_t mpc8_q1_len_counts[16] = {
90  0, 0, 5, 5, 1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 0, 0
91 };
92 
93 #define MPC8_Q9UP_BITS 9
94 
95 static const uint8_t mpc8_q9up_len_counts[16] = {
96  0, 0, 0, 0, 0, 2, 38, 134, 71, 9, 2, 0, 0, 0, 0, 0
97 };
98 
99 #define MPC8_Q2_BITS 9
100 
101 static const uint8_t mpc8_q2_len_counts[2][16] = {
102  { 0, 0, 1, 6, 0, 17, 9, 24, 24, 9, 27, 4, 4, 0, 0, 0 },
103  { 0, 0, 0, 1, 16, 10, 6, 48, 9, 27, 4, 4, 0, 0, 0, 0 },
104 };
105 
106 #define MPC8_Q3_BITS 9
107 #define MPC8_Q4_BITS 9
108 
109 static const uint8_t mpc8_q34_len_counts[2][16] = {
110  { 0, 0, 1, 6, 6, 11, 13, 8, 4, 0, 0, 0, 0, 0, 0, 0 },
111  { 0, 0, 0, 1, 12, 23, 14, 19, 8, 4, 0, 0, 0, 0, 0, 0 },
112 };
113 
114 static const uint8_t mpc8_q5_8_len_counts[2][4][16] = {
115  { /* Q5[0], Q6[0], Q7[0], Q8[0] */
116  { 0, 1, 4, 2, 2, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
117  { 0, 1, 2, 4, 3, 7, 2, 4, 8, 0, 0, 0, 0, 0, 0, 0 },
118  { 0, 1, 2, 2, 4, 6, 10, 10, 12, 16, 0, 0, 0, 0, 0, 0 },
119  { 0, 1, 2, 1, 3, 8, 8, 15, 24, 42, 17, 6, 0, 0, 0, 0 },
120  },
121  { /* Q5[1], Q6[1], Q7[1], Q8[1] */
122  { 0, 0, 5, 4, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
123  { 0, 0, 0, 11, 6, 4, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0 },
124  { 0, 0, 0, 0, 20, 15, 10, 14, 4, 0, 0, 0, 0, 0, 0, 0 },
125  { 0, 0, 0, 0, 0, 26, 55, 38, 8, 0, 0, 0, 0, 0, 0, 0 },
126  }
127 };
128 
129 static const uint8_t mpc8_q_syms[] = {
130  /* Q1 VLC symbols - 19 entries */
131  17, 18, 16, 15, 14, 13, 12, 0, 11, 1, 2, 8, 9, 10, 3,
132  4, 5, 6, 7,
133  /* Q9UP VLC symbols - 256 entries */
134  254, 255, 0, 1, 2, 3, 4, 250, 251, 252, 253, 5, 6, 7, 8,
135  9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24, 25,
136  26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41,
137  213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
138  228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
139  243, 244, 245, 246, 247, 248, 249, 19, 20, 40, 42, 43, 44, 45, 46,
140  47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
141  62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
142  77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
143  92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
144  107, 147, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
145  162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
146  177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
147  192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206,
148  207, 208, 209, 210, 211, 212, 108, 109, 110, 111, 112, 113, 114, 115, 116,
149  117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 129, 130, 131, 132, 133,
150  134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 148, 127,
151  128,
152  /* Q2[0] VLC symbols - 125 entries */
153  4, 24, 100, 120, 0, 20, 104, 124, 1, 3, 5, 9, 10, 14, 15,
154  19, 21, 23, 25, 29, 45, 49, 75, 79, 95, 99, 101, 103, 105, 109,
155  114, 115, 119, 121, 123, 2, 22, 50, 54, 70, 74, 102, 110, 122, 6,
156  8, 16, 18, 26, 28, 30, 34, 40, 44, 46, 48, 76, 78, 80, 84,
157  90, 94, 96, 98, 106, 108, 116, 118, 7, 11, 13, 17, 27, 35, 39,
158  47, 51, 53, 55, 59, 65, 69, 71, 73, 77, 85, 89, 97, 107, 111,
159  113, 117, 12, 33, 43, 52, 60, 64, 72, 91, 112, 31, 32, 36, 38,
160  41, 42, 56, 58, 66, 68, 81, 82, 83, 86, 88, 92, 93, 37, 57,
161  61, 63, 67, 87, 62,
162  /* Q3 VLC symbols - 49 entries */
163  13, 3, 109, 99, 14, 2, 29, 19, 93, 83, 110, 98, 15, 0, 1,
164  18, 45, 35, 61, 51, 77, 67, 111, 96, 97, 30, 31, 17, 46, 34,
165  78, 66, 94, 95, 81, 82, 16, 33, 62, 50, 79, 80, 47, 32, 63,
166  49, 64, 65, 48,
167  /* Q5[0] VLC symbols - 15 entries */
168  0, 1, 13, 14, 2, 12, 3, 11, 4, 10, 5, 6, 8, 9, 7,
169  /* Q6[0] VLC symbols - 31 entries */
170  0, 1, 2, 3, 27, 28, 29, 30, 4, 5, 25, 26, 6, 24, 7,
171  8, 9, 20, 21, 22, 23, 10, 11, 19, 12, 13, 17, 18, 14, 16,
172  15,
173  /* Q7[0] VLC symbols - 63 entries */
174  0, 1, 2, 5, 6, 7, 8, 9, 53, 54, 55, 56, 57, 60, 61,
175  62, 3, 4, 10, 11, 12, 13, 49, 50, 51, 52, 58, 59, 14, 15,
176  16, 17, 18, 43, 45, 46, 47, 48, 19, 20, 21, 22, 23, 39, 40,
177  41, 42, 44, 24, 25, 26, 36, 37, 38, 27, 28, 34, 35, 29, 33,
178  30, 32, 31,
179  /* Q8[0] VLC symbols - 127 entries */
180  11, 12, 111, 113, 114, 115, 0, 1, 13, 14, 15, 16, 17, 18, 19,
181  21, 104, 105, 107, 108, 109, 110, 112, 2, 3, 4, 5, 6, 8, 10,
182  20, 22, 23, 24, 25, 26, 27, 28, 29, 31, 32, 33, 34, 35, 92,
183  93, 95, 96, 97, 98, 99, 100, 101, 102, 103, 106, 116, 117, 120, 121,
184  122, 123, 124, 125, 126, 7, 9, 30, 36, 37, 38, 39, 40, 41, 42,
185  43, 45, 83, 84, 85, 86, 87, 88, 89, 90, 91, 94, 118, 119, 44,
186  46, 47, 48, 49, 50, 51, 75, 76, 77, 78, 79, 80, 81, 82, 52,
187  53, 54, 55, 71, 72, 73, 74, 56, 57, 58, 59, 67, 68, 69, 70,
188  60, 65, 66, 61, 62, 64, 63,
189  /* Q2[1] VLC symbols - 125 entries */
190  4, 24, 100, 120, 0, 20, 104, 124, 1, 3, 5, 9, 10, 15, 19,
191  21, 23, 25, 29, 45, 49, 75, 79, 95, 99, 101, 102, 103, 105, 109,
192  114, 115, 119, 121, 123, 2, 14, 22, 50, 54, 70, 74, 110, 122, 6,
193  7, 8, 11, 13, 16, 17, 18, 26, 27, 28, 30, 34, 35, 39, 40,
194  44, 46, 47, 48, 51, 53, 55, 59, 65, 69, 71, 73, 76, 77, 78,
195  80, 84, 85, 89, 90, 94, 96, 97, 98, 106, 107, 108, 111, 113, 116,
196  117, 118, 12, 52, 60, 64, 72, 112, 31, 33, 36, 41, 43, 81, 83,
197  88, 91, 93, 32, 37, 38, 42, 56, 57, 58, 61, 63, 66, 67, 68,
198  82, 86, 87, 92, 62,
199  /* Q4 VLC symbols - 81 entries */
200  12, 4, 140, 132, 13, 3, 28, 20, 124, 116, 141, 131, 14, 1, 2,
201  29, 19, 44, 36, 60, 52, 92, 84, 108, 100, 125, 115, 142, 143, 129,
202  130, 15, 0, 30, 18, 45, 35, 76, 68, 109, 99, 126, 127, 114, 128,
203  31, 16, 17, 46, 47, 33, 34, 61, 62, 50, 51, 77, 67, 93, 94,
204  82, 83, 110, 111, 97, 98, 112, 113, 32, 63, 48, 49, 78, 79, 65,
205  66, 95, 80, 81, 96, 64,
206  /* Q5[1] VLC symbols - 15 entries */
207  0, 1, 13, 14, 2, 12, 3, 4, 10, 11, 5, 6, 7, 8, 9,
208  /* Q6[1] VLC symbols - 31 entries */
209  0, 1, 29, 30, 2, 3, 4, 26, 27, 28, 5, 6, 24, 25, 7,
210  8, 9, 21, 22, 23, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
211  20,
212  /* Q7[1] VLC symbols - 63 entries */
213  0, 1, 61, 62, 2, 3, 4, 5, 6, 7, 8, 54, 55, 56, 57,
214  58, 59, 60, 9, 10, 11, 12, 13, 49, 50, 51, 52, 53, 14, 15,
215  16, 17, 18, 19, 20, 21, 42, 43, 44, 45, 46, 47, 48, 22, 23,
216  24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
217  39, 40, 41,
218  /* Q8[1] VLC symbols - 127 entries */
219  0, 1, 2, 3, 123, 124, 125, 126, 4, 5, 6, 7, 8, 9, 10,
220  11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 103, 104, 105, 106,
221  107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
222  122, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
223  36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 75,
224  77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
225  92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 50, 51, 52, 53,
226  54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
227  69, 70, 71, 72, 73, 74, 76,
228 };
229 
230 #endif /* AVCODEC_MPC8HUFF_H */
static const uint8_t mpc8_q_syms[]
Definition: mpc8huff.h:129
uint8_t
static const uint8_t mpc8_bands_syms[MPC8_BANDS_SIZE]
Definition: mpc8huff.h:32
static const uint8_t mpc8_res_syms[]
Definition: mpc8huff.h:75
#define MPC8_BANDS_SIZE
Definition: mpc8huff.h:29
static const uint8_t mpc8_q5_8_len_counts[2][4][16]
Definition: mpc8huff.h:114
static const uint8_t mpc8_dscf_syms[]
Definition: mpc8huff.h:55
static const uint8_t mpc8_q9up_len_counts[16]
Definition: mpc8huff.h:95
static const uint8_t mpc8_dscf_len_counts[2][16]
Definition: mpc8huff.h:68
static const uint8_t mpc8_bands_len_counts[16]
Definition: mpc8huff.h:36
static const uint8_t mpc8_q1_len_counts[16]
Definition: mpc8huff.h:89
static const uint8_t mpc8_res_len_counts[2][16]
Definition: mpc8huff.h:82
static const uint8_t mpc8_q34_len_counts[2][16]
Definition: mpc8huff.h:109
static const uint8_t mpc8_scfi_syms[]
Definition: mpc8huff.h:40
static const uint8_t mpc8_scfi_len_counts[2][16]
Definition: mpc8huff.h:47
static const uint8_t mpc8_q2_len_counts[2][16]
Definition: mpc8huff.h:101